forked from Yara724/api
31 lines
894 B
TypeScript
31 lines
894 B
TypeScript
import { Module } from "@nestjs/common";
|
|
import { ConfigService } from "@nestjs/config";
|
|
import { APP_GUARD } from "@nestjs/core";
|
|
import { JwtModule } from "@nestjs/jwt";
|
|
import { StringValue } from "ms";
|
|
import { AuthGuard, RolesGuard } from "./guards";
|
|
import { AuthController } from "./auth.controller";
|
|
import { AuthService } from "./auth.service";
|
|
|
|
@Module({
|
|
imports: [
|
|
JwtModule.registerAsync({
|
|
global: true,
|
|
inject: [ConfigService],
|
|
useFactory: (configService: ConfigService) => ({
|
|
secret: configService.get<string>("JWT_SECRET"),
|
|
signOptions: {
|
|
expiresIn: configService.get<StringValue>("JWT_EXPIRY"),
|
|
},
|
|
}),
|
|
}),
|
|
],
|
|
controllers: [AuthController],
|
|
providers: [
|
|
{ provide: APP_GUARD, useClass: AuthGuard },
|
|
{ provide: APP_GUARD, useClass: RolesGuard },
|
|
AuthService,
|
|
],
|
|
})
|
|
export class AuthModule {}
|