Skip to content

Commit

Permalink
refactor: move ClassSerializerInterceptor to AppModule
Browse files Browse the repository at this point in the history
  • Loading branch information
rjlopezdev committed Oct 15, 2024
1 parent 958c9ad commit 3747f75
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
10 changes: 8 additions & 2 deletions apps/your-burger-api/src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -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: [
Expand All @@ -11,6 +12,11 @@ import { ProposalModule } from './proposal/proposal.module';
MikroOrmModule.forRoot(config),
],
controllers: [],
providers: [],
providers: [
{
provide: APP_INTERCEPTOR,
useClass: ClassSerializerInterceptor,
},
],
})
export class AppModule {}
5 changes: 2 additions & 3 deletions apps/your-burger-api/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 3747f75

Please sign in to comment.