fix user module

This commit is contained in:
yaschalew
2026-06-23 10:53:57 +03:00
parent 78692c6b59
commit eeb7ce8cae
2 changed files with 62 additions and 0 deletions

View File

@@ -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,