mirror of
https://github.com/nestjs/nest.git
synced 2026-02-22 07:21:39 +00:00
Compare commits
106 Commits
v10.3.0
...
fix/fastif
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e5612e0197 | ||
|
|
6c54448bf7 | ||
|
|
5bba7e9d26 | ||
|
|
9004a4a624 | ||
|
|
4f45a7019f | ||
|
|
4bb43f0c47 | ||
|
|
fe2cd7ffb0 | ||
|
|
3be74404d2 | ||
|
|
71e83b048d | ||
|
|
ed44a0a910 | ||
|
|
6a59e7ae4e | ||
|
|
29f84b21ed | ||
|
|
b23f21067f | ||
|
|
674bfc5e83 | ||
|
|
d352e6f138 | ||
|
|
9dcbb6b14c | ||
|
|
9a1faf150c | ||
|
|
242718dbaf | ||
|
|
6be56d0013 | ||
|
|
11d4a2cec8 | ||
|
|
c769951dcd | ||
|
|
929174b8ad | ||
|
|
fb442a2e91 | ||
|
|
fe6868d7e3 | ||
|
|
fa0a085d57 | ||
|
|
b03d8702d7 | ||
|
|
60542ea1b5 | ||
|
|
468c179e18 | ||
|
|
fabbd09906 | ||
|
|
7cebc3b1eb | ||
|
|
aacea0e07c | ||
|
|
927525e082 | ||
|
|
37f332c2c7 | ||
|
|
11ebf30c53 | ||
|
|
0697076e1f | ||
|
|
6302f75996 | ||
|
|
3a0a3d1df4 | ||
|
|
742c92e7e0 | ||
|
|
608af53693 | ||
|
|
7df1d07bd2 | ||
|
|
c3d8247859 | ||
|
|
b2a35f231a | ||
|
|
d224961d61 | ||
|
|
da6b39ffbd | ||
|
|
d97196c2dc | ||
|
|
2110c8727e | ||
|
|
cfd2a30b35 | ||
|
|
866787996a | ||
|
|
760a40e4ce | ||
|
|
fcf1cad484 | ||
|
|
88880f9a21 | ||
|
|
f92f029505 | ||
|
|
0c4ee5e190 | ||
|
|
88ef0d33b7 | ||
|
|
bcb1f204bd | ||
|
|
1b47dc6ae0 | ||
|
|
95d3a92eb7 | ||
|
|
308e143fa3 | ||
|
|
b5f8da18ce | ||
|
|
41d52dae60 | ||
|
|
74135867ef | ||
|
|
362e4d8fa8 | ||
|
|
f16c47b05f | ||
|
|
c116e1c72c | ||
|
|
21edc331b2 | ||
|
|
69f432b738 | ||
|
|
f5e82fe052 | ||
|
|
8706662a22 | ||
|
|
6e5143d79f | ||
|
|
3282db1630 | ||
|
|
05e49963ac | ||
|
|
8ea3a5088c | ||
|
|
f60e62888e | ||
|
|
73059a3acf | ||
|
|
dc9ee85374 | ||
|
|
4fd0957efc | ||
|
|
d18343c920 | ||
|
|
ef5f17efe1 | ||
|
|
fffdbb26c9 | ||
|
|
fbca5ac5a9 | ||
|
|
c52d33348a | ||
|
|
87412ad51e | ||
|
|
a815394556 | ||
|
|
2effb83b21 | ||
|
|
85966703ac | ||
|
|
6098e2465f | ||
|
|
5db74f80c6 | ||
|
|
b5cab0f907 | ||
|
|
232582477e | ||
|
|
7ec42c7329 | ||
|
|
1073c41dc4 | ||
|
|
26bd9662f8 | ||
|
|
bd03c036cd | ||
|
|
22d4a1edff | ||
|
|
c8da134e6c | ||
|
|
0c0c377188 | ||
|
|
8879391672 | ||
|
|
244b44580c | ||
|
|
924c5f32bb | ||
|
|
d46db256af | ||
|
|
df0270af04 | ||
|
|
93a2b48be7 | ||
|
|
619b98caf7 | ||
|
|
84bd87c86a | ||
|
|
dc5aaf9af3 | ||
|
|
9af95fcf50 |
@@ -1,11 +1,11 @@
|
||||
<p align="center">
|
||||
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="120" alt="Nest Logo" /></a>
|
||||
<a href="https://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="120" alt="Nest Logo" /></a>
|
||||
</p>
|
||||
|
||||
[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456
|
||||
[circleci-url]: https://circleci.com/gh/nestjs/nest
|
||||
|
||||
<p align="center">A progressive <a href="http://nodejs.org" target="_blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
|
||||
<p align="center">A progressive <a href="https://nodejs.org" target="_blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
|
||||
<p align="center">
|
||||
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
|
||||
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
|
||||
@@ -136,7 +136,8 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
|
||||
<td align="center" valign="middle"><a href="https://boringowl.io/" target="_blank"><img src="https://nestjs.com/img/boringowl-logo.svg" width="120" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://www.mobilefactory.jp/" target="_blank"><img src="https://nestjs.com/img/mobilefactory-logo.png" width="100" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://nordbot.app/" target="_blank"><img src="https://nestjs.com/img/nordbot-logo.png" width="120" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://doppio.sh/" target="_blank"><img src="https://nestjs.com/img/dopiosh-logo.png" width="50" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://doppio.sh/" target="_blank"><img src="https://nestjs.com/img/dopiosh-logo.png" width="50" valign="middle" /></a></td></tr><tr>
|
||||
<td align="center" valign="middle"><a href="https://www.hingehealth.com/" target="_blank"><img src="https://nestjs.com/img/hinge-health-logo.svg" width="100" valign="middle" /></a></td>
|
||||
</tr></table>
|
||||
|
||||
## Backers
|
||||
|
||||
@@ -3,7 +3,10 @@ import {
|
||||
Get,
|
||||
MiddlewareConsumer,
|
||||
Module,
|
||||
NestMiddleware,
|
||||
NestModule,
|
||||
Query,
|
||||
Req,
|
||||
RequestMethod,
|
||||
} from '@nestjs/common';
|
||||
import {
|
||||
@@ -14,178 +17,385 @@ import { Test } from '@nestjs/testing';
|
||||
import { expect } from 'chai';
|
||||
import { AppModule } from '../src/app.module';
|
||||
|
||||
const INCLUDED_VALUE = 'test_included';
|
||||
const QUERY_VALUE = 'test_query';
|
||||
const REQ_URL_VALUE = 'test_req_url';
|
||||
const RETURN_VALUE = 'test';
|
||||
const SCOPED_VALUE = 'test_scoped';
|
||||
const WILDCARD_VALUE = 'test_wildcard';
|
||||
|
||||
@Controller()
|
||||
class TestController {
|
||||
@Get('express_style_wildcard/wildcard_nested')
|
||||
express_style_wildcard() {
|
||||
return RETURN_VALUE;
|
||||
}
|
||||
|
||||
@Get('test')
|
||||
test() {
|
||||
return RETURN_VALUE;
|
||||
}
|
||||
|
||||
@Get('query')
|
||||
query() {
|
||||
return RETURN_VALUE;
|
||||
}
|
||||
|
||||
@Get('tests/wildcard_nested')
|
||||
wildcard_nested() {
|
||||
return RETURN_VALUE;
|
||||
}
|
||||
|
||||
@Get('tests/included')
|
||||
included() {
|
||||
return RETURN_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
@Controller(QUERY_VALUE)
|
||||
class TestQueryController {
|
||||
@Get()
|
||||
[QUERY_VALUE](@Query('test') test: string) {
|
||||
return test;
|
||||
}
|
||||
}
|
||||
|
||||
@Module({
|
||||
imports: [AppModule],
|
||||
controllers: [TestController, TestQueryController],
|
||||
})
|
||||
class TestModule {
|
||||
configure(consumer: MiddlewareConsumer) {
|
||||
consumer
|
||||
.apply((req, res, next) => res.end(INCLUDED_VALUE))
|
||||
.forRoutes({ path: 'tests/included', method: RequestMethod.POST })
|
||||
.apply((req, res, next) => res.end(`${REQ_URL_VALUE}${req.url}`))
|
||||
.forRoutes('req/url/')
|
||||
.apply((req, res, next) => res.end(WILDCARD_VALUE))
|
||||
.forRoutes('express_style_wildcard/*', 'tests/(.*)')
|
||||
.apply((req, res, next) => res.end(QUERY_VALUE))
|
||||
.forRoutes('query')
|
||||
.apply((req, res, next) => next())
|
||||
.forRoutes(TestQueryController)
|
||||
.apply((req, res, next) => res.end(SCOPED_VALUE))
|
||||
.forRoutes(TestController)
|
||||
.apply((req, res, next) => res.end(RETURN_VALUE))
|
||||
.exclude({ path: QUERY_VALUE, method: -1 as any })
|
||||
.forRoutes('(.*)');
|
||||
}
|
||||
}
|
||||
|
||||
describe('Middleware (FastifyAdapter)', () => {
|
||||
let app: NestFastifyApplication;
|
||||
|
||||
beforeEach(async () => {
|
||||
app = (
|
||||
await Test.createTestingModule({
|
||||
imports: [TestModule],
|
||||
}).compile()
|
||||
).createNestApplication<NestFastifyApplication>(new FastifyAdapter());
|
||||
describe('should return expected values depending on the route', () => {
|
||||
const INCLUDED_VALUE = 'test_included';
|
||||
const QUERY_VALUE = 'test_query';
|
||||
const REQ_URL_VALUE = 'test_req_url';
|
||||
const RETURN_VALUE = 'test';
|
||||
const SCOPED_VALUE = 'test_scoped';
|
||||
const WILDCARD_VALUE = 'test_wildcard';
|
||||
|
||||
await app.init();
|
||||
@Controller()
|
||||
class TestController {
|
||||
@Get('express_style_wildcard/wildcard_nested')
|
||||
express_style_wildcard() {
|
||||
return RETURN_VALUE;
|
||||
}
|
||||
|
||||
@Get('test')
|
||||
test() {
|
||||
return RETURN_VALUE;
|
||||
}
|
||||
|
||||
@Get('query')
|
||||
query() {
|
||||
return RETURN_VALUE;
|
||||
}
|
||||
|
||||
@Get('tests/wildcard_nested')
|
||||
wildcard_nested() {
|
||||
return RETURN_VALUE;
|
||||
}
|
||||
|
||||
@Get('tests/included')
|
||||
included() {
|
||||
return RETURN_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
@Controller(QUERY_VALUE)
|
||||
class TestQueryController {
|
||||
@Get()
|
||||
[QUERY_VALUE](@Query('test') test: string) {
|
||||
return test;
|
||||
}
|
||||
}
|
||||
|
||||
@Module({
|
||||
imports: [AppModule],
|
||||
controllers: [TestController, TestQueryController],
|
||||
})
|
||||
class TestModule {
|
||||
configure(consumer: MiddlewareConsumer) {
|
||||
consumer
|
||||
.apply((req, res, next) => res.end(INCLUDED_VALUE))
|
||||
.forRoutes({ path: 'tests/included', method: RequestMethod.POST })
|
||||
.apply((req, res, next) => res.end(REQ_URL_VALUE))
|
||||
.forRoutes('req/url/(.*)')
|
||||
.apply((req, res, next) => res.end(WILDCARD_VALUE))
|
||||
.forRoutes('express_style_wildcard/*', 'tests/(.*)')
|
||||
.apply((req, res, next) => res.end(QUERY_VALUE))
|
||||
.forRoutes('query')
|
||||
.apply((req, res, next) => next())
|
||||
.forRoutes(TestQueryController)
|
||||
.apply((req, res, next) => res.end(SCOPED_VALUE))
|
||||
.forRoutes(TestController)
|
||||
.apply((req, res, next) => res.end(RETURN_VALUE))
|
||||
.exclude({ path: QUERY_VALUE, method: -1 as any })
|
||||
.forRoutes('(.*)');
|
||||
}
|
||||
}
|
||||
|
||||
beforeEach(async () => {
|
||||
app = (
|
||||
await Test.createTestingModule({
|
||||
imports: [TestModule],
|
||||
}).compile()
|
||||
).createNestApplication<NestFastifyApplication>(new FastifyAdapter());
|
||||
|
||||
await app.init();
|
||||
});
|
||||
|
||||
it(`forRoutes((.*))`, () => {
|
||||
return app
|
||||
.inject({
|
||||
method: 'GET',
|
||||
url: '/hello',
|
||||
})
|
||||
.then(({ payload }) => expect(payload).to.be.eql(RETURN_VALUE));
|
||||
});
|
||||
|
||||
it(`forRoutes(TestController)`, () => {
|
||||
return app
|
||||
.inject({
|
||||
method: 'GET',
|
||||
url: '/test',
|
||||
})
|
||||
.then(({ payload }) => expect(payload).to.be.eql(SCOPED_VALUE));
|
||||
});
|
||||
|
||||
it(`query?test=${QUERY_VALUE} forRoutes(query)`, () => {
|
||||
return app
|
||||
.inject({
|
||||
method: 'GET',
|
||||
url: '/query',
|
||||
query: {
|
||||
test: QUERY_VALUE,
|
||||
},
|
||||
})
|
||||
.then(({ payload }) => expect(payload).to.be.eql(QUERY_VALUE));
|
||||
});
|
||||
|
||||
it(`${QUERY_VALUE}?test=${QUERY_VALUE} forRoutes(${QUERY_VALUE})`, () => {
|
||||
return app
|
||||
.inject({
|
||||
method: 'GET',
|
||||
url: QUERY_VALUE,
|
||||
query: {
|
||||
test: QUERY_VALUE,
|
||||
},
|
||||
})
|
||||
.then(({ payload }) => expect(payload).to.be.eql(QUERY_VALUE));
|
||||
});
|
||||
|
||||
it(`forRoutes(tests/(.*))`, () => {
|
||||
return app
|
||||
.inject({
|
||||
method: 'GET',
|
||||
url: '/tests/wildcard_nested',
|
||||
})
|
||||
.then(({ payload }) => expect(payload).to.be.eql(WILDCARD_VALUE));
|
||||
});
|
||||
|
||||
it(`forRoutes(express_style_wildcard/*)`, () => {
|
||||
return app
|
||||
.inject({
|
||||
method: 'GET',
|
||||
url: '/express_style_wildcard/wildcard_nested',
|
||||
})
|
||||
.then(({ payload }) => expect(payload).to.be.eql(WILDCARD_VALUE));
|
||||
});
|
||||
|
||||
it(`forRoutes(req/url/)`, () => {
|
||||
const reqUrl = '/test';
|
||||
return app
|
||||
.inject({
|
||||
method: 'GET',
|
||||
url: `/req/url${reqUrl}`,
|
||||
})
|
||||
.then(({ payload }) => expect(payload).to.be.eql(REQ_URL_VALUE));
|
||||
});
|
||||
|
||||
it(`GET forRoutes(POST tests/included)`, () => {
|
||||
return app
|
||||
.inject({
|
||||
method: 'GET',
|
||||
url: '/tests/included',
|
||||
})
|
||||
.then(({ payload }) => expect(payload).to.be.eql(WILDCARD_VALUE));
|
||||
});
|
||||
|
||||
it(`POST forRoutes(POST tests/included)`, () => {
|
||||
return app
|
||||
.inject({
|
||||
method: 'POST',
|
||||
url: '/tests/included',
|
||||
})
|
||||
.then(({ payload }) => expect(payload).to.be.eql(INCLUDED_VALUE));
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
await app.close();
|
||||
});
|
||||
});
|
||||
|
||||
it(`forRoutes((.*))`, () => {
|
||||
return app
|
||||
.inject({
|
||||
method: 'GET',
|
||||
url: '/hello',
|
||||
})
|
||||
.then(({ payload }) => expect(payload).to.be.eql(RETURN_VALUE));
|
||||
});
|
||||
describe.only('should execute middleware only once for given routes', () => {
|
||||
class Middleware implements NestMiddleware {
|
||||
use(request: any, reply: any, next: () => void) {
|
||||
if (request.middlewareExecutionCount === undefined) {
|
||||
request.middlewareExecutionCount = 1;
|
||||
} else {
|
||||
request.middlewareExecutionCount++;
|
||||
}
|
||||
next();
|
||||
}
|
||||
}
|
||||
|
||||
it(`forRoutes(TestController)`, () => {
|
||||
return app
|
||||
.inject({
|
||||
method: 'GET',
|
||||
url: '/test',
|
||||
})
|
||||
.then(({ payload }) => expect(payload).to.be.eql(SCOPED_VALUE));
|
||||
});
|
||||
@Controller()
|
||||
class AbcController {
|
||||
@Get('/a')
|
||||
async a(@Req() request: any) {
|
||||
return this.validateExecutionCount({
|
||||
request,
|
||||
expected: 1,
|
||||
});
|
||||
}
|
||||
|
||||
it(`query?test=${QUERY_VALUE} forRoutes(query)`, () => {
|
||||
return app
|
||||
.inject({
|
||||
method: 'GET',
|
||||
url: '/query',
|
||||
query: {
|
||||
test: QUERY_VALUE,
|
||||
},
|
||||
})
|
||||
.then(({ payload }) => expect(payload).to.be.eql(QUERY_VALUE));
|
||||
});
|
||||
@Get('/a/b')
|
||||
async ab(@Req() request: any) {
|
||||
return this.validateExecutionCount({
|
||||
request,
|
||||
expected: 1,
|
||||
});
|
||||
}
|
||||
|
||||
it(`${QUERY_VALUE}?test=${QUERY_VALUE} forRoutes(${QUERY_VALUE})`, () => {
|
||||
return app
|
||||
.inject({
|
||||
method: 'GET',
|
||||
url: QUERY_VALUE,
|
||||
query: {
|
||||
test: QUERY_VALUE,
|
||||
},
|
||||
})
|
||||
.then(({ payload }) => expect(payload).to.be.eql(QUERY_VALUE));
|
||||
});
|
||||
@Get('/a/b/c')
|
||||
async abc(@Req() request: any) {
|
||||
return this.validateExecutionCount({
|
||||
request,
|
||||
expected: 1,
|
||||
});
|
||||
}
|
||||
|
||||
it(`forRoutes(tests/(.*))`, () => {
|
||||
return app
|
||||
.inject({
|
||||
method: 'GET',
|
||||
url: '/tests/wildcard_nested',
|
||||
})
|
||||
.then(({ payload }) => expect(payload).to.be.eql(WILDCARD_VALUE));
|
||||
});
|
||||
@Get('/similar')
|
||||
async withSimilar(@Req() request: any) {
|
||||
return this.validateExecutionCount({
|
||||
request,
|
||||
expected: 1,
|
||||
});
|
||||
}
|
||||
|
||||
it(`forRoutes(express_style_wildcard/*)`, () => {
|
||||
return app
|
||||
.inject({
|
||||
method: 'GET',
|
||||
url: '/express_style_wildcard/wildcard_nested',
|
||||
})
|
||||
.then(({ payload }) => expect(payload).to.be.eql(WILDCARD_VALUE));
|
||||
});
|
||||
@Get('/similar/test')
|
||||
async withSimilarTest(@Req() request: any) {
|
||||
return this.validateExecutionCount({
|
||||
request,
|
||||
expected: 1,
|
||||
});
|
||||
}
|
||||
|
||||
it(`forRoutes(req/url/)`, () => {
|
||||
const reqUrl = '/test';
|
||||
return app
|
||||
.inject({
|
||||
method: 'GET',
|
||||
url: `/req/url${reqUrl}`,
|
||||
})
|
||||
.then(({ payload }) =>
|
||||
expect(payload).to.be.eql(`${REQ_URL_VALUE}${reqUrl}`),
|
||||
);
|
||||
});
|
||||
@Get('/similar/:id')
|
||||
async withSimilarId(@Req() request: any) {
|
||||
return this.validateExecutionCount({
|
||||
request,
|
||||
expected: 1,
|
||||
});
|
||||
}
|
||||
|
||||
it(`GET forRoutes(POST tests/included)`, () => {
|
||||
return app
|
||||
.inject({
|
||||
method: 'GET',
|
||||
url: '/tests/included',
|
||||
})
|
||||
.then(({ payload }) => expect(payload).to.be.eql(WILDCARD_VALUE));
|
||||
});
|
||||
private validateExecutionCount({
|
||||
request,
|
||||
expected,
|
||||
}: {
|
||||
request: any;
|
||||
expected: number;
|
||||
}) {
|
||||
let actual: number | undefined;
|
||||
actual = request.raw.middlewareExecutionCount;
|
||||
actual ??= 0;
|
||||
|
||||
it(`POST forRoutes(POST tests/included)`, () => {
|
||||
return app
|
||||
.inject({
|
||||
method: 'POST',
|
||||
url: '/tests/included',
|
||||
})
|
||||
.then(({ payload }) => expect(payload).to.be.eql(INCLUDED_VALUE));
|
||||
});
|
||||
return {
|
||||
success: actual === expected,
|
||||
actual,
|
||||
expected,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
afterEach(async () => {
|
||||
await app.close();
|
||||
@Module({
|
||||
controllers: [AbcController],
|
||||
})
|
||||
class TestModule implements NestModule {
|
||||
configure(consumer: MiddlewareConsumer) {
|
||||
consumer.apply(Middleware).forRoutes(AbcController);
|
||||
}
|
||||
}
|
||||
|
||||
beforeEach(async () => {
|
||||
app = (
|
||||
await Test.createTestingModule({
|
||||
imports: [TestModule],
|
||||
}).compile()
|
||||
).createNestApplication<NestFastifyApplication>(new FastifyAdapter());
|
||||
|
||||
await app.init();
|
||||
});
|
||||
|
||||
it(`GET forRoutes(/a/b/c)`, () => {
|
||||
return app
|
||||
.inject({
|
||||
method: 'GET',
|
||||
url: '/a/b/c',
|
||||
})
|
||||
.then(({ payload }) => {
|
||||
expect(payload).to.be.eql(
|
||||
JSON.stringify({
|
||||
success: true,
|
||||
actual: 1,
|
||||
expected: 1,
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it(`GET forRoutes(/a/b)`, () => {
|
||||
return app
|
||||
.inject({
|
||||
method: 'GET',
|
||||
url: '/a/b',
|
||||
})
|
||||
.then(({ payload }) =>
|
||||
expect(payload).to.be.eql(
|
||||
JSON.stringify({
|
||||
success: true,
|
||||
actual: 1,
|
||||
expected: 1,
|
||||
}),
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
it(`GET forRoutes(/a)`, () => {
|
||||
return app
|
||||
.inject({
|
||||
method: 'GET',
|
||||
url: '/a',
|
||||
})
|
||||
.then(({ payload }) =>
|
||||
expect(payload).to.be.eql(
|
||||
JSON.stringify({
|
||||
success: true,
|
||||
actual: 1,
|
||||
expected: 1,
|
||||
}),
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
it(`GET forRoutes(/similar)`, () => {
|
||||
return app
|
||||
.inject({
|
||||
method: 'GET',
|
||||
url: '/similar',
|
||||
})
|
||||
.then(({ payload }) =>
|
||||
expect(payload).to.be.eql(
|
||||
JSON.stringify({
|
||||
success: true,
|
||||
actual: 1,
|
||||
expected: 1,
|
||||
}),
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
it(`GET forRoutes(/similar/test)`, () => {
|
||||
return app
|
||||
.inject({
|
||||
method: 'GET',
|
||||
url: '/similar/test',
|
||||
})
|
||||
.then(({ payload }) =>
|
||||
expect(payload).to.be.eql(
|
||||
JSON.stringify({
|
||||
success: true,
|
||||
actual: 1,
|
||||
expected: 1,
|
||||
}),
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
it(`GET forRoutes(/similar/arbitrary)`, () => {
|
||||
return app
|
||||
.inject({
|
||||
method: 'GET',
|
||||
url: '/similar/arbitrary',
|
||||
})
|
||||
.then(({ payload }) =>
|
||||
expect(payload).to.be.eql(
|
||||
JSON.stringify({
|
||||
success: true,
|
||||
actual: 1,
|
||||
expected: 1,
|
||||
}),
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
await app.close();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -3,5 +3,5 @@
|
||||
"packages": [
|
||||
"packages/*"
|
||||
],
|
||||
"version": "9.4.0"
|
||||
"version": "9.4.2"
|
||||
}
|
||||
|
||||
33707
package-lock.json
generated
33707
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
44
package.json
44
package.json
@@ -71,45 +71,45 @@
|
||||
"object-hash": "3.0.0",
|
||||
"path-to-regexp": "3.2.0",
|
||||
"reflect-metadata": "0.1.13",
|
||||
"rxjs": "7.8.0",
|
||||
"rxjs": "7.8.1",
|
||||
"socket.io": "4.6.1",
|
||||
"tslib": "2.5.0",
|
||||
"tslib": "2.5.2",
|
||||
"uid": "2.0.2",
|
||||
"uuid": "9.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@apollo/server": "4.7.0",
|
||||
"@apollo/server": "4.7.1",
|
||||
"@codechecks/client": "0.1.12",
|
||||
"@commitlint/cli": "17.6.1",
|
||||
"@commitlint/config-angular": "17.6.1",
|
||||
"@fastify/cors": "^8.0.0",
|
||||
"@commitlint/cli": "17.6.3",
|
||||
"@commitlint/config-angular": "17.6.3",
|
||||
"@fastify/cors": "8.2.1",
|
||||
"@fastify/formbody": "7.4.0",
|
||||
"@fastify/middie": "8.1.0",
|
||||
"@fastify/middie": "8.3.0",
|
||||
"@fastify/multipart": "7.6.0",
|
||||
"@fastify/static": "6.10.1",
|
||||
"@fastify/view": "7.4.1",
|
||||
"@grpc/grpc-js": "1.8.14",
|
||||
"@grpc/proto-loader": "0.7.6",
|
||||
"@grpc/proto-loader": "0.7.7",
|
||||
"@nestjs/apollo": "11.0.5",
|
||||
"@nestjs/graphql": "11.0.5",
|
||||
"@nestjs/mongoose": "9.2.2",
|
||||
"@nestjs/typeorm": "9.0.1",
|
||||
"@types/amqplib": "0.10.1",
|
||||
"@types/bytes": "3.1.1",
|
||||
"@types/chai": "4.3.4",
|
||||
"@types/chai": "4.3.5",
|
||||
"@types/chai-as-promised": "7.1.5",
|
||||
"@types/cors": "2.8.13",
|
||||
"@types/express": "4.17.17",
|
||||
"@types/gulp": "4.0.10",
|
||||
"@types/http-errors": "2.0.1",
|
||||
"@types/mocha": "10.0.1",
|
||||
"@types/node": "18.16.0",
|
||||
"@types/sinon": "10.0.14",
|
||||
"@types/node": "20.2.3",
|
||||
"@types/sinon": "10.0.15",
|
||||
"@types/supertest": "2.0.12",
|
||||
"@types/ws": "8.5.4",
|
||||
"@typescript-eslint/eslint-plugin": "4.33.0",
|
||||
"@typescript-eslint/parser": "4.33.0",
|
||||
"amqp-connection-manager": "4.1.12",
|
||||
"amqp-connection-manager": "4.1.13",
|
||||
"amqplib": "0.10.3",
|
||||
"artillery": "1.7.9",
|
||||
"body-parser": "1.20.2",
|
||||
@@ -122,7 +122,7 @@
|
||||
"commitlint-circle": "1.0.0",
|
||||
"concurrently": "8.0.1",
|
||||
"conventional-changelog": "3.1.25",
|
||||
"core-js": "3.30.1",
|
||||
"core-js": "3.30.2",
|
||||
"coveralls": "3.1.1",
|
||||
"delete-empty": "3.0.0",
|
||||
"engine.io-client": "6.4.0",
|
||||
@@ -131,9 +131,9 @@
|
||||
"eslint-plugin-import": "2.27.5",
|
||||
"eventsource": "2.0.2",
|
||||
"fancy-log": "2.0.0",
|
||||
"fastify": "4.15.0",
|
||||
"fastify": "4.17.0",
|
||||
"graphql": "16.6.0",
|
||||
"graphql-tools": "8.3.20",
|
||||
"graphql-tools": "9.0.0",
|
||||
"gulp": "4.0.2",
|
||||
"gulp-clang-format": "1.0.27",
|
||||
"gulp-clean": "0.4.0",
|
||||
@@ -149,34 +149,34 @@
|
||||
"lerna": "2.11.0",
|
||||
"lerna-changelog": "2.2.0",
|
||||
"light-my-request": "5.9.1",
|
||||
"lint-staged": "13.2.1",
|
||||
"lint-staged": "13.2.2",
|
||||
"markdown-table": "2.0.0",
|
||||
"merge-graphql-schemas": "1.7.8",
|
||||
"mocha": "10.2.0",
|
||||
"mongoose": "7.0.4",
|
||||
"mongoose": "7.2.0",
|
||||
"mqtt": "4.3.7",
|
||||
"multer": "1.4.4",
|
||||
"mysql2": "3.2.3",
|
||||
"mysql2": "3.3.1",
|
||||
"nats": "2.13.1",
|
||||
"nodemon": "2.0.22",
|
||||
"nyc": "15.1.0",
|
||||
"prettier": "2.8.8",
|
||||
"redis": "4.6.5",
|
||||
"redis": "4.6.6",
|
||||
"rxjs-compat": "6.6.7",
|
||||
"sinon": "15.0.4",
|
||||
"sinon": "15.1.0",
|
||||
"sinon-chai": "3.7.0",
|
||||
"socket.io-client": "4.6.1",
|
||||
"subscriptions-transport-ws": "0.11.0",
|
||||
"supertest": "6.3.3",
|
||||
"ts-morph": "18.0.0",
|
||||
"ts-node": "10.9.1",
|
||||
"typeorm": "0.3.15",
|
||||
"typeorm": "0.3.16",
|
||||
"typescript": "5.0.4",
|
||||
"wrk": "1.2.1",
|
||||
"ws": "8.13.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 16"
|
||||
"node": ">= 12.9.0"
|
||||
},
|
||||
"collective": {
|
||||
"type": "opencollective",
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
<p align="center">
|
||||
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="120" alt="Nest Logo" /></a>
|
||||
<a href="https://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="120" alt="Nest Logo" /></a>
|
||||
</p>
|
||||
|
||||
[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456
|
||||
[circleci-url]: https://circleci.com/gh/nestjs/nest
|
||||
|
||||
<p align="center">A progressive <a href="http://nodejs.org" target="_blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
|
||||
<p align="center">A progressive <a href="https://nodejs.org" target="_blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
|
||||
<p align="center">
|
||||
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
|
||||
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
|
||||
@@ -132,7 +132,7 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
|
||||
<td align="center" valign="middle"><a href="https://klqc.de" target="_blank"><img src="https://nestjs.com/img/klcqcl-logo.png" width="120" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://thecasinowizard.com/bonuses/no-deposit-bonuses/" target="_blank"><img src="https://nestjs.com/img/casinowizard-logo.png" width="120" valign="middle" /></a></td></tr><tr>
|
||||
<td align="center" valign="middle"><a href="https://polygon-software.ch/" target="_blank"><img src="https://nestjs.com/img/polygon-logo.svg" width="120" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://mobilereality.pl/" target="_blank"><img src="https://nestjs.com/img/mobile-reality-logo.png" width="45" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://themobilereality.com/" target="_blank"><img src="https://nestjs.com/img/mobile-reality-logo.png" width="45" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://boringowl.io/" target="_blank"><img src="https://nestjs.com/img/boringowl-logo.svg" width="120" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://www.mobilefactory.jp/" target="_blank"><img src="https://nestjs.com/img/mobilefactory-logo.png" width="100" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://nordbot.app/" target="_blank"><img src="https://nestjs.com/img/nordbot-logo.png" width="120" valign="middle" /></a></td>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nestjs/common",
|
||||
"version": "9.4.0",
|
||||
"version": "9.4.2",
|
||||
"description": "Nest - modern, fast, powerful node.js web framework (@common)",
|
||||
"author": "Kamil Mysliwiec",
|
||||
"homepage": "https://nestjs.com",
|
||||
@@ -19,7 +19,7 @@
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"iterare": "1.2.1",
|
||||
"tslib": "2.5.0",
|
||||
"tslib": "2.5.2",
|
||||
"uid": "2.0.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
|
||||
@@ -3,6 +3,7 @@ import { IFile } from './interfaces';
|
||||
|
||||
export type MaxFileSizeValidatorOptions = {
|
||||
maxSize: number;
|
||||
message?: string | ((maxSize: number) => string);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -14,6 +15,14 @@ export type MaxFileSizeValidatorOptions = {
|
||||
*/
|
||||
export class MaxFileSizeValidator extends FileValidator<MaxFileSizeValidatorOptions> {
|
||||
buildErrorMessage(): string {
|
||||
if ('message' in this.validationOptions) {
|
||||
if (typeof this.validationOptions.message === 'function') {
|
||||
return this.validationOptions.message(this.validationOptions.maxSize);
|
||||
}
|
||||
|
||||
return this.validationOptions.message;
|
||||
}
|
||||
|
||||
return `Validation failed (expected size is less than ${this.validationOptions.maxSize})`;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { ArgumentMetadata, HttpStatus, Injectable, Optional } from '../index';
|
||||
import { ArgumentMetadata, HttpStatus } from '../index';
|
||||
import { Injectable, Optional } from '../decorators/core';
|
||||
import { PipeTransform } from '../interfaces/features/pipe-transform.interface';
|
||||
import {
|
||||
ErrorHttpStatusCode,
|
||||
|
||||
@@ -80,6 +80,7 @@ export class ConsoleLogger implements LoggerService {
|
||||
* Write an 'error' level log, if the configured level allows for it.
|
||||
* Prints to `stderr` with newline.
|
||||
*/
|
||||
error(message: any, stackOrContext?: string): void;
|
||||
error(message: any, stack?: string, context?: string): void;
|
||||
error(message: any, ...optionalParams: [...any, string?, string?]): void;
|
||||
error(message: any, ...optionalParams: any[]) {
|
||||
@@ -281,6 +282,19 @@ export class ConsoleLogger implements LoggerService {
|
||||
}
|
||||
|
||||
private getContextAndStackAndMessagesToPrint(args: unknown[]) {
|
||||
if (args.length === 2) {
|
||||
return this.isStackFormat(args[1])
|
||||
? {
|
||||
messages: [args[0]],
|
||||
stack: args[1] as string,
|
||||
context: this.context,
|
||||
}
|
||||
: {
|
||||
messages: [args[0]],
|
||||
context: args[1] as string,
|
||||
};
|
||||
}
|
||||
|
||||
const { messages, context } = this.getContextAndMessagesToPrint(args);
|
||||
if (messages?.length <= 1) {
|
||||
return { messages, context };
|
||||
@@ -298,6 +312,14 @@ export class ConsoleLogger implements LoggerService {
|
||||
};
|
||||
}
|
||||
|
||||
private isStackFormat(stack: unknown) {
|
||||
if (!isString(stack) && !isUndefined(stack)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return /^(.)+\n\s+at .+:\d+:\d+$/.test(stack);
|
||||
}
|
||||
|
||||
private getColorByLogLevel(level: LogLevel) {
|
||||
switch (level) {
|
||||
case 'debug':
|
||||
|
||||
@@ -188,6 +188,7 @@ export class Logger implements LoggerService {
|
||||
/**
|
||||
* Write an 'error' level log.
|
||||
*/
|
||||
static error(message: any, stackOrContext?: string): void;
|
||||
static error(message: any, context?: string): void;
|
||||
static error(message: any, stack?: string, context?: string): void;
|
||||
static error(
|
||||
|
||||
@@ -70,7 +70,7 @@ describe('Logger', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('should print one error to the console', () => {
|
||||
it('should print one error to the console with context', () => {
|
||||
const message = 'random error';
|
||||
const context = 'RandomContext';
|
||||
|
||||
@@ -83,6 +83,20 @@ describe('Logger', () => {
|
||||
expect(processStderrWriteSpy.firstCall.firstArg).to.include(message);
|
||||
});
|
||||
|
||||
it('should print one error to the console with stacktrace', () => {
|
||||
const message = 'random error';
|
||||
const stacktrace = 'Error: message\n at <anonymous>:1:2';
|
||||
|
||||
Logger.error(message, stacktrace);
|
||||
|
||||
expect(processStderrWriteSpy.calledTwice).to.be.true;
|
||||
expect(processStderrWriteSpy.firstCall.firstArg).to.not.include(`[]`);
|
||||
expect(processStderrWriteSpy.firstCall.firstArg).to.include(message);
|
||||
expect(processStderrWriteSpy.secondCall.firstArg).to.equal(
|
||||
stacktrace + '\n',
|
||||
);
|
||||
});
|
||||
|
||||
it('should print one error without context to the console', () => {
|
||||
const message = 'random error without context';
|
||||
|
||||
@@ -354,7 +368,7 @@ describe('Logger', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('should print one error to the console', () => {
|
||||
it('should print one error to the console with context', () => {
|
||||
const message = 'random error';
|
||||
const context = 'RandomContext';
|
||||
|
||||
@@ -367,6 +381,20 @@ describe('Logger', () => {
|
||||
expect(processStderrWriteSpy.firstCall.firstArg).to.include(message);
|
||||
});
|
||||
|
||||
it('should print one error to the console with stacktrace', () => {
|
||||
const message = 'random error';
|
||||
const stacktrace = 'Error: message\n at <anonymous>:1:2';
|
||||
|
||||
logger.error(message, stacktrace);
|
||||
|
||||
expect(processStderrWriteSpy.calledTwice).to.be.true;
|
||||
expect(processStderrWriteSpy.firstCall.firstArg).to.not.include(`[]`);
|
||||
expect(processStderrWriteSpy.firstCall.firstArg).to.include(message);
|
||||
expect(processStderrWriteSpy.secondCall.firstArg).to.equal(
|
||||
stacktrace + '\n',
|
||||
);
|
||||
});
|
||||
|
||||
it('should print one error without context to the console', () => {
|
||||
const message = 'random error without context';
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
<p align="center">
|
||||
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="120" alt="Nest Logo" /></a>
|
||||
<a href="https://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="120" alt="Nest Logo" /></a>
|
||||
</p>
|
||||
|
||||
[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456
|
||||
[circleci-url]: https://circleci.com/gh/nestjs/nest
|
||||
|
||||
<p align="center">A progressive <a href="http://nodejs.org" target="_blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
|
||||
<p align="center">A progressive <a href="https://nodejs.org" target="_blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
|
||||
<p align="center">
|
||||
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
|
||||
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
|
||||
@@ -132,7 +132,7 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
|
||||
<td align="center" valign="middle"><a href="https://klqc.de" target="_blank"><img src="https://nestjs.com/img/klcqcl-logo.png" width="120" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://thecasinowizard.com/bonuses/no-deposit-bonuses/" target="_blank"><img src="https://nestjs.com/img/casinowizard-logo.png" width="120" valign="middle" /></a></td></tr><tr>
|
||||
<td align="center" valign="middle"><a href="https://polygon-software.ch/" target="_blank"><img src="https://nestjs.com/img/polygon-logo.svg" width="120" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://mobilereality.pl/" target="_blank"><img src="https://nestjs.com/img/mobile-reality-logo.png" width="45" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://themobilereality.com/" target="_blank"><img src="https://nestjs.com/img/mobile-reality-logo.png" width="45" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://boringowl.io/" target="_blank"><img src="https://nestjs.com/img/boringowl-logo.svg" width="120" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://www.mobilefactory.jp/" target="_blank"><img src="https://nestjs.com/img/mobilefactory-logo.png" width="100" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://nordbot.app/" target="_blank"><img src="https://nestjs.com/img/nordbot-logo.png" width="120" valign="middle" /></a></td>
|
||||
|
||||
@@ -113,7 +113,7 @@ export class MiddlewareBuilder implements MiddlewareConsumer {
|
||||
const routeMatch = routesWithRegex.find(isOverlapped);
|
||||
|
||||
if (routeMatch === undefined) {
|
||||
return route;
|
||||
return route;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nestjs/core",
|
||||
"version": "9.4.0",
|
||||
"version": "9.4.2",
|
||||
"description": "Nest - modern, fast, powerful node.js web framework (@core)",
|
||||
"author": "Kamil Mysliwiec",
|
||||
"license": "MIT",
|
||||
@@ -32,11 +32,11 @@
|
||||
"fast-safe-stringify": "2.1.1",
|
||||
"iterare": "1.2.1",
|
||||
"path-to-regexp": "3.2.0",
|
||||
"tslib": "2.5.0",
|
||||
"tslib": "2.5.2",
|
||||
"uid": "2.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nestjs/common": "9.4.0"
|
||||
"@nestjs/common": "9.4.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@nestjs/common": "^9.0.0",
|
||||
|
||||
@@ -386,7 +386,9 @@ export class DependenciesScanner {
|
||||
const moduleImports = moduleRef.imports;
|
||||
moduleImports.forEach(importedModuleRef => {
|
||||
if (importedModuleRef) {
|
||||
importedModuleRef.distance = distance;
|
||||
if (distance > importedModuleRef.distance) {
|
||||
importedModuleRef.distance = distance;
|
||||
}
|
||||
calculateDistance(importedModuleRef, distance + 1);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
<p align="center">
|
||||
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="120" alt="Nest Logo" /></a>
|
||||
<a href="https://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="120" alt="Nest Logo" /></a>
|
||||
</p>
|
||||
|
||||
[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456
|
||||
[circleci-url]: https://circleci.com/gh/nestjs/nest
|
||||
|
||||
<p align="center">A progressive <a href="http://nodejs.org" target="_blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
|
||||
<p align="center">A progressive <a href="https://nodejs.org" target="_blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
|
||||
<p align="center">
|
||||
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
|
||||
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
|
||||
@@ -132,7 +132,7 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
|
||||
<td align="center" valign="middle"><a href="https://klqc.de" target="_blank"><img src="https://nestjs.com/img/klcqcl-logo.png" width="120" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://thecasinowizard.com/bonuses/no-deposit-bonuses/" target="_blank"><img src="https://nestjs.com/img/casinowizard-logo.png" width="120" valign="middle" /></a></td></tr><tr>
|
||||
<td align="center" valign="middle"><a href="https://polygon-software.ch/" target="_blank"><img src="https://nestjs.com/img/polygon-logo.svg" width="120" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://mobilereality.pl/" target="_blank"><img src="https://nestjs.com/img/mobile-reality-logo.png" width="45" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://themobilereality.com/" target="_blank"><img src="https://nestjs.com/img/mobile-reality-logo.png" width="45" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://boringowl.io/" target="_blank"><img src="https://nestjs.com/img/boringowl-logo.svg" width="120" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://www.mobilefactory.jp/" target="_blank"><img src="https://nestjs.com/img/mobilefactory-logo.png" width="100" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://nordbot.app/" target="_blank"><img src="https://nestjs.com/img/nordbot-logo.png" width="120" valign="middle" /></a></td>
|
||||
|
||||
@@ -40,6 +40,11 @@ export const RQM_DEFAULT_QUEUE_OPTIONS = {};
|
||||
export const RQM_DEFAULT_NOACK = true;
|
||||
export const RQM_DEFAULT_PERSISTENT = false;
|
||||
export const RQM_DEFAULT_NO_ASSERT = false;
|
||||
export const RQM_NO_EVENT_HANDLER = (
|
||||
text: TemplateStringsArray,
|
||||
pattern: string,
|
||||
) =>
|
||||
`An unsupported event was received. It has been acknowledged, so it will not be re-delivered. Pattern: ${pattern}`;
|
||||
export const GRPC_DEFAULT_PROTO_LOADER = '@grpc/proto-loader';
|
||||
|
||||
export const NO_EVENT_HANDLER = (text: TemplateStringsArray, pattern: string) =>
|
||||
|
||||
@@ -16,26 +16,29 @@ import {
|
||||
@Module({})
|
||||
export class ClientsModule {
|
||||
static register(options: ClientsModuleOptions): DynamicModule {
|
||||
const clients = (options || []).map(item => ({
|
||||
const clientsOptions = !Array.isArray(options) ? options.clients : options;
|
||||
const clients = (clientsOptions || []).map(item => ({
|
||||
provide: item.name,
|
||||
useValue: this.assignOnAppShutdownHook(ClientProxyFactory.create(item)),
|
||||
}));
|
||||
return {
|
||||
module: ClientsModule,
|
||||
global: !Array.isArray(options) && options.isGlobal,
|
||||
providers: clients,
|
||||
exports: clients,
|
||||
};
|
||||
}
|
||||
|
||||
static registerAsync(options: ClientsModuleAsyncOptions): DynamicModule {
|
||||
const providers: Provider[] = options.reduce(
|
||||
const clientsOptions = !Array.isArray(options) ? options.clients : options;
|
||||
const providers: Provider[] = clientsOptions.reduce(
|
||||
(accProviders: Provider[], item) =>
|
||||
accProviders
|
||||
.concat(this.createAsyncProviders(item))
|
||||
.concat(item.extraProviders || []),
|
||||
[],
|
||||
);
|
||||
const imports = options.reduce(
|
||||
const imports = clientsOptions.reduce(
|
||||
(accImports, option) =>
|
||||
option.imports && !accImports.includes(option.imports)
|
||||
? accImports.concat(option.imports)
|
||||
@@ -44,6 +47,7 @@ export class ClientsModule {
|
||||
);
|
||||
return {
|
||||
module: ClientsModule,
|
||||
global: !Array.isArray(options) && options.isGlobal,
|
||||
imports,
|
||||
providers: providers,
|
||||
exports: providers,
|
||||
|
||||
@@ -7,7 +7,12 @@ export type ClientProviderOptions = ClientProvider & {
|
||||
name: string | symbol;
|
||||
};
|
||||
|
||||
export type ClientsModuleOptions = Array<ClientProviderOptions>;
|
||||
export type ClientsModuleOptions =
|
||||
| Array<ClientProviderOptions>
|
||||
| {
|
||||
clients: Array<ClientProviderOptions>;
|
||||
isGlobal?: boolean;
|
||||
};
|
||||
|
||||
export interface ClientsModuleOptionsFactory {
|
||||
createClientOptions(): Promise<ClientProvider> | ClientProvider;
|
||||
@@ -23,4 +28,9 @@ export interface ClientsProviderAsyncOptions
|
||||
name: string | symbol;
|
||||
}
|
||||
|
||||
export type ClientsModuleAsyncOptions = Array<ClientsProviderAsyncOptions>;
|
||||
export type ClientsModuleAsyncOptions =
|
||||
| Array<ClientsProviderAsyncOptions>
|
||||
| {
|
||||
clients: Array<ClientsProviderAsyncOptions>;
|
||||
isGlobal?: boolean;
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nestjs/microservices",
|
||||
"version": "9.4.0",
|
||||
"version": "9.4.2",
|
||||
"description": "Nest - modern, fast, powerful node.js web framework (@microservices)",
|
||||
"author": "Kamil Mysliwiec",
|
||||
"license": "MIT",
|
||||
@@ -19,11 +19,11 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"iterare": "1.2.1",
|
||||
"tslib": "2.5.0"
|
||||
"tslib": "2.5.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nestjs/common": "9.4.0",
|
||||
"@nestjs/core": "9.4.0"
|
||||
"@nestjs/common": "9.4.2",
|
||||
"@nestjs/core": "9.4.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@grpc/grpc-js": "*",
|
||||
|
||||
@@ -221,7 +221,7 @@ export class ServerGrpc extends Server implements CustomTransportStrategy {
|
||||
return async (call: GrpcCall, callback: Function) => {
|
||||
const handler = methodHandler(call.request, call.metadata, call);
|
||||
this.transformToObservable(await handler).subscribe({
|
||||
next: data => callback(null, data),
|
||||
next: async data => callback(null, await data),
|
||||
error: (err: any) => callback(err),
|
||||
});
|
||||
};
|
||||
|
||||
@@ -17,6 +17,7 @@ import {
|
||||
RQM_DEFAULT_QUEUE,
|
||||
RQM_DEFAULT_QUEUE_OPTIONS,
|
||||
RQM_DEFAULT_URL,
|
||||
RQM_NO_EVENT_HANDLER,
|
||||
} from '../constants';
|
||||
import { RmqContext } from '../ctx-host';
|
||||
import { Transport } from '../enums';
|
||||
@@ -25,6 +26,7 @@ import { CustomTransportStrategy, RmqOptions } from '../interfaces';
|
||||
import {
|
||||
IncomingRequest,
|
||||
OutgoingResponse,
|
||||
ReadPacket,
|
||||
} from '../interfaces/packet.interface';
|
||||
import { RmqRecordSerializer } from '../serializers/rmq-record.serializer';
|
||||
import { Server } from './server';
|
||||
@@ -42,6 +44,7 @@ export class ServerRMQ extends Server implements CustomTransportStrategy {
|
||||
protected readonly urls: string[] | RmqUrl[];
|
||||
protected readonly queue: string;
|
||||
protected readonly prefetchCount: number;
|
||||
protected readonly noAck: boolean;
|
||||
protected readonly queueOptions: any;
|
||||
protected readonly isGlobalPrefetchCount: boolean;
|
||||
protected readonly noAssert: boolean;
|
||||
@@ -54,6 +57,7 @@ export class ServerRMQ extends Server implements CustomTransportStrategy {
|
||||
this.prefetchCount =
|
||||
this.getOptionsProp(this.options, 'prefetchCount') ||
|
||||
RQM_DEFAULT_PREFETCH_COUNT;
|
||||
this.noAck = this.getOptionsProp(this.options, 'noAck', RQM_DEFAULT_NOACK);
|
||||
this.isGlobalPrefetchCount =
|
||||
this.getOptionsProp(this.options, 'isGlobalPrefetchCount') ||
|
||||
RQM_DEFAULT_IS_GLOBAL_PREFETCH_COUNT;
|
||||
@@ -141,8 +145,6 @@ export class ServerRMQ extends Server implements CustomTransportStrategy {
|
||||
}
|
||||
|
||||
public async setupChannel(channel: any, callback: Function) {
|
||||
const noAck = this.getOptionsProp(this.options, 'noAck', RQM_DEFAULT_NOACK);
|
||||
|
||||
if (!this.queueOptions.noAssert) {
|
||||
await channel.assertQueue(this.queue, this.queueOptions);
|
||||
}
|
||||
@@ -151,7 +153,7 @@ export class ServerRMQ extends Server implements CustomTransportStrategy {
|
||||
this.queue,
|
||||
(msg: Record<string, any>) => this.handleMessage(msg, channel),
|
||||
{
|
||||
noAck,
|
||||
noAck: this.noAck,
|
||||
},
|
||||
);
|
||||
callback();
|
||||
@@ -200,6 +202,19 @@ export class ServerRMQ extends Server implements CustomTransportStrategy {
|
||||
response$ && this.send(response$, publish);
|
||||
}
|
||||
|
||||
public async handleEvent(
|
||||
pattern: string,
|
||||
packet: ReadPacket,
|
||||
context: RmqContext,
|
||||
): Promise<any> {
|
||||
const handler = this.getHandlerByPattern(pattern);
|
||||
if (!handler && !this.noAck) {
|
||||
this.channel.nack(context.getMessage(), false, false);
|
||||
return this.logger.warn(RQM_NO_EVENT_HANDLER`${pattern}`);
|
||||
}
|
||||
return super.handleEvent(pattern, packet, context);
|
||||
}
|
||||
|
||||
public sendMessage<T = any>(
|
||||
message: T,
|
||||
replyTo: any,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Logger } from '@nestjs/common';
|
||||
import { expect } from 'chai';
|
||||
import { join } from 'path';
|
||||
import { of } from 'rxjs';
|
||||
import { of, ReplaySubject, Subject } from 'rxjs';
|
||||
import * as sinon from 'sinon';
|
||||
import { CANCEL_EVENT } from '../../constants';
|
||||
import { InvalidGrpcPackageException } from '../../errors/invalid-grpc-package.exception';
|
||||
@@ -442,6 +442,29 @@ describe('ServerGrpc', () => {
|
||||
expect(native.called).to.be.true;
|
||||
expect(callback.called).to.be.true;
|
||||
});
|
||||
|
||||
it('should await when a promise is return by the native', async () => {
|
||||
const call = { write: sinon.spy(), end: sinon.spy() };
|
||||
const callback = sinon.spy();
|
||||
|
||||
const original = { native: Function };
|
||||
const mock = sinon.mock(original);
|
||||
|
||||
mock
|
||||
.expects('native')
|
||||
.once()
|
||||
.returns(
|
||||
(() => {
|
||||
const sub = new ReplaySubject<any>(1);
|
||||
sub.next(new Promise(resolve => resolve({ foo: 'bar' })));
|
||||
return sub.asObservable();
|
||||
})(),
|
||||
);
|
||||
|
||||
await server.createUnaryServiceMethod(original.native)(call, callback);
|
||||
mock.verify();
|
||||
expect(callback.calledWith(null, { foo: 'bar' })).to.be.true;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ import * as sinon from 'sinon';
|
||||
import { NO_MESSAGE_HANDLER } from '../../constants';
|
||||
import { BaseRpcContext } from '../../ctx-host/base-rpc.context';
|
||||
import { ServerRMQ } from '../../server/server-rmq';
|
||||
import { RmqContext } from '../../ctx-host';
|
||||
|
||||
describe('ServerRMQ', () => {
|
||||
let server: ServerRMQ;
|
||||
@@ -99,10 +100,15 @@ describe('ServerRMQ', () => {
|
||||
data: 'tests',
|
||||
id: '3',
|
||||
});
|
||||
const channel = {
|
||||
nack: sinon.spy(),
|
||||
};
|
||||
|
||||
let sendMessageStub: sinon.SinonStub;
|
||||
|
||||
beforeEach(() => {
|
||||
sendMessageStub = sinon.stub(server, 'sendMessage').callsFake(() => ({}));
|
||||
(server as any).channel = channel;
|
||||
});
|
||||
it('should call "handleEvent" if identifier is not present', async () => {
|
||||
const handleEventSpy = sinon.spy(server, 'handleEvent');
|
||||
@@ -223,9 +229,33 @@ describe('ServerRMQ', () => {
|
||||
server.handleEvent(
|
||||
channel,
|
||||
{ pattern: '', data },
|
||||
new BaseRpcContext([]),
|
||||
new RmqContext([{}, {}, '']),
|
||||
);
|
||||
expect(handler.calledWith(data)).to.be.true;
|
||||
});
|
||||
|
||||
it('should negative acknowledge without retrying if key does not exists in handlers object and noAck option is false', () => {
|
||||
const nack = sinon.spy();
|
||||
const message = { pattern: 'no-exists', data };
|
||||
(server as any).channel = {
|
||||
nack,
|
||||
};
|
||||
(server as any).noAck = false;
|
||||
server.handleEvent(channel, message, new RmqContext([message, '', '']));
|
||||
|
||||
expect(nack.calledWith(message, false, false)).to.be.true;
|
||||
});
|
||||
|
||||
it('should not negative acknowledge if key does not exists in handlers object but noAck option is true', () => {
|
||||
const nack = sinon.spy();
|
||||
const message = { pattern: 'no-exists', data };
|
||||
(server as any).channel = {
|
||||
nack,
|
||||
};
|
||||
(server as any).noAck = true;
|
||||
server.handleEvent(channel, message, new RmqContext([message, '', '']));
|
||||
|
||||
expect(nack.calledWith(message, false, false)).not.to.be.true;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
<p align="center">
|
||||
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="120" alt="Nest Logo" /></a>
|
||||
<a href="https://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="120" alt="Nest Logo" /></a>
|
||||
</p>
|
||||
|
||||
[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456
|
||||
[circleci-url]: https://circleci.com/gh/nestjs/nest
|
||||
|
||||
<p align="center">A progressive <a href="http://nodejs.org" target="_blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
|
||||
<p align="center">A progressive <a href="https://nodejs.org" target="_blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
|
||||
<p align="center">
|
||||
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
|
||||
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
|
||||
@@ -132,7 +132,7 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
|
||||
<td align="center" valign="middle"><a href="https://klqc.de" target="_blank"><img src="https://nestjs.com/img/klcqcl-logo.png" width="120" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://thecasinowizard.com/bonuses/no-deposit-bonuses/" target="_blank"><img src="https://nestjs.com/img/casinowizard-logo.png" width="120" valign="middle" /></a></td></tr><tr>
|
||||
<td align="center" valign="middle"><a href="https://polygon-software.ch/" target="_blank"><img src="https://nestjs.com/img/polygon-logo.svg" width="120" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://mobilereality.pl/" target="_blank"><img src="https://nestjs.com/img/mobile-reality-logo.png" width="45" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://themobilereality.com/" target="_blank"><img src="https://nestjs.com/img/mobile-reality-logo.png" width="45" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://boringowl.io/" target="_blank"><img src="https://nestjs.com/img/boringowl-logo.svg" width="120" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://www.mobilefactory.jp/" target="_blank"><img src="https://nestjs.com/img/mobilefactory-logo.png" width="100" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://nordbot.app/" target="_blank"><img src="https://nestjs.com/img/nordbot-logo.png" width="120" valign="middle" /></a></td>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nestjs/platform-express",
|
||||
"version": "9.4.0",
|
||||
"version": "9.4.2",
|
||||
"description": "Nest - modern, fast, powerful node.js web framework (@platform-express)",
|
||||
"author": "Kamil Mysliwiec",
|
||||
"license": "MIT",
|
||||
@@ -22,11 +22,11 @@
|
||||
"cors": "2.8.5",
|
||||
"express": "4.18.2",
|
||||
"multer": "1.4.4-lts.1",
|
||||
"tslib": "2.5.0"
|
||||
"tslib": "2.5.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nestjs/common": "9.4.0",
|
||||
"@nestjs/core": "9.4.0"
|
||||
"@nestjs/common": "9.4.2",
|
||||
"@nestjs/core": "9.4.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@nestjs/common": "^9.0.0",
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
<p align="center">
|
||||
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="120" alt="Nest Logo" /></a>
|
||||
<a href="https://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="120" alt="Nest Logo" /></a>
|
||||
</p>
|
||||
|
||||
[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456
|
||||
[circleci-url]: https://circleci.com/gh/nestjs/nest
|
||||
|
||||
<p align="center">A progressive <a href="http://nodejs.org" target="_blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
|
||||
<p align="center">A progressive <a href="https://nodejs.org" target="_blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
|
||||
<p align="center">
|
||||
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
|
||||
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
|
||||
@@ -132,7 +132,7 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
|
||||
<td align="center" valign="middle"><a href="https://klqc.de" target="_blank"><img src="https://nestjs.com/img/klcqcl-logo.png" width="120" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://thecasinowizard.com/bonuses/no-deposit-bonuses/" target="_blank"><img src="https://nestjs.com/img/casinowizard-logo.png" width="120" valign="middle" /></a></td></tr><tr>
|
||||
<td align="center" valign="middle"><a href="https://polygon-software.ch/" target="_blank"><img src="https://nestjs.com/img/polygon-logo.svg" width="120" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://mobilereality.pl/" target="_blank"><img src="https://nestjs.com/img/mobile-reality-logo.png" width="45" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://themobilereality.com/" target="_blank"><img src="https://nestjs.com/img/mobile-reality-logo.png" width="45" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://boringowl.io/" target="_blank"><img src="https://nestjs.com/img/boringowl-logo.svg" width="120" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://www.mobilefactory.jp/" target="_blank"><img src="https://nestjs.com/img/mobilefactory-logo.png" width="100" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://nordbot.app/" target="_blank"><img src="https://nestjs.com/img/nordbot-logo.png" width="120" valign="middle" /></a></td>
|
||||
|
||||
@@ -4,9 +4,9 @@ import {
|
||||
RawBodyRequest,
|
||||
RequestMethod,
|
||||
StreamableFile,
|
||||
VERSION_NEUTRAL,
|
||||
VersioningOptions,
|
||||
VersioningType,
|
||||
VERSION_NEUTRAL,
|
||||
} from '@nestjs/common';
|
||||
import { VersionValue } from '@nestjs/common/interfaces';
|
||||
import {
|
||||
@@ -17,7 +17,6 @@ import { loadPackage } from '@nestjs/common/utils/load-package.util';
|
||||
import { isString, isUndefined } from '@nestjs/common/utils/shared.utils';
|
||||
import { AbstractHttpAdapter } from '@nestjs/core/adapters/http-adapter';
|
||||
import {
|
||||
fastify,
|
||||
FastifyBaseLogger,
|
||||
FastifyBodyParser,
|
||||
FastifyInstance,
|
||||
@@ -33,6 +32,7 @@ import {
|
||||
RawServerBase,
|
||||
RawServerDefault,
|
||||
RequestGenericInterface,
|
||||
fastify,
|
||||
} from 'fastify';
|
||||
import * as Reply from 'fastify/lib/reply';
|
||||
import { kRouteContext } from 'fastify/lib/symbols';
|
||||
@@ -40,10 +40,11 @@ import { RouteShorthandMethod } from 'fastify/types/route';
|
||||
import * as http2 from 'http2';
|
||||
import * as https from 'https';
|
||||
import {
|
||||
Chain as LightMyRequestChain,
|
||||
InjectOptions,
|
||||
Chain as LightMyRequestChain,
|
||||
Response as LightMyRequestResponse,
|
||||
} from 'light-my-request';
|
||||
import * as pathToRegexp from 'path-to-regexp';
|
||||
// `querystring` is used internally in fastify for registering urlencoded body parser.
|
||||
import { parse as querystringParse } from 'querystring';
|
||||
import { NestFastifyBodyParserOptions } from '../interfaces';
|
||||
@@ -547,11 +548,24 @@ export class FastifyAdapter<
|
||||
// Fallback to "(.*)" to support plugins like GraphQL
|
||||
normalizedPath = normalizedPath === '/(.*)' ? '(.*)' : normalizedPath;
|
||||
|
||||
const re = pathToRegexp(normalizedPath);
|
||||
|
||||
// The following type assertion is valid as we use import('@fastify/middie') rather than require('@fastify/middie')
|
||||
// ref https://github.com/fastify/middie/pull/55
|
||||
this.instance.use(
|
||||
normalizedPath,
|
||||
callback as Parameters<TInstance['use']>['1'],
|
||||
(req: any, res: any, next: Function) => {
|
||||
const queryParamsIndex = req.originalUrl.indexOf('?');
|
||||
const pathname =
|
||||
queryParamsIndex >= 0
|
||||
? req.originalUrl.slice(0, queryParamsIndex)
|
||||
: req.originalUrl;
|
||||
|
||||
if (!re.exec(pathname + '/') && normalizedPath) {
|
||||
return next();
|
||||
}
|
||||
return callback(req, res, next);
|
||||
},
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nestjs/platform-fastify",
|
||||
"version": "9.4.0",
|
||||
"version": "9.4.2",
|
||||
"description": "Nest - modern, fast, powerful node.js web framework (@platform-fastify)",
|
||||
"author": "Kamil Mysliwiec",
|
||||
"license": "MIT",
|
||||
@@ -20,11 +20,11 @@
|
||||
"dependencies": {
|
||||
"@fastify/cors": "8.2.1",
|
||||
"@fastify/formbody": "7.4.0",
|
||||
"@fastify/middie": "8.1.0",
|
||||
"fastify": "4.15.0",
|
||||
"@fastify/middie": "8.3.0",
|
||||
"fastify": "4.17.0",
|
||||
"light-my-request": "5.9.1",
|
||||
"path-to-regexp": "3.2.0",
|
||||
"tslib": "2.5.0"
|
||||
"tslib": "2.5.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@fastify/static": "^6.0.0",
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
<p align="center">
|
||||
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="120" alt="Nest Logo" /></a>
|
||||
<a href="https://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="120" alt="Nest Logo" /></a>
|
||||
</p>
|
||||
|
||||
[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456
|
||||
[circleci-url]: https://circleci.com/gh/nestjs/nest
|
||||
|
||||
<p align="center">A progressive <a href="http://nodejs.org" target="_blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
|
||||
<p align="center">A progressive <a href="https://nodejs.org" target="_blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
|
||||
<p align="center">
|
||||
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
|
||||
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
|
||||
@@ -132,7 +132,7 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
|
||||
<td align="center" valign="middle"><a href="https://klqc.de" target="_blank"><img src="https://nestjs.com/img/klcqcl-logo.png" width="120" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://thecasinowizard.com/bonuses/no-deposit-bonuses/" target="_blank"><img src="https://nestjs.com/img/casinowizard-logo.png" width="120" valign="middle" /></a></td></tr><tr>
|
||||
<td align="center" valign="middle"><a href="https://polygon-software.ch/" target="_blank"><img src="https://nestjs.com/img/polygon-logo.svg" width="120" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://mobilereality.pl/" target="_blank"><img src="https://nestjs.com/img/mobile-reality-logo.png" width="45" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://themobilereality.com/" target="_blank"><img src="https://nestjs.com/img/mobile-reality-logo.png" width="45" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://boringowl.io/" target="_blank"><img src="https://nestjs.com/img/boringowl-logo.svg" width="120" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://www.mobilefactory.jp/" target="_blank"><img src="https://nestjs.com/img/mobilefactory-logo.png" width="100" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://nordbot.app/" target="_blank"><img src="https://nestjs.com/img/nordbot-logo.png" width="120" valign="middle" /></a></td>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nestjs/platform-socket.io",
|
||||
"version": "9.4.0",
|
||||
"version": "9.4.2",
|
||||
"description": "Nest - modern, fast, powerful node.js web framework (@platform-socket.io)",
|
||||
"author": "Kamil Mysliwiec",
|
||||
"license": "MIT",
|
||||
@@ -19,7 +19,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"socket.io": "4.6.1",
|
||||
"tslib": "2.5.0"
|
||||
"tslib": "2.5.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@nestjs/common": "^9.0.0",
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
<p align="center">
|
||||
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="120" alt="Nest Logo" /></a>
|
||||
<a href="https://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="120" alt="Nest Logo" /></a>
|
||||
</p>
|
||||
|
||||
[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456
|
||||
[circleci-url]: https://circleci.com/gh/nestjs/nest
|
||||
|
||||
<p align="center">A progressive <a href="http://nodejs.org" target="_blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
|
||||
<p align="center">A progressive <a href="https://nodejs.org" target="_blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
|
||||
<p align="center">
|
||||
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
|
||||
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
|
||||
@@ -132,7 +132,7 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
|
||||
<td align="center" valign="middle"><a href="https://klqc.de" target="_blank"><img src="https://nestjs.com/img/klcqcl-logo.png" width="120" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://thecasinowizard.com/bonuses/no-deposit-bonuses/" target="_blank"><img src="https://nestjs.com/img/casinowizard-logo.png" width="120" valign="middle" /></a></td></tr><tr>
|
||||
<td align="center" valign="middle"><a href="https://polygon-software.ch/" target="_blank"><img src="https://nestjs.com/img/polygon-logo.svg" width="120" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://mobilereality.pl/" target="_blank"><img src="https://nestjs.com/img/mobile-reality-logo.png" width="45" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://themobilereality.com/" target="_blank"><img src="https://nestjs.com/img/mobile-reality-logo.png" width="45" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://boringowl.io/" target="_blank"><img src="https://nestjs.com/img/boringowl-logo.svg" width="120" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://www.mobilefactory.jp/" target="_blank"><img src="https://nestjs.com/img/mobilefactory-logo.png" width="100" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://nordbot.app/" target="_blank"><img src="https://nestjs.com/img/nordbot-logo.png" width="120" valign="middle" /></a></td>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nestjs/platform-ws",
|
||||
"version": "9.4.0",
|
||||
"version": "9.4.2",
|
||||
"description": "Nest - modern, fast, powerful node.js web framework (@platform-ws)",
|
||||
"author": "Kamil Mysliwiec",
|
||||
"license": "MIT",
|
||||
@@ -18,7 +18,7 @@
|
||||
"access": "public"
|
||||
},
|
||||
"dependencies": {
|
||||
"tslib": "2.5.0",
|
||||
"tslib": "2.5.2",
|
||||
"ws": "8.13.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
<p align="center">
|
||||
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="120" alt="Nest Logo" /></a>
|
||||
<a href="https://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="120" alt="Nest Logo" /></a>
|
||||
</p>
|
||||
|
||||
[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456
|
||||
[circleci-url]: https://circleci.com/gh/nestjs/nest
|
||||
|
||||
<p align="center">A progressive <a href="http://nodejs.org" target="_blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
|
||||
<p align="center">A progressive <a href="https://nodejs.org" target="_blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
|
||||
<p align="center">
|
||||
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
|
||||
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
|
||||
@@ -132,7 +132,7 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
|
||||
<td align="center" valign="middle"><a href="https://klqc.de" target="_blank"><img src="https://nestjs.com/img/klcqcl-logo.png" width="120" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://thecasinowizard.com/bonuses/no-deposit-bonuses/" target="_blank"><img src="https://nestjs.com/img/casinowizard-logo.png" width="120" valign="middle" /></a></td></tr><tr>
|
||||
<td align="center" valign="middle"><a href="https://polygon-software.ch/" target="_blank"><img src="https://nestjs.com/img/polygon-logo.svg" width="120" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://mobilereality.pl/" target="_blank"><img src="https://nestjs.com/img/mobile-reality-logo.png" width="45" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://themobilereality.com/" target="_blank"><img src="https://nestjs.com/img/mobile-reality-logo.png" width="45" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://boringowl.io/" target="_blank"><img src="https://nestjs.com/img/boringowl-logo.svg" width="120" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://www.mobilefactory.jp/" target="_blank"><img src="https://nestjs.com/img/mobilefactory-logo.png" width="100" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://nordbot.app/" target="_blank"><img src="https://nestjs.com/img/nordbot-logo.png" width="120" valign="middle" /></a></td>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nestjs/testing",
|
||||
"version": "9.4.0",
|
||||
"version": "9.4.2",
|
||||
"description": "Nest - modern, fast, powerful node.js web framework (@testing)",
|
||||
"author": "Kamil Mysliwiec",
|
||||
"license": "MIT",
|
||||
@@ -18,7 +18,7 @@
|
||||
"access": "public"
|
||||
},
|
||||
"dependencies": {
|
||||
"tslib": "2.5.0"
|
||||
"tslib": "2.5.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@nestjs/common": "^9.0.0",
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
<p align="center">
|
||||
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="120" alt="Nest Logo" /></a>
|
||||
<a href="https://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="120" alt="Nest Logo" /></a>
|
||||
</p>
|
||||
|
||||
[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456
|
||||
[circleci-url]: https://circleci.com/gh/nestjs/nest
|
||||
|
||||
<p align="center">A progressive <a href="http://nodejs.org" target="_blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
|
||||
<p align="center">A progressive <a href="https://nodejs.org" target="_blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
|
||||
<p align="center">
|
||||
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
|
||||
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
|
||||
@@ -132,7 +132,7 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
|
||||
<td align="center" valign="middle"><a href="https://klqc.de" target="_blank"><img src="https://nestjs.com/img/klcqcl-logo.png" width="120" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://thecasinowizard.com/bonuses/no-deposit-bonuses/" target="_blank"><img src="https://nestjs.com/img/casinowizard-logo.png" width="120" valign="middle" /></a></td></tr><tr>
|
||||
<td align="center" valign="middle"><a href="https://polygon-software.ch/" target="_blank"><img src="https://nestjs.com/img/polygon-logo.svg" width="120" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://mobilereality.pl/" target="_blank"><img src="https://nestjs.com/img/mobile-reality-logo.png" width="45" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://themobilereality.com/" target="_blank"><img src="https://nestjs.com/img/mobile-reality-logo.png" width="45" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://boringowl.io/" target="_blank"><img src="https://nestjs.com/img/boringowl-logo.svg" width="120" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://www.mobilefactory.jp/" target="_blank"><img src="https://nestjs.com/img/mobilefactory-logo.png" width="100" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://nordbot.app/" target="_blank"><img src="https://nestjs.com/img/nordbot-logo.png" width="120" valign="middle" /></a></td>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nestjs/websockets",
|
||||
"version": "9.4.0",
|
||||
"version": "9.4.2",
|
||||
"description": "Nest - modern, fast, powerful node.js web framework (@websockets)",
|
||||
"author": "Kamil Mysliwiec",
|
||||
"license": "MIT",
|
||||
@@ -15,11 +15,11 @@
|
||||
"dependencies": {
|
||||
"iterare": "1.2.1",
|
||||
"object-hash": "3.0.0",
|
||||
"tslib": "2.5.0"
|
||||
"tslib": "2.5.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nestjs/common": "9.4.0",
|
||||
"@nestjs/core": "9.4.0"
|
||||
"@nestjs/common": "9.4.2",
|
||||
"@nestjs/core": "9.4.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@nestjs/common": "^9.0.0",
|
||||
|
||||
28
readme_zh.md
28
readme_zh.md
@@ -1,22 +1,22 @@
|
||||
<p align="center">
|
||||
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo_text.svg" width="320" alt="Nest Logo" /></a>
|
||||
<a href="https://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="120" alt="Nest Logo" /></a>
|
||||
</p>
|
||||
|
||||
[travis-image]: https://api.travis-ci.org/nestjs/nest.svg?branch=master
|
||||
[travis-url]: https://travis-ci.org/nestjs/nest
|
||||
[linux-image]: https://img.shields.io/travis/nestjs/nest/master.svg?label=linux
|
||||
[linux-url]: https://travis-ci.org/nestjs/nest
|
||||
[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456
|
||||
[circleci-url]: https://circleci.com/gh/nestjs/nest
|
||||
|
||||
<p align="center">用于构建高效且可扩展的服务器端应用程序的渐进式 <a href="http://nodejs.cn" target="blank">Node.js</a> 框架,深受 <a href="https://angular.cn" target="_blank">Angular</a> 的启发。</p>
|
||||
<p align="center">用于构建高效且可扩展的服务器端应用程序的渐进式 <a href="http://nodejs.cn" target="blank">Node.js</a> 框架,深受 <a href="https://angular.cn" target="_blank">Angular</a> 的启发。</p>
|
||||
<p align="center">
|
||||
<a href="https://www.npmjs.com/~nestjscore"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
|
||||
<a href="https://www.npmjs.com/~nestjscore"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
|
||||
<a href="https://www.npmjs.com/~nestjscore"><img src="https://img.shields.io/npm/dm/@nestjs/core.svg" alt="NPM Downloads" /></a>
|
||||
<a href="https://travis-ci.org/nestjs/nest"><img src="https://api.travis-ci.org/nestjs/nest.svg?branch=master" alt="Travis" /></a>
|
||||
<a href="https://travis-ci.org/nestjs/nest"><img src="https://img.shields.io/travis/nestjs/nest/master.svg?label=linux" alt="Linux" /></a>
|
||||
<a href="https://coveralls.io/github/nestjs/nest?branch=master"><img src="https://coveralls.io/repos/github/nestjs/nest/badge.svg?branch=master#5" alt="Coverage" /></a>
|
||||
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
|
||||
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
|
||||
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/dm/@nestjs/common.svg" alt="NPM Downloads" /></a>
|
||||
<a href="https://circleci.com/gh/nestjs/nest" target="_blank"><img src="https://img.shields.io/circleci/build/github/nestjs/nest/master" alt="CircleCI" /></a>
|
||||
<a href="https://discord.gg/G7Qnnhy" target="_blank"><img src="https://img.shields.io/badge/discord-online-brightgreen.svg" alt="Discord"/></a>
|
||||
<a href="https://opencollective.com/nest#backer"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
|
||||
<a href="https://opencollective.com/nest#sponsor"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
|
||||
<a href="https://opencollective.com/nest#backer" target="_blank"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
|
||||
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
|
||||
<a href="https://paypal.me/kamilmysliwiec" target="_blank"><img src="https://img.shields.io/badge/Donate-PayPal-ff3f59.svg"/></a>
|
||||
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://img.shields.io/badge/Support%20us-Open%20Collective-41B883.svg" alt="Support us"></a>
|
||||
<a href="https://twitter.com/nestframework" target="_blank"><img src="https://img.shields.io/twitter/follow/nestframework.svg?style=social&label=Follow"></a>
|
||||
</p>
|
||||
<!--[](https://opencollective.com/nest#backer)
|
||||
[](https://opencollective.com/nest#sponsor)-->
|
||||
|
||||
12
sample/02-gateways/package-lock.json
generated
12
sample/02-gateways/package-lock.json
generated
@@ -3671,9 +3671,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/engine.io": {
|
||||
"version": "6.4.1",
|
||||
"resolved": "https://registry.npmjs.org/engine.io/-/engine.io-6.4.1.tgz",
|
||||
"integrity": "sha512-JFYQurD/nbsA5BSPmbaOSLa3tSVj8L6o4srSwXXY3NqE+gGUNmmPTbhn8tjzcCtSqhFgIeqef81ngny8JM25hw==",
|
||||
"version": "6.4.2",
|
||||
"resolved": "https://registry.npmjs.org/engine.io/-/engine.io-6.4.2.tgz",
|
||||
"integrity": "sha512-FKn/3oMiJjrOEOeUub2WCox6JhxBXq/Zn3fZOMCBxKnNYtsdKjxhl7yR3fZhM9PV+rdE75SU5SYMc+2PGzo+Tg==",
|
||||
"dependencies": {
|
||||
"@types/cookie": "^0.4.1",
|
||||
"@types/cors": "^2.8.12",
|
||||
@@ -11722,9 +11722,9 @@
|
||||
}
|
||||
},
|
||||
"engine.io": {
|
||||
"version": "6.4.1",
|
||||
"resolved": "https://registry.npmjs.org/engine.io/-/engine.io-6.4.1.tgz",
|
||||
"integrity": "sha512-JFYQurD/nbsA5BSPmbaOSLa3tSVj8L6o4srSwXXY3NqE+gGUNmmPTbhn8tjzcCtSqhFgIeqef81ngny8JM25hw==",
|
||||
"version": "6.4.2",
|
||||
"resolved": "https://registry.npmjs.org/engine.io/-/engine.io-6.4.2.tgz",
|
||||
"integrity": "sha512-FKn/3oMiJjrOEOeUub2WCox6JhxBXq/Zn3fZOMCBxKnNYtsdKjxhl7yR3fZhM9PV+rdE75SU5SYMc+2PGzo+Tg==",
|
||||
"requires": {
|
||||
"@types/cookie": "^0.4.1",
|
||||
"@types/cors": "^2.8.12",
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
### Mongoose sample
|
||||
### Mongo TypeORM sample
|
||||
|
||||
### Installation
|
||||
|
||||
|
||||
`npm install`
|
||||
|
||||
### Running
|
||||
@@ -23,4 +22,4 @@ After running the sample, you can stop the Docker container with
|
||||
|
||||
Then, run Nest as usual:
|
||||
|
||||
`npm run start`
|
||||
`npm run start`
|
||||
|
||||
Reference in New Issue
Block a user