dependencies Legend  Declarations  Module  Bootstrap  Providers  Exports cluster_AuthModule cluster_AuthModule_exports cluster_AuthModule_providers ApiKeyGuard ApiKeyGuard ApiKeysService ApiKeysService AuthService AuthService CombinedAuthGuard CombinedAuthGuard TotpService TotpService AuthModule AuthModule AuthModule->ApiKeyGuard AuthModule->ApiKeysService AuthModule->AuthService AuthModule->CombinedAuthGuard AuthModule->TotpService ApiKeysService ApiKeysService ApiKeysService->AuthModule AuthService AuthService AuthService->AuthModule JwtStrategy JwtStrategy JwtStrategy->AuthModule TotpService TotpService TotpService->AuthModule
import { Global, Module } from '@nestjs/common';
import { JwtModule } from '@nestjs/jwt';
import { PassportModule } from '@nestjs/passport';
import { ConfigService } from '@nestjs/config';
import { AuthController } from './auth.controller';
import { AuthService } from './auth.service';
import { JwtStrategy } from './strategies/jwt.strategy';
import { ApiKeysController } from './api-keys.controller';
import { ApiKeysService } from './api-keys.service';
import { ApiKeyGuard } from './guards/api-key.guard';
import { CombinedAuthGuard } from './guards/combined-auth.guard';
import { TotpService } from './totp.service';

@Global()
@Module({
  imports: [
    PassportModule.register({ defaultStrategy: 'jwt' }),
    JwtModule.registerAsync({
      inject: [ConfigService],
      useFactory: (configService: ConfigService) => {
        const secret = configService.get<string>('jwt.secret') || configService.get<string>('JWT_SECRET');
        if (!secret) {
          throw new Error('FATAL: JWT_SECRET environment variable is required. Cannot start without it.');
        }
        return {
          secret,
          signOptions: {
            expiresIn: configService.get<string>('jwt.expiresIn') || '24h',
          },
        };
      },
    }),
  ],
  controllers: [AuthController, ApiKeysController],
  providers: [AuthService, JwtStrategy, ApiKeysService, ApiKeyGuard, CombinedAuthGuard, TotpService],
  exports: [AuthService, JwtModule, ApiKeysService, ApiKeyGuard, CombinedAuthGuard, TotpService],
})
export class AuthModule {}

results matching ""

    No results matching ""