Forked from
Eclipse Projects / xfsc / Organization Credential Manager / OCM-Engine
302 commits behind the upstream repository.
-
Konstantin Tsabolov authoredKonstantin Tsabolov authored
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
response-format.interceptor.ts 612 B
import type {
CallHandler,
ExecutionContext,
NestInterceptor,
} from '@nestjs/common';
import { Injectable } from '@nestjs/common';
import { map, type Observable } from 'rxjs';
@Injectable()
export class ResponseFormatInterceptor implements NestInterceptor {
public intercept(
context: ExecutionContext,
next: CallHandler,
): Observable<unknown> {
const ctx = context.switchToHttp();
const response = ctx.getResponse();
return next.handle().pipe(
map((data) => {
return {
statusCode: response.statusCode,
data,
};
}),
);
}
}