(mw: Middleware)
| 293 | }) |
| 294 | |
| 295 | const handle = (mw: Middleware) => async (req: Req, res: Res, next?: NextFunction) => { |
| 296 | const { path, handler, type, regex } = mw |
| 297 | |
| 298 | const params = regex ? getURLParams(regex, pathname) : {} |
| 299 | |
| 300 | if (type === 'route') req.params = params |
| 301 | |
| 302 | if (path.includes(':')) { |
| 303 | const url = req.url.slice(req.url.indexOf(Object.values(params)[0]) + Object.values(params)[0].length) |
| 304 | |
| 305 | req.url = lead(url) |
| 306 | } else { |
| 307 | req.url = lead(req.url.substring(path.length)) |
| 308 | } |
| 309 | |
| 310 | req.path = getPathname(req.url) |
| 311 | |
| 312 | if (this.settings?.enableReqRoute) req.route = getRouteFromApp(this as any, handler) |
| 313 | |
| 314 | await applyHandler<Req, Res>((handler as unknown) as Handler<Req, Res>)(req, res, next) |
| 315 | } |
| 316 | |
| 317 | let idx = 0 |
| 318 |
nothing calls this directly
no test coverage detected