Skip to content

Commit

Permalink
refactor: get req config w/o function
Browse files Browse the repository at this point in the history
  • Loading branch information
c0sx committed Sep 22, 2024
1 parent 18e963a commit a601917
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,16 +220,8 @@ async function fastifyUnderPressure (fastify, opts) {
return false
}

function getReqConfig(req) {
if (req.routeOptions && req.routeOptions.config) {
return req.routeOptions.config
}

return req.context.config
}

function onRequest (req, reply, next) {
const config = getReqConfig(req)
const config = req.routeOptions && req.routeOptions.config ? req.routeOptions.config : req.context.config
const _pressureHandler = config.pressureHandler || pressureHandler
if (checkMaxEventLoopDelay && eventLoopDelay > maxEventLoopDelay) {
handlePressure(_pressureHandler, req, reply, next, TYPE_EVENT_LOOP_DELAY, eventLoopDelay)
Expand Down

0 comments on commit a601917

Please sign in to comment.