MCPcopy Index your code
hub / github.com/honojs/node-server / createAdaptorServer

Function createAdaptorServer

src/server.ts:7–24  ·  view source on GitHub ↗
(options: Options)

Source from the content-addressed store, hash-verified

5import { setupWebSocket } from './websocket'
6
7export 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
26export const serve = (
27 options: Options,

Callers 6

startServerFunction · 0.90
server.test.tsFile · 0.90
runnerFunction · 0.90
response.test.tsFile · 0.90
serveFunction · 0.85

Calls 2

getRequestListenerFunction · 0.90
setupWebSocketFunction · 0.90

Tested by 2

startServerFunction · 0.72
runnerFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…