* @param {import('./fastify.js').FastifyServerOptions} serverOptions
(serverOptions)
| 87 | * @param {import('./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 | // Default router |
| 99 | const router = buildRouting(options.routerOptions) |
| 100 | |
| 101 | // 404 router, used for handling encapsulated 404 handlers |
| 102 | const fourOhFour = build404(options) |
| 103 | |
| 104 | // 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 | // Public API |
| 120 | const fastify = { |
| 121 | // 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 | // Standard |
| 135 | 'GET', |
| 136 | 'HEAD', |
| 137 | 'TRACE' |
| 138 | ]), |
| 139 | bodywith: new Set([ |
| 140 | // Standard |
| 141 | 'DELETE', |
| 142 | 'OPTIONS', |
| 143 | 'PATCH', |
| 144 | 'PUT', |
| 145 | 'POST' |
| 146 | ]) |
no test coverage detected
searching dependent graphs…