@browserless.io/browserless 2.0.0-beta-1 → 2.0.0-beta-4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/browserless.js +157 -15
- package/build/browserless.d.ts +23 -18
- package/build/browserless.js +24 -17
- package/build/browsers/cdp-chromium.d.ts +17 -14
- package/build/browsers/index.d.ts +27 -10
- package/build/browsers/index.js +2 -12
- package/build/browsers/playwright-chromium.d.ts +12 -9
- package/build/browsers/playwright-firefox.d.ts +12 -9
- package/build/browsers/playwright-webkit.d.ts +12 -9
- package/build/config.d.ts +31 -31
- package/build/exports.d.ts +2 -0
- package/build/exports.js +2 -0
- package/build/file-system.d.ts +2 -2
- package/build/limiter.d.ts +34 -11
- package/build/metrics.d.ts +17 -11
- package/build/monitoring.d.ts +3 -2
- package/build/router.d.ts +28 -0
- package/build/router.js +138 -0
- package/build/routes/chromium/http/content-post.body.json +8 -8
- package/build/routes/chromium/http/download-post.js +1 -1
- package/build/routes/chromium/http/function-post.js +1 -1
- package/build/routes/chromium/http/pdf-post.body.json +8 -8
- package/build/routes/chromium/http/performance.js +1 -1
- package/build/routes/chromium/http/scrape-post.body.json +8 -8
- package/build/routes/chromium/http/screenshot-post.body.json +8 -8
- package/build/routes/chromium/utils/function/client.d.ts +3 -3
- package/build/routes/management/http/config-get.js +1 -1
- package/build/routes/management/http/metrics-get.js +1 -1
- package/build/routes/management/http/metrics-total-get.js +1 -1
- package/build/routes/management/http/sessions-get.js +3 -3
- package/build/routes/management/http/static-get.js +1 -1
- package/build/server.d.ts +22 -27
- package/build/server.js +29 -149
- package/build/token.d.ts +6 -0
- package/build/token.js +21 -0
- package/build/types.d.ts +85 -14
- package/build/utils.d.ts +1 -2
- package/build/utils.js +0 -13
- package/build/webhooks.d.ts +2 -2
- package/docker/sdk/Dockerfile +2 -6
- package/package.json +6 -6
- package/src/browserless.ts +44 -32
- package/src/browsers/cdp-chromium.ts +13 -13
- package/src/browsers/index.ts +9 -24
- package/src/browsers/playwright-chromium.ts +9 -9
- package/src/browsers/playwright-firefox.ts +9 -9
- package/src/browsers/playwright-webkit.ts +9 -9
- package/src/config.ts +32 -31
- package/src/exports.ts +2 -0
- package/src/file-system.ts +2 -2
- package/src/limiter.ts +11 -11
- package/src/metrics.ts +11 -11
- package/src/monitoring.ts +2 -2
- package/src/router.ts +234 -0
- package/src/routes/chromium/http/download-post.ts +1 -1
- package/src/routes/chromium/http/function-post.ts +1 -1
- package/src/routes/chromium/http/performance.ts +1 -1
- package/src/routes/chromium/utils/function/client.ts +2 -2
- package/src/routes/management/http/config-get.ts +1 -1
- package/src/routes/management/http/metrics-get.ts +1 -1
- package/src/routes/management/http/metrics-total-get.ts +1 -1
- package/src/routes/management/http/sessions-get.ts +3 -3
- package/src/routes/management/http/static-get.ts +1 -1
- package/src/server.ts +43 -238
- package/src/token.ts +40 -0
- package/src/types.ts +91 -17
- package/src/utils.ts +0 -25
- package/src/webhooks.ts +2 -2
- package/static/docs/swagger.json +9 -9
- package/tsconfig.json +7 -10
package/build/config.d.ts
CHANGED
|
@@ -2,37 +2,37 @@
|
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
import { EventEmitter } from 'events';
|
|
4
4
|
export declare class Config extends EventEmitter {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
5
|
+
protected readonly debug: string;
|
|
6
|
+
protected readonly host: string;
|
|
7
|
+
protected readonly external: string | undefined;
|
|
8
|
+
protected readonly isWin: boolean;
|
|
9
|
+
protected port: number;
|
|
10
|
+
protected downloadsDir: string;
|
|
11
|
+
protected dataDir: string;
|
|
12
|
+
protected metricsJSONPath: string;
|
|
13
|
+
protected createDataDir: boolean;
|
|
14
|
+
protected createDownloadsDir: boolean;
|
|
15
|
+
protected routes: string;
|
|
16
|
+
protected token: string | null;
|
|
17
|
+
protected concurrent: number;
|
|
18
|
+
protected queued: number;
|
|
19
|
+
protected timeout: number;
|
|
20
|
+
protected static: string;
|
|
21
|
+
protected retries: number;
|
|
22
|
+
protected allowFileProtocol: boolean;
|
|
23
|
+
protected allowGet: boolean;
|
|
24
|
+
protected allowCors: boolean;
|
|
25
|
+
protected corsMethods: string;
|
|
26
|
+
protected corsOrigin: string;
|
|
27
|
+
protected corsMaxAge: number;
|
|
28
|
+
protected maxCpu: number;
|
|
29
|
+
protected maxMemory: number;
|
|
30
|
+
protected healthCheck: boolean;
|
|
31
|
+
protected failedHealthURL: string | null;
|
|
32
|
+
protected queueAlertURL: string | null;
|
|
33
|
+
protected rejectAlertURL: string | null;
|
|
34
|
+
protected timeoutAlertURL: string | null;
|
|
35
|
+
protected errorAlertURL: string | null;
|
|
36
36
|
getRoutes: () => string;
|
|
37
37
|
getHost: () => string;
|
|
38
38
|
getPort: () => number;
|
package/build/exports.d.ts
CHANGED
|
@@ -8,8 +8,10 @@ export * from './limiter.js';
|
|
|
8
8
|
export * from './metrics.js';
|
|
9
9
|
export * from './mime-types.js';
|
|
10
10
|
export * from './monitoring.js';
|
|
11
|
+
export * from './router.js';
|
|
11
12
|
export * from './server.js';
|
|
12
13
|
export * from './shim.js';
|
|
14
|
+
export * from './token.js';
|
|
13
15
|
export * from './types.js';
|
|
14
16
|
export * from './utils.js';
|
|
15
17
|
export * from './webhooks.js';
|
package/build/exports.js
CHANGED
|
@@ -9,8 +9,10 @@ export * from './limiter.js';
|
|
|
9
9
|
export * from './metrics.js';
|
|
10
10
|
export * from './mime-types.js';
|
|
11
11
|
export * from './monitoring.js';
|
|
12
|
+
export * from './router.js';
|
|
12
13
|
export * from './server.js';
|
|
13
14
|
export * from './shim.js';
|
|
15
|
+
export * from './token.js';
|
|
14
16
|
export * from './types.js';
|
|
15
17
|
export * from './utils.js';
|
|
16
18
|
export * from './webhooks.js';
|
package/build/file-system.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Config } from '@browserless.io/browserless';
|
|
2
2
|
export declare class FileSystem {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
protected config: Config;
|
|
4
|
+
protected fsMap: Map<string, string[]>;
|
|
5
5
|
constructor(config: Config);
|
|
6
6
|
/**
|
|
7
7
|
* Appends contents to a file-path for persistance. File contents are
|
package/build/limiter.d.ts
CHANGED
|
@@ -1,20 +1,42 @@
|
|
|
1
|
+
/// <reference types="debug" />
|
|
1
2
|
import { Config, Metrics, Monitoring, WebHooks } from '@browserless.io/browserless';
|
|
2
3
|
import q from 'queue';
|
|
3
4
|
export type LimitFn<TArgs extends unknown[], TResult> = (...args: TArgs) => Promise<TResult>;
|
|
4
5
|
export type ErrorFn<TArgs extends unknown[]> = (...args: TArgs) => void;
|
|
6
|
+
interface Job {
|
|
7
|
+
(): Promise<unknown>;
|
|
8
|
+
args: unknown[];
|
|
9
|
+
onTimeoutFn: (job: Job) => unknown;
|
|
10
|
+
start: number;
|
|
11
|
+
timeout: number;
|
|
12
|
+
}
|
|
5
13
|
export declare class Limiter extends q {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
14
|
+
protected config: Config;
|
|
15
|
+
protected metrics: Metrics;
|
|
16
|
+
protected monitor: Monitoring;
|
|
17
|
+
protected webhooks: WebHooks;
|
|
18
|
+
protected queued: number;
|
|
19
|
+
protected debug: import("debug").Debugger;
|
|
12
20
|
constructor(config: Config, metrics: Metrics, monitor: Monitoring, webhooks: WebHooks);
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
21
|
+
protected handleEnd(): void;
|
|
22
|
+
protected handleSuccess({ detail: { job } }: {
|
|
23
|
+
detail: {
|
|
24
|
+
job: Job;
|
|
25
|
+
};
|
|
26
|
+
}): void;
|
|
27
|
+
protected handleJobTimeout({ detail: { next, job }, }: {
|
|
28
|
+
detail: {
|
|
29
|
+
job: Job;
|
|
30
|
+
next: Job;
|
|
31
|
+
};
|
|
32
|
+
}): void;
|
|
33
|
+
protected handleFail({ detail: { error, job }, }: {
|
|
34
|
+
detail: {
|
|
35
|
+
error: unknown;
|
|
36
|
+
job: Job;
|
|
37
|
+
};
|
|
38
|
+
}): void;
|
|
39
|
+
protected logQueue(message: string): void;
|
|
18
40
|
get executing(): number;
|
|
19
41
|
get waiting(): number;
|
|
20
42
|
get willQueue(): boolean;
|
|
@@ -22,3 +44,4 @@ export declare class Limiter extends q {
|
|
|
22
44
|
get hasCapacity(): boolean;
|
|
23
45
|
limit: <TArgs extends unknown[], TResult>(limitFn: LimitFn<TArgs, TResult>, overCapacityFn: ErrorFn<TArgs>, onTimeoutFn: ErrorFn<TArgs>, timeoutOverrideFn: (...args: TArgs) => number | undefined) => LimitFn<TArgs, unknown>;
|
|
24
46
|
}
|
|
47
|
+
export {};
|
package/build/metrics.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { IBrowserlessStats } from '@browserless.io/browserless';
|
|
2
2
|
export declare class Metrics {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
3
|
+
protected sessionTimes: number[];
|
|
4
|
+
protected successful: number;
|
|
5
|
+
protected queued: number;
|
|
6
|
+
protected rejected: number;
|
|
7
|
+
protected unauthorized: number;
|
|
8
|
+
protected concurrent: number;
|
|
9
|
+
protected timedout: number;
|
|
10
|
+
protected running: number;
|
|
11
|
+
protected unhealthy: number;
|
|
12
|
+
protected error: number;
|
|
13
13
|
addSuccessful: (sessionTime: number) => number;
|
|
14
14
|
addTimedout: (sessionTime: number) => number;
|
|
15
15
|
addError: (sessionTime: number) => number;
|
|
@@ -20,5 +20,11 @@ export declare class Metrics {
|
|
|
20
20
|
addRunning: () => number;
|
|
21
21
|
get: () => Omit<IBrowserlessStats, 'cpu' | 'memory'>;
|
|
22
22
|
reset: () => void;
|
|
23
|
-
|
|
23
|
+
protected calculateStats(sessionTimes: number[]): {
|
|
24
|
+
maxTime: number;
|
|
25
|
+
meanTime: number;
|
|
26
|
+
minTime: number;
|
|
27
|
+
totalTime: number;
|
|
28
|
+
units: number;
|
|
29
|
+
};
|
|
24
30
|
}
|
package/build/monitoring.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
/// <reference types="debug" />
|
|
1
2
|
import { Config, IResourceLoad } from '@browserless.io/browserless';
|
|
2
3
|
export declare class Monitoring {
|
|
3
|
-
|
|
4
|
-
|
|
4
|
+
protected config: Config;
|
|
5
|
+
protected log: import("debug").Debugger;
|
|
5
6
|
constructor(config: Config);
|
|
6
7
|
getMachineStats: () => Promise<IResourceLoad>;
|
|
7
8
|
overloaded: () => Promise<{
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/// <reference types="debug" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
/// <reference types="node" />
|
|
4
|
+
import { BrowserHTTPRoute, BrowserManager, BrowserWebsocketRoute, Config, HTTPRoute, Limiter, Request, Response, WebSocketRoute } from '@browserless.io/browserless';
|
|
5
|
+
import stream from 'stream';
|
|
6
|
+
export declare class Router {
|
|
7
|
+
protected config: Config;
|
|
8
|
+
protected browserManager: BrowserManager;
|
|
9
|
+
protected limiter: Limiter;
|
|
10
|
+
protected log: import("debug").Debugger;
|
|
11
|
+
protected verbose: import("debug").Debugger;
|
|
12
|
+
protected httpRoutes: Array<HTTPRoute | BrowserHTTPRoute>;
|
|
13
|
+
protected webSocketRoutes: Array<WebSocketRoute | BrowserWebsocketRoute>;
|
|
14
|
+
constructor(config: Config, browserManager: BrowserManager, limiter: Limiter);
|
|
15
|
+
protected getTimeout(req: Request): number | undefined;
|
|
16
|
+
protected onQueueFullHTTP: (_req: Request, res: Response) => void;
|
|
17
|
+
protected onQueueFullWebSocket: (_req: Request, socket: stream.Duplex) => void;
|
|
18
|
+
protected onHTTPTimeout: (_req: Request, res: Response) => void;
|
|
19
|
+
protected onWebsocketTimeout: (_req: Request, socket: stream.Duplex) => void;
|
|
20
|
+
protected wrapHTTPHandler: (route: HTTPRoute | BrowserHTTPRoute, handler: HTTPRoute['handler'] | BrowserHTTPRoute['handler']) => (req: Request, res: Response) => Promise<unknown>;
|
|
21
|
+
protected wrapWebSocketHandler: (route: WebSocketRoute | BrowserWebsocketRoute, handler: WebSocketRoute['handler'] | BrowserWebsocketRoute['handler']) => (req: Request, socket: stream.Duplex, head: Buffer) => Promise<unknown>;
|
|
22
|
+
registerHTTPRoute(route: HTTPRoute | BrowserHTTPRoute): HTTPRoute | BrowserHTTPRoute;
|
|
23
|
+
registerWebSocketRoute(route: WebSocketRoute | BrowserWebsocketRoute): WebSocketRoute | BrowserWebsocketRoute;
|
|
24
|
+
teardown(): Promise<void>;
|
|
25
|
+
getStaticHandler(): HTTPRoute;
|
|
26
|
+
getRouteForHTTPRequest(req: Request): Promise<HTTPRoute | BrowserHTTPRoute | null>;
|
|
27
|
+
getRouteForWebSocketRequest(req: Request): Promise<WebSocketRoute | BrowserWebsocketRoute | undefined>;
|
|
28
|
+
}
|
package/build/router.js
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { HTTPManagementRoutes, contentTypes, createLogger, isConnected, writeResponse, } from '@browserless.io/browserless';
|
|
2
|
+
import micromatch from 'micromatch';
|
|
3
|
+
export class Router {
|
|
4
|
+
config;
|
|
5
|
+
browserManager;
|
|
6
|
+
limiter;
|
|
7
|
+
log = createLogger('router');
|
|
8
|
+
verbose = createLogger('router:verbose');
|
|
9
|
+
httpRoutes = [];
|
|
10
|
+
webSocketRoutes = [];
|
|
11
|
+
constructor(config, browserManager, limiter) {
|
|
12
|
+
this.config = config;
|
|
13
|
+
this.browserManager = browserManager;
|
|
14
|
+
this.limiter = limiter;
|
|
15
|
+
}
|
|
16
|
+
getTimeout(req) {
|
|
17
|
+
const timer = req.parsed.searchParams.get('timeout');
|
|
18
|
+
return timer ? +timer : undefined;
|
|
19
|
+
}
|
|
20
|
+
onQueueFullHTTP = (_req, res) => {
|
|
21
|
+
this.log(`Queue is full, sending 429 response`);
|
|
22
|
+
return writeResponse(res, 429, 'Too many requests');
|
|
23
|
+
};
|
|
24
|
+
onQueueFullWebSocket = (_req, socket) => {
|
|
25
|
+
this.log(`Queue is full, sending 429 response`);
|
|
26
|
+
return writeResponse(socket, 429, 'Too many requests');
|
|
27
|
+
};
|
|
28
|
+
onHTTPTimeout = (_req, res) => {
|
|
29
|
+
this.log(`HTTP job has timedout, sending 429 response`);
|
|
30
|
+
return writeResponse(res, 408, 'Request has timed out');
|
|
31
|
+
};
|
|
32
|
+
onWebsocketTimeout = (_req, socket) => {
|
|
33
|
+
this.log(`Websocket job has timedout, sending 429 response`);
|
|
34
|
+
return writeResponse(socket, 408, 'Request has timed out');
|
|
35
|
+
};
|
|
36
|
+
wrapHTTPHandler = (route, handler) => async (req, res) => {
|
|
37
|
+
if (!isConnected(res)) {
|
|
38
|
+
this.log(`HTTP Request has closed prior to running`);
|
|
39
|
+
return Promise.resolve();
|
|
40
|
+
}
|
|
41
|
+
if (route.browser) {
|
|
42
|
+
const browser = await this.browserManager.getBrowserForRequest(req, route);
|
|
43
|
+
if (!isConnected(res)) {
|
|
44
|
+
this.log(`HTTP Request has closed prior to running`);
|
|
45
|
+
this.browserManager.complete(browser);
|
|
46
|
+
return Promise.resolve();
|
|
47
|
+
}
|
|
48
|
+
if (!browser) {
|
|
49
|
+
return writeResponse(res, 500, `Error loading the browser.`);
|
|
50
|
+
}
|
|
51
|
+
if (!isConnected(res)) {
|
|
52
|
+
this.log(`HTTP Request has closed prior to running`);
|
|
53
|
+
return Promise.resolve();
|
|
54
|
+
}
|
|
55
|
+
try {
|
|
56
|
+
this.verbose(`Running found HTTP handler.`);
|
|
57
|
+
return await handler(req, res, browser);
|
|
58
|
+
}
|
|
59
|
+
finally {
|
|
60
|
+
this.verbose(`HTTP Request handler has finished.`);
|
|
61
|
+
this.browserManager.complete(browser);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return handler(req, res);
|
|
65
|
+
};
|
|
66
|
+
wrapWebSocketHandler = (route, handler) => async (req, socket, head) => {
|
|
67
|
+
if (!isConnected(socket)) {
|
|
68
|
+
this.log(`WebSocket Request has closed prior to running`);
|
|
69
|
+
return Promise.resolve();
|
|
70
|
+
}
|
|
71
|
+
if (route.browser) {
|
|
72
|
+
const browser = await this.browserManager.getBrowserForRequest(req, route);
|
|
73
|
+
if (!isConnected(socket)) {
|
|
74
|
+
this.log(`WebSocket Request has closed prior to running`);
|
|
75
|
+
this.browserManager.complete(browser);
|
|
76
|
+
return Promise.resolve();
|
|
77
|
+
}
|
|
78
|
+
if (!browser) {
|
|
79
|
+
return writeResponse(socket, 500, `Error loading the browser.`);
|
|
80
|
+
}
|
|
81
|
+
try {
|
|
82
|
+
this.verbose(`Running found WebSocket handler.`);
|
|
83
|
+
await handler(req, socket, head, browser);
|
|
84
|
+
}
|
|
85
|
+
finally {
|
|
86
|
+
this.verbose(`WebSocket Request handler has finished.`);
|
|
87
|
+
this.browserManager.complete(browser);
|
|
88
|
+
}
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
return handler(req, socket, head);
|
|
92
|
+
};
|
|
93
|
+
registerHTTPRoute(route) {
|
|
94
|
+
this.verbose(`Registering HTTP ${route.method.toUpperCase()} ${route.path}`);
|
|
95
|
+
route.getBrowserManager = () => this.browserManager;
|
|
96
|
+
const bound = route.handler.bind(route);
|
|
97
|
+
const wrapped = this.wrapHTTPHandler(route, bound);
|
|
98
|
+
route.handler = route.concurrency
|
|
99
|
+
? this.limiter.limit(wrapped, this.onQueueFullHTTP, this.onHTTPTimeout, this.getTimeout)
|
|
100
|
+
: wrapped;
|
|
101
|
+
this.httpRoutes.push(route);
|
|
102
|
+
return route;
|
|
103
|
+
}
|
|
104
|
+
registerWebSocketRoute(route) {
|
|
105
|
+
this.verbose(`Registering WebSocket "${route.path}"`);
|
|
106
|
+
route.getBrowserManager = () => this.browserManager;
|
|
107
|
+
const bound = route.handler.bind(route);
|
|
108
|
+
const wrapped = this.wrapWebSocketHandler(route, bound);
|
|
109
|
+
route.handler = route.concurrency
|
|
110
|
+
? this.limiter.limit(wrapped, this.onQueueFullWebSocket, this.onWebsocketTimeout, this.getTimeout)
|
|
111
|
+
: wrapped;
|
|
112
|
+
this.webSocketRoutes.push(route);
|
|
113
|
+
return route;
|
|
114
|
+
}
|
|
115
|
+
teardown() {
|
|
116
|
+
this.httpRoutes = [];
|
|
117
|
+
this.webSocketRoutes = [];
|
|
118
|
+
return this.browserManager.stop();
|
|
119
|
+
}
|
|
120
|
+
getStaticHandler() {
|
|
121
|
+
return this.httpRoutes.find((route) => route.path === HTTPManagementRoutes.static);
|
|
122
|
+
}
|
|
123
|
+
async getRouteForHTTPRequest(req) {
|
|
124
|
+
const accepts = (req.headers['accept']?.toLowerCase() || '*/*').split(',');
|
|
125
|
+
const contentType = req.headers['content-type']?.toLowerCase();
|
|
126
|
+
return (this.httpRoutes.find((r) => micromatch.isMatch(req.parsed.pathname, r.path) &&
|
|
127
|
+
r.method === req.method?.toLocaleLowerCase() &&
|
|
128
|
+
(accepts.some((a) => a.startsWith('*/*')) ||
|
|
129
|
+
r.contentTypes.some((contentType) => accepts.includes(contentType))) &&
|
|
130
|
+
((!contentType && r.accepts.includes(contentTypes.any)) ||
|
|
131
|
+
r.accepts.includes(contentType))) ||
|
|
132
|
+
(req.method?.toLowerCase() === 'get' ? this.getStaticHandler() : null));
|
|
133
|
+
}
|
|
134
|
+
async getRouteForWebSocketRequest(req) {
|
|
135
|
+
const { pathname } = req.parsed;
|
|
136
|
+
return this.webSocketRoutes.find((r) => micromatch.isMatch(pathname, r.path));
|
|
137
|
+
}
|
|
138
|
+
}
|
|
@@ -398,14 +398,14 @@
|
|
|
398
398
|
"length": {
|
|
399
399
|
"type": "number"
|
|
400
400
|
},
|
|
401
|
-
"__@toStringTag@
|
|
401
|
+
"__@toStringTag@10725": {
|
|
402
402
|
"type": "string",
|
|
403
403
|
"const": "Uint8Array"
|
|
404
404
|
}
|
|
405
405
|
},
|
|
406
406
|
"required": [
|
|
407
407
|
"BYTES_PER_ELEMENT",
|
|
408
|
-
"__@toStringTag@
|
|
408
|
+
"__@toStringTag@10725",
|
|
409
409
|
"buffer",
|
|
410
410
|
"byteLength",
|
|
411
411
|
"byteOffset",
|
|
@@ -440,13 +440,13 @@
|
|
|
440
440
|
"byteLength": {
|
|
441
441
|
"type": "number"
|
|
442
442
|
},
|
|
443
|
-
"__@toStringTag@
|
|
443
|
+
"__@toStringTag@10725": {
|
|
444
444
|
"type": "string"
|
|
445
445
|
}
|
|
446
446
|
},
|
|
447
447
|
"additionalProperties": false,
|
|
448
448
|
"required": [
|
|
449
|
-
"__@toStringTag@
|
|
449
|
+
"__@toStringTag@10725",
|
|
450
450
|
"byteLength"
|
|
451
451
|
]
|
|
452
452
|
},
|
|
@@ -456,18 +456,18 @@
|
|
|
456
456
|
"byteLength": {
|
|
457
457
|
"type": "number"
|
|
458
458
|
},
|
|
459
|
-
"__@species@
|
|
459
|
+
"__@species@10826": {
|
|
460
460
|
"$ref": "#/definitions/SharedArrayBuffer"
|
|
461
461
|
},
|
|
462
|
-
"__@toStringTag@
|
|
462
|
+
"__@toStringTag@10725": {
|
|
463
463
|
"type": "string",
|
|
464
464
|
"const": "SharedArrayBuffer"
|
|
465
465
|
}
|
|
466
466
|
},
|
|
467
467
|
"additionalProperties": false,
|
|
468
468
|
"required": [
|
|
469
|
-
"__@species@
|
|
470
|
-
"__@toStringTag@
|
|
469
|
+
"__@species@10826",
|
|
470
|
+
"__@toStringTag@10725",
|
|
471
471
|
"byteLength"
|
|
472
472
|
]
|
|
473
473
|
},
|
|
@@ -18,7 +18,7 @@ const route = {
|
|
|
18
18
|
that are written for execution inside of the browser. Once your script is finished, any
|
|
19
19
|
downloaded files from Chromium are returned back with the appropriate content-type header.`),
|
|
20
20
|
handler: async (req, res, browser) => new Promise(async (resolve, reject) => {
|
|
21
|
-
const {
|
|
21
|
+
const { getConfig: getConfig, getDebug: getDebug } = route;
|
|
22
22
|
if (!getConfig || !getDebug) {
|
|
23
23
|
return reject(new ServerError(`Couldn't load configuration for request`));
|
|
24
24
|
}
|
|
@@ -15,7 +15,7 @@ const route = {
|
|
|
15
15
|
Values returned from the function are checked and an appropriate content-type and response is sent back
|
|
16
16
|
to your HTTP call.`),
|
|
17
17
|
handler: async (req, res, browser) => {
|
|
18
|
-
const {
|
|
18
|
+
const { getConfig: getConfig, getDebug: getDebug } = route;
|
|
19
19
|
if (!getConfig || !getDebug) {
|
|
20
20
|
throw new ServerError(`Couldn't load configuration for request`);
|
|
21
21
|
}
|
|
@@ -538,14 +538,14 @@
|
|
|
538
538
|
"length": {
|
|
539
539
|
"type": "number"
|
|
540
540
|
},
|
|
541
|
-
"__@toStringTag@
|
|
541
|
+
"__@toStringTag@42863": {
|
|
542
542
|
"type": "string",
|
|
543
543
|
"const": "Uint8Array"
|
|
544
544
|
}
|
|
545
545
|
},
|
|
546
546
|
"required": [
|
|
547
547
|
"BYTES_PER_ELEMENT",
|
|
548
|
-
"__@toStringTag@
|
|
548
|
+
"__@toStringTag@42863",
|
|
549
549
|
"buffer",
|
|
550
550
|
"byteLength",
|
|
551
551
|
"byteOffset",
|
|
@@ -580,13 +580,13 @@
|
|
|
580
580
|
"byteLength": {
|
|
581
581
|
"type": "number"
|
|
582
582
|
},
|
|
583
|
-
"__@toStringTag@
|
|
583
|
+
"__@toStringTag@42863": {
|
|
584
584
|
"type": "string"
|
|
585
585
|
}
|
|
586
586
|
},
|
|
587
587
|
"additionalProperties": false,
|
|
588
588
|
"required": [
|
|
589
|
-
"__@toStringTag@
|
|
589
|
+
"__@toStringTag@42863",
|
|
590
590
|
"byteLength"
|
|
591
591
|
]
|
|
592
592
|
},
|
|
@@ -596,18 +596,18 @@
|
|
|
596
596
|
"byteLength": {
|
|
597
597
|
"type": "number"
|
|
598
598
|
},
|
|
599
|
-
"__@species@
|
|
599
|
+
"__@species@42964": {
|
|
600
600
|
"$ref": "#/definitions/SharedArrayBuffer"
|
|
601
601
|
},
|
|
602
|
-
"__@toStringTag@
|
|
602
|
+
"__@toStringTag@42863": {
|
|
603
603
|
"type": "string",
|
|
604
604
|
"const": "SharedArrayBuffer"
|
|
605
605
|
}
|
|
606
606
|
},
|
|
607
607
|
"additionalProperties": false,
|
|
608
608
|
"required": [
|
|
609
|
-
"__@species@
|
|
610
|
-
"__@toStringTag@
|
|
609
|
+
"__@species@42964",
|
|
610
|
+
"__@toStringTag@42863",
|
|
611
611
|
"byteLength"
|
|
612
612
|
]
|
|
613
613
|
},
|
|
@@ -8,7 +8,7 @@ const route = {
|
|
|
8
8
|
contentTypes: [contentTypes.json],
|
|
9
9
|
description: `Run lighthouse performance audits with a supplied "url" in your JSON payload.`,
|
|
10
10
|
handler: async (req, res, browser) => {
|
|
11
|
-
const {
|
|
11
|
+
const { getConfig: getConfig } = route;
|
|
12
12
|
if (!req.body) {
|
|
13
13
|
throw new BadRequest(`No JSON body present`);
|
|
14
14
|
}
|
|
@@ -445,14 +445,14 @@
|
|
|
445
445
|
"length": {
|
|
446
446
|
"type": "number"
|
|
447
447
|
},
|
|
448
|
-
"__@toStringTag@
|
|
448
|
+
"__@toStringTag@64356": {
|
|
449
449
|
"type": "string",
|
|
450
450
|
"const": "Uint8Array"
|
|
451
451
|
}
|
|
452
452
|
},
|
|
453
453
|
"required": [
|
|
454
454
|
"BYTES_PER_ELEMENT",
|
|
455
|
-
"__@toStringTag@
|
|
455
|
+
"__@toStringTag@64356",
|
|
456
456
|
"buffer",
|
|
457
457
|
"byteLength",
|
|
458
458
|
"byteOffset",
|
|
@@ -487,13 +487,13 @@
|
|
|
487
487
|
"byteLength": {
|
|
488
488
|
"type": "number"
|
|
489
489
|
},
|
|
490
|
-
"__@toStringTag@
|
|
490
|
+
"__@toStringTag@64356": {
|
|
491
491
|
"type": "string"
|
|
492
492
|
}
|
|
493
493
|
},
|
|
494
494
|
"additionalProperties": false,
|
|
495
495
|
"required": [
|
|
496
|
-
"__@toStringTag@
|
|
496
|
+
"__@toStringTag@64356",
|
|
497
497
|
"byteLength"
|
|
498
498
|
]
|
|
499
499
|
},
|
|
@@ -503,18 +503,18 @@
|
|
|
503
503
|
"byteLength": {
|
|
504
504
|
"type": "number"
|
|
505
505
|
},
|
|
506
|
-
"__@species@
|
|
506
|
+
"__@species@64457": {
|
|
507
507
|
"$ref": "#/definitions/SharedArrayBuffer"
|
|
508
508
|
},
|
|
509
|
-
"__@toStringTag@
|
|
509
|
+
"__@toStringTag@64356": {
|
|
510
510
|
"type": "string",
|
|
511
511
|
"const": "SharedArrayBuffer"
|
|
512
512
|
}
|
|
513
513
|
},
|
|
514
514
|
"additionalProperties": false,
|
|
515
515
|
"required": [
|
|
516
|
-
"__@species@
|
|
517
|
-
"__@toStringTag@
|
|
516
|
+
"__@species@64457",
|
|
517
|
+
"__@toStringTag@64356",
|
|
518
518
|
"byteLength"
|
|
519
519
|
]
|
|
520
520
|
},
|
|
@@ -488,14 +488,14 @@
|
|
|
488
488
|
"length": {
|
|
489
489
|
"type": "number"
|
|
490
490
|
},
|
|
491
|
-
"__@toStringTag@
|
|
491
|
+
"__@toStringTag@75317": {
|
|
492
492
|
"type": "string",
|
|
493
493
|
"const": "Uint8Array"
|
|
494
494
|
}
|
|
495
495
|
},
|
|
496
496
|
"required": [
|
|
497
497
|
"BYTES_PER_ELEMENT",
|
|
498
|
-
"__@toStringTag@
|
|
498
|
+
"__@toStringTag@75317",
|
|
499
499
|
"buffer",
|
|
500
500
|
"byteLength",
|
|
501
501
|
"byteOffset",
|
|
@@ -530,13 +530,13 @@
|
|
|
530
530
|
"byteLength": {
|
|
531
531
|
"type": "number"
|
|
532
532
|
},
|
|
533
|
-
"__@toStringTag@
|
|
533
|
+
"__@toStringTag@75317": {
|
|
534
534
|
"type": "string"
|
|
535
535
|
}
|
|
536
536
|
},
|
|
537
537
|
"additionalProperties": false,
|
|
538
538
|
"required": [
|
|
539
|
-
"__@toStringTag@
|
|
539
|
+
"__@toStringTag@75317",
|
|
540
540
|
"byteLength"
|
|
541
541
|
]
|
|
542
542
|
},
|
|
@@ -546,18 +546,18 @@
|
|
|
546
546
|
"byteLength": {
|
|
547
547
|
"type": "number"
|
|
548
548
|
},
|
|
549
|
-
"__@species@
|
|
549
|
+
"__@species@75418": {
|
|
550
550
|
"$ref": "#/definitions/SharedArrayBuffer"
|
|
551
551
|
},
|
|
552
|
-
"__@toStringTag@
|
|
552
|
+
"__@toStringTag@75317": {
|
|
553
553
|
"type": "string",
|
|
554
554
|
"const": "SharedArrayBuffer"
|
|
555
555
|
}
|
|
556
556
|
},
|
|
557
557
|
"additionalProperties": false,
|
|
558
558
|
"required": [
|
|
559
|
-
"__@species@
|
|
560
|
-
"__@toStringTag@
|
|
559
|
+
"__@species@75418",
|
|
560
|
+
"__@toStringTag@75317",
|
|
561
561
|
"byteLength"
|
|
562
562
|
]
|
|
563
563
|
},
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { Page } from 'puppeteer-core';
|
|
1
|
+
import { Browser, Page } from 'puppeteer-core';
|
|
2
2
|
type codeHandler = (params: {
|
|
3
3
|
context: unknown;
|
|
4
4
|
page: Page;
|
|
5
5
|
}) => Promise<unknown>;
|
|
6
6
|
export declare class FunctionRunner {
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
protected browser?: Browser;
|
|
8
|
+
protected page?: Page;
|
|
9
9
|
log: () => {
|
|
10
10
|
(...data: any[]): void;
|
|
11
11
|
(message?: any, ...optionalParams: any[]): void;
|
|
@@ -7,7 +7,7 @@ const route = {
|
|
|
7
7
|
contentTypes: [contentTypes.json],
|
|
8
8
|
description: `Returns a JSON payload of the current system configuration.`,
|
|
9
9
|
handler: async (_req, res) => {
|
|
10
|
-
const {
|
|
10
|
+
const { getConfig: getConfig } = route;
|
|
11
11
|
if (!getConfig) {
|
|
12
12
|
throw new ServerError(`Couldn't locate the config object`);
|
|
13
13
|
}
|