@@ -68,8 +68,11 @@ export class FastifyAdapter<TInstance = any> extends AbstractHttpAdapter {
6868
6969 public setErrorHandler (
7070 handler : Parameters < fastify . FastifyInstance [ 'setErrorHandler' ] > [ 0 ] ,
71- prefix = '/' ,
71+ prefix ?: string ,
7272 ) {
73+ if ( ! prefix ) {
74+ return this . instance . setErrorHandler ( handler ) ;
75+ }
7376 return this . registerWithPrefix (
7477 async ( instance : fastify . FastifyInstance ) : Promise < void > => {
7578 instance . setErrorHandler ( handler ) ;
@@ -80,8 +83,11 @@ export class FastifyAdapter<TInstance = any> extends AbstractHttpAdapter {
8083
8184 public setNotFoundHandler (
8285 handler : Parameters < fastify . FastifyInstance [ 'setNotFoundHandler' ] > [ 0 ] ,
83- prefix = '/' ,
86+ prefix ?: string ,
8487 ) {
88+ if ( ! prefix ) {
89+ return this . instance . setNotFoundHandler ( handler ) ;
90+ }
8591 return this . registerWithPrefix (
8692 async ( instance : fastify . FastifyInstance ) : Promise < void > => {
8793 instance . setNotFoundHandler ( handler ) ;
@@ -152,22 +158,16 @@ export class FastifyAdapter<TInstance = any> extends AbstractHttpAdapter {
152158 return request . raw . url ;
153159 }
154160
155- public enableCors ( options : CorsOptions , prefix = '/' ) {
156- return this . registerWithPrefix (
157- async ( instance : fastify . FastifyInstance ) : Promise < void > => {
158- instance . register ( cors , ( options as unknown ) as { } ) ;
159- } ,
160- prefix ,
161- ) ;
161+ public enableCors ( options : CorsOptions ) {
162+ try {
163+ this . register ( cors , options ) ;
164+ } catch { }
162165 }
163166
164- public registerParserMiddleware ( prefix = '/' ) {
165- return this . registerWithPrefix (
166- async ( instance : fastify . FastifyInstance ) : Promise < void > => {
167- instance . register ( formBody ) ;
168- } ,
169- prefix ,
170- ) ;
167+ public registerParserMiddleware ( ) {
168+ try {
169+ this . register ( formBody ) ;
170+ } catch { }
171171 }
172172
173173 public createMiddlewareFactory (
0 commit comments