UNPKG

generator-nest-js-boilerplate

Version:

This generator will help you to build your own Nest.js Mongodb API using TypeScript 4

23 lines (20 loc) 490 B
import { CallHandler, ExecutionContext, Injectable, NestInterceptor, } from '@nestjs/common'; import { Observable } from 'rxjs'; import { map } from 'rxjs/operators'; @Injectable() export default class WrapResponseInterceptor implements NestInterceptor { intercept(context: ExecutionContext, next: CallHandler): Observable<any> { return next.handle().pipe( map((...args) => { return { data: args[0].data ?? args[0], }; }), ); } }