-
Notifications
You must be signed in to change notification settings - Fork 20
/
auth.module.ts
executable file
·35 lines (35 loc) · 1.09 KB
/
auth.module.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { Module } from '@nestjs/common';
import { JwtModule } from '@nestjs/jwt';
import { PassportModule } from '@nestjs/passport';
import { AuthController } from './auth.controller';
import { AuthService } from './auth.service';
import { JwtStrategy } from './jwt.strategy';
import { ConfigModule } from './../config/config.module';
import { ConfigService } from './../config/config.service';
import { CoreModule } from './../core/core.module';
@Module({
imports: [
CoreModule,
PassportModule.register({ defaultStrategy: 'jwt', session: true }),
JwtModule.registerAsync({
imports: [
ConfigModule,
],
useFactory: async (configService: ConfigService) => {
return {
secretOrPrivateKey: configService.get('JWT_SECRET_KEY'),
signOptions: {
algorithm: configService.get('JWT_ALGORITHM'),
expiresIn: configService.get('JWT_EXPIRE_IN'),
},
};
},
inject: [
ConfigService,
],
}),
],
controllers: [AuthController],
providers: [AuthService, JwtStrategy]
})
export class AuthModule { }