File tree Expand file tree Collapse file tree
packages/platform-fastify/adapters Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- import { RequestMethod , HttpStatus } from '@nestjs/common' ;
1+ import { HttpStatus , RequestMethod } from '@nestjs/common' ;
22import { CorsOptions } from '@nestjs/common/interfaces/external/cors-options.interface' ;
33import { NestApplicationOptions } from '@nestjs/common/interfaces/nest-application-options.interface' ;
44import { loadPackage } from '@nestjs/common/utils/load-package.util' ;
55import { AbstractHttpAdapter } from '@nestjs/core/adapters/http-adapter' ;
66import * as fastify from 'fastify' ;
77import * as cors from 'fastify-cors' ;
88import * as formBody from 'fastify-formbody' ;
9+ import * as Reply from 'fastify/lib/Reply' ;
910import * as pathToRegexp from 'path-to-regexp' ;
1011
1112export class FastifyAdapter extends AbstractHttpAdapter {
@@ -35,6 +36,17 @@ export class FastifyAdapter extends AbstractHttpAdapter {
3536 }
3637
3738 public reply ( response : any , body : any , statusCode ?: number ) {
39+ const isNativeResponse = typeof response . status !== 'function' ;
40+ if ( isNativeResponse ) {
41+ const fastifyContext = {
42+ preSerialization : null ,
43+ preValidation : [ ] ,
44+ preHandler : [ ] ,
45+ onSend : [ ] ,
46+ onError : [ ] ,
47+ } ;
48+ response = new Reply ( response , fastifyContext , { } ) ;
49+ }
3850 if ( statusCode ) {
3951 response . status ( statusCode ) ;
4052 }
You can’t perform that action at this time.
0 commit comments