()
| 345 | } |
| 346 | |
| 347 | public async start() { |
| 348 | const httpRoutes: Array<HTTPRoute | BrowserHTTPRoute> = []; |
| 349 | const wsRoutes: Array<WebSocketRoute | BrowserWebsocketRoute> = []; |
| 350 | const internalBrowsers = [ |
| 351 | ChromiumCDP, |
| 352 | ChromeCDP, |
| 353 | EdgeCDP, |
| 354 | FirefoxPlaywright, |
| 355 | EdgePlaywright, |
| 356 | ChromiumPlaywright, |
| 357 | WebKitPlaywright, |
| 358 | ]; |
| 359 | |
| 360 | const [[internalHttpRouteFiles, internalWsRouteFiles], installedBrowsers] = |
| 361 | await Promise.all([getRouteFiles(this.config), availableBrowsers]); |
| 362 | |
| 363 | const hasDebugger = await this.config.hasDebugger(); |
| 364 | const debuggerURL = |
| 365 | hasDebugger && |
| 366 | makeExternalURL(this.config.getExternalAddress(), `/debugger/?token=xxx`); |
| 367 | const docsLink = makeExternalURL( |
| 368 | this.config.getExternalAddress(), |
| 369 | '/docs/', |
| 370 | ); |
| 371 | |
| 372 | this.logger.info(printLogo(docsLink, debuggerURL)); |
| 373 | this.logger.info(`Running as user "${userInfo().username}"`); |
| 374 | this.logger.debug('Starting import of HTTP Routes'); |
| 375 | |
| 376 | for (const httpRoute of [ |
| 377 | ...this.httpRouteFiles, |
| 378 | ...internalHttpRouteFiles, |
| 379 | ]) { |
| 380 | if (httpRoute.endsWith('js')) { |
| 381 | const [bodySchema, querySchema] = await Promise.all( |
| 382 | routeSchemas.map(async (schemaType) => { |
| 383 | const schemaPath = path.parse(httpRoute); |
| 384 | schemaPath.base = `${schemaPath.name}.${schemaType}.json`; |
| 385 | return await readFile(path.format(schemaPath), 'utf-8').catch( |
| 386 | () => '', |
| 387 | ); |
| 388 | }), |
| 389 | ); |
| 390 | |
| 391 | const routeImport = `${ |
| 392 | this.config.getIsWin() ? 'file:///' : '' |
| 393 | }${httpRoute}`; |
| 394 | const { |
| 395 | default: Route, |
| 396 | }: { default: Implements<HTTPRoute> | Implements<BrowserHTTPRoute> } = |
| 397 | await import(routeImport + `?cb=${Date.now()}`); |
| 398 | const route = new Route( |
| 399 | this.browserManager, |
| 400 | this.config, |
| 401 | this.fileSystem, |
| 402 | this.metrics, |
| 403 | this.monitoring, |
| 404 | this.staticSDKDir, |
no test coverage detected