* Push middleware to the stack
(...args: UseMethodParams<Req, Res, App>)
| 261 | * Push middleware to the stack |
| 262 | */ |
| 263 | use(...args: UseMethodParams<Req, Res, App>) { |
| 264 | const base = args[0] |
| 265 | |
| 266 | const handlers = args.slice(1).flat() |
| 267 | |
| 268 | if (typeof base === 'string') { |
| 269 | pushMiddleware(this.middleware)({ |
| 270 | path: base, |
| 271 | handler: handlers[0] as Handler, |
| 272 | handlers: handlers.slice(1) as Handler[], |
| 273 | type: 'mw' |
| 274 | }) |
| 275 | } else { |
| 276 | pushMiddleware(this.middleware)({ |
| 277 | path: '/', |
| 278 | handler: Array.isArray(base) ? base[0] : (base as Handler), |
| 279 | handlers: Array.isArray(base) |
| 280 | ? [...(base.slice(1) as Handler[]), ...(handlers as Handler[])] |
| 281 | : (handlers as Handler[]), |
| 282 | type: 'mw' |
| 283 | }) |
| 284 | } |
| 285 | |
| 286 | return this |
| 287 | } |
| 288 | } |
nothing calls this directly
no test coverage detected