сервис, который ходит в базу, но вылетает ошибка. Подскажите пожалуйста, что делаю не так?
модуль
@Module({
imports: [
CustomerModule,
BotUpdate,
HttpModule.registerAsync({
imports: [ConfigModule],
useFactory: async (configService: ConfigService) => ({
baseURL: `http://localhost:${configService.get(
'PORT',
)}/${API_GLOBAL_PREFIX}`,
}),
inject: [ConfigService],
}),
TelegrafModule.forRootAsync({
useFactory: async (configService: ConfigService) => ({
token: configService.get('BOT_TOKEN'),
middlewares: [sessionMiddleware],
}),
inject: [ConfigService],
}),
],
})
export class BotModule {}
bot.update.ts
@Update()
export class BotUpdate {
constructor(private readonly customerService: CustomerService) {}
@Start()
async onStart(@Ctx() ctx: Context) {
const currentUser = this.customerService.findOneById(1);
}
}
ошибка
Error: Nest can't resolve dependencies of the BotUpdate (?). Please make sure that the argument CustomerService at index [0] is available in the BotUpdate context.
Potential solutions:
- Is BotUpdate a valid NestJS module?
- If CustomerService is a provider, is it part of the current BotUpdate?
- If CustomerService is exported from a separate @Module, is that module imported within BotUpdate?
@Module({
imports: [ /* the Module containing CustomerService */ ]
})
А CustomerModule покажи
import { Module } from '@nestjs/common'; import { CustomerController } from './customer.controller'; import { CustomerService } from './customer.service'; import { customerProviders } from './customer.providers'; @Module({ controllers: [CustomerController], providers: [CustomerService, ...customerProviders], exports: [CustomerService], }) export class CustomerModule {}
Обсуждают сегодня