How to use the awilix.asClass 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 SelfKeyFoundation / Identity-Wallet / src / main / context.js View on Github external
inventoryService: asClass(InventoryService).singleton(),
		inventorySyncJobHandler: asClass(InventorySyncJobHandler).singleton(),
		marketplaceCountryService: asClass(MarketplaceCountryService).singleton(),
		marketplaceCountrySyncJobHandler: asClass(MarketplaceCountrySyncJobHandler).singleton(),
		taxTreatiesService: asClass(TaxTreatiesService).singleton(),
		taxTreatiesSyncJobHandler: asClass(TaxTreatiesSyncJobHandler).singleton(),
		web3Service: asClass(Web3Service).singleton(),
		walletService: asClass(WalletService).singleton(),
		addressBookService: asClass(AddressBookService).singleton(),
		// TODO: refactor to not use static methods
		CrashReportService: asValue(CrashReportService),
		txHistoryService: asClass(TxHistoryService).singleton(),
		TxHistoryService: asValue(TxHistoryService),
		priceService: asClass(PriceService).singleton(),
		lwsService: asClass(LWSService).singleton(),
		exchangesService: asClass(ExchangesService).singleton(),
		identityService: asClass(IdentityService).singleton(),
		marketplaceService: asClass(MarketplaceService).singleton(),
		paymentService: asClass(PaymentService).singleton(),
		selfkeyService: asClass(SelfkeyService).singleton(),
		rpcHandler: asFunction(cradle => {
			let Handler = RpcHandler(cradle);
			return new Handler();
		}).singleton(),
		stakingService: asClass(StakingService).singleton(),
		tokenService: asClass(TokenService).singleton(),
		walletTokenService: asClass(WalletTokenService).singleton(),
		incorporationsService: asClass(IncorporationsService).singleton(),
		bankAccountsService: asClass(BankAccountsService).singleton(),
		guideSettingsService: asClass(GuideSettingsService).singleton(),
		countryService: asClass(CountryService).singleton(),
		kycApplicationService: asClass(KycApplicationService).singleton(),
github antoinechalifour / memento / src / index.ts View on Github external
configuration.cacheDirectory = cacheDirectory;
    }

    container.register({
      // Constants
      config: asValue(configuration),

      // Use cases
      respondToRequestUseCase: asClass(RespondToRequest),
      clearAllRequestsUseCase: asClass(ClearAllRequests),
      clearRequestUseCase: asClass(ClearRequest),
      refreshRequestUseCase: asClass(RefreshRequest),
      listRequestsUseCase: asClass(ListRequest),
      getRequestDetailsUseCase: asClass(GetRequestDetails),
      setResponseTimeUseCase: asClass(SetResponseTime),
      importCurlUseCase: asClass(ImportCurl),

      // Repositories
      requestRepository: asClass(RequestRepositoryFile),

      // Services
      networkService: asClass(NetworkServiceAxios),
    });
  }
github SelfKeyFoundation / Identity-Wallet / src / main / context.js View on Github external
export const registerMainServices = container => {
	container.register({
		app: asFunction(createApp).singleton(),
		networkService: asClass(NetworkService).singleton(),
		schedulerService: asClass(SchedulerService).singleton(),
		vendorService: asClass(VendorService).singleton(),
		vendorSyncJobHandler: asClass(VendorSyncJobHandler).singleton(),
		inventoryService: asClass(InventoryService).singleton(),
		inventorySyncJobHandler: asClass(InventorySyncJobHandler).singleton(),
		marketplaceCountryService: asClass(MarketplaceCountryService).singleton(),
		marketplaceCountrySyncJobHandler: asClass(MarketplaceCountrySyncJobHandler).singleton(),
		taxTreatiesService: asClass(TaxTreatiesService).singleton(),
		taxTreatiesSyncJobHandler: asClass(TaxTreatiesSyncJobHandler).singleton(),
		web3Service: asClass(Web3Service).singleton(),
		walletService: asClass(WalletService).singleton(),
		addressBookService: asClass(AddressBookService).singleton(),
		// TODO: refactor to not use static methods
		CrashReportService: asValue(CrashReportService),
		txHistoryService: asClass(TxHistoryService).singleton(),
		TxHistoryService: asValue(TxHistoryService),
		priceService: asClass(PriceService).singleton(),
		lwsService: asClass(LWSService).singleton(),
github antoinechalifour / memento / src / index.ts View on Github external
// Use cases
      respondToRequestUseCase: asClass(RespondToRequest),
      clearAllRequestsUseCase: asClass(ClearAllRequests),
      clearRequestUseCase: asClass(ClearRequest),
      refreshRequestUseCase: asClass(RefreshRequest),
      listRequestsUseCase: asClass(ListRequest),
      getRequestDetailsUseCase: asClass(GetRequestDetails),
      setResponseTimeUseCase: asClass(SetResponseTime),
      importCurlUseCase: asClass(ImportCurl),

      // Repositories
      requestRepository: asClass(RequestRepositoryFile),

      // Services
      networkService: asClass(NetworkServiceAxios),
    });
  }
github asyrafduyshart / node-clean-architecture / src / container.js View on Github external
const swaggerMiddleware = require('./interfaces/http/swagger/swaggerMiddleware');

const MongoUsersRepository = require('./infra/repository/user/MongoUsersRepository');

const { User: UserModel } = require('./infra/database/models');

const logger = require('./infra/logging/logger');

const database = require('./infra/mongoose');

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 }),
github SelfKeyFoundation / Identity-Wallet / src / main / context.js View on Github external
export const registerMainServices = container => {
	container.register({
		app: asFunction(createApp).singleton(),
		networkService: asClass(NetworkService).singleton(),
		schedulerService: asClass(SchedulerService).singleton(),
		vendorService: asClass(VendorService).singleton(),
		vendorSyncJobHandler: asClass(VendorSyncJobHandler).singleton(),
		inventoryService: asClass(InventoryService).singleton(),
		inventorySyncJobHandler: asClass(InventorySyncJobHandler).singleton(),
		marketplaceCountryService: asClass(MarketplaceCountryService).singleton(),
		marketplaceCountrySyncJobHandler: asClass(MarketplaceCountrySyncJobHandler).singleton(),
		taxTreatiesService: asClass(TaxTreatiesService).singleton(),
		taxTreatiesSyncJobHandler: asClass(TaxTreatiesSyncJobHandler).singleton(),
		web3Service: asClass(Web3Service).singleton(),
		walletService: asClass(WalletService).singleton(),
		addressBookService: asClass(AddressBookService).singleton(),
		// TODO: refactor to not use static methods
		CrashReportService: asValue(CrashReportService),
		txHistoryService: asClass(TxHistoryService).singleton(),
		TxHistoryService: asValue(TxHistoryService),
		priceService: asClass(PriceService).singleton(),
github SelfKeyFoundation / Identity-Wallet / src / main / context.js View on Github external
identityService: asClass(IdentityService).singleton(),
		marketplaceService: asClass(MarketplaceService).singleton(),
		paymentService: asClass(PaymentService).singleton(),
		selfkeyService: asClass(SelfkeyService).singleton(),
		rpcHandler: asFunction(cradle => {
			let Handler = RpcHandler(cradle);
			return new Handler();
		}).singleton(),
		stakingService: asClass(StakingService).singleton(),
		tokenService: asClass(TokenService).singleton(),
		walletTokenService: asClass(WalletTokenService).singleton(),
		incorporationsService: asClass(IncorporationsService).singleton(),
		bankAccountsService: asClass(BankAccountsService).singleton(),
		guideSettingsService: asClass(GuideSettingsService).singleton(),
		countryService: asClass(CountryService).singleton(),
		kycApplicationService: asClass(KycApplicationService).singleton(),
		didService: asClass(DIDService).singleton(),
		autoUpdateService: asClass(AutoUpdateService).singleton(),
		marketplaceOrdersService: asClass(MarketplaceOrdersService).singleton()
	});
};
github commander-mvc / commander-mvc / src / lib / register-injectable.ts View on Github external
function getResolver (options: InjectableTableEntry) {
  const provider = options.provider
  if (provider.useConstructor) {
    return asClass(provider.useConstructor, options)
  } else if (provider.useValue) {
    return asValue(provider.useValue)
  } else if (provider.useFactory) {
    return asFunction(provider.useFactory)
  } else {
    throw new Error('useConstructor, useValue, or useFactory must be specified')
  }
}
github SelfKeyFoundation / Identity-Wallet / src / main / context.js View on Github external
paymentService: asClass(PaymentService).singleton(),
		selfkeyService: asClass(SelfkeyService).singleton(),
		rpcHandler: asFunction(cradle => {
			let Handler = RpcHandler(cradle);
			return new Handler();
		}).singleton(),
		stakingService: asClass(StakingService).singleton(),
		tokenService: asClass(TokenService).singleton(),
		walletTokenService: asClass(WalletTokenService).singleton(),
		incorporationsService: asClass(IncorporationsService).singleton(),
		bankAccountsService: asClass(BankAccountsService).singleton(),
		guideSettingsService: asClass(GuideSettingsService).singleton(),
		countryService: asClass(CountryService).singleton(),
		kycApplicationService: asClass(KycApplicationService).singleton(),
		didService: asClass(DIDService).singleton(),
		autoUpdateService: asClass(AutoUpdateService).singleton(),
		marketplaceOrdersService: asClass(MarketplaceOrdersService).singleton()
	});
};
github asyrafduyshart / node-clean-architecture / src / container.js View on Github external
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),
  deleteUser: asClass(DeleteUser),

  //Serializer
  userSerializer: asValue(UserSerializer)
});

module.exports = container;