33 lines
1.1 KiB
TypeScript
33 lines
1.1 KiB
TypeScript
import { Module } from '@nestjs/common';
|
|
import { TypeOrmModule } from '@nestjs/typeorm';
|
|
import { JwtModule } from '@nestjs/jwt';
|
|
import { PassportModule } from '@nestjs/passport';
|
|
import { ConfigModule, ConfigService } from '@nestjs/config';
|
|
import { AuthController } from './auth.controller';
|
|
import { AuthService } from './auth.service';
|
|
import { Tenant } from './entities/tenant.entity';
|
|
import { User } from './entities/user.entity';
|
|
import { JwtStrategy } from './strategies/jwt.strategy';
|
|
import { JwtAuthGuard } from './guards/jwt-auth.guard';
|
|
|
|
@Module({
|
|
imports: [
|
|
TypeOrmModule.forFeature([Tenant, User]),
|
|
PassportModule.register({ defaultStrategy: 'jwt' }),
|
|
JwtModule.registerAsync({
|
|
imports: [ConfigModule],
|
|
inject: [ConfigService],
|
|
useFactory: (configService: ConfigService) => ({
|
|
secret: configService.get('JWT_SECRET'),
|
|
signOptions: {
|
|
expiresIn: configService.get('JWT_EXPIRES_IN', '24h'),
|
|
},
|
|
}),
|
|
}),
|
|
],
|
|
controllers: [AuthController],
|
|
providers: [AuthService, JwtStrategy, JwtAuthGuard],
|
|
exports: [AuthService, JwtAuthGuard, TypeOrmModule],
|
|
})
|
|
export class AuthModule {}
|