service.module.ts 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. import { Module, OnModuleInit } from '@nestjs/common';
  2. import { TypeOrmModule } from '@nestjs/typeorm';
  3. import { ConfigModule } from '../config/config.module';
  4. import { getConfig } from '../config/vendure-config';
  5. import { TranslationUpdaterService } from './helpers/translation-updater.service';
  6. import { AdjustmentApplicatorService } from './providers/adjustment-applicator.service';
  7. import { AdministratorService } from './providers/administrator.service';
  8. import { AssetService } from './providers/asset.service';
  9. import { AuthService } from './providers/auth.service';
  10. import { ChannelService } from './providers/channel.service';
  11. import { CountryService } from './providers/country.service';
  12. import { CustomerGroupService } from './providers/customer-group.service';
  13. import { CustomerService } from './providers/customer.service';
  14. import { FacetValueService } from './providers/facet-value.service';
  15. import { FacetService } from './providers/facet.service';
  16. import { OrderService } from './providers/order.service';
  17. import { PasswordService } from './providers/password.service';
  18. import { ProductOptionGroupService } from './providers/product-option-group.service';
  19. import { ProductOptionService } from './providers/product-option.service';
  20. import { ProductVariantService } from './providers/product-variant.service';
  21. import { ProductService } from './providers/product.service';
  22. import { PromotionService } from './providers/promotion.service';
  23. import { RoleService } from './providers/role.service';
  24. import { TaxCategoryService } from './providers/tax-category.service';
  25. import { TaxRateService } from './providers/tax-rate.service';
  26. import { ZoneService } from './providers/zone.service';
  27. const exportedProviders = [
  28. PromotionService,
  29. AdministratorService,
  30. AssetService,
  31. AuthService,
  32. ChannelService,
  33. CountryService,
  34. CustomerGroupService,
  35. CustomerService,
  36. FacetService,
  37. FacetValueService,
  38. OrderService,
  39. ProductOptionService,
  40. ProductOptionGroupService,
  41. ProductService,
  42. ProductVariantService,
  43. RoleService,
  44. TaxCategoryService,
  45. TaxRateService,
  46. ZoneService,
  47. ];
  48. /**
  49. * The ServiceModule is responsible for the service layer, i.e. accessing the database
  50. * and implementing the main business logic of the application.
  51. *
  52. * The exported providers are used in the ApiModule, which is responsible for parsing requests
  53. * into a format suitable for the service layer logic.
  54. */
  55. @Module({
  56. imports: [ConfigModule, TypeOrmModule.forRoot(getConfig().dbConnectionOptions)],
  57. providers: [
  58. ...exportedProviders,
  59. PasswordService,
  60. TranslationUpdaterService,
  61. AdjustmentApplicatorService,
  62. ],
  63. exports: exportedProviders,
  64. })
  65. export class ServiceModule implements OnModuleInit {
  66. constructor(
  67. private channelService: ChannelService,
  68. private roleService: RoleService,
  69. private administratorService: AdministratorService,
  70. ) {}
  71. async onModuleInit() {
  72. await this.channelService.initChannels();
  73. await this.roleService.initRoles();
  74. await this.administratorService.initAdministrators();
  75. }
  76. }