42 lines
1.1 KiB
TypeScript
42 lines
1.1 KiB
TypeScript
import { Global, Module } from '@nestjs/common';
|
|
import { AuthService } from './auth.service';
|
|
import { AuthController } from './auth.controller';
|
|
import { APP_GUARD } from '@nestjs/core';
|
|
import { AuthGuard } from './guards/auth.guard';
|
|
import { UserModule } from 'src/user/user.module';
|
|
import { RequestContextModule } from 'core/als/request-context.module';
|
|
import { BullModule } from '@nestjs/bullmq';
|
|
import { PrismaModule } from 'src/prisma/prisma.module';
|
|
import { JwtModule } from '@nestjs/jwt';
|
|
import { ConfigModule, ConfigService } from '@nestjs/config';
|
|
|
|
@Global()
|
|
@Module({
|
|
providers: [
|
|
AuthService,
|
|
{
|
|
provide: APP_GUARD,
|
|
useClass: AuthGuard,
|
|
},
|
|
],
|
|
controllers: [AuthController],
|
|
imports: [
|
|
BullModule.registerQueue({
|
|
name: "mail"
|
|
}),
|
|
JwtModule.registerAsync({
|
|
global: true,
|
|
imports: [ConfigModule],
|
|
inject: [ConfigService],
|
|
useFactory: (config: ConfigService) => ({
|
|
secret: config.get<string>("TOKEN_SECRET"),
|
|
signOptions: { expiresIn: '7d' }
|
|
})
|
|
}),
|
|
UserModule,
|
|
RequestContextModule,
|
|
PrismaModule
|
|
],
|
|
})
|
|
export class AuthModule { }
|