forked from MergeFi/backend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauth.module.ts
More file actions
31 lines (30 loc) · 1.07 KB
/
Copy pathauth.module.ts
File metadata and controls
31 lines (30 loc) · 1.07 KB
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
import { Module } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import { JwtModule } from '@nestjs/jwt';
import { PassportModule } from '@nestjs/passport';
import { UsersModule } from '../users/users.module';
import { AuthService } from './auth.service';
import { AuthController } from './auth.controller';
import { JwtStrategy } from './strategies/jwt.strategy';
import { GithubStrategy } from './strategies/github.strategy';
import { AppConfig } from '../config/configuration';
@Module({
imports: [
UsersModule,
PassportModule.register({ defaultStrategy: 'jwt' }),
JwtModule.registerAsync({
inject: [ConfigService],
useFactory: (configService: ConfigService<AppConfig, true>) => {
const jwt = configService.get('jwt', { infer: true });
return {
secret: jwt.secret,
signOptions: { expiresIn: jwt.expiresIn as unknown as number },
};
},
}),
],
controllers: [AuthController],
providers: [AuthService, JwtStrategy, GithubStrategy],
exports: [AuthService],
})
export class AuthModule {}