MCPcopy
hub / github.com/fastify/fastify / serverFactory

Function serverFactory

test/types/serverFactory.tst.ts:15–24  ·  view source on GitHub ↗
(handler, opts)

Source from the content-addressed store, hash-verified

13}
14
15const serverFactory: FastifyServerFactory<http.Server> = (handler, opts) => {
16 const server = http.createServer((req: CustomIncomingMessage, res: CustomServerResponse) => {
17 req.fakeMethod = () => {}
18 res.fakeMethod = () => {}
19
20 handler(req, res)
21 })
22
23 return server
24}
25
26// The request and reply objects should have the fakeMethods available (even though they may be undefined)
27const customServer = fastify<http.Server, CustomIncomingMessage, CustomServerResponse>({ serverFactory })

Callers

nothing calls this directly

Calls 1

handlerFunction · 0.70

Tested by

no test coverage detected