* @param {import('./fastify.js').FastifyServerOptions} serverOptions
(serverOptions)
| 87 | * @param {import(class="st">'./fastify.js').FastifyServerOptions} serverOptions |
| 88 | */ |
| 89 | function 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 | ]) |
no test coverage detected