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

Function buildRouting

lib/route.js:77–584  ·  view source on GitHub ↗
(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 ignoreTrailingSlash
87 let ignoreDuplicateSlashes
88 let return503OnClosing
89 let globalExposeHeadRoutes
90 let keepAliveConnections
91
92 let closing = false
93
94 return {
95 /**
96 * @param {import('../fastify').FastifyServerOptions} options
97 * @param {*} fastifyArgs
98 */
99 setup (options, fastifyArgs) {
100 avvio = fastifyArgs.avvio
101 fourOhFour = fastifyArgs.fourOhFour
102 logger = options.logger
103 hasLogger = fastifyArgs.hasLogger
104 setupResponseListeners = fastifyArgs.setupResponseListeners
105 throwIfAlreadyStarted = fastifyArgs.throwIfAlreadyStarted
106
107 globalExposeHeadRoutes = options.exposeHeadRoutes
108
109 ignoreTrailingSlash = options.routerOptions.ignoreTrailingSlash
110 ignoreDuplicateSlashes = options.routerOptions.ignoreDuplicateSlashes
111 return503OnClosing = Object.hasOwn(options, 'return503OnClosing') ? options.return503OnClosing : true
112 keepAliveConnections = fastifyArgs.keepAliveConnections
113 },
114 routing: router.lookup.bind(router), // router func to find the right handler to call
115 route, // configure a route in the fastify instance
116 hasRoute,
117 prepareRoute,
118 routeHandler,
119 closeRoutes: () => { closing = true },
120 printRoutes: router.prettyPrint.bind(router),
121 addConstraintStrategy,
122 hasConstraintStrategy,
123 isAsyncConstraint,
124 findRoute
125 }
126
127 function addConstraintStrategy (strategy) {
128 throwIfAlreadyStarted('Cannot add constraint strategy!')
129 return router.addConstraintStrategy(strategy)
130 }
131
132 function hasConstraintStrategy (strategyName) {
133 return router.hasConstraintStrategy(strategyName)
134 }

Callers 1

fastifyFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected