Browse Source

initialize the jwt module

Sven Czarnian 2 years ago
parent
commit
dbe7e7ef42
1 changed files with 14 additions and 1 deletions
  1. 14 1
      src/auth/auth.module.ts

+ 14 - 1
src/auth/auth.module.ts

@@ -1,9 +1,22 @@
 import { HttpModule } from '@nestjs/axios';
 import { Module } from '@nestjs/common';
+import { ConfigService } from '@nestjs/config';
+import { JwtModule } from '@nestjs/jwt';
 import { AuthController } from './auth.controller';
+import { JwtStrategy } from './strategies/jwt.strategy';
 
 @Module({
-  imports: [HttpModule],
+  imports: [
+    HttpModule,
+    JwtModule.registerAsync({
+      inject: [ConfigService],
+      useFactory: async (config: ConfigService) => ({
+        secret: config.get<string>('server.jwt-secret'),
+        signOptions: { expiresIn: '1h' },
+      }),
+    }),
+  ],
+  providers: [JwtStrategy],
   controllers: [AuthController],
 })
 export class AuthModule {}