How to use co-compose - 2 common examples

To help you get started, we’ve selected a few co-compose examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github adonisjs / adonis-framework / packages / server / src / routePreProcessor.ts View on Github external
async function middlewareHandler (ctx: HttpContextContract) {
  await new Middleware()
    .register(ctx.route!.meta.resolvedMiddleware)
    .runner()
    .finalHandler(finalHandler, [ctx])
    .resolve(middlewareExecutor)
    .run([ctx])
}
github adonisjs / adonis-framework / packages / server / src / Server.ts View on Github external
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)
    }

    /**

co-compose

AdonisJS and Koa style middleware layer with ability to run parallel middleware

MIT
Latest version published 2 years ago

Package Health Score

53 / 100
Full package analysis

Popular co-compose functions