甚至是吧filter使用到app的全局去,按理一般应该是会在全局使用的,不过多人开发以及不同的功能模块会有不同的处理逻辑也不一定

This commit is contained in:
Jeremy Yin 2019-06-18 22:48:25 +08:00
parent b4306f2cbb
commit c956570805
2 changed files with 3 additions and 1 deletions

View File

@ -1,8 +1,10 @@
import { NestFactory } from '@nestjs/core'; import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module'; import { AppModule } from './app.module';
import { DemoFilter } from './core/filters/demo.filter'
async function bootstrap() { async function bootstrap() {
const app = await NestFactory.create(AppModule); const app = await NestFactory.create(AppModule);
app.useGlobalFilters(new DemoFilter());
await app.listen(3000); await app.listen(3000);
} }
bootstrap(); bootstrap();

View File

@ -5,7 +5,7 @@ import { DemoFilter } from '../../core/filters/demo.filter'
@Controller('posts') @Controller('posts')
@UseFilters(DemoFilter) // @UseFilters(DemoFilter)
export class PostsController { export class PostsController {
constructor(private readonly demoService: DemoService) {} constructor(private readonly demoService: DemoService) {}