2026-05-11 13:42:13 +03:30
|
|
|
import { Global, Module } from '@nestjs/common';
|
2026-05-11 12:40:42 +03:30
|
|
|
import { ConfigModule, ConfigService } from '@nestjs/config';
|
|
|
|
|
import { JwtModule } from '@nestjs/jwt';
|
|
|
|
|
import { TypeOrmModule } from '@nestjs/typeorm';
|
|
|
|
|
import { AuthOtpEntity } from '../../entities/auth-otp.entity';
|
|
|
|
|
import { UserEntity } from '../../entities/user.entity';
|
|
|
|
|
import { AuthController } from './auth.controller';
|
|
|
|
|
import { AuthService } from './auth.service';
|
2026-05-13 18:48:38 +03:30
|
|
|
import { SmsService } from './sms.service';
|
2026-05-11 12:40:42 +03:30
|
|
|
import { JwtAuthGuard } from './guards/jwt-auth.guard';
|
|
|
|
|
import { RolesGuard } from './guards/roles.guard';
|
|
|
|
|
|
2026-05-11 13:42:13 +03:30
|
|
|
@Global()
|
2026-05-11 12:40:42 +03:30
|
|
|
@Module({
|
|
|
|
|
imports: [
|
|
|
|
|
TypeOrmModule.forFeature([AuthOtpEntity, UserEntity]),
|
|
|
|
|
JwtModule.registerAsync({
|
|
|
|
|
imports: [ConfigModule],
|
|
|
|
|
inject: [ConfigService],
|
|
|
|
|
useFactory: (config: ConfigService) => ({
|
|
|
|
|
secret: config.get<string>('JWT_SECRET') ?? 'montime-dev-secret-change-me',
|
|
|
|
|
signOptions: {
|
|
|
|
|
expiresIn: config.get<string>('JWT_EXPIRES_IN') ?? '30d',
|
|
|
|
|
},
|
|
|
|
|
}),
|
|
|
|
|
}),
|
|
|
|
|
],
|
|
|
|
|
controllers: [AuthController],
|
2026-05-13 18:48:38 +03:30
|
|
|
providers: [AuthService, SmsService, JwtAuthGuard, RolesGuard],
|
2026-05-23 18:13:09 +03:30
|
|
|
exports: [JwtAuthGuard, RolesGuard, JwtModule, SmsService],
|
2026-05-11 12:40:42 +03:30
|
|
|
})
|
|
|
|
|
export class AuthModule {}
|