vaimee / zion

A scalable Thing Description Directory
Apache License 2.0
17 stars 4 forks source link

Can't import config service in TDLifeCycleEvents #2

Closed relu91 closed 2 years ago

relu91 commented 2 years ago

cabe601 introduced support for recording events in the memory. The length of the array used to record the events should be configured using the ConfigService. However, if you try to inject the service as a constructor parameter, Nest screams:

[Nest] 14328  - 21/06/2022, 12:51:29   ERROR [ExceptionHandler] Nest can't resolve dependencies of the TDLifeCycleEventRepository (?). Please make sure that the argument dependency at index [0] is available in the PersistenceModule context.

Potential solutions:
- If dependency is a provider, is it part of the current PersistenceModule?
- If dependency is exported from a separate @Module, is that module imported within PersistenceModule?
  @Module({
    imports: [ /* the Module containing dependency */ ]
  })

Notice that I checked for imports:

  imports: [
    ConfigModule, // importing ConfigModule
    KnexModule.forRootAsync({
      imports: [ConfigModule],
      useFactory: (config: ConfigService) => ({
        config: {
          client: 'pg',
          connection: {
            host: config.dbHost,
            port: config.dbPort,
            user: config.dbUser,
            password: config.dbPassword,
            database: config.dbDatabase,
          },
        },
      }),
      inject: [ConfigService],
    }),
  ],