Merge pull request #907 from bigcapitalhq/feature/20260121130702
hotbug(server): interceptors order
This commit is contained in:
@@ -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<any> {
|
||||
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;
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user