How to use the awilix.InjectionMode.CLASSIC function in awilix

To help you get started, we’ve selected a few awilix 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 mollyywang / koa2-mongodb-jwt-server / src / lib / container.js View on Github external
export function configureContainer() {
  const opts = {
    injectionMode: InjectionMode.CLASSIC
  }
  return createContainer(opts)
    // load modules and registers 加载,注册模块 e.g. import userService from `services/user-service.js` 
    .loadModules(modulesToLoad, {
      cwd: `${__dirname}/..`,
      formatName: 'camelCase'
    })
    .register({
      // construct logger 
      logger: asValue(logger)
    })
}
github jeffijoe / koa-es7-boilerplate / src / lib / container.js View on Github external
export function configureContainer() {
  const opts = {
    // Classic means Awilix will look at function parameter
    // names rather than passing a Proxy.
    injectionMode: InjectionMode.CLASSIC
  }
  return createContainer(opts)
    .loadModules(modulesToLoad, {
      // `modulesToLoad` paths should be relative
      // to this file's parent directory.
      cwd: `${__dirname}/..`,
      // Example: registers `services/todo-service.js` as `todoService`
      formatName: 'camelCase'
    })
    .register({
      // Our logger is already constructed,
      // so provide it as-is to anyone who wants it.
      logger: asValue(logger)
    })
}
github jeffijoe / typesync / src / cli.ts View on Github external
export async function startCli() {
  try {
    // Awilix is a dependency injection container.
    const container = createContainer({
      injectionMode: InjectionMode.CLASSIC
    }).register({
      typeDefinitionSource: asFunction(createTypeDefinitionSource).singleton(),
      packageJSONService: asFunction(createPackageJSONFileService).singleton(),
      packageSource: asFunction(createPackageSource).singleton(),
      globber: asFunction(createGlobber).singleton(),
      typeSyncer: asFunction(createTypeSyncer)
    })
    await run(container.resolve('typeSyncer'))
  } catch (err) {
    C.error(err)
    process.exitCode = 1
  }
}
github dannielhugo / typescript-clean-architecture / src / deliveries / api / app.ts View on Github external
private registerModule(
    globPattern,
    formatName?
  ): void {
    this.container.loadModules(globPattern, {
      formatName: formatName || 'camelCase',
      cwd: '.',
      resolverOptions: {
        injectionMode: InjectionMode.CLASSIC,
        lifetime: Lifetime.SINGLETON
      }
    });
  }