小编DaC*_*rse的帖子

How do you inject a service in NestJS into a typeorm repository?

I have a UserRepository which handles creating/authenticating users infront of the database. I want to perform hashing & validation for the user's password, so I created a seperate service for that purpose, trying to follow single repsonsibility principle, which is declared like this:

@Injectable()
export default class HashService
Run Code Online (Sandbox Code Playgroud)

And I import it in my module:

@Module({
    imports: [TypeOrmModule.forFeature([UserRepository])],
    controllers: [AuthController],
    providers: [AuthService, HashService],
})
export class AuthModule {}
Run Code Online (Sandbox Code Playgroud)

I wish to inject it into UserRepository, I tried passing in …

typescript typeorm nestjs

9
推荐指数
1
解决办法
1286
查看次数

标签 统计

nestjs ×1

typeorm ×1

typescript ×1