I'm new to NestJs environement , and Im currently facing this error , and looked for the issues solutions on github but couldn't help me on getting a result to my error.
[Nest] 22140 - 21/06/2021 à 14:51:40 [ExceptionHandler] Nest can't resolve dependencies of the UsersRepository (?). Please make sure that the argument Connection at index [0] is available in the TypeOrmModule context.
Potential solutions:
- If Connection is a provider, is it part of the current TypeOrmModule?
- If Connection is exported from a separate @Module, is that module imported within TypeOrmModule?
@Module({
imports: [ /* the Module containing Connection */ ]
})
And I'm already declaring it on my auth.module.ts
import { Module } from '@nestjs/common';
import { AuthService } from './auth.service';
import { AuthController } from './auth.controller';
import { TypeOrmModule } from '@nestjs/typeorm';
import { UsersRepository } from './users.repository';
@Module({
imports: [TypeOrmModule.forFeature([UsersRepository])],
providers: [AuthService],
controllers: [AuthController],
})
export class AuthModule {}
and using it on my service file .
import { Injectable } from '@nestjs/common';
import { UsersRepository } from './users.repository';
import { InjectRepository } from '@nestjs/typeorm';
import { AuthCredentialsDto } from './dto/auth-credentials.dto';
@Injectable()
export class AuthService {
constructor (
@InjectRepository(UsersRepository)
private usersRepository: UsersRepository,
) {}
async signUp(authCredentialsDto: AuthCredentialsDto): Promise<void> {
return this.usersRepository.createUser(authCredentialsDto);
}
}