Skip to content

Commit

Permalink
Further special routing modes improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
schamberg97 committed Sep 3, 2020
1 parent 5d2c311 commit 02d63bd
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/routing/sequential.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ module.exports = (config = {}) => {
appPrev: [],
reqPropertiesEssential: [],
reqProperties: [],
urlPrevious: [],
specialType: config.specialType
urlPrevious: []
}
res.locals = Object.create(null) // res.locals is rather convenient at times, so we leave it even for API routes
req.paramsCalled = {} // needed for app.param
Expand All @@ -105,6 +104,7 @@ module.exports = (config = {}) => {
match = router.find(req.method, req.path, req, res)
match.routesLength = match.sRoutes.length // LRU cache is incapable of storing Array of objects or Array-like objects...
match.routes = Object.assign({}, match.sRoutes) // But it is capable of storing Objects with numbered access without length property ;)
if (!match.specialType) match.specialType = config.specialType
// so we naturally store length property separately
// this might be complicated and counter-intuitive approach, but using other cache will reduce performance
cache.set(reqCacheKey, match)
Expand All @@ -114,11 +114,12 @@ module.exports = (config = {}) => {
} else {
// route validation
match = router.find(req.method, req.path, req, res)
if (!match.specialType) match.specialType = config.specialType
match.routes = match.sRoutes
}

if (match.handlers.length > 0) {
req.rData_internal.specialType ? '' : req.rData_internal.specialType = match.specialType
req.rData_internal.specialType = match.specialType
req.rData_internal.noEtag = match.noEtag

const middlewares = [...match.handlers]
Expand Down

0 comments on commit 02d63bd

Please sign in to comment.