Spaces:
Sleeping
Sleeping
| import { Module } from '@nestjs/common'; | |
| import { JwtModule } from '@nestjs/jwt'; | |
| import { PassportModule } from '@nestjs/passport'; | |
| import { MongooseModule } from '@nestjs/mongoose'; | |
| import { ConfigService } from '@nestjs/config'; | |
| import { AuthController } from './auth.controller'; | |
| import { AuthService } from './auth.service'; | |
| import { JwtStrategy } from './strategies/jwt.strategy'; | |
| import { User, UserSchema } from './schemas/user.schema'; | |
| ({ | |
| imports: [ | |
| MongooseModule.forFeature([{ name: User.name, schema: UserSchema }]), | |
| PassportModule.register({ defaultStrategy: 'jwt' }), | |
| JwtModule.registerAsync({ | |
| inject: [ConfigService], | |
| useFactory: (config: ConfigService) => ({ | |
| secret: config.get<string>('JWT_SECRET', 'medicode-secret-key'), | |
| signOptions: { expiresIn: config.get<string>('JWT_EXPIRES', '7d') }, | |
| }), | |
| }), | |
| ], | |
| controllers: [AuthController], | |
| providers: [AuthService, JwtStrategy], | |
| exports: [JwtStrategy, PassportModule, AuthService], | |
| }) | |
| export class AuthModule {} | |