Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function middlewareHandler (ctx: HttpContextContract) {
await new Middleware()
.register(ctx.route!.meta.resolvedMiddleware)
.runner()
.finalHandler(finalHandler, [ctx])
.resolve(middlewareExecutor)
.run([ctx])
}
public optimize () {
/**
* Choose the correct route handler based upon existence
* of global middleware
*/
if (this._middlewareStore.get().length) {
this._globalMiddleware = new Middleware().register(this._middlewareStore.get())
this._routeHandler = this._executeMiddleware.bind(this)
} else {
this._routeHandler = this._executeFinalHandler.bind(this)
}
/**
* Choose correct hooks handler, based upon existence
* of before hooks
*/
if (this._hooks.before.length) {
this._hooksHandler = this._executeHooksAndHandler.bind(this)
} else {
this._hooksHandler = this._handleRequest.bind(this)
}
/**