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

Function buildRouting

lib/route.js:77–592  ·  lib/route.js::buildRouting
(options)

Source from the content-addressed store, hash-verified

75]
76
77function buildRouting (options) {
78 const router = FindMyWay(options)
79
80 let avvio
81 let fourOhFour
82 let logger
83 let hasLogger
84 let setupResponseListeners
85 let throwIfAlreadyStarted
86 let disableRequestLogging
87 let disableRequestLoggingFn
88 let ignoreTrailingSlash
89 let ignoreDuplicateSlashes
90 let return503OnClosing
91 let globalExposeHeadRoutes
92 let keepAliveConnections
93
94 let closing = false
95
96 return {
97 /**
98 * @param {import(class="st">'../fastify').FastifyServerOptions} options
99 * @param {*} fastifyArgs
100 */
101 setup (options, fastifyArgs) {
102 avvio = fastifyArgs.avvio
103 fourOhFour = fastifyArgs.fourOhFour
104 logger = options.logger
105 hasLogger = fastifyArgs.hasLogger
106 setupResponseListeners = fastifyArgs.setupResponseListeners
107 throwIfAlreadyStarted = fastifyArgs.throwIfAlreadyStarted
108
109 globalExposeHeadRoutes = options.exposeHeadRoutes
110 disableRequestLogging = options.disableRequestLogging
111 if (typeof disableRequestLogging === class="st">'function') {
112 disableRequestLoggingFn = options.disableRequestLogging
113 }
114
115 ignoreTrailingSlash = options.routerOptions.ignoreTrailingSlash
116 ignoreDuplicateSlashes = options.routerOptions.ignoreDuplicateSlashes
117 return503OnClosing = Object.hasOwn(options, class="st">'return503OnClosing') ? options.return503OnClosing : true
118 keepAliveConnections = fastifyArgs.keepAliveConnections
119 },
120 routing: router.lookup.bind(router), class="cm">// router func to find the right handler to call
121 route, class="cm">// configure a route in the fastify instance
122 hasRoute,
123 prepareRoute,
124 routeHandler,
125 closeRoutes: () => { closing = true },
126 printRoutes: router.prettyPrint.bind(router),
127 addConstraintStrategy,
128 hasConstraintStrategy,
129 isAsyncConstraint,
130 findRoute
131 }
132
133 function addConstraintStrategy (strategy) {
134 throwIfAlreadyStarted(class="st">'Cannot add constraint strategy!')

Callers 1

fastifyFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected