diff --git a/apps/your-burger-api/src/app/app.module.ts b/apps/your-burger-api/src/app/app.module.ts index 6c76a0a..42f8d63 100644 --- a/apps/your-burger-api/src/app/app.module.ts +++ b/apps/your-burger-api/src/app/app.module.ts @@ -1,8 +1,9 @@ -import { Module } from '@nestjs/common'; +import { ClassSerializerInterceptor, Module } from '@nestjs/common'; import { BurgerBusinessModule } from './burger-business/burger-business.module'; import { MikroOrmModule } from '@mikro-orm/nestjs'; import config from '../mikro-orm.config'; import { ProposalModule } from './proposal/proposal.module'; +import { APP_INTERCEPTOR } from '@nestjs/core'; @Module({ imports: [ @@ -11,6 +12,11 @@ import { ProposalModule } from './proposal/proposal.module'; MikroOrmModule.forRoot(config), ], controllers: [], - providers: [], + providers: [ + { + provide: APP_INTERCEPTOR, + useClass: ClassSerializerInterceptor, + }, + ], }) export class AppModule {} diff --git a/apps/your-burger-api/src/main.ts b/apps/your-burger-api/src/main.ts index ac9e35e..ad10eec 100644 --- a/apps/your-burger-api/src/main.ts +++ b/apps/your-burger-api/src/main.ts @@ -3,18 +3,17 @@ * This is only a minimal backend to get started. */ -import { ClassSerializerInterceptor, Logger } from '@nestjs/common'; -import { NestFactory, Reflector } from '@nestjs/core'; +import { NestFactory } from '@nestjs/core'; import { AppModule } from './app/app.module'; import { setupOpenApi } from './open-api'; +import { Logger } from '@nestjs/common'; async function bootstrap() { const app = await NestFactory.create(AppModule); const globalPrefix = 'api'; app.setGlobalPrefix(globalPrefix); const port = process.env.PORT || 3000; - app.useGlobalInterceptors(new ClassSerializerInterceptor(Reflector)); setupOpenApi(app);