How to use the awilix-express.scopePerRequest function in awilix-express

To help you get started, we’ve selected a few awilix-express 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 asyrafduyshart / node-clean-architecture / src / container.js View on Github external
const container = createContainer();

container.register({
  // System
  app: asClass(Application, { lifetime: Lifetime.SINGLETON }),
  server: asClass(Server, { lifetime: Lifetime.SINGLETON }),
  
  router: asFunction(router, { lifetime: Lifetime.SINGLETON }),
  logger: asFunction(logger, { lifetime: Lifetime.SINGLETON }),

  config: asValue(config),

  //Middlewares
  loggerMiddleware: asFunction(loggerMiddleware, { lifetime: Lifetime.SINGLETON }),
  containerMiddleware: asValue(scopePerRequest(container)),
  errorHandler: asValue(config.production ? errorHandler : devErrorHandler),
  swaggerMiddleware: asValue(swaggerMiddleware),


  //Repositories
  usersRepository: asClass(MongoUsersRepository, { lifetime: Lifetime.SINGLETON }),

  //Database
  database: asFunction(database),
  UserModel: asValue(UserModel),

  //Operations
  createUser: asClass(CreateUser),
  getAllUsers: asClass(GetAllUsers),
  updateUser: asClass(UpdateUser),
  getUserByUid: asClass(GetByUid),
github talyssonoc / node-api-boilerplate / src / container.js View on Github external
})
  .register({
    router: asFunction(router).singleton(),
    logger: asFunction(logger).singleton()
  })
  .register({
    config: asValue(config)
  });

// Middlewares
container
  .register({
    loggerMiddleware: asFunction(loggerMiddleware).singleton()
  })
  .register({
    containerMiddleware: asValue(scopePerRequest(container)),
    errorHandler: asValue(config.production ? errorHandler : devErrorHandler),
    swaggerMiddleware: asValue([swaggerMiddleware])
  });

// Repositories
container.register({
  usersRepository: asClass(SequelizeUsersRepository).singleton()
});

// Database
container.register({
  database: asValue(database),
  UserModel: asValue(UserModel)
});

// Operations
github vitta-health / attiv / framework / application / config / Container.ts View on Github external
const container = createContainer();

container
  .register({
    app: asClass(Application).singleton(),
    server: asClass(serverListen).singleton(),
  })
  .register({
    router: asFunction(routerApp).singleton(),
    DbContext: asClass(DbContext).scoped(),
    DbContextMongo: asClass(DbContextMongo).scoped(),
  });

container.register({
  containerMiddleware: asValue(scopePerRequest(container)),
});

export default container;

awilix-express

Awilix helpers for Express

MIT
Latest version published 11 months ago

Package Health Score

56 / 100
Full package analysis

Similar packages