auth.module.ts 988 B

123456789101112131415161718192021222324252627282930
  1. import { Module } from '@nestjs/common';
  2. import { JwtModule } from '@nestjs/jwt';
  3. import { ConfigModule, ConfigService } from '@nestjs/config';
  4. import { PrismaMongoModule } from '../../prisma/prisma-mongo.module';
  5. import { RabbitmqModule } from '../../rabbitmq/rabbitmq.module';
  6. import { AuthController } from './auth.controller';
  7. import { AuthService } from './auth.service';
  8. import { CoreModule } from '@box/core/core.module';
  9. @Module({
  10. imports: [
  11. PrismaMongoModule,
  12. RabbitmqModule,
  13. CoreModule,
  14. JwtModule.registerAsync({
  15. imports: [ConfigModule],
  16. inject: [ConfigService],
  17. useFactory: (configService: ConfigService) => ({
  18. secret: configService.get<string>('JWT_SECRET') || 'default-secret-key',
  19. signOptions: {
  20. expiresIn: configService.get<string>('JWT_EXPIRES_IN') || '7d',
  21. },
  22. }),
  23. }),
  24. ],
  25. controllers: [AuthController],
  26. providers: [AuthService],
  27. exports: [AuthService],
  28. })
  29. export class AuthModule {}