Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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(),
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),
});
}
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(),
// 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),
});
}
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 }),
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(),
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()
});
};
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')
}
}
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()
});
};
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;