(consumer: MiddlewareConsumer)
| 611 | }) |
| 612 | class DataModule implements NestModule { |
| 613 | configure(consumer: MiddlewareConsumer) { |
| 614 | consumer |
| 615 | .apply((req, res, next) => { |
| 616 | req.extras = { data: 'Data attached in middleware' }; |
| 617 | req.headers['ping'] = 'pong'; |
| 618 | |
| 619 | // When global prefix is set and the route is the root path |
| 620 | if (req.originalUrl === '/api') { |
| 621 | return res.end(JSON.stringify({ success: true, pong: 'pong' })); |
| 622 | } |
| 623 | next(); |
| 624 | }) |
| 625 | .forRoutes('{*path}'); |
| 626 | } |
| 627 | } |
| 628 | |
| 629 | beforeEach(async () => { |