MCPcopy Create free account
hub / github.com/fastify/fastify / fastify

Function fastify

fastify.js:90–843  ·  view source on GitHub ↗

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

(serverOptions)

Source from the content-addressed store, hash-verified

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

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