32 lines
961 B
TypeScript
32 lines
961 B
TypeScript
import { Module } from '@nestjs/common';
|
|
import { UserService } from './user.service';
|
|
import { UserController } from './user.controller';
|
|
import { TypeOrmModule } from '@nestjs/typeorm';
|
|
import { User } from './entities/user.entity';
|
|
import { ConfigService } from '@nestjs/config';
|
|
import { JwtModule } from '@nestjs/jwt';
|
|
import { PassportModule } from '@nestjs/passport';
|
|
import { JwtStrategy } from './jwt.strategy';
|
|
|
|
@Module({
|
|
imports: [
|
|
TypeOrmModule.forFeature([User]),
|
|
PassportModule.register({ defaultStrategy: 'jwt' }),
|
|
JwtModule.registerAsync({
|
|
inject: [ConfigService],
|
|
useFactory: async (configService: ConfigService) => {
|
|
return {
|
|
global: true,
|
|
secret: configService.get('JWT_SECRET'),
|
|
signOptions: { expiresIn: '1h' },
|
|
};
|
|
},
|
|
|
|
}),
|
|
],
|
|
controllers: [UserController],
|
|
providers: [UserService,JwtStrategy],
|
|
exports: [UserService],
|
|
})
|
|
export class UserModule { }
|