@@ -2,7 +2,6 @@ import compression from '@fastify/compress';
2
2
import cookieParser from '@fastify/cookie' ;
3
3
import cors from '@fastify/cors' ;
4
4
import websocket from '@fastify/websocket' ;
5
- import { DiscoveryService } from '@golevelup/nestjs-discovery' ;
6
5
import {
7
6
VERSION_NEUTRAL ,
8
7
type VersionValue ,
@@ -16,15 +15,15 @@ import {
16
15
import type { FastifyInstance , HTTPMethods , RouteOptions } from 'fastify' ;
17
16
import rawBody from 'fastify-raw-body' ;
18
17
import * as zlib from 'node:zlib' ;
19
- import { uniqueDiscoveredMethods } from '~/common/discovery-unique-methods' ;
20
18
import { type ConfigService } from '~/core/config/config.service' ;
19
+ import { MetadataDiscovery } from '~/core/discovery' ;
21
20
import {
22
21
GlobalHttpHook ,
23
22
RawBody ,
24
23
RouteConfig ,
25
24
RouteConstraints ,
26
25
} from './decorators' ;
27
- import type { CookieOptions , CorsOptions , HttpHooks , IResponse } from './types' ;
26
+ import type { CookieOptions , CorsOptions , IResponse } from './types' ;
28
27
29
28
export type NestHttpApplication = NestFastifyApplication & {
30
29
configure : (
@@ -73,15 +72,13 @@ export class HttpAdapter extends PatchedFastifyAdapter {
73
72
config . applyTimeouts ( app . getHttpServer ( ) , config . httpTimeouts ) ;
74
73
75
74
// Attach hooks
76
- const globalHooks = await app
77
- . get ( DiscoveryService )
78
- . providerMethodsWithMetaAtKey < keyof HttpHooks > ( GlobalHttpHook . KEY ) ;
75
+ const globalHooks = app
76
+ . get ( MetadataDiscovery )
77
+ . discover ( GlobalHttpHook )
78
+ . methods ( ) ;
79
79
const fastify = app . getHttpAdapter ( ) . getInstance ( ) ;
80
- for ( const globalHook of uniqueDiscoveredMethods ( globalHooks ) ) {
81
- const handler = globalHook . discoveredMethod . handler . bind (
82
- globalHook . discoveredMethod . parentClass . instance ,
83
- ) ;
84
- fastify . addHook ( globalHook . meta , handler ) ;
80
+ for ( const globalHook of globalHooks ) {
81
+ fastify . addHook ( globalHook . meta , globalHook . method ) ;
85
82
}
86
83
}
87
84
0 commit comments