feat: auth guard 增加
This commit is contained in:
1 parent
346742b157
commit
a2ee53f83a
11 files changed
+245
-6
No files matched your search
@@ -1,8 +1,15 @@
|
||||
import { Global, Module } from '@nestjs/common';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { ConfigModule, ConfigService } from '@nestjs/config';
|
||||
import { TokenController } from './controller/token.controller';
|
||||
import { UserService } from './service/user.service';
|
||||
import { User } from './entity/user.entity';
|
||||
import { APP_GUARD } from '@nestjs/core';
|
||||
import { AuthGuard } from './guards/auth.guard';
|
||||
import { JwtService } from '@nestjs/jwt';
|
||||
|
||||
@Module({
|
||||
controllers: [TokenController],
|
||||
imports: [
|
||||
ConfigModule.forRoot({
|
||||
isGlobal: true,
|
||||
@@ -21,11 +28,23 @@ import { ConfigModule, ConfigService } from '@nestjs/config';
|
||||
password: configService.get<string>('DB_PASSWORD'),
|
||||
database: configService.get<string>('DB_NAME'),
|
||||
autoLoadEntities: true,
|
||||
entities: [__dirname + '/**/*.entity{.ts,.js}'],
|
||||
synchronize: process.env.NODE_ENV === 'development',
|
||||
logging: true,
|
||||
}),
|
||||
inject: [ConfigService],
|
||||
}),
|
||||
TypeOrmModule.forFeature([User]),
|
||||
],
|
||||
providers: [
|
||||
{
|
||||
provide: APP_GUARD,
|
||||
useClass: AuthGuard,
|
||||
},
|
||||
UserService,
|
||||
JwtService,
|
||||
],
|
||||
exports: [UserService],
|
||||
})
|
||||
@Global()
|
||||
export class CoreModule {}
|
||||
Reference in new issue
Block a user