(reqUrl: string, res: ServerResponse)
| 365 | } |
| 366 | |
| 367 | _processDebugRequest(reqUrl: string, res: ServerResponse) { |
| 368 | let ret = '<!doctype html>'; |
| 369 | const pathname = url.parse(reqUrl).pathname; |
| 370 | /* $FlowFixMe: pathname would be null for an invalid URL */ |
| 371 | const parts = pathname.split('/').filter(Boolean); |
| 372 | if (parts.length === 1) { |
| 373 | ret += '<div><a href="/debug/bundles">Cached Bundles</a></div>'; |
| 374 | res.end(ret); |
| 375 | } else if (parts[1] === 'bundles') { |
| 376 | ret += '<h1> Cached Bundles </h1>'; |
| 377 | Promise.all(Object.keys(this._bundles).map(optionsJson => |
| 378 | this._bundles[optionsJson].then(p => { |
| 379 | ret += '<div><h2>' + optionsJson + '</h2>'; |
| 380 | ret += p.getDebugInfo(); |
| 381 | }) |
| 382 | )).then( |
| 383 | () => res.end(ret), |
| 384 | e => { |
| 385 | res.writeHead(500); |
| 386 | res.end('Internal Error'); |
| 387 | terminal.log(e.stack); // eslint-disable-line no-console-disallow |
| 388 | } |
| 389 | ); |
| 390 | } else { |
| 391 | res.writeHead(404); |
| 392 | res.end('Invalid debug request'); |
| 393 | return; |
| 394 | } |
| 395 | } |
| 396 | |
| 397 | _processOnChangeRequest(req: IncomingMessage, res: ServerResponse) { |
| 398 | const watchers = this._changeWatchers; |
no test coverage detected