mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-21 07:10:33 +00:00
hotbug(server): interceptors order
This commit is contained in:
@@ -5,15 +5,18 @@ import {
|
|||||||
NestInterceptor,
|
NestInterceptor,
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import { Observable, map } from 'rxjs';
|
import { Observable, map } from 'rxjs';
|
||||||
import { mapValues, mapValuesDeep } from '@/utils/deepdash';
|
import { mapValuesDeep } from '@/utils/deepdash';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class ToJsonInterceptor implements NestInterceptor {
|
export class ToJsonInterceptor implements NestInterceptor {
|
||||||
intercept(context: ExecutionContext, next: CallHandler): Observable<any> {
|
intercept(context: ExecutionContext, next: CallHandler): Observable<any> {
|
||||||
return next.handle().pipe(
|
return next.handle().pipe(
|
||||||
map((data) => {
|
map((data) => {
|
||||||
|
if (data === null || data === undefined) {
|
||||||
|
return data;
|
||||||
|
}
|
||||||
return mapValuesDeep(data, (value) => {
|
return mapValuesDeep(data, (value) => {
|
||||||
if (value && typeof value.toJSON === 'function') {
|
if (value !== null && value !== undefined && typeof value.toJSON === 'function') {
|
||||||
return value.toJSON();
|
return value.toJSON();
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
|
|||||||
@@ -36,8 +36,8 @@ import { PdfTemplatesModule } from '../PdfTemplate/PdfTemplates.module';
|
|||||||
import { BranchesModule } from '../Branches/Branches.module';
|
import { BranchesModule } from '../Branches/Branches.module';
|
||||||
import { WarehousesModule } from '../Warehouses/Warehouses.module';
|
import { WarehousesModule } from '../Warehouses/Warehouses.module';
|
||||||
import { SerializeInterceptor } from '@/common/interceptors/serialize.interceptor';
|
import { SerializeInterceptor } from '@/common/interceptors/serialize.interceptor';
|
||||||
import { ValidationPipe } from '@/common/pipes/ClassValidation.pipe';
|
|
||||||
import { ToJsonInterceptor } from '@/common/interceptors/to-json.interceptor';
|
import { ToJsonInterceptor } from '@/common/interceptors/to-json.interceptor';
|
||||||
|
import { ValidationPipe } from '@/common/pipes/ClassValidation.pipe';
|
||||||
import { ServiceErrorFilter } from '@/common/filters/service-error.filter';
|
import { ServiceErrorFilter } from '@/common/filters/service-error.filter';
|
||||||
import { ModelHasRelationsFilter } from '@/common/filters/model-has-relations.filter';
|
import { ModelHasRelationsFilter } from '@/common/filters/model-has-relations.filter';
|
||||||
import { ChromiumlyTenancyModule } from '../ChromiumlyTenancy/ChromiumlyTenancy.module';
|
import { ChromiumlyTenancyModule } from '../ChromiumlyTenancy/ChromiumlyTenancy.module';
|
||||||
@@ -248,11 +248,11 @@ import { AppThrottleModule } from './AppThrottle.module';
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
provide: APP_INTERCEPTOR,
|
provide: APP_INTERCEPTOR,
|
||||||
useClass: ToJsonInterceptor,
|
useClass: SerializeInterceptor,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
provide: APP_INTERCEPTOR,
|
provide: APP_INTERCEPTOR,
|
||||||
useClass: SerializeInterceptor,
|
useClass: ToJsonInterceptor,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
provide: APP_INTERCEPTOR,
|
provide: APP_INTERCEPTOR,
|
||||||
|
|||||||
Reference in New Issue
Block a user