1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 | import * as http from 'http';
|
13 | import { BenchmarkResponse } from './types';
|
14 | import { NpmInstall } from './versions';
|
15 | export interface ServerOpts {
|
16 | host: string;
|
17 | ports: number[];
|
18 | root: string;
|
19 | npmInstalls: NpmInstall[];
|
20 | mountPoints: MountPoint[];
|
21 | resolveBareModules: boolean;
|
22 | cache: boolean;
|
23 | }
|
24 | export interface MountPoint {
|
25 | diskPath: string;
|
26 | urlPath: string;
|
27 | }
|
28 | export interface Session {
|
29 | bytesSent: number;
|
30 | userAgent: string;
|
31 | }
|
32 | export declare class Server {
|
33 | readonly url: string;
|
34 | readonly port: number;
|
35 | private readonly server;
|
36 | private session;
|
37 | private deferredResults;
|
38 | private readonly urlCache;
|
39 | static start(opts: ServerOpts): Promise<Server>;
|
40 | constructor(server: http.Server, opts: ServerOpts);
|
41 | /**
|
42 | * Mark the end of one session, return the data instrumented from it, and
|
43 | * begin a new session.
|
44 | */
|
45 | endSession(): Session;
|
46 | nextResults(): Promise<BenchmarkResponse>;
|
47 | close(): Promise<unknown>;
|
48 | private instrumentRequests;
|
49 | /**
|
50 | * Cache all downstream middleware responses by URL in memory. This is
|
51 | * especially helpful when bare module resolution is enabled, because that
|
52 | * requires expensive parsing of all HTML and JavaScript that we really don't
|
53 | * want to do for every benchmark sample.
|
54 | */
|
55 | private cache;
|
56 | private serveBenchLib;
|
57 | private submitResults;
|
58 | }
|