From d7331554ad64ff1de93d55eb230ae54098dbecc2 Mon Sep 17 00:00:00 2001 From: Ahmed Bouhuolia Date: Wed, 21 Jan 2026 13:07:03 +0200 Subject: [PATCH] hotbug(server): interceptors order --- .../server/src/common/interceptors/to-json.interceptor.ts | 7 +++++-- packages/server/src/modules/App/App.module.ts | 6 +++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/server/src/common/interceptors/to-json.interceptor.ts b/packages/server/src/common/interceptors/to-json.interceptor.ts index cd0f03bdc..bb3ae2f6f 100644 --- a/packages/server/src/common/interceptors/to-json.interceptor.ts +++ b/packages/server/src/common/interceptors/to-json.interceptor.ts @@ -5,15 +5,18 @@ import { NestInterceptor, } from '@nestjs/common'; import { Observable, map } from 'rxjs'; -import { mapValues, mapValuesDeep } from '@/utils/deepdash'; +import { mapValuesDeep } from '@/utils/deepdash'; @Injectable() export class ToJsonInterceptor implements NestInterceptor { intercept(context: ExecutionContext, next: CallHandler): Observable { return next.handle().pipe( map((data) => { + if (data === null || data === undefined) { + return data; + } return mapValuesDeep(data, (value) => { - if (value && typeof value.toJSON === 'function') { + if (value !== null && value !== undefined && typeof value.toJSON === 'function') { return value.toJSON(); } return value; diff --git a/packages/server/src/modules/App/App.module.ts b/packages/server/src/modules/App/App.module.ts index ded1ffda5..e50bfcd91 100644 --- a/packages/server/src/modules/App/App.module.ts +++ b/packages/server/src/modules/App/App.module.ts @@ -36,8 +36,8 @@ import { PdfTemplatesModule } from '../PdfTemplate/PdfTemplates.module'; import { BranchesModule } from '../Branches/Branches.module'; import { WarehousesModule } from '../Warehouses/Warehouses.module'; import { SerializeInterceptor } from '@/common/interceptors/serialize.interceptor'; -import { ValidationPipe } from '@/common/pipes/ClassValidation.pipe'; import { ToJsonInterceptor } from '@/common/interceptors/to-json.interceptor'; +import { ValidationPipe } from '@/common/pipes/ClassValidation.pipe'; import { ServiceErrorFilter } from '@/common/filters/service-error.filter'; import { ModelHasRelationsFilter } from '@/common/filters/model-has-relations.filter'; import { ChromiumlyTenancyModule } from '../ChromiumlyTenancy/ChromiumlyTenancy.module'; @@ -248,11 +248,11 @@ import { AppThrottleModule } from './AppThrottle.module'; }, { provide: APP_INTERCEPTOR, - useClass: ToJsonInterceptor, + useClass: SerializeInterceptor, }, { provide: APP_INTERCEPTOR, - useClass: SerializeInterceptor, + useClass: ToJsonInterceptor, }, { provide: APP_INTERCEPTOR,