@@ -15,9 +15,9 @@ import {
15
15
} from '@nestjs/platform-fastify' ;
16
16
import { Test } from '@nestjs/testing' ;
17
17
import { expect } from 'chai' ;
18
- import { AppModule } from '../src/app.module' ;
19
- import * as request from 'supertest' ;
20
18
import { FastifyRequest } from 'fastify' ;
19
+ import * as request from 'supertest' ;
20
+ import { AppModule } from '../src/app.module' ;
21
21
22
22
describe ( 'Middleware (FastifyAdapter)' , ( ) => {
23
23
let app : NestFastifyApplication ;
@@ -37,6 +37,11 @@ describe('Middleware (FastifyAdapter)', () => {
37
37
return RETURN_VALUE ;
38
38
}
39
39
40
+ @Get ( 'legacy_style_wildcard/wildcard_nested' )
41
+ legacy_style_wildcard ( ) {
42
+ return RETURN_VALUE ;
43
+ }
44
+
40
45
@Get ( 'test' )
41
46
test ( ) {
42
47
return RETURN_VALUE ;
@@ -76,9 +81,13 @@ describe('Middleware (FastifyAdapter)', () => {
76
81
. apply ( ( req , res , next ) => res . end ( INCLUDED_VALUE ) )
77
82
. forRoutes ( { path : 'tests/included' , method : RequestMethod . POST } )
78
83
. apply ( ( req , res , next ) => res . end ( REQ_URL_VALUE ) )
79
- . forRoutes ( 'req/url/(.*) ' )
84
+ . forRoutes ( 'req/url/* ' )
80
85
. apply ( ( req , res , next ) => res . end ( WILDCARD_VALUE ) )
81
- . forRoutes ( 'express_style_wildcard/*' , 'tests/(.*)' )
86
+ . forRoutes (
87
+ 'express_style_wildcard/*' ,
88
+ 'tests/*path' ,
89
+ 'legacy_style_wildcard/(.*)' ,
90
+ )
82
91
. apply ( ( req , res , next ) => res . end ( QUERY_VALUE ) )
83
92
. forRoutes ( 'query' )
84
93
. apply ( ( req , res , next ) => next ( ) )
@@ -87,7 +96,7 @@ describe('Middleware (FastifyAdapter)', () => {
87
96
. forRoutes ( TestController )
88
97
. apply ( ( req , res , next ) => res . end ( RETURN_VALUE ) )
89
98
. exclude ( { path : QUERY_VALUE , method : - 1 as any } )
90
- . forRoutes ( '(.*) ' ) ;
99
+ . forRoutes ( '* ' ) ;
91
100
}
92
101
}
93
102
@@ -101,7 +110,7 @@ describe('Middleware (FastifyAdapter)', () => {
101
110
await app . init ( ) ;
102
111
} ) ;
103
112
104
- it ( `forRoutes((.*) )` , ( ) => {
113
+ it ( `forRoutes(* )` , ( ) => {
105
114
return app
106
115
. inject ( {
107
116
method : 'GET' ,
@@ -143,7 +152,7 @@ describe('Middleware (FastifyAdapter)', () => {
143
152
. then ( ( { payload } ) => expect ( payload ) . to . be . eql ( QUERY_VALUE ) ) ;
144
153
} ) ;
145
154
146
- it ( `forRoutes(tests/(.*) )` , ( ) => {
155
+ it ( `forRoutes(tests/*path )` , ( ) => {
147
156
return app
148
157
. inject ( {
149
158
method : 'GET' ,
@@ -161,6 +170,15 @@ describe('Middleware (FastifyAdapter)', () => {
161
170
. then ( ( { payload } ) => expect ( payload ) . to . be . eql ( WILDCARD_VALUE ) ) ;
162
171
} ) ;
163
172
173
+ it ( `forRoutes(legacy_style_wildcard/*)` , ( ) => {
174
+ return app
175
+ . inject ( {
176
+ method : 'GET' ,
177
+ url : '/legacy_style_wildcard/wildcard_nested' ,
178
+ } )
179
+ . then ( ( { payload } ) => expect ( payload ) . to . be . eql ( WILDCARD_VALUE ) ) ;
180
+ } ) ;
181
+
164
182
it ( `forRoutes(req/url/)` , ( ) => {
165
183
const reqUrl = '/test' ;
166
184
return app
0 commit comments