|
5 | 5 | Module,
|
6 | 6 | NestMiddleware,
|
7 | 7 | NestModule,
|
| 8 | + Param, |
8 | 9 | Query,
|
9 | 10 | Req,
|
10 | 11 | RequestMethod,
|
@@ -439,6 +440,11 @@ describe('Middleware (FastifyAdapter)', () => {
|
439 | 440 | async rootPath(@Req() req: FastifyRequest['raw']) {
|
440 | 441 | return { success: true, root: true };
|
441 | 442 | }
|
| 443 | + |
| 444 | + @Get(':id') |
| 445 | + async record(@Req() req: FastifyRequest['raw'], @Param('id') id: string) { |
| 446 | + return { success: true, record: id }; |
| 447 | + } |
442 | 448 | }
|
443 | 449 |
|
444 | 450 | @Module({
|
@@ -535,6 +541,32 @@ describe('Middleware (FastifyAdapter)', () => {
|
535 | 541 | .expect(200, { success: true, root: true });
|
536 | 542 | });
|
537 | 543 |
|
| 544 | + it(`GET forRoutes('{*path}') with global prefix and exclude pattern with wildcard`, async () => { |
| 545 | + app.setGlobalPrefix('/api', { exclude: ['/{*path}'] }); |
| 546 | + await app.init(); |
| 547 | + await app.getHttpAdapter().getInstance().ready(); |
| 548 | + |
| 549 | + await request(app.getHttpServer()) |
| 550 | + .get('/pong') |
| 551 | + .expect(200, { success: true, pong: 'pong' }); |
| 552 | + await request(app.getHttpServer()) |
| 553 | + .get('/api/abc123') |
| 554 | + .expect(200, { success: true, pong: 'abc123' }); |
| 555 | + }); |
| 556 | + |
| 557 | + it(`GET forRoutes('{*path}') with global prefix and exclude pattern with parameter`, async () => { |
| 558 | + app.setGlobalPrefix('/api', { exclude: ['/:id'] }); |
| 559 | + await app.init(); |
| 560 | + await app.getHttpAdapter().getInstance().ready(); |
| 561 | + |
| 562 | + await request(app.getHttpServer()) |
| 563 | + .get('/abc123') |
| 564 | + .expect(200, { success: true, record: 'abc123' }); |
| 565 | + await request(app.getHttpServer()) |
| 566 | + .get('/api/pong') |
| 567 | + .expect(200, { success: true, pong: 'pong' }); |
| 568 | + }); |
| 569 | + |
538 | 570 | it(`GET forRoutes('{*path}') with global prefix and global prefix options`, async () => {
|
539 | 571 | app.setGlobalPrefix('/api', { exclude: ['/'] });
|
540 | 572 | await app.init();
|
|
0 commit comments