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

Function fastify

fastify.js:89–850  ·  fastify.js::fastify

* @param {import('./fastify.js').FastifyServerOptions} serverOptions

(serverOptions)

Source from the content-addressed store, hash-verified

87 * @param {import(class="st">'./fastify.js').FastifyServerOptions} serverOptions
88 */
89function fastify (serverOptions) {
90 const {
91 options,
92 genReqId,
93 disableRequestLogging,
94 hasLogger,
95 initialConfig
96 } = processOptions(serverOptions, defaultRoute, onBadUrl, onMaxParamLength)
97
98 class="cm">// Default router
99 const router = buildRouting(options.routerOptions)
100
101 class="cm">// 404 router, used for handling encapsulated 404 handlers
102 const fourOhFour = build404(options)
103
104 class="cm">// HTTP server and its handler
105 const httpHandler = wrapRouting(router, options)
106
107 const {
108 server,
109 listen,
110 forceCloseConnections,
111 serverHasCloseAllConnections,
112 serverHasCloseHttp2Sessions,
113 keepAliveConnections
114 } = createServer(options, httpHandler)
115
116 const setupResponseListeners = Reply.setupResponseListeners
117 const schemaController = SchemaController.buildSchemaController(null, options.schemaController)
118
119 class="cm">// Public API
120 const fastify = {
121 class="cm">// Fastify internals
122 [kState]: {
123 listening: false,
124 closing: false,
125 started: false,
126 ready: false,
127 booting: false,
128 aborted: false,
129 readyResolver: null
130 },
131 [kKeepAliveConnections]: keepAliveConnections,
132 [kSupportedHTTPMethods]: {
133 bodyless: new Set([
134 class="cm">// Standard
135 class="st">'GET',
136 class="st">'HEAD',
137 class="st">'TRACE'
138 ]),
139 bodywith: new Set([
140 class="cm">// Standard
141 class="st">'DELETE',
142 class="st">'OPTIONS',
143 class="st">'PATCH',
144 class="st">'PUT',
145 class="st">'POST'
146 ])

Callers 15

named-exports.mjsFile · 0.90
simple.mjsFile · 0.90
same-shape.test.jsFile · 0.85
logger.tst.tsFile · 0.85
hooks.tst.tsFile · 0.85
reply.tst.tsFile · 0.85
route.tst.tsFile · 0.85
instance.tst.tsFile · 0.85

Calls 11

processOptionsFunction · 0.85
buildRoutingFunction · 0.85
wrapRoutingFunction · 0.85
createServerFunction · 0.85
buildErrorHandlerFunction · 0.85
hookRunnerApplicationFunction · 0.85
findRouteMethod · 0.80
closeMethod · 0.80
setNotFoundHandlerMethod · 0.80
doneFunction · 0.50

Tested by

no test coverage detected