Skip to content

Commit 9e5f77c

Browse files
chore: resolve conflicts
2 parents 8bcd1e5 + cb739ad commit 9e5f77c

30 files changed

+933
-302
lines changed

integration/hello-world/e2e/exclude-middleware-fastify.spec.ts

+33-4
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,16 @@ class TestController {
5050
return RETURN_VALUE;
5151
}
5252

53+
@Get('legacy-wildcard/overview')
54+
testLegacyWildcard() {
55+
return RETURN_VALUE;
56+
}
57+
58+
@Get('splat-wildcard/overview')
59+
testSplatWildcard() {
60+
return RETURN_VALUE;
61+
}
62+
5363
@Get('overview/:id')
5464
overviewById() {
5565
return RETURN_VALUE;
@@ -64,10 +74,17 @@ class TestModule {
6474
configure(consumer: MiddlewareConsumer) {
6575
consumer
6676
.apply((req, res, next) => res.end(MIDDLEWARE_VALUE))
67-
.exclude('test', 'overview/:id', 'wildcard/(.*)', {
68-
path: 'middleware',
69-
method: RequestMethod.POST,
70-
})
77+
.exclude(
78+
'test',
79+
'overview/:id',
80+
'wildcard/*',
81+
'legacy-wildcard/(.*)',
82+
'splat-wildcard/*splat',
83+
{
84+
path: 'middleware',
85+
method: RequestMethod.POST,
86+
},
87+
)
7188
.forRoutes('*');
7289
}
7390
}
@@ -126,6 +143,18 @@ describe('Exclude middleware (fastify)', () => {
126143
.expect(200, RETURN_VALUE);
127144
});
128145

146+
it(`should exclude "/legacy-wildcard/overview" endpoint (by wildcard, legacy syntax)`, () => {
147+
return request(app.getHttpServer())
148+
.get('/legacy-wildcard/overview')
149+
.expect(200, RETURN_VALUE);
150+
});
151+
152+
it(`should exclude "/splat-wildcard/overview" endpoint (by wildcard, new syntax)`, () => {
153+
return request(app.getHttpServer())
154+
.get('/splat-wildcard/overview')
155+
.expect(200, RETURN_VALUE);
156+
});
157+
129158
afterEach(async () => {
130159
await app.close();
131160
});

integration/hello-world/e2e/exclude-middleware.spec.ts

+34-5
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,16 @@ class TestController {
4141
return RETURN_VALUE;
4242
}
4343

44+
@Get('legacy-wildcard/overview')
45+
testLegacyWildcard() {
46+
return RETURN_VALUE;
47+
}
48+
49+
@Get('splat-wildcard/overview')
50+
testSplatWildcard() {
51+
return RETURN_VALUE;
52+
}
53+
4454
@Get('overview/:id')
4555
overviewById() {
4656
return RETURN_VALUE;
@@ -60,12 +70,19 @@ class TestModule {
6070
configure(consumer: MiddlewareConsumer) {
6171
consumer
6272
.apply((req, res, next) => res.send(MIDDLEWARE_VALUE))
63-
.exclude('test', 'overview/:id', 'wildcard/(.*)', {
64-
path: 'middleware',
65-
method: RequestMethod.POST,
66-
})
73+
.exclude(
74+
'test',
75+
'overview/:id',
76+
'wildcard/*',
77+
'legacy-wildcard/(.*)',
78+
'splat-wildcard/*splat',
79+
{
80+
path: 'middleware',
81+
method: RequestMethod.POST,
82+
},
83+
)
6784
.exclude('multiple/exclude')
68-
.forRoutes('*');
85+
.forRoutes('*path');
6986
}
7087
}
7188

@@ -116,6 +133,18 @@ describe('Exclude middleware', () => {
116133
.expect(200, RETURN_VALUE);
117134
});
118135

136+
it(`should exclude "/legacy-wildcard/overview" endpoint (by wildcard, legacy syntax)`, () => {
137+
return request(app.getHttpServer())
138+
.get('/legacy-wildcard/overview')
139+
.expect(200, RETURN_VALUE);
140+
});
141+
142+
it(`should exclude "/splat-wildcard/overview" endpoint (by wildcard, new syntax)`, () => {
143+
return request(app.getHttpServer())
144+
.get('/splat-wildcard/overview')
145+
.expect(200, RETURN_VALUE);
146+
});
147+
119148
it(`should exclude "/multiple/exclude" endpoint`, () => {
120149
return request(app.getHttpServer())
121150
.get('/multiple/exclude')

integration/hello-world/e2e/express-instance.spec.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ import { ExpressAdapter } from '@nestjs/platform-express';
33
import { Test } from '@nestjs/testing';
44
import * as express from 'express';
55
import * as request from 'supertest';
6+
import { App } from 'supertest/types';
67
import { AppModule } from '../src/app.module';
78

89
describe('Hello world (express instance)', () => {
9-
let server;
10+
let server: App;
1011
let app: INestApplication;
1112

1213
beforeEach(async () => {

integration/hello-world/e2e/middleware-class.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import {
88
RequestMethod,
99
} from '@nestjs/common';
1010
import { Test } from '@nestjs/testing';
11+
import { Response } from 'express';
1112
import * as request from 'supertest';
1213
import { AppModule } from '../src/app.module';
13-
import { Response } from 'express';
1414

1515
const INCLUDED_VALUE = 'test_included';
1616
const RETURN_VALUE = 'test';

integration/hello-world/e2e/middleware-fastify.spec.ts

+25-7
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ import {
1515
} from '@nestjs/platform-fastify';
1616
import { Test } from '@nestjs/testing';
1717
import { expect } from 'chai';
18-
import { AppModule } from '../src/app.module';
19-
import * as request from 'supertest';
2018
import { FastifyRequest } from 'fastify';
19+
import * as request from 'supertest';
20+
import { AppModule } from '../src/app.module';
2121

2222
describe('Middleware (FastifyAdapter)', () => {
2323
let app: NestFastifyApplication;
@@ -37,6 +37,11 @@ describe('Middleware (FastifyAdapter)', () => {
3737
return RETURN_VALUE;
3838
}
3939

40+
@Get('legacy_style_wildcard/wildcard_nested')
41+
legacy_style_wildcard() {
42+
return RETURN_VALUE;
43+
}
44+
4045
@Get('test')
4146
test() {
4247
return RETURN_VALUE;
@@ -76,9 +81,13 @@ describe('Middleware (FastifyAdapter)', () => {
7681
.apply((req, res, next) => res.end(INCLUDED_VALUE))
7782
.forRoutes({ path: 'tests/included', method: RequestMethod.POST })
7883
.apply((req, res, next) => res.end(REQ_URL_VALUE))
79-
.forRoutes('req/url/(.*)')
84+
.forRoutes('req/url/*')
8085
.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+
)
8291
.apply((req, res, next) => res.end(QUERY_VALUE))
8392
.forRoutes('query')
8493
.apply((req, res, next) => next())
@@ -87,7 +96,7 @@ describe('Middleware (FastifyAdapter)', () => {
8796
.forRoutes(TestController)
8897
.apply((req, res, next) => res.end(RETURN_VALUE))
8998
.exclude({ path: QUERY_VALUE, method: -1 as any })
90-
.forRoutes('(.*)');
99+
.forRoutes('*');
91100
}
92101
}
93102

@@ -101,7 +110,7 @@ describe('Middleware (FastifyAdapter)', () => {
101110
await app.init();
102111
});
103112

104-
it(`forRoutes((.*))`, () => {
113+
it(`forRoutes(*)`, () => {
105114
return app
106115
.inject({
107116
method: 'GET',
@@ -143,7 +152,7 @@ describe('Middleware (FastifyAdapter)', () => {
143152
.then(({ payload }) => expect(payload).to.be.eql(QUERY_VALUE));
144153
});
145154

146-
it(`forRoutes(tests/(.*))`, () => {
155+
it(`forRoutes(tests/*path)`, () => {
147156
return app
148157
.inject({
149158
method: 'GET',
@@ -161,6 +170,15 @@ describe('Middleware (FastifyAdapter)', () => {
161170
.then(({ payload }) => expect(payload).to.be.eql(WILDCARD_VALUE));
162171
});
163172

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+
164182
it(`forRoutes(req/url/)`, () => {
165183
const reqUrl = '/test';
166184
return app

integration/hello-world/e2e/middleware.spec.ts

+13-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ class TestController {
2626
return RETURN_VALUE;
2727
}
2828

29+
@Get('legacy-wildcard/overview')
30+
legacyWildcard() {
31+
return RETURN_VALUE;
32+
}
33+
2934
@Get('exclude')
3035
exclude() {
3136
return EXCLUDE_VALUE;
@@ -40,7 +45,7 @@ class TestModule {
4045
configure(consumer: MiddlewareConsumer) {
4146
consumer
4247
.apply((req, res, next) => res.send(WILDCARD_VALUE))
43-
.forRoutes('tests/*')
48+
.forRoutes('tests/*path', 'legacy-wildcard/*')
4449
.apply((req, res, next) => res.send(SCOPED_VALUE))
4550
.exclude('exclude')
4651
.forRoutes(TestController)
@@ -86,6 +91,13 @@ describe('Middleware', () => {
8691
.expect(200, WILDCARD_VALUE);
8792
});
8893

94+
it(`forRoutes(legacy-wildcard/*)`, async () => {
95+
app = await createApp();
96+
return request(app.getHttpServer())
97+
.get('/legacy-wildcard/overview')
98+
.expect(200, WILDCARD_VALUE);
99+
});
100+
89101
afterEach(async () => {
90102
await app.close();
91103
});

integration/nest-application/global-prefix/e2e/global-prefix.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ describe('Global prefix', () => {
127127

128128
await request(server)
129129
.get('/api/test/params')
130-
.expect(200, { '0': 'params', tenantId: 'test' });
130+
.expect(200, { tenantId: 'test', path: ['params'] });
131131
});
132132

133133
it(`should execute middleware only once`, async () => {

integration/nest-application/global-prefix/src/app.module.ts

+11-5
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,30 @@ export class AppModule {
1616
.apply((req, res, next) => res.status(201).end(MIDDLEWARE_VALUE))
1717
.forRoutes({ path: MIDDLEWARE_VALUE, method: RequestMethod.POST })
1818
.apply((req, res, next) => res.end(MIDDLEWARE_PARAM_VALUE))
19-
.forRoutes({ path: MIDDLEWARE_VALUE + '/*', method: RequestMethod.GET })
19+
.forRoutes({
20+
path: MIDDLEWARE_VALUE + '/*path',
21+
method: RequestMethod.GET,
22+
})
2023
.apply((req, res, next) => res.status(201).end(MIDDLEWARE_PARAM_VALUE))
21-
.forRoutes({ path: MIDDLEWARE_VALUE + '/*', method: RequestMethod.POST })
24+
.forRoutes({
25+
path: MIDDLEWARE_VALUE + '/*path',
26+
method: RequestMethod.POST,
27+
})
2228
.apply((req, res, next) => {
2329
req.extras = { data: 'Data attached in middleware' };
2430
next();
2531
})
26-
.forRoutes({ path: '*', method: RequestMethod.GET })
32+
.forRoutes({ path: '*path', method: RequestMethod.GET })
2733
.apply((req, res, next) => {
2834
req.middlewareParams = req.params;
2935
next();
3036
})
31-
.forRoutes({ path: '*', method: RequestMethod.GET })
37+
.forRoutes({ path: '*path', method: RequestMethod.GET })
3238
.apply((req, res, next) => {
3339
this.count += 1;
3440
req.count = this.count;
3541
next();
3642
})
37-
.forRoutes('*');
43+
.forRoutes('*path');
3844
}
3945
}

lerna.json

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
{
22
"lerna": "2.4.0",
3-
"packages": [
4-
"packages/*"
5-
],
6-
"version": "10.4.15"
3+
"packages": ["packages/*"],
4+
"version": "11.0.0-next.1"
75
}

0 commit comments

Comments
 (0)