@@ -10,7 +10,7 @@ import {
1010 OnModuleInit ,
1111} from '@nestjs/common' ;
1212import { RequestContext } from '@medibloc/nestjs-request-context' ;
13- import { from , Observable } from 'rxjs' ;
13+ import { from , lastValueFrom , Observable } from 'rxjs' ;
1414import { catchError , map , mergeMap } from 'rxjs/operators' ;
1515import { ControllerResponse } from './controller.core' ;
1616import { TransactionsContext } from '../utils/transactions.utils' ;
@@ -47,9 +47,8 @@ export class HttpInterceptor implements NestInterceptor, OnModuleInit {
4747 this . db . Prisma . $transaction (
4848 async ( prisma ) => {
4949 await ctx . transactions . init ( prisma ) ;
50- return next
51- . handle ( )
52- . pipe (
50+ return lastValueFrom (
51+ next . handle ( ) . pipe (
5352 mergeMap ( async ( data ) => {
5453 if ( data instanceof ControllerResponse ) {
5554 return data ;
@@ -75,8 +74,8 @@ export class HttpInterceptor implements NestInterceptor, OnModuleInit {
7574 'or a BaseError<string>' ,
7675 ) ;
7776 } ) ,
78- )
79- . toPromise ( ) ;
77+ ) ,
78+ ) ;
8079 } ,
8180 { maxWait : 20000 , timeout : 50000 } ,
8281 ) ,
@@ -142,7 +141,7 @@ export class HttpInterceptor implements NestInterceptor, OnModuleInit {
142141 if ( process . env [ 'TEST' ] !== 'true' ) {
143142 response . send (
144143 `${ R . omit ( [ 'stack' ] , body ) } \nStack: ${
145- process . env [ 'FULL_PRODUCTION_MODE ' ] !== 'true ' ? body ?. stack : ''
144+ process . env [ 'ENVIRONMENT ' ] !== 'prod ' ? body ?. stack : ''
146145 } `,
147146 ) ;
148147 } else {
0 commit comments