mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-27 08:32:54 +00:00
fix user module
This commit is contained in:
@@ -8,6 +8,7 @@ import {
|
||||
import { Readable } from "stream";
|
||||
import { Observable } from "rxjs";
|
||||
import { map } from "rxjs/operators";
|
||||
import { flatResponseModules } from "../constants/apiModules";
|
||||
|
||||
export interface StandardResponse<T> {
|
||||
success: true;
|
||||
@@ -33,6 +34,25 @@ export class ResponseTransformInterceptor<T> implements NestInterceptor<
|
||||
) {
|
||||
return data;
|
||||
}
|
||||
const request = _context.switchToHttp().getRequest();
|
||||
const path = request.route?.path ?? request.originalUrl ?? "";
|
||||
|
||||
const shouldFlatten = flatResponseModules.some((module) =>
|
||||
path.startsWith(module),
|
||||
);
|
||||
|
||||
if (
|
||||
shouldFlatten &&
|
||||
data &&
|
||||
typeof data === "object" &&
|
||||
!Array.isArray(data)
|
||||
) {
|
||||
return {
|
||||
success: true,
|
||||
...data,
|
||||
timestamp: new Date().toISOString(),
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
|
||||
Reference in New Issue
Block a user