(options: Options)
| 5 | import { setupWebSocket } from './websocket' |
| 6 | |
| 7 | export const createAdaptorServer = (options: Options): ServerType => { |
| 8 | const fetchCallback = options.fetch |
| 9 | const requestListener = getRequestListener(fetchCallback, { |
| 10 | hostname: options.hostname, |
| 11 | overrideGlobalObjects: options.overrideGlobalObjects, |
| 12 | autoCleanupIncoming: options.autoCleanupIncoming, |
| 13 | }) |
| 14 | // ts will complain about createServerHTTP and createServerHTTP2 not being callable, which works just fine |
| 15 | // eslint-disable-next-line @typescript-eslint/no-explicit-any |
| 16 | const createServer: any = options.createServer || createServerHTTP |
| 17 | const server: ServerType = createServer(options.serverOptions || {}, requestListener) |
| 18 | if (options.websocket && options.websocket.server) { |
| 19 | if (options.websocket.server.options.noServer !== true) |
| 20 | throw new Error('WebSocket server must be created with { noServer: true } option') |
| 21 | setupWebSocket({ server, fetchCallback, wss: options.websocket.server }) |
| 22 | } |
| 23 | return server |
| 24 | } |
| 25 | |
| 26 | export const serve = ( |
| 27 | options: Options, |
searching dependent graphs…