@@ -12,7 +12,18 @@ import {
12
12
FastifyAdapter ,
13
13
NestFastifyApplication ,
14
14
} from '@nestjs/platform-fastify' ;
15
- import type { FastifyInstance , HTTPMethods , RouteOptions } from 'fastify' ;
15
+ import type {
16
+ FastifyInstance ,
17
+ FastifyReply ,
18
+ FastifyRequest ,
19
+ HTTPMethods ,
20
+ RawReplyDefaultExpression ,
21
+ RawRequestDefaultExpression ,
22
+ RawServerBase ,
23
+ RawServerDefault ,
24
+ RequestGenericInterface ,
25
+ RouteOptions ,
26
+ } from 'fastify' ;
16
27
import rawBody from 'fastify-raw-body' ;
17
28
import * as zlib from 'node:zlib' ;
18
29
import { uniqueDiscoveredMethods } from '~/common/discovery-unique-methods' ;
@@ -34,8 +45,41 @@ export type NestHttpApplication = NestFastifyApplication & {
34
45
35
46
export class HttpAdapterHost extends HttpAdapterHostImpl < HttpAdapter > { }
36
47
48
+ type FastifyRawRequest < TServer extends RawServerBase > =
49
+ RawRequestDefaultExpression < TServer > & {
50
+ originalUrl ?: string ;
51
+ } ;
52
+
37
53
// @ts -expect-error Convert private methods to protected
38
- class PatchedFastifyAdapter extends FastifyAdapter {
54
+ class PatchedFastifyAdapter <
55
+ TServer extends RawServerBase = RawServerDefault ,
56
+ TRawRequest extends FastifyRawRequest < TServer > = FastifyRawRequest < TServer > ,
57
+ TRawResponse extends RawReplyDefaultExpression < TServer > = RawReplyDefaultExpression < TServer > ,
58
+ TRequest extends FastifyRequest <
59
+ RequestGenericInterface ,
60
+ TServer ,
61
+ TRawRequest
62
+ > = FastifyRequest < RequestGenericInterface , TServer , TRawRequest > ,
63
+ TReply extends FastifyReply <
64
+ RequestGenericInterface ,
65
+ TServer ,
66
+ TRawRequest ,
67
+ TRawResponse
68
+ > = FastifyReply < RequestGenericInterface , TServer , TRawRequest , TRawResponse > ,
69
+ TInstance extends FastifyInstance <
70
+ TServer ,
71
+ TRawRequest ,
72
+ TRawResponse
73
+ > = FastifyInstance < TServer , TRawRequest , TRawResponse > ,
74
+ > extends FastifyAdapter <
75
+ TServer ,
76
+ TRawRequest ,
77
+ TRawResponse ,
78
+ TRequest ,
79
+ // @ts -expect-error they haven't upgraded to v5 signature yet.
80
+ TReply ,
81
+ TInstance
82
+ > {
39
83
protected injectRouteOptions (
40
84
routerMethodKey : Uppercase < HTTPMethods > ,
41
85
...args : any [ ]
0 commit comments