mirror of
https://github.com/nestjs/nest.git
synced 2026-02-24 00:02:56 +00:00
Compare commits
129 Commits
v7.0.2
...
seclace-fe
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b039ac9f6d | ||
|
|
15f3ee9ad6 | ||
|
|
e4a8cfbfa9 | ||
|
|
749ab49153 | ||
|
|
b9a9d58bd1 | ||
|
|
f829f9c25f | ||
|
|
8fad078b5c | ||
|
|
abbe2d9700 | ||
|
|
9d87d17ae3 | ||
|
|
b417928177 | ||
|
|
75799a31dc | ||
|
|
fb194199ad | ||
|
|
356fcd74a8 | ||
|
|
af8164ff5c | ||
|
|
e9dcd8fc84 | ||
|
|
93313f505a | ||
|
|
05b3dee522 | ||
|
|
447f341d28 | ||
|
|
dff909bd99 | ||
|
|
4635a35fc8 | ||
|
|
6c54451121 | ||
|
|
3e270a3285 | ||
|
|
1c1d4e9ce2 | ||
|
|
f7b48a3e18 | ||
|
|
6d0bbc8255 | ||
|
|
87abfaf036 | ||
|
|
89f6a69cf8 | ||
|
|
4b3d476571 | ||
|
|
14075d9591 | ||
|
|
0691c5c11d | ||
|
|
08c005054c | ||
|
|
c2f6b2d413 | ||
|
|
831dac8e8a | ||
|
|
c7b70ee096 | ||
|
|
de58066618 | ||
|
|
acd6923ed9 | ||
|
|
6d6715322f | ||
|
|
c47f160322 | ||
|
|
9b5779de73 | ||
|
|
d3d01ccde9 | ||
|
|
c978fc2caa | ||
|
|
2ee05ecd79 | ||
|
|
41cc8bab79 | ||
|
|
3a08a26d20 | ||
|
|
35b79eb10e | ||
|
|
8a3d82c054 | ||
|
|
b3e1fa7867 | ||
|
|
b368f074bb | ||
|
|
3a09bf70ab | ||
|
|
fe888916f4 | ||
|
|
2e30be8a28 | ||
|
|
a276847de0 | ||
|
|
00658ca30e | ||
|
|
c368fe4255 | ||
|
|
5f7874fd61 | ||
|
|
c2e9646cd6 | ||
|
|
0e5b402a6f | ||
|
|
3dae6178b7 | ||
|
|
6b3c932193 | ||
|
|
4a8b385fb1 | ||
|
|
b068f41e08 | ||
|
|
d40ecde991 | ||
|
|
02f7d9795a | ||
|
|
9242745e62 | ||
|
|
2f3b39faa1 | ||
|
|
7954d75daf | ||
|
|
b46afb4413 | ||
|
|
de104f7407 | ||
|
|
96515c749e | ||
|
|
7064f145cf | ||
|
|
e9f5211404 | ||
|
|
a011ca7e6e | ||
|
|
7248dd9add | ||
|
|
7999e592c4 | ||
|
|
9e2d683dd0 | ||
|
|
a6e73b7b27 | ||
|
|
f7d0ebb3bf | ||
|
|
dd33623711 | ||
|
|
98cf199a4c | ||
|
|
4035426ce3 | ||
|
|
18a54786d4 | ||
|
|
af203b761a | ||
|
|
06e5381b7c | ||
|
|
f2b22856e2 | ||
|
|
e9611e4430 | ||
|
|
429a1dc974 | ||
|
|
70b7813915 | ||
|
|
41381dcd42 | ||
|
|
32d2172461 | ||
|
|
5bebd05be2 | ||
|
|
e6d644bc8a | ||
|
|
46477638a9 | ||
|
|
7548e288ee | ||
|
|
e83a1fed77 | ||
|
|
539c3312da | ||
|
|
015d419601 | ||
|
|
31c9b0b990 | ||
|
|
a8dcaae673 | ||
|
|
1912732a43 | ||
|
|
2e8305cc15 | ||
|
|
0781e09f92 | ||
|
|
578588d1f9 | ||
|
|
456b34bc60 | ||
|
|
49059c01bd | ||
|
|
5d1076b527 | ||
|
|
3812864353 | ||
|
|
6b96700a17 | ||
|
|
4ffb16fb8c | ||
|
|
a6a45d056e | ||
|
|
f0fdcfcd89 | ||
|
|
1069de9a00 | ||
|
|
854c602b27 | ||
|
|
62a8fa3848 | ||
|
|
f815474b6d | ||
|
|
a5271dde02 | ||
|
|
243e3a2151 | ||
|
|
07a076c156 | ||
|
|
cde810c391 | ||
|
|
8324e149cc | ||
|
|
484cbd0c2c | ||
|
|
5ffcce26b4 | ||
|
|
e1ec7ef47a | ||
|
|
35c88bf5a1 | ||
|
|
2df93e9046 | ||
|
|
6d56bab026 | ||
|
|
30c20ec0b9 | ||
|
|
90cbb7892c | ||
|
|
e89f27b954 | ||
|
|
e1d303d019 |
@@ -1,4 +1,5 @@
|
||||
{
|
||||
"singleQuote": true,
|
||||
"arrowParens": "avoid",
|
||||
"trailingComma": "all"
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ Nest is a framework for building efficient, scalable <a href="http://nodejs.org"
|
||||
## Philosophy
|
||||
|
||||
<p>In recent years, thanks to Node.js, JavaScript has become the “lingua franca” of the web for both front and backend applications, giving rise to awesome projects like <a href="https://angular.io/" target="_blank">Angular</a>, <a href="https://github.com/facebook/react" target="_blank">React</a> and <a href="https://github.com/vuejs/vue" target="_blank">Vue</a> which improve developer productivity and enable the construction of fast, testable, extensible frontend applications. However, on the server-side, while there are a lot of superb libraries, helpers and tools for Node, none of them effectively solve the main problem - the architecture.</p>
|
||||
<p>Nest aims to provide an application architecture out of the box which allows for effortless creation of highly testable, scalable, loosely coupled and easily maintainable applications.</p>
|
||||
<p>Nest aims to provide an application architecture out of the box which allows for effortless creation of highly testable, scalable, loosely coupled and easily maintainable applications. The architecture is heavily inspired by Angular.</p>
|
||||
|
||||
## Getting started
|
||||
|
||||
|
||||
@@ -18,25 +18,19 @@ describe('Error messages', () => {
|
||||
});
|
||||
|
||||
it(`/GET`, () => {
|
||||
return request(server)
|
||||
.get('/sync')
|
||||
.expect(HttpStatus.BAD_REQUEST)
|
||||
.expect({
|
||||
statusCode: 400,
|
||||
error: 'Bad Request',
|
||||
message: 'Integration test',
|
||||
});
|
||||
return request(server).get('/sync').expect(HttpStatus.BAD_REQUEST).expect({
|
||||
statusCode: 400,
|
||||
error: 'Bad Request',
|
||||
message: 'Integration test',
|
||||
});
|
||||
});
|
||||
|
||||
it(`/GET (Promise/async)`, () => {
|
||||
return request(server)
|
||||
.get('/async')
|
||||
.expect(HttpStatus.BAD_REQUEST)
|
||||
.expect({
|
||||
statusCode: 400,
|
||||
error: 'Bad Request',
|
||||
message: 'Integration test',
|
||||
});
|
||||
return request(server).get('/async').expect(HttpStatus.BAD_REQUEST).expect({
|
||||
statusCode: 400,
|
||||
error: 'Bad Request',
|
||||
message: 'Integration test',
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
|
||||
@@ -78,16 +78,11 @@ describe('Exclude middleware (fastify)', () => {
|
||||
).createNestApplication<NestFastifyApplication>(new FastifyAdapter());
|
||||
|
||||
await app.init();
|
||||
await app
|
||||
.getHttpAdapter()
|
||||
.getInstance()
|
||||
.ready();
|
||||
await app.getHttpAdapter().getInstance().ready();
|
||||
});
|
||||
|
||||
it(`should exclude "/test" endpoint`, () => {
|
||||
return request(app.getHttpServer())
|
||||
.get('/test')
|
||||
.expect(200, RETURN_VALUE);
|
||||
return request(app.getHttpServer()).get('/test').expect(200, RETURN_VALUE);
|
||||
});
|
||||
|
||||
it(`should not exclude "/test2" endpoint`, () => {
|
||||
|
||||
@@ -77,9 +77,7 @@ describe('Exclude middleware', () => {
|
||||
});
|
||||
|
||||
it(`should exclude "/test" endpoint`, () => {
|
||||
return request(app.getHttpServer())
|
||||
.get('/test')
|
||||
.expect(200, RETURN_VALUE);
|
||||
return request(app.getHttpServer()).get('/test').expect(200, RETURN_VALUE);
|
||||
});
|
||||
|
||||
it(`should not exclude "/test2" endpoint`, () => {
|
||||
|
||||
@@ -20,10 +20,7 @@ describe('Hello world (express instance)', () => {
|
||||
});
|
||||
|
||||
it(`/GET`, () => {
|
||||
return request(server)
|
||||
.get('/hello')
|
||||
.expect(200)
|
||||
.expect('Hello world!');
|
||||
return request(server).get('/hello').expect(200).expect('Hello world!');
|
||||
});
|
||||
|
||||
it(`/GET (Promise/async)`, () => {
|
||||
@@ -41,14 +38,11 @@ describe('Hello world (express instance)', () => {
|
||||
});
|
||||
|
||||
it(`/GET { host: ":tenant.example.com" } not matched`, () => {
|
||||
return request(server)
|
||||
.get('/host')
|
||||
.expect(404)
|
||||
.expect({
|
||||
statusCode: 404,
|
||||
error: 'Not Found',
|
||||
message: 'Cannot GET /host',
|
||||
});
|
||||
return request(server).get('/host').expect(404).expect({
|
||||
statusCode: 404,
|
||||
error: 'Not Found',
|
||||
message: 'Cannot GET /host',
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
|
||||
@@ -29,10 +29,7 @@ describe('Hello world (express instance with multiple applications)', () => {
|
||||
});
|
||||
|
||||
it(`/GET`, () => {
|
||||
return request(server)
|
||||
.get('/hello')
|
||||
.expect(200)
|
||||
.expect('Hello world!');
|
||||
return request(server).get('/hello').expect(200).expect('Hello world!');
|
||||
});
|
||||
|
||||
it(`/GET (app2)`, () => {
|
||||
|
||||
@@ -37,8 +37,6 @@ describe('Guards', () => {
|
||||
app = (await createTestModule(new AuthGuard())).createNestApplication();
|
||||
|
||||
await app.init();
|
||||
return request(app.getHttpServer())
|
||||
.get('/hello')
|
||||
.expect(401);
|
||||
return request(app.getHttpServer()).get('/hello').expect(401);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -77,9 +77,7 @@ describe('Interceptors', () => {
|
||||
).createNestApplication();
|
||||
|
||||
await app.init();
|
||||
return request(app.getHttpServer())
|
||||
.get('/hello')
|
||||
.expect(200, RETURN_VALUE);
|
||||
return request(app.getHttpServer()).get('/hello').expect(200, RETURN_VALUE);
|
||||
});
|
||||
|
||||
it(`should map response`, async () => {
|
||||
|
||||
@@ -18,12 +18,9 @@ describe('Hello world (default adapter)', () => {
|
||||
});
|
||||
|
||||
it(`host=example.com should execute locally injected pipe by HelloController`, () => {
|
||||
return request(server)
|
||||
.get('/hello/local-pipe/1')
|
||||
.expect(200)
|
||||
.expect({
|
||||
id: '1',
|
||||
});
|
||||
return request(server).get('/hello/local-pipe/1').expect(200).expect({
|
||||
id: '1',
|
||||
});
|
||||
});
|
||||
|
||||
it(`host=host.example.com should execute locally injected pipe by HostController`, () => {
|
||||
@@ -39,14 +36,11 @@ describe('Hello world (default adapter)', () => {
|
||||
});
|
||||
|
||||
it(`should return 404 for mismatched host`, () => {
|
||||
return request(server)
|
||||
.get('/host/local-pipe/1')
|
||||
.expect(404)
|
||||
.expect({
|
||||
error: 'Not Found',
|
||||
message: 'Cannot GET /host/local-pipe/1',
|
||||
statusCode: 404,
|
||||
});
|
||||
return request(server).get('/host/local-pipe/1').expect(404).expect({
|
||||
error: 'Not Found',
|
||||
message: 'Cannot GET /host/local-pipe/1',
|
||||
statusCode: 404,
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
|
||||
@@ -51,9 +51,7 @@ describe('Middleware (class)', () => {
|
||||
});
|
||||
|
||||
it(`forRoutes(*)`, () => {
|
||||
return request(app.getHttpServer())
|
||||
.get('/hello')
|
||||
.expect(200, RETURN_VALUE);
|
||||
return request(app.getHttpServer()).get('/hello').expect(200, RETURN_VALUE);
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
|
||||
@@ -57,15 +57,11 @@ describe('Middleware', () => {
|
||||
});
|
||||
|
||||
it(`forRoutes(*)`, () => {
|
||||
return request(app.getHttpServer())
|
||||
.get('/hello')
|
||||
.expect(200, RETURN_VALUE);
|
||||
return request(app.getHttpServer()).get('/hello').expect(200, RETURN_VALUE);
|
||||
});
|
||||
|
||||
it(`forRoutes(TestController)`, () => {
|
||||
return request(app.getHttpServer())
|
||||
.get('/test')
|
||||
.expect(200, SCOPED_VALUE);
|
||||
return request(app.getHttpServer()).get('/test').expect(200, SCOPED_VALUE);
|
||||
});
|
||||
|
||||
it(`forRoutes(tests/*)`, () => {
|
||||
|
||||
@@ -33,9 +33,7 @@ describe('MQTT transport', () => {
|
||||
});
|
||||
|
||||
it(`Broadcast (2 subscribers)`, () => {
|
||||
return request(server)
|
||||
.get('/broadcast')
|
||||
.expect(200, '2');
|
||||
return request(server).get('/broadcast').expect(200, '2');
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
|
||||
@@ -33,9 +33,7 @@ describe('NATS transport', () => {
|
||||
});
|
||||
|
||||
it(`Broadcast (2 subscribers)`, () => {
|
||||
return request(server)
|
||||
.get('/broadcast')
|
||||
.expect(200, '2');
|
||||
return request(server).get('/broadcast').expect(200, '2');
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
|
||||
@@ -33,9 +33,7 @@ describe('REDIS transport', () => {
|
||||
});
|
||||
|
||||
it(`Broadcast (2 subscribers)`, () => {
|
||||
return request(server)
|
||||
.get('/broadcast')
|
||||
.expect(200, '2');
|
||||
return request(server).get('/broadcast').expect(200, '2');
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
|
||||
@@ -129,11 +129,7 @@ describe('Advanced GRPC transport', () => {
|
||||
callHandler.on('error', (err: any) => {
|
||||
// We want to fail only on real errors while Cancellation error
|
||||
// is expected
|
||||
if (
|
||||
String(err)
|
||||
.toLowerCase()
|
||||
.indexOf('cancelled') === -1
|
||||
) {
|
||||
if (String(err).toLowerCase().indexOf('cancelled') === -1) {
|
||||
fail('gRPC Stream error happened, error: ' + err);
|
||||
}
|
||||
});
|
||||
@@ -165,11 +161,7 @@ describe('Advanced GRPC transport', () => {
|
||||
callHandler.on('error', (err: any) => {
|
||||
// We want to fail only on real errors while Cancellation error
|
||||
// is expected
|
||||
if (
|
||||
String(err)
|
||||
.toLowerCase()
|
||||
.indexOf('cancelled') === -1
|
||||
) {
|
||||
if (String(err).toLowerCase().indexOf('cancelled') === -1) {
|
||||
fail('gRPC Stream error happened, error: ' + err);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -63,11 +63,7 @@ describe('GRPC transport', () => {
|
||||
callHandler.on('error', (err: any) => {
|
||||
// We want to fail only on real errors while Cancellation error
|
||||
// is expected
|
||||
if (
|
||||
String(err)
|
||||
.toLowerCase()
|
||||
.indexOf('cancelled') === -1
|
||||
) {
|
||||
if (String(err).toLowerCase().indexOf('cancelled') === -1) {
|
||||
fail('gRPC Stream error happened, error: ' + err);
|
||||
}
|
||||
});
|
||||
@@ -89,11 +85,7 @@ describe('GRPC transport', () => {
|
||||
callHandler.on('error', (err: any) => {
|
||||
// We want to fail only on real errors while Cancellation error
|
||||
// is expected
|
||||
if (
|
||||
String(err)
|
||||
.toLowerCase()
|
||||
.indexOf('cancelled') === -1
|
||||
) {
|
||||
if (String(err).toLowerCase().indexOf('cancelled') === -1) {
|
||||
fail('gRPC Stream error happened, error: ' + err);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -106,17 +106,11 @@ describe('Kafka transport', () => {
|
||||
user: newUser,
|
||||
};
|
||||
it(`/POST (sync command create user)`, () => {
|
||||
return request(server)
|
||||
.post('/user')
|
||||
.send(userDto)
|
||||
.expect(200);
|
||||
return request(server).post('/user').send(userDto).expect(200);
|
||||
});
|
||||
|
||||
it(`/POST (sync command create business`, () => {
|
||||
return request(server)
|
||||
.post('/business')
|
||||
.send(businessDto)
|
||||
.expect(200);
|
||||
return request(server).post('/business').send(businessDto).expect(200);
|
||||
});
|
||||
|
||||
it(`/POST (sync command create user) Concurrency Test`, async () => {
|
||||
@@ -124,12 +118,7 @@ describe('Kafka transport', () => {
|
||||
for (let concurrencyKey = 0; concurrencyKey < 100; concurrencyKey++) {
|
||||
const innerUserDto = JSON.parse(JSON.stringify(userDto));
|
||||
innerUserDto.name += `+${concurrencyKey}`;
|
||||
promises.push(
|
||||
request(server)
|
||||
.post('/user')
|
||||
.send(userDto)
|
||||
.expect(200),
|
||||
);
|
||||
promises.push(request(server).post('/user').send(userDto).expect(200));
|
||||
}
|
||||
await Promise.all(promises);
|
||||
});
|
||||
|
||||
@@ -49,7 +49,7 @@ describe('MQTT transport', () => {
|
||||
.expect(200, '15');
|
||||
});
|
||||
|
||||
it(`/POST (concurrent)`, function() {
|
||||
it(`/POST (concurrent)`, function () {
|
||||
return request(server)
|
||||
.post('/concurrent')
|
||||
.send([
|
||||
|
||||
@@ -75,12 +75,10 @@ describe('NATS transport', () => {
|
||||
});
|
||||
|
||||
it(`/GET (exception)`, () => {
|
||||
return request(server)
|
||||
.get('/exception')
|
||||
.expect(200, {
|
||||
message: 'test',
|
||||
status: 'error',
|
||||
});
|
||||
return request(server).get('/exception').expect(200, {
|
||||
message: 'test',
|
||||
status: 'error',
|
||||
});
|
||||
});
|
||||
|
||||
it(`/POST (event notification)`, done => {
|
||||
|
||||
@@ -49,7 +49,7 @@ describe('REDIS transport', () => {
|
||||
.expect(200, '15');
|
||||
});
|
||||
|
||||
it(`/POST (concurrent)`, function() {
|
||||
it(`/POST (concurrent)`, function () {
|
||||
this.retries(10);
|
||||
|
||||
return request(server)
|
||||
|
||||
@@ -76,9 +76,7 @@ describe('RPC transport', () => {
|
||||
});
|
||||
|
||||
it(`/POST (pattern not found)`, () => {
|
||||
return request(server)
|
||||
.post('/?command=test')
|
||||
.expect(500);
|
||||
return request(server).post('/?command=test').expect(500);
|
||||
});
|
||||
|
||||
it(`/POST (event notification)`, done => {
|
||||
|
||||
@@ -65,7 +65,7 @@ describe('WebSocketGateway (WsAdapter)', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it(`should support 2 different gateways`, async function() {
|
||||
it(`should support 2 different gateways`, async function () {
|
||||
this.retries(10);
|
||||
|
||||
app = await createNestApp(ApplicationGateway, CoreGateway);
|
||||
|
||||
@@ -3,5 +3,5 @@
|
||||
"packages": [
|
||||
"packages/*"
|
||||
],
|
||||
"version": "7.0.2"
|
||||
"version": "7.0.5"
|
||||
}
|
||||
|
||||
1621
package-lock.json
generated
1621
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
40
package.json
40
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nestjs/core",
|
||||
"version": "6.11.7",
|
||||
"version": "7.0.3",
|
||||
"description": "Modern, fast, powerful node.js web framework",
|
||||
"homepage": "https://nestjs.com",
|
||||
"repository": {
|
||||
@@ -54,11 +54,11 @@
|
||||
"@nuxtjs/opencollective": "0.2.2",
|
||||
"axios": "0.19.2",
|
||||
"class-transformer": "0.2.3",
|
||||
"class-validator": "0.11.0",
|
||||
"class-validator": "0.11.1",
|
||||
"cli-color": "2.0.0",
|
||||
"cors": "2.8.5",
|
||||
"express": "4.17.1",
|
||||
"fast-json-stringify": "1.17.0",
|
||||
"fast-json-stringify": "1.18.0",
|
||||
"fast-safe-stringify": "2.0.7",
|
||||
"iterare": "1.2.0",
|
||||
"object-hash": "2.0.3",
|
||||
@@ -74,7 +74,7 @@
|
||||
"@commitlint/cli": "8.3.5",
|
||||
"@commitlint/config-angular": "8.3.4",
|
||||
"@grpc/proto-loader": "0.5.3",
|
||||
"@nestjs/graphql": "7.0.1",
|
||||
"@nestjs/graphql": "7.1.1",
|
||||
"@nestjs/mongoose": "6.4.0",
|
||||
"@nestjs/typeorm": "7.0.0",
|
||||
"@types/amqplib": "0.5.13",
|
||||
@@ -87,24 +87,24 @@
|
||||
"@types/fastify-cors": "2.1.0",
|
||||
"@types/gulp": "4.0.6",
|
||||
"@types/kafka-node": "2.0.9",
|
||||
"@types/mocha": "7.0.1",
|
||||
"@types/mongoose": "5.7.6",
|
||||
"@types/mocha": "7.0.2",
|
||||
"@types/mongoose": "5.7.7",
|
||||
"@types/node": "10.17.3",
|
||||
"@types/redis": "2.8.16",
|
||||
"@types/reflect-metadata": "0.0.5",
|
||||
"@types/sinon": "7.5.2",
|
||||
"@types/socket.io": "2.1.4",
|
||||
"@types/ws": "7.2.2",
|
||||
"@typescript-eslint/eslint-plugin": "2.23.0",
|
||||
"@typescript-eslint/parser": "2.23.0",
|
||||
"@types/ws": "7.2.3",
|
||||
"@typescript-eslint/eslint-plugin": "2.25.0",
|
||||
"@typescript-eslint/parser": "2.25.0",
|
||||
"amqp-connection-manager": "3.2.0",
|
||||
"amqplib": "0.5.5",
|
||||
"apollo-server-express": "2.11.0",
|
||||
"artillery": "1.6.0-29",
|
||||
"artillery": "1.6.0",
|
||||
"awesome-typescript-loader": "5.2.1",
|
||||
"body-parser": "1.19.0",
|
||||
"bytes": "3.1.0",
|
||||
"cache-manager": "3.2.0",
|
||||
"cache-manager": "3.2.1",
|
||||
"chai": "4.2.0",
|
||||
"chai-as-promised": "7.1.1",
|
||||
"clang-format": "1.4.0",
|
||||
@@ -112,14 +112,14 @@
|
||||
"concurrently": "5.1.0",
|
||||
"conventional-changelog": "3.1.18",
|
||||
"core-js": "3.6.4",
|
||||
"coveralls": "3.0.9",
|
||||
"coveralls": "3.0.11",
|
||||
"delete-empty": "3.0.0",
|
||||
"engine.io-client": "3.4.0",
|
||||
"eslint": "6.8.0",
|
||||
"eslint-config-prettier": "6.10.0",
|
||||
"eslint-config-prettier": "6.10.1",
|
||||
"eslint-plugin-import": "2.20.1",
|
||||
"fancy-log": "1.3.3",
|
||||
"fastify": "2.12.1",
|
||||
"fastify": "2.13.0",
|
||||
"fastify-cors": "3.0.2",
|
||||
"fastify-formbody": "3.1.0",
|
||||
"fastify-multipart": "1.0.5",
|
||||
@@ -138,18 +138,18 @@
|
||||
"json-loader": "0.5.7",
|
||||
"kafkajs": "1.12.0",
|
||||
"lerna": "2.11.0",
|
||||
"lint-staged": "10.0.8",
|
||||
"lint-staged": "10.0.9",
|
||||
"markdown-table": "2.0.0",
|
||||
"merge-graphql-schemas": "1.7.6",
|
||||
"mocha": "7.0.1",
|
||||
"mongoose": "5.9.4",
|
||||
"mocha": "7.1.1",
|
||||
"mongoose": "5.9.6",
|
||||
"mqtt": "3.0.0",
|
||||
"multer": "1.4.2",
|
||||
"mysql": "2.18.1",
|
||||
"nats": "1.4.2",
|
||||
"nats": "1.4.8",
|
||||
"nodemon": "2.0.2",
|
||||
"nyc": "15.0.0",
|
||||
"prettier": "1.19.1",
|
||||
"prettier": "2.0.2",
|
||||
"redis": "3.0.2",
|
||||
"rxjs-compat": "6.5.4",
|
||||
"sinon": "9.0.1",
|
||||
@@ -158,7 +158,7 @@
|
||||
"subscriptions-transport-ws": "0.9.16",
|
||||
"supertest": "4.0.2",
|
||||
"ts-morph": "7.0.0",
|
||||
"ts-node": "8.6.2",
|
||||
"ts-node": "8.8.1",
|
||||
"typeorm": "0.2.24",
|
||||
"typescript": "3.7.2",
|
||||
"wrk": "1.2.0",
|
||||
|
||||
@@ -31,7 +31,7 @@ Nest is a framework for building efficient, scalable <a href="http://nodejs.org"
|
||||
## Philosophy
|
||||
|
||||
<p>In recent years, thanks to Node.js, JavaScript has become the “lingua franca” of the web for both front and backend applications, giving rise to awesome projects like <a href="https://angular.io/" target="_blank">Angular</a>, <a href="https://github.com/facebook/react" target="_blank">React</a> and <a href="https://github.com/vuejs/vue" target="_blank">Vue</a> which improve developer productivity and enable the construction of fast, testable, extensible frontend applications. However, on the server-side, while there are a lot of superb libraries, helpers and tools for Node, none of them effectively solve the main problem - the architecture.</p>
|
||||
<p>Nest aims to provide an application architecture out of the box which allows for effortless creation of highly testable, scalable, loosely coupled and easily maintainable applications.</p>
|
||||
<p>Nest aims to provide an application architecture out of the box which allows for effortless creation of highly testable, scalable, loosely coupled and easily maintainable applications. The architecture is heavily inspired by Angular.</p>
|
||||
|
||||
## Getting started
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ export function flatten<T extends Array<unknown> = any>(
|
||||
}
|
||||
|
||||
/**
|
||||
* Decorator that sets required dependencies (required with a vanilla JavaScript pjects)
|
||||
* Decorator that sets required dependencies (required with a vanilla JavaScript objects)
|
||||
*/
|
||||
export const Dependencies = (
|
||||
...dependencies: Array<unknown>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { HttpException } from './http.exception';
|
||||
import { HttpStatus } from '../enums/http-status.enum';
|
||||
import { HttpException } from './http.exception';
|
||||
|
||||
/**
|
||||
* Defines an HTTP exception for *Bad Gateway* type errors.
|
||||
@@ -17,25 +17,32 @@ export class BadGatewayException extends HttpException {
|
||||
*
|
||||
* @usageNotes
|
||||
* The HTTP response status code will be 502.
|
||||
* - The `objectOrError` argument defines the JSON response body or the error string.
|
||||
* - The `message` argument contains a short description of the HTTP error.
|
||||
* - The `objectOrError` argument defines the JSON response body or the message string.
|
||||
* - The `description` argument contains a short description of the HTTP error.
|
||||
*
|
||||
* By default, the JSON response body contains two properties:
|
||||
* - `statusCode`: this will be the value 502.
|
||||
* - `message`: the string `'Bad Gateway'` by default; override this by supplying
|
||||
* a string in the `message` parameter.
|
||||
* a string in the `objectOrError` parameter.
|
||||
*
|
||||
* If the parameter `objectOrError` is a string, the response body will contain an
|
||||
* additional property, `error`, containing the given string. To override the
|
||||
* additional property, `error`, with a short description of the HTTP error. To override the
|
||||
* entire JSON response body, pass an object instead. Nest will serialize the object
|
||||
* and return it as the JSON response body.
|
||||
*
|
||||
* @param objectOrError string or object describing the error condition.
|
||||
* @param message a short description of the HTTP error.
|
||||
* @param description a short description of the HTTP error.
|
||||
*/
|
||||
constructor(objectOrError?: string | object | any, message = 'Bad Gateway') {
|
||||
constructor(
|
||||
objectOrError?: string | object | any,
|
||||
description = 'Bad Gateway',
|
||||
) {
|
||||
super(
|
||||
HttpException.createBody(objectOrError, message, HttpStatus.BAD_GATEWAY),
|
||||
HttpException.createBody(
|
||||
objectOrError,
|
||||
description,
|
||||
HttpStatus.BAD_GATEWAY,
|
||||
),
|
||||
HttpStatus.BAD_GATEWAY,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { HttpException } from './http.exception';
|
||||
import { HttpStatus } from '../enums/http-status.enum';
|
||||
import { HttpException } from './http.exception';
|
||||
|
||||
/**
|
||||
* Defines an HTTP exception for *Bad Request* type errors.
|
||||
@@ -17,25 +17,32 @@ export class BadRequestException extends HttpException {
|
||||
*
|
||||
* @usageNotes
|
||||
* The HTTP response status code will be 400.
|
||||
* - The `objectOrError` argument defines the JSON response body or the error string.
|
||||
* - The `message` argument contains a short description of the HTTP error.
|
||||
* - The `objectOrError` argument defines the JSON response body or the message string.
|
||||
* - The `description` argument contains a short description of the HTTP error.
|
||||
*
|
||||
* By default, the JSON response body contains two properties:
|
||||
* - `statusCode`: this will be the value 400.
|
||||
* - `message`: the string `'Bad Request'` by default; override this by supplying
|
||||
* a string in the `message` parameter.
|
||||
* a string in the `objectOrError` parameter.
|
||||
*
|
||||
* If the parameter `objectOrError` is a string, the response body will contain an
|
||||
* additional property, `error`, containing the given string. To override the
|
||||
* additional property, `error`, with a short description of the HTTP error. To override the
|
||||
* entire JSON response body, pass an object instead. Nest will serialize the object
|
||||
* and return it as the JSON response body.
|
||||
*
|
||||
* @param objectOrError string or object describing the error condition.
|
||||
* @param message a short description of the HTTP error.
|
||||
* @param description a short description of the HTTP error.
|
||||
*/
|
||||
constructor(objectOrError?: string | object | any, message = 'Bad Request') {
|
||||
constructor(
|
||||
objectOrError?: string | object | any,
|
||||
description = 'Bad Request',
|
||||
) {
|
||||
super(
|
||||
HttpException.createBody(objectOrError, message, HttpStatus.BAD_REQUEST),
|
||||
HttpException.createBody(
|
||||
objectOrError,
|
||||
description,
|
||||
HttpStatus.BAD_REQUEST,
|
||||
),
|
||||
HttpStatus.BAD_REQUEST,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { HttpException } from './http.exception';
|
||||
import { HttpStatus } from '../enums/http-status.enum';
|
||||
import { HttpException } from './http.exception';
|
||||
|
||||
/**
|
||||
* Defines an HTTP exception for *Conflict* type errors.
|
||||
@@ -17,25 +17,25 @@ export class ConflictException extends HttpException {
|
||||
*
|
||||
* @usageNotes
|
||||
* The HTTP response status code will be 409.
|
||||
* - The `objectOrError` argument defines the JSON response body or the error string.
|
||||
* - The `message` argument contains a short description of the HTTP error.
|
||||
* - The `objectOrError` argument defines the JSON response body or the message string.
|
||||
* - The `description` argument contains a short description of the HTTP error.
|
||||
*
|
||||
* By default, the JSON response body contains two properties:
|
||||
* - `statusCode`: this will be the value 409.
|
||||
* - `message`: the string `'Conflict'` by default; override this by supplying
|
||||
* a string in the `message` parameter.
|
||||
* a string in the `objectOrError` parameter.
|
||||
*
|
||||
* If the parameter `objectOrError` is a string, the response body will contain an
|
||||
* additional property, `error`, containing the given string. To override the
|
||||
* additional property, `error`, with a short description of the HTTP error. To override the
|
||||
* entire JSON response body, pass an object instead. Nest will serialize the object
|
||||
* and return it as the JSON response body.
|
||||
*
|
||||
* @param objectOrError string or object describing the error condition.
|
||||
* @param message a short description of the HTTP error.
|
||||
* @param description a short description of the HTTP error.
|
||||
*/
|
||||
constructor(objectOrError?: string | object | any, message = 'Conflict') {
|
||||
constructor(objectOrError?: string | object | any, description = 'Conflict') {
|
||||
super(
|
||||
HttpException.createBody(objectOrError, message, HttpStatus.CONFLICT),
|
||||
HttpException.createBody(objectOrError, description, HttpStatus.CONFLICT),
|
||||
HttpStatus.CONFLICT,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { HttpException } from './http.exception';
|
||||
import { HttpStatus } from '../enums/http-status.enum';
|
||||
import { HttpException } from './http.exception';
|
||||
|
||||
/**
|
||||
* Defines an HTTP exception for *Forbidden* type errors.
|
||||
@@ -17,25 +17,32 @@ export class ForbiddenException extends HttpException {
|
||||
*
|
||||
* @usageNotes
|
||||
* The HTTP response status code will be 403.
|
||||
* - The `objectOrError` argument defines the JSON response body or the error string.
|
||||
* - The `message` argument contains a short description of the HTTP error.
|
||||
* - The `objectOrError` argument defines the JSON response body or the message string.
|
||||
* - The `description` argument contains a short description of the HTTP error.
|
||||
*
|
||||
* By default, the JSON response body contains two properties:
|
||||
* - `statusCode`: this will be the value 403.
|
||||
* - `message`: the string `'Forbidden'` by default; override this by supplying
|
||||
* a string in the `message` parameter.
|
||||
* a string in the `objectOrError` parameter.
|
||||
*
|
||||
* If the parameter `objectOrError` is a string, the response body will contain an
|
||||
* additional property, `error`, containing the given string. To override the
|
||||
* additional property, `error`, with a short description of the HTTP error. To override the
|
||||
* entire JSON response body, pass an object instead. Nest will serialize the object
|
||||
* and return it as the JSON response body.
|
||||
*
|
||||
* @param objectOrError string or object describing the error condition.
|
||||
* @param message a short description of the HTTP error.
|
||||
* @param description a short description of the HTTP error.
|
||||
*/
|
||||
constructor(objectOrError?: string | object | any, message = 'Forbidden') {
|
||||
constructor(
|
||||
objectOrError?: string | object | any,
|
||||
description = 'Forbidden',
|
||||
) {
|
||||
super(
|
||||
HttpException.createBody(objectOrError, message, HttpStatus.FORBIDDEN),
|
||||
HttpException.createBody(
|
||||
objectOrError,
|
||||
description,
|
||||
HttpStatus.FORBIDDEN,
|
||||
),
|
||||
HttpStatus.FORBIDDEN,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { HttpException } from './http.exception';
|
||||
import { HttpStatus } from '../enums/http-status.enum';
|
||||
import { HttpException } from './http.exception';
|
||||
|
||||
/**
|
||||
* Defines an HTTP exception for *Gatway Timeout* type errors.
|
||||
@@ -17,30 +17,30 @@ export class GatewayTimeoutException extends HttpException {
|
||||
*
|
||||
* @usageNotes
|
||||
* The HTTP response status code will be 504.
|
||||
* - The `objectOrError` argument defines the JSON response body or the error string.
|
||||
* - The `message` argument contains a short description of the HTTP error.
|
||||
* - The `objectOrError` argument defines the JSON response body or the message string.
|
||||
* - The `description` argument contains a short description of the HTTP error.
|
||||
*
|
||||
* By default, the JSON response body contains two properties:
|
||||
* - `statusCode`: this will be the value 504.
|
||||
* - `message`: the string `'Gateway Timeout'` by default; override this by supplying
|
||||
* a string in the `message` parameter.
|
||||
* a string in the `objectOrError` parameter.
|
||||
*
|
||||
* If the parameter `objectOrError` is a string, the response body will contain an
|
||||
* additional property, `error`, containing the given string. To override the
|
||||
* additional property, `error`, with a short description of the HTTP error. To override the
|
||||
* entire JSON response body, pass an object instead. Nest will serialize the object
|
||||
* and return it as the JSON response body.
|
||||
*
|
||||
* @param objectOrError string or object describing the error condition.
|
||||
* @param message a short description of the HTTP error.
|
||||
* @param description a short description of the HTTP error.
|
||||
*/
|
||||
constructor(
|
||||
objectOrError?: string | object | any,
|
||||
message = 'Gateway Timeout',
|
||||
description = 'Gateway Timeout',
|
||||
) {
|
||||
super(
|
||||
HttpException.createBody(
|
||||
objectOrError,
|
||||
message,
|
||||
description,
|
||||
HttpStatus.GATEWAY_TIMEOUT,
|
||||
),
|
||||
HttpStatus.GATEWAY_TIMEOUT,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { HttpException } from './http.exception';
|
||||
import { HttpStatus } from '../enums/http-status.enum';
|
||||
import { HttpException } from './http.exception';
|
||||
|
||||
/**
|
||||
* Defines an HTTP exception for *Gone* type errors.
|
||||
@@ -17,25 +17,25 @@ export class GoneException extends HttpException {
|
||||
*
|
||||
* @usageNotes
|
||||
* The HTTP response status code will be 410.
|
||||
* - The `objectOrError` argument defines the JSON response body or the error string.
|
||||
* - The `message` argument contains a short description of the HTTP error.
|
||||
* - The `objectOrError` argument defines the JSON response body or the message string.
|
||||
* - The `description` argument contains a short description of the HTTP error.
|
||||
*
|
||||
* By default, the JSON response body contains two properties:
|
||||
* - `statusCode`: this will be the value 410.
|
||||
* - `message`: the string `'Gone'` by default; override this by supplying
|
||||
* a string in the `message` parameter.
|
||||
* a string in the `objectOrError` parameter.
|
||||
*
|
||||
* If the parameter `objectOrError` is a string, the response body will contain an
|
||||
* additional property, `error`, containing the given string. To override the
|
||||
* additional property, `error`, with a short description of the HTTP error. To override the
|
||||
* entire JSON response body, pass an object instead. Nest will serialize the object
|
||||
* and return it as the JSON response body.
|
||||
*
|
||||
* @param objectOrError string or object describing the error condition.
|
||||
* @param message a short description of the HTTP error.
|
||||
* @param description a short description of the HTTP error.
|
||||
*/
|
||||
constructor(objectOrError?: string | object | any, message = 'Gone') {
|
||||
constructor(objectOrError?: string | object | any, description = 'Gone') {
|
||||
super(
|
||||
HttpException.createBody(objectOrError, message, HttpStatus.GONE),
|
||||
HttpException.createBody(objectOrError, description, HttpStatus.GONE),
|
||||
HttpStatus.GONE,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { HttpException } from './http.exception';
|
||||
import { HttpStatus } from '../enums/http-status.enum';
|
||||
import { HttpException } from './http.exception';
|
||||
|
||||
/**
|
||||
* Defines an HTTP exception for *Http Version Not Supported* type errors.
|
||||
@@ -17,30 +17,30 @@ export class HttpVersionNotSupportedException extends HttpException {
|
||||
*
|
||||
* @usageNotes
|
||||
* The HTTP response status code will be 505.
|
||||
* - The `objectOrError` argument defines the JSON response body or the error string.
|
||||
* - The `message` argument contains a short description of the HTTP error.
|
||||
* - The `objectOrError` argument defines the JSON response body or the message string.
|
||||
* - The `description` argument contains a short description of the HTTP error.
|
||||
*
|
||||
* By default, the JSON response body contains two properties:
|
||||
* - `statusCode`: this will be the value 505.
|
||||
* - `message`: the string `'HTTP Version Not Supported'` by default; override this by supplying
|
||||
* a string in the `message` parameter.
|
||||
* a string in the `objectOrError` parameter.
|
||||
*
|
||||
* If the parameter `objectOrError` is a string, the response body will contain an
|
||||
* additional property, `error`, containing the given string. To override the
|
||||
* additional property, `error`, with a short description of the HTTP error. To override the
|
||||
* entire JSON response body, pass an object instead. Nest will serialize the object
|
||||
* and return it as the JSON response body.
|
||||
*
|
||||
* @param objectOrError string or object describing the error condition.
|
||||
* @param message a short description of the HTTP error.
|
||||
* @param description a short description of the HTTP error.
|
||||
*/
|
||||
constructor(
|
||||
objectOrError?: string | object | any,
|
||||
message = 'HTTP Version Not Supported',
|
||||
description = 'HTTP Version Not Supported',
|
||||
) {
|
||||
super(
|
||||
HttpException.createBody(
|
||||
objectOrError,
|
||||
message,
|
||||
description,
|
||||
HttpStatus.HTTP_VERSION_NOT_SUPPORTED,
|
||||
),
|
||||
HttpStatus.HTTP_VERSION_NOT_SUPPORTED,
|
||||
|
||||
@@ -20,27 +20,30 @@ export class ImATeapotException extends HttpException {
|
||||
*
|
||||
* @usageNotes
|
||||
* The HTTP response status code will be 418.
|
||||
* - The `objectOrError` argument defines the JSON response body or the error string.
|
||||
* - The `message` argument contains a short description of the HTTP error.
|
||||
* - The `objectOrError` argument defines the JSON response body or the message string.
|
||||
* - The `description` argument contains a short description of the HTTP error.
|
||||
*
|
||||
* By default, the JSON response body contains two properties:
|
||||
* - `statusCode`: this will be the value 418.
|
||||
* - `message`: the string `"I'm a Teapot"` by default; override this by supplying
|
||||
* a string in the `message` parameter.
|
||||
* a string in the `objectOrError` parameter.
|
||||
*
|
||||
* If the parameter `objectOrError` is a string, the response body will contain an
|
||||
* additional property, `error`, containing the given string. To override the
|
||||
* additional property, `error`, with a short description of the HTTP error. To override the
|
||||
* entire JSON response body, pass an object instead. Nest will serialize the object
|
||||
* and return it as the JSON response body.
|
||||
*
|
||||
* @param objectOrError string or object describing the error condition.
|
||||
* @param message a short description of the HTTP error.
|
||||
* @param description a short description of the HTTP error.
|
||||
*/
|
||||
constructor(objectOrError?: string | object | any, message = `I'm a teapot`) {
|
||||
constructor(
|
||||
objectOrError?: string | object | any,
|
||||
description = `I'm a teapot`,
|
||||
) {
|
||||
super(
|
||||
HttpException.createBody(
|
||||
objectOrError,
|
||||
message,
|
||||
description,
|
||||
HttpStatus.I_AM_A_TEAPOT,
|
||||
),
|
||||
HttpStatus.I_AM_A_TEAPOT,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { HttpException } from './http.exception';
|
||||
import { HttpStatus } from '../enums/http-status.enum';
|
||||
import { HttpException } from './http.exception';
|
||||
|
||||
/**
|
||||
* Defines an HTTP exception for *Internal Server Error* type errors.
|
||||
@@ -17,30 +17,30 @@ export class InternalServerErrorException extends HttpException {
|
||||
*
|
||||
* @usageNotes
|
||||
* The HTTP response status code will be 500.
|
||||
* - The `objectOrError` argument defines the JSON response body or the error string.
|
||||
* - The `message` argument contains a short description of the HTTP error.
|
||||
* - The `objectOrError` argument defines the JSON response body or the message string.
|
||||
* - The `description` argument contains a short description of the HTTP error.
|
||||
*
|
||||
* By default, the JSON response body contains two properties:
|
||||
* - `statusCode`: this will be the value 500.
|
||||
* - `message`: the string `'Internal Server Error'` by default; override this by supplying
|
||||
* a string in the `message` parameter.
|
||||
* a string in the `objectOrError` parameter.
|
||||
*
|
||||
* If the parameter `objectOrError` is a string, the response body will contain an
|
||||
* additional property, `error`, containing the given string. To override the
|
||||
* additional property, `error`, with a short description of the HTTP error. To override the
|
||||
* entire JSON response body, pass an object instead. Nest will serialize the object
|
||||
* and return it as the JSON response body.
|
||||
*
|
||||
* @param objectOrError string or object describing the error condition.
|
||||
* @param message a short description of the HTTP error.
|
||||
* @param description a short description of the HTTP error.
|
||||
*/
|
||||
constructor(
|
||||
objectOrError?: string | object | any,
|
||||
message = 'Internal Server Error',
|
||||
description = 'Internal Server Error',
|
||||
) {
|
||||
super(
|
||||
HttpException.createBody(
|
||||
objectOrError,
|
||||
message,
|
||||
description,
|
||||
HttpStatus.INTERNAL_SERVER_ERROR,
|
||||
),
|
||||
HttpStatus.INTERNAL_SERVER_ERROR,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { HttpException } from './http.exception';
|
||||
import { HttpStatus } from '../enums/http-status.enum';
|
||||
import { HttpException } from './http.exception';
|
||||
|
||||
/**
|
||||
* Defines an HTTP exception for *Method Not Allowed* type errors.
|
||||
@@ -17,30 +17,30 @@ export class MethodNotAllowedException extends HttpException {
|
||||
*
|
||||
* @usageNotes
|
||||
* The HTTP response status code will be 405.
|
||||
* - The `objectOrError` argument defines the JSON response body or the error string.
|
||||
* - The `message` argument contains a short description of the HTTP error.
|
||||
* - The `objectOrError` argument defines the JSON response body or the message string.
|
||||
* - The `description` argument contains a short description of the HTTP error.
|
||||
*
|
||||
* By default, the JSON response body contains two properties:
|
||||
* - `statusCode`: this will be the value 405.
|
||||
* - `message`: the string `'Method Not Allowed'` by default; override this by supplying
|
||||
* a string in the `message` parameter.
|
||||
* a string in the `objectOrError` parameter.
|
||||
*
|
||||
* If the parameter `objectOrError` is a string, the response body will contain an
|
||||
* additional property, `error`, containing the given string. To override the
|
||||
* additional property, `error`, with a short description of the HTTP error. To override the
|
||||
* entire JSON response body, pass an object instead. Nest will serialize the object
|
||||
* and return it as the JSON response body.
|
||||
*
|
||||
* @param objectOrError string or object describing the error condition.
|
||||
* @param message a short description of the HTTP error.
|
||||
* @param description a short description of the HTTP error.
|
||||
*/
|
||||
constructor(
|
||||
objectOrError?: string | object | any,
|
||||
message = 'Method Not Allowed',
|
||||
description = 'Method Not Allowed',
|
||||
) {
|
||||
super(
|
||||
HttpException.createBody(
|
||||
objectOrError,
|
||||
message,
|
||||
description,
|
||||
HttpStatus.METHOD_NOT_ALLOWED,
|
||||
),
|
||||
HttpStatus.METHOD_NOT_ALLOWED,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { HttpException } from './http.exception';
|
||||
import { HttpStatus } from '../enums/http-status.enum';
|
||||
import { HttpException } from './http.exception';
|
||||
|
||||
/**
|
||||
* Defines an HTTP exception for *Not Acceptable* type errors.
|
||||
@@ -17,8 +17,8 @@ export class NotAcceptableException extends HttpException {
|
||||
*
|
||||
* @usageNotes
|
||||
* The HTTP response status code will be 406.
|
||||
* - The `objectOrError` argument defines the JSON response body or the error string.
|
||||
* - The `message` argument contains a short description of the HTTP error.
|
||||
* - The `objectOrError` argument defines the JSON response body or the message string.
|
||||
* - The `description` argument contains a short description of the HTTP error.
|
||||
*
|
||||
* By default, the JSON response body contains two properties:
|
||||
* - `statusCode`: this will be the value 406.
|
||||
@@ -26,21 +26,21 @@ export class NotAcceptableException extends HttpException {
|
||||
* a string in the `error` parameter.
|
||||
*
|
||||
* If the parameter `objectOrError` is a string, the response body will contain an
|
||||
* additional property, `error`, containing the given string. To override the
|
||||
* additional property, `error`, with a short description of the HTTP error. To override the
|
||||
* entire JSON response body, pass an object instead. Nest will serialize the object
|
||||
* and return it as the JSON response body.
|
||||
*
|
||||
* @param objectOrError string or object describing the error condition.
|
||||
* @param message a short description of the HTTP error.
|
||||
* @param description a short description of the HTTP error.
|
||||
*/
|
||||
constructor(
|
||||
objectOrError?: string | object | any,
|
||||
message = 'Not Acceptable',
|
||||
description = 'Not Acceptable',
|
||||
) {
|
||||
super(
|
||||
HttpException.createBody(
|
||||
objectOrError,
|
||||
message,
|
||||
description,
|
||||
HttpStatus.NOT_ACCEPTABLE,
|
||||
),
|
||||
HttpStatus.NOT_ACCEPTABLE,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { HttpException } from './http.exception';
|
||||
import { HttpStatus } from '../enums/http-status.enum';
|
||||
import { HttpException } from './http.exception';
|
||||
|
||||
/**
|
||||
* Defines an HTTP exception for *Not Found* type errors.
|
||||
@@ -17,25 +17,32 @@ export class NotFoundException extends HttpException {
|
||||
*
|
||||
* @usageNotes
|
||||
* The HTTP response status code will be 404.
|
||||
* - The `objectOrError` argument defines the JSON response body or the error string.
|
||||
* - The `message` argument contains a short description of the HTTP error.
|
||||
* - The `objectOrError` argument defines the JSON response body or the message string.
|
||||
* - The `description` argument contains a short description of the HTTP error.
|
||||
*
|
||||
* By default, the JSON response body contains two properties:
|
||||
* - `statusCode`: this will be the value 404.
|
||||
* - `message`: the string `'Not Found'` by default; override this by supplying
|
||||
* a string in the `message` parameter.
|
||||
* a string in the `objectOrError` parameter.
|
||||
*
|
||||
* If the parameter `objectOrError` is a string, the response body will contain an
|
||||
* additional property, `error`, containing the given string. To override the
|
||||
* additional property, `error`, with a short description of the HTTP error. To override the
|
||||
* entire JSON response body, pass an object instead. Nest will serialize the object
|
||||
* and return it as the JSON response body.
|
||||
*
|
||||
* @param objectOrError string or object describing the error condition.
|
||||
* @param message a short description of the HTTP error.
|
||||
* @param description a short description of the HTTP error.
|
||||
*/
|
||||
constructor(objectOrError?: string | object | any, message = 'Not Found') {
|
||||
constructor(
|
||||
objectOrError?: string | object | any,
|
||||
description = 'Not Found',
|
||||
) {
|
||||
super(
|
||||
HttpException.createBody(objectOrError, message, HttpStatus.NOT_FOUND),
|
||||
HttpException.createBody(
|
||||
objectOrError,
|
||||
description,
|
||||
HttpStatus.NOT_FOUND,
|
||||
),
|
||||
HttpStatus.NOT_FOUND,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { HttpException } from './http.exception';
|
||||
import { HttpStatus } from '../enums/http-status.enum';
|
||||
import { HttpException } from './http.exception';
|
||||
|
||||
/**
|
||||
* Defines an HTTP exception for *Not Implemented* type errors.
|
||||
@@ -17,30 +17,30 @@ export class NotImplementedException extends HttpException {
|
||||
*
|
||||
* @usageNotes
|
||||
* The HTTP response status code will be 501.
|
||||
* - The `objectOrError` argument defines the JSON response body or the error string.
|
||||
* - The `message` argument contains a short description of the HTTP error.
|
||||
* - The `objectOrError` argument defines the JSON response body or the message string.
|
||||
* - The `description` argument contains a short description of the HTTP error.
|
||||
*
|
||||
* By default, the JSON response body contains two properties:
|
||||
* - `statusCode`: this will be the value 501.
|
||||
* - `message`: the string `'Not Implemented'` by default; override this by supplying
|
||||
* a string in the `message` parameter.
|
||||
* a string in the `objectOrError` parameter.
|
||||
*
|
||||
* If the parameter `objectOrError` is a string, the response body will contain an
|
||||
* additional property, `error`, containing the given string. To override the
|
||||
* additional property, `error`, with a short description of the HTTP error. To override the
|
||||
* entire JSON response body, pass an object instead. Nest will serialize the object
|
||||
* and return it as the JSON response body.
|
||||
*
|
||||
* @param message string or object describing the error condition.
|
||||
* @param description string or object describing the error condition.
|
||||
* @param error a short description of the HTTP error.
|
||||
*/
|
||||
constructor(
|
||||
objectOrError?: string | object | any,
|
||||
message = 'Not Implemented',
|
||||
description = 'Not Implemented',
|
||||
) {
|
||||
super(
|
||||
HttpException.createBody(
|
||||
objectOrError,
|
||||
message,
|
||||
description,
|
||||
HttpStatus.NOT_IMPLEMENTED,
|
||||
),
|
||||
HttpStatus.NOT_IMPLEMENTED,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { HttpException } from './http.exception';
|
||||
import { HttpStatus } from '../enums/http-status.enum';
|
||||
import { HttpException } from './http.exception';
|
||||
|
||||
/**
|
||||
* Defines an HTTP exception for *Payload Too Large* type errors.
|
||||
@@ -17,30 +17,30 @@ export class PayloadTooLargeException extends HttpException {
|
||||
*
|
||||
* @usageNotes
|
||||
* The HTTP response status code will be 413.
|
||||
* - The `objectOrError` argument defines the JSON response body or the error string.
|
||||
* - The `message` argument contains a short description of the HTTP error.
|
||||
* - The `objectOrError` argument defines the JSON response body or the message string.
|
||||
* - The `description` argument contains a short description of the HTTP error.
|
||||
*
|
||||
* By default, the JSON response body contains two properties:
|
||||
* - `statusCode`: this will be the value 413.
|
||||
* - `message`: the string `'Payload Too Large'` by default; override this by supplying
|
||||
* a string in the `message` parameter.
|
||||
* a string in the `objectOrError` parameter.
|
||||
*
|
||||
* If the parameter `objectOrError` is a string, the response body will contain an
|
||||
* additional property, `error`, containing the given string. To override the
|
||||
* additional property, `error`, with a short description of the HTTP error. To override the
|
||||
* entire JSON response body, pass an object instead. Nest will serialize the object
|
||||
* and return it as the JSON response body.
|
||||
*
|
||||
* @param objectOrError string or object describing the error condition.
|
||||
* @param message a short description of the HTTP error.
|
||||
* @param description a short description of the HTTP error.
|
||||
*/
|
||||
constructor(
|
||||
objectOrError?: string | object | any,
|
||||
message = 'Payload Too Large',
|
||||
description = 'Payload Too Large',
|
||||
) {
|
||||
super(
|
||||
HttpException.createBody(
|
||||
objectOrError,
|
||||
message,
|
||||
description,
|
||||
HttpStatus.PAYLOAD_TOO_LARGE,
|
||||
),
|
||||
HttpStatus.PAYLOAD_TOO_LARGE,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { HttpException } from './http.exception';
|
||||
import { HttpStatus } from '../enums/http-status.enum';
|
||||
import { HttpException } from './http.exception';
|
||||
|
||||
/**
|
||||
* Defines an HTTP exception for *Request Timeout* type errors.
|
||||
@@ -17,30 +17,30 @@ export class RequestTimeoutException extends HttpException {
|
||||
*
|
||||
* @usageNotes
|
||||
* The HTTP response status code will be 408.
|
||||
* - The `objectOrError` argument defines the JSON response body or the error string.
|
||||
* - The `message` argument contains a short description of the HTTP error.
|
||||
* - The `objectOrError` argument defines the JSON response body or the message string.
|
||||
* - The `description` argument contains a short description of the HTTP error.
|
||||
*
|
||||
* By default, the JSON response body contains two properties:
|
||||
* - `statusCode`: this will be the value 408.
|
||||
* - `message`: the string `'Request Timeout'` by default; override this by supplying
|
||||
* a string in the `message` parameter.
|
||||
* a string in the `objectOrError` parameter.
|
||||
*
|
||||
* If the parameter `objectOrError` is a string, the response body will contain an
|
||||
* additional property, `error`, containing the given string. To override the
|
||||
* additional property, `error`, with a short description of the HTTP error. To override the
|
||||
* entire JSON response body, pass an object instead. Nest will serialize the object
|
||||
* and return it as the JSON response body.
|
||||
*
|
||||
* @param objectOrError string or object describing the error condition.
|
||||
* @param message a short description of the HTTP error.
|
||||
* @param description a short description of the HTTP error.
|
||||
*/
|
||||
constructor(
|
||||
objectOrError?: string | object | any,
|
||||
message = 'Request Timeout',
|
||||
description = 'Request Timeout',
|
||||
) {
|
||||
super(
|
||||
HttpException.createBody(
|
||||
objectOrError,
|
||||
message,
|
||||
description,
|
||||
HttpStatus.REQUEST_TIMEOUT,
|
||||
),
|
||||
HttpStatus.REQUEST_TIMEOUT,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { HttpException } from './http.exception';
|
||||
import { HttpStatus } from '../enums/http-status.enum';
|
||||
import { HttpException } from './http.exception';
|
||||
|
||||
/**
|
||||
* Defines an HTTP exception for *Service Unavailable* type errors.
|
||||
@@ -17,30 +17,30 @@ export class ServiceUnavailableException extends HttpException {
|
||||
*
|
||||
* @usageNotes
|
||||
* The HTTP response status code will be 503.
|
||||
* - The `objectOrError` argument defines the JSON response body or the error string.
|
||||
* - The `message` argument contains a short description of the HTTP error.
|
||||
* - The `objectOrError` argument defines the JSON response body or the message string.
|
||||
* - The `description` argument contains a short description of the HTTP error.
|
||||
*
|
||||
* By default, the JSON response body contains two properties:
|
||||
* - `statusCode`: this will be the value 503.
|
||||
* - `message`: the string `'Service Unavailable'` by default; override this by supplying
|
||||
* a string in the `message` parameter.
|
||||
* a string in the `objectOrError` parameter.
|
||||
*
|
||||
* If the parameter `objectOrError` is a string, the response body will contain an
|
||||
* additional property, `error`, containing the given string. To override the
|
||||
* additional property, `error`, with a short description of the HTTP error. To override the
|
||||
* entire JSON response body, pass an object instead. Nest will serialize the object
|
||||
* and return it as the JSON response body.
|
||||
*
|
||||
* @param objectOrError string or object describing the error condition.
|
||||
* @param message a short description of the HTTP error.
|
||||
* @param description a short description of the HTTP error.
|
||||
*/
|
||||
constructor(
|
||||
objectOrError?: string | object | any,
|
||||
message = 'Service Unavailable',
|
||||
description = 'Service Unavailable',
|
||||
) {
|
||||
super(
|
||||
HttpException.createBody(
|
||||
objectOrError,
|
||||
message,
|
||||
description,
|
||||
HttpStatus.SERVICE_UNAVAILABLE,
|
||||
),
|
||||
HttpStatus.SERVICE_UNAVAILABLE,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { HttpException } from './http.exception';
|
||||
import { HttpStatus } from '../enums/http-status.enum';
|
||||
import { HttpException } from './http.exception';
|
||||
|
||||
/**
|
||||
* Defines an HTTP exception for *Unauthorized* type errors.
|
||||
@@ -17,25 +17,32 @@ export class UnauthorizedException extends HttpException {
|
||||
*
|
||||
* @usageNotes
|
||||
* The HTTP response status code will be 401.
|
||||
* - The `objectOrError` argument defines the JSON response body or the error string.
|
||||
* - The `message` argument contains a short description of the HTTP error.
|
||||
* - The `objectOrError` argument defines the JSON response body or the message string.
|
||||
* - The `description` argument contains a short description of the HTTP error.
|
||||
*
|
||||
* By default, the JSON response body contains two properties:
|
||||
* - `statusCode`: this will be the value 401.
|
||||
* - `message`: the string `'Unauthorized'` by default; override this by supplying
|
||||
* a string in the `message` parameter.
|
||||
* a string in the `objectOrError` parameter.
|
||||
*
|
||||
* If the parameter `objectOrError` is a string, the response body will contain an
|
||||
* additional property, `error`, containing the given string. To override the
|
||||
* additional property, `error`, with a short description of the HTTP error. To override the
|
||||
* entire JSON response body, pass an object instead. Nest will serialize the object
|
||||
* and return it as the JSON response body.
|
||||
*
|
||||
* @param objectOrError string or object describing the error condition.
|
||||
* @param message a short description of the HTTP error.
|
||||
* @param description a short description of the HTTP error.
|
||||
*/
|
||||
constructor(objectOrError?: string | object | any, message = 'Unauthorized') {
|
||||
constructor(
|
||||
objectOrError?: string | object | any,
|
||||
description = 'Unauthorized',
|
||||
) {
|
||||
super(
|
||||
HttpException.createBody(objectOrError, message, HttpStatus.UNAUTHORIZED),
|
||||
HttpException.createBody(
|
||||
objectOrError,
|
||||
description,
|
||||
HttpStatus.UNAUTHORIZED,
|
||||
),
|
||||
HttpStatus.UNAUTHORIZED,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { HttpException } from './http.exception';
|
||||
import { HttpStatus } from '../enums/http-status.enum';
|
||||
import { HttpException } from './http.exception';
|
||||
|
||||
/**
|
||||
* Defines an HTTP exception for *Unprocessable Entity* type errors.
|
||||
@@ -17,30 +17,30 @@ export class UnprocessableEntityException extends HttpException {
|
||||
*
|
||||
* @usageNotes
|
||||
* The HTTP response status code will be 422.
|
||||
* - The `objectOrError` argument defines the JSON response body or the error string.
|
||||
* - The `message` argument contains a short description of the HTTP error.
|
||||
* - The `objectOrError` argument defines the JSON response body or the message string.
|
||||
* - The `description` argument contains a short description of the HTTP error.
|
||||
*
|
||||
* By default, the JSON response body contains two properties:
|
||||
* - `statusCode`: this will be the value 422.
|
||||
* - `message`: the string `'Unprocessable Entity'` by default; override this by supplying
|
||||
* a string in the `message` parameter.
|
||||
* a string in the `objectOrError` parameter.
|
||||
*
|
||||
* If the parameter `objectOrError` is a string, the response body will contain an
|
||||
* additional property, `error`, containing the given string. To override the
|
||||
* additional property, `error`, with a short description of the HTTP error. To override the
|
||||
* entire JSON response body, pass an object instead. Nest will serialize the object
|
||||
* and return it as the JSON response body.
|
||||
*
|
||||
* @param objectOrError string or object describing the error condition.
|
||||
* @param message a short description of the HTTP error.
|
||||
* @param description a short description of the HTTP error.
|
||||
*/
|
||||
constructor(
|
||||
objectOrError?: string | object | any,
|
||||
message = 'Unprocessable Entity',
|
||||
description = 'Unprocessable Entity',
|
||||
) {
|
||||
super(
|
||||
HttpException.createBody(
|
||||
objectOrError,
|
||||
message,
|
||||
description,
|
||||
HttpStatus.UNPROCESSABLE_ENTITY,
|
||||
),
|
||||
HttpStatus.UNPROCESSABLE_ENTITY,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { HttpException } from './http.exception';
|
||||
import { HttpStatus } from '../enums/http-status.enum';
|
||||
import { HttpException } from './http.exception';
|
||||
|
||||
/**
|
||||
* Defines an HTTP exception for *Unsupported Media Type* type errors.
|
||||
@@ -17,30 +17,30 @@ export class UnsupportedMediaTypeException extends HttpException {
|
||||
*
|
||||
* @usageNotes
|
||||
* The HTTP response status code will be 415.
|
||||
* - The `objectOrError` argument defines the JSON response body or the error string.
|
||||
* - The `message` argument contains a short description of the HTTP error.
|
||||
* - The `objectOrError` argument defines the JSON response body or the message string.
|
||||
* - The `description` argument contains a short description of the HTTP error.
|
||||
*
|
||||
* By default, the JSON response body contains two properties:
|
||||
* - `statusCode`: this will be the value 415.
|
||||
* - `message`: the string `'Unsupported Media Type'` by default; override this by supplying
|
||||
* a string in the `message` parameter.
|
||||
* a string in the `objectOrError` parameter.
|
||||
*
|
||||
* If the parameter `objectOrError` is a string, the response body will contain an
|
||||
* additional property, `error`, containing the given string. To override the
|
||||
* additional property, `error`, with a short description of the HTTP error. To override the
|
||||
* entire JSON response body, pass an object instead. Nest will serialize the object
|
||||
* and return it as the JSON response body.
|
||||
*
|
||||
* @param objectOrError string or object describing the error condition.
|
||||
* @param message a short description of the HTTP error.
|
||||
* @param description a short description of the HTTP error.
|
||||
*/
|
||||
constructor(
|
||||
objectOrError?: string | object | any,
|
||||
message = 'Unsupported Media Type',
|
||||
description = 'Unsupported Media Type',
|
||||
) {
|
||||
super(
|
||||
HttpException.createBody(
|
||||
objectOrError,
|
||||
message,
|
||||
description,
|
||||
HttpStatus.UNSUPPORTED_MEDIA_TYPE,
|
||||
),
|
||||
HttpStatus.UNSUPPORTED_MEDIA_TYPE,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nestjs/common",
|
||||
"version": "7.0.2",
|
||||
"version": "7.0.5",
|
||||
"description": "Nest - modern, fast, powerful node.js web framework (@common)",
|
||||
"author": "Kamil Mysliwiec",
|
||||
"homepage": "https://nestjs.com",
|
||||
|
||||
@@ -1,12 +1,8 @@
|
||||
import {
|
||||
ArgumentMetadata,
|
||||
BadRequestException,
|
||||
Injectable,
|
||||
Optional,
|
||||
} from '../index';
|
||||
import { ArgumentMetadata, HttpStatus, Injectable, Optional } from '../index';
|
||||
import { Type } from '../interfaces';
|
||||
import { PipeTransform } from '../interfaces/features/pipe-transform.interface';
|
||||
import { isString } from '../utils/shared.utils';
|
||||
import { HttpErrorByCode } from '../utils/http-error-by-code.util';
|
||||
import { isNil, isString } from '../utils/shared.utils';
|
||||
import { ValidationPipe, ValidationPipeOptions } from './validation.pipe';
|
||||
|
||||
const VALIDATION_ERROR_MESSAGE = 'Validation failed (parsable array expected)';
|
||||
@@ -42,9 +38,13 @@ export class ParseArrayPipe implements PipeTransform {
|
||||
...options,
|
||||
});
|
||||
|
||||
const { exceptionFactory } = options;
|
||||
const {
|
||||
exceptionFactory,
|
||||
errorHttpStatusCode = HttpStatus.BAD_REQUEST,
|
||||
} = options;
|
||||
this.exceptionFactory =
|
||||
exceptionFactory || (error => new BadRequestException(error));
|
||||
exceptionFactory ||
|
||||
(error => new HttpErrorByCode[errorHttpStatusCode](error));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -57,9 +57,11 @@ export class ParseArrayPipe implements PipeTransform {
|
||||
async transform(value: any, metadata: ArgumentMetadata): Promise<any> {
|
||||
if (!value && !this.options.optional) {
|
||||
throw this.exceptionFactory(VALIDATION_ERROR_MESSAGE);
|
||||
} else if (isNil(value) && this.options.optional) {
|
||||
return value;
|
||||
}
|
||||
|
||||
if (!Array.isArray(value) && !this.options.optional) {
|
||||
if (!Array.isArray(value)) {
|
||||
if (!isString(value)) {
|
||||
throw this.exceptionFactory(VALIDATION_ERROR_MESSAGE);
|
||||
} else {
|
||||
@@ -84,7 +86,7 @@ export class ParseArrayPipe implements PipeTransform {
|
||||
} catch {}
|
||||
return this.validationPipe.transform(item, validationMetadata);
|
||||
};
|
||||
value = await Promise.all((value as unknown[]).map(toClassInstance));
|
||||
value = await Promise.all(value.map(toClassInstance));
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
import { BadRequestException } from '../exceptions/bad-request.exception';
|
||||
import { ArgumentMetadata, Injectable, Optional } from '../index';
|
||||
import { ArgumentMetadata, HttpStatus, Injectable, Optional } from '../index';
|
||||
import { PipeTransform } from '../interfaces/features/pipe-transform.interface';
|
||||
import {
|
||||
ErrorHttpStatusCode,
|
||||
HttpErrorByCode,
|
||||
} from '../utils/http-error-by-code.util';
|
||||
|
||||
export interface ParseBoolPipeOptions {
|
||||
errorHttpStatusCode?: ErrorHttpStatusCode;
|
||||
exceptionFactory?: (error: string) => any;
|
||||
}
|
||||
|
||||
@@ -20,9 +24,13 @@ export class ParseBoolPipe
|
||||
|
||||
constructor(@Optional() options?: ParseBoolPipeOptions) {
|
||||
options = options || {};
|
||||
const { exceptionFactory } = options;
|
||||
const {
|
||||
exceptionFactory,
|
||||
errorHttpStatusCode = HttpStatus.BAD_REQUEST,
|
||||
} = options;
|
||||
this.exceptionFactory =
|
||||
exceptionFactory || (error => new BadRequestException(error));
|
||||
exceptionFactory ||
|
||||
(error => new HttpErrorByCode[errorHttpStatusCode](error));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
import { BadRequestException } from '../exceptions/bad-request.exception';
|
||||
import { ArgumentMetadata, HttpStatus, Injectable, Optional } from '../index';
|
||||
import { PipeTransform } from '../interfaces/features/pipe-transform.interface';
|
||||
import { ArgumentMetadata, Injectable, Optional } from '../index';
|
||||
import {
|
||||
ErrorHttpStatusCode,
|
||||
HttpErrorByCode,
|
||||
} from '../utils/http-error-by-code.util';
|
||||
|
||||
export interface ParseIntPipeOptions {
|
||||
errorHttpStatusCode?: ErrorHttpStatusCode;
|
||||
exceptionFactory?: (error: string) => any;
|
||||
}
|
||||
|
||||
@@ -19,9 +23,14 @@ export class ParseIntPipe implements PipeTransform<string> {
|
||||
|
||||
constructor(@Optional() options?: ParseIntPipeOptions) {
|
||||
options = options || {};
|
||||
const { exceptionFactory } = options;
|
||||
const {
|
||||
exceptionFactory,
|
||||
errorHttpStatusCode = HttpStatus.BAD_REQUEST,
|
||||
} = options;
|
||||
|
||||
this.exceptionFactory =
|
||||
exceptionFactory || (error => new BadRequestException(error));
|
||||
exceptionFactory ||
|
||||
(error => new HttpErrorByCode[errorHttpStatusCode](error));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
import { Optional } from '../decorators';
|
||||
import { ArgumentMetadata, BadRequestException, Injectable } from '../index';
|
||||
import { ArgumentMetadata, HttpStatus, Injectable } from '../index';
|
||||
import { PipeTransform } from '../interfaces/features/pipe-transform.interface';
|
||||
import {
|
||||
ErrorHttpStatusCode,
|
||||
HttpErrorByCode,
|
||||
} from '../utils/http-error-by-code.util';
|
||||
import { isUUID } from '../utils/is-uuid';
|
||||
|
||||
export interface ParseUUIDPipeOptions {
|
||||
version?: '3' | '4' | '5';
|
||||
errorHttpStatusCode?: ErrorHttpStatusCode;
|
||||
exceptionFactory?: (errors: string) => any;
|
||||
}
|
||||
|
||||
@@ -15,10 +20,16 @@ export class ParseUUIDPipe implements PipeTransform<string> {
|
||||
|
||||
constructor(@Optional() options?: ParseUUIDPipeOptions) {
|
||||
options = options || {};
|
||||
const {
|
||||
exceptionFactory,
|
||||
errorHttpStatusCode = HttpStatus.BAD_REQUEST,
|
||||
version,
|
||||
} = options;
|
||||
|
||||
this.version = options.version;
|
||||
this.version = version;
|
||||
this.exceptionFactory =
|
||||
options.exceptionFactory || (error => new BadRequestException(error));
|
||||
exceptionFactory ||
|
||||
(error => new HttpErrorByCode[errorHttpStatusCode](error));
|
||||
}
|
||||
async transform(value: string, metadata: ArgumentMetadata): Promise<string> {
|
||||
if (!isUUID(value, this.version)) {
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
import iterate from 'iterare';
|
||||
import { Optional } from '../decorators';
|
||||
import { Injectable } from '../decorators/core';
|
||||
import {
|
||||
ArgumentMetadata,
|
||||
BadRequestException,
|
||||
ValidationError,
|
||||
} from '../index';
|
||||
import { HttpStatus } from '../enums/http-status.enum';
|
||||
import { ArgumentMetadata, ValidationError } from '../index';
|
||||
import { ClassTransformOptions } from '../interfaces/external/class-transform-options.interface';
|
||||
import { ValidatorOptions } from '../interfaces/external/validator-options.interface';
|
||||
import { PipeTransform } from '../interfaces/features/pipe-transform.interface';
|
||||
import {
|
||||
ErrorHttpStatusCode,
|
||||
HttpErrorByCode,
|
||||
} from '../utils/http-error-by-code.util';
|
||||
import { loadPackage } from '../utils/load-package.util';
|
||||
import { isNil } from '../utils/shared.utils';
|
||||
|
||||
@@ -16,6 +17,7 @@ export interface ValidationPipeOptions extends ValidatorOptions {
|
||||
transform?: boolean;
|
||||
disableErrorMessages?: boolean;
|
||||
transformOptions?: ClassTransformOptions;
|
||||
errorHttpStatusCode?: ErrorHttpStatusCode;
|
||||
exceptionFactory?: (errors: ValidationError[]) => any;
|
||||
validateCustomDecorators?: boolean;
|
||||
}
|
||||
@@ -29,6 +31,7 @@ export class ValidationPipe implements PipeTransform<any> {
|
||||
protected isDetailedOutputDisabled?: boolean;
|
||||
protected validatorOptions: ValidatorOptions;
|
||||
protected transformOptions: ClassTransformOptions;
|
||||
protected errorHttpStatusCode: ErrorHttpStatusCode;
|
||||
protected exceptionFactory: (errors: ValidationError[]) => any;
|
||||
protected validateCustomDecorators: boolean;
|
||||
|
||||
@@ -37,15 +40,18 @@ export class ValidationPipe implements PipeTransform<any> {
|
||||
const {
|
||||
transform,
|
||||
disableErrorMessages,
|
||||
errorHttpStatusCode,
|
||||
transformOptions,
|
||||
validateCustomDecorators,
|
||||
...validatorOptions
|
||||
} = options;
|
||||
|
||||
this.isTransformEnabled = !!transform;
|
||||
this.validatorOptions = validatorOptions;
|
||||
this.transformOptions = transformOptions;
|
||||
this.isDetailedOutputDisabled = disableErrorMessages;
|
||||
this.validateCustomDecorators = validateCustomDecorators || false;
|
||||
this.errorHttpStatusCode = errorHttpStatusCode || HttpStatus.BAD_REQUEST;
|
||||
this.exceptionFactory =
|
||||
options.exceptionFactory || this.createExceptionFactory();
|
||||
|
||||
@@ -60,7 +66,9 @@ export class ValidationPipe implements PipeTransform<any> {
|
||||
public async transform(value: any, metadata: ArgumentMetadata) {
|
||||
const { metatype } = metadata;
|
||||
if (!metatype || !this.toValidate(metadata)) {
|
||||
return value;
|
||||
return this.isTransformEnabled
|
||||
? this.transformPrimitive(value, metadata)
|
||||
: value;
|
||||
}
|
||||
const originalValue = value;
|
||||
value = this.toEmptyIfNil(value);
|
||||
@@ -110,15 +118,10 @@ export class ValidationPipe implements PipeTransform<any> {
|
||||
public createExceptionFactory() {
|
||||
return (validationErrors: ValidationError[] = []) => {
|
||||
if (this.isDetailedOutputDisabled) {
|
||||
return new BadRequestException();
|
||||
return new HttpErrorByCode[this.errorHttpStatusCode]();
|
||||
}
|
||||
const errors = iterate(validationErrors)
|
||||
.filter(item => !!item.constraints)
|
||||
.map(item => Object.values(item.constraints))
|
||||
.flatten()
|
||||
.toArray();
|
||||
|
||||
return new BadRequestException(errors);
|
||||
const errors = this.flattenValidationErrors(validationErrors);
|
||||
return new HttpErrorByCode[this.errorHttpStatusCode](errors);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -131,6 +134,24 @@ export class ValidationPipe implements PipeTransform<any> {
|
||||
return !types.some(t => metatype === t) && !isNil(metatype);
|
||||
}
|
||||
|
||||
private transformPrimitive(value: any, metadata: ArgumentMetadata) {
|
||||
if (!metadata.data) {
|
||||
// leave top-level query/param objects unmodified
|
||||
return value;
|
||||
}
|
||||
const { type, metatype } = metadata;
|
||||
if (type !== 'param' && type !== 'query') {
|
||||
return value;
|
||||
}
|
||||
if (metatype === Boolean) {
|
||||
return value === true || value === 'true';
|
||||
}
|
||||
if (metatype === Number) {
|
||||
return +value;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
private toEmptyIfNil<T = any, R = any>(value: T): R | {} {
|
||||
return isNil(value) ? {} : value;
|
||||
}
|
||||
@@ -146,4 +167,46 @@ export class ValidationPipe implements PipeTransform<any> {
|
||||
private isPrimitive(value: unknown): boolean {
|
||||
return ['number', 'boolean', 'string'].includes(typeof value);
|
||||
}
|
||||
|
||||
private flattenValidationErrors(
|
||||
validationErrors: ValidationError[],
|
||||
): string[] {
|
||||
return iterate(validationErrors)
|
||||
.map(error => this.mapChildrenToValidationErrors(error))
|
||||
.flatten()
|
||||
.filter(item => !!item.constraints)
|
||||
.map(item => Object.values(item.constraints))
|
||||
.flatten()
|
||||
.toArray();
|
||||
}
|
||||
|
||||
private mapChildrenToValidationErrors(
|
||||
error: ValidationError,
|
||||
): ValidationError[] {
|
||||
if (!(error.children && error.children.length)) {
|
||||
return [error];
|
||||
}
|
||||
const validationErrors = [];
|
||||
for (const item of error.children) {
|
||||
if (item.children && item.children.length) {
|
||||
validationErrors.push(...this.mapChildrenToValidationErrors(item));
|
||||
}
|
||||
validationErrors.push(this.prependConstraintsWithParentProp(error, item));
|
||||
}
|
||||
return validationErrors;
|
||||
}
|
||||
|
||||
private prependConstraintsWithParentProp(
|
||||
parentError: ValidationError,
|
||||
error: ValidationError,
|
||||
): ValidationError {
|
||||
const constraints = {};
|
||||
for (const key in error.constraints) {
|
||||
constraints[key] = `${parentError.property}.${error.constraints[key]}`;
|
||||
}
|
||||
return {
|
||||
...error,
|
||||
constraints,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { expect } from 'chai';
|
||||
import { BadRequestException } from '../../exceptions';
|
||||
import { ArgumentMetadata } from '../../interfaces/features/pipe-transform.interface';
|
||||
import { ParseArrayPipe } from '../../pipes/parse-array.pipe';
|
||||
|
||||
@@ -11,8 +12,9 @@ describe('ParseArrayPipe', () => {
|
||||
it('should throw an exception', async () => {
|
||||
target = new ParseArrayPipe({ optional: false });
|
||||
|
||||
return expect(target.transform(undefined, {} as ArgumentMetadata)).to
|
||||
.be.rejected;
|
||||
return expect(
|
||||
target.transform(undefined, {} as ArgumentMetadata),
|
||||
).to.to.be.rejectedWith(BadRequestException);
|
||||
});
|
||||
});
|
||||
describe('and optional enabled', () => {
|
||||
@@ -30,16 +32,32 @@ describe('ParseArrayPipe', () => {
|
||||
target = new ParseArrayPipe();
|
||||
});
|
||||
it('should throw an exception (boolean)', async () => {
|
||||
return expect(target.transform(true, {} as ArgumentMetadata)).to.be
|
||||
.rejected;
|
||||
return expect(
|
||||
target.transform(true, {} as ArgumentMetadata),
|
||||
).to.be.rejectedWith(BadRequestException);
|
||||
});
|
||||
it('should throw an exception (number)', async () => {
|
||||
return expect(target.transform(3, {} as ArgumentMetadata)).to.be
|
||||
.rejected;
|
||||
return expect(
|
||||
target.transform(3, {} as ArgumentMetadata),
|
||||
).to.be.rejectedWith(BadRequestException);
|
||||
});
|
||||
it('should throw an exception (object)', async () => {
|
||||
return expect(target.transform({}, {} as ArgumentMetadata)).to.be
|
||||
.rejected;
|
||||
return expect(
|
||||
target.transform({}, {} as ArgumentMetadata),
|
||||
).to.be.rejectedWith(BadRequestException);
|
||||
});
|
||||
|
||||
describe('and "optional" is enabled', () => {
|
||||
it('should throw an exception', async () => {
|
||||
const pipe = new ParseArrayPipe({
|
||||
optional: true,
|
||||
items: String,
|
||||
separator: ',',
|
||||
});
|
||||
return expect(
|
||||
pipe.transform({}, {} as ArgumentMetadata),
|
||||
).to.be.rejectedWith(BadRequestException);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -1,8 +1,16 @@
|
||||
import * as chai from 'chai';
|
||||
import { expect } from 'chai';
|
||||
import * as chaiAsPromised from 'chai-as-promised';
|
||||
import { Exclude, Expose } from 'class-transformer';
|
||||
import { IsOptional, IsString } from 'class-validator';
|
||||
import { Exclude, Expose, Type } from 'class-transformer';
|
||||
import {
|
||||
IsBoolean,
|
||||
IsDefined,
|
||||
IsOptional,
|
||||
IsString,
|
||||
ValidateNested,
|
||||
} from 'class-validator';
|
||||
import { HttpStatus } from '../../enums';
|
||||
import { UnprocessableEntityException } from '../../exceptions';
|
||||
import { ArgumentMetadata } from '../../interfaces';
|
||||
import { ValidationPipe } from '../../pipes/validation.pipe';
|
||||
chai.use(chaiAsPromised);
|
||||
@@ -25,10 +33,11 @@ class TestModelInternal {
|
||||
}
|
||||
|
||||
class TestModel {
|
||||
constructor() {}
|
||||
@IsString() public prop1: string;
|
||||
@IsString()
|
||||
public prop1: string;
|
||||
|
||||
@IsString() public prop2: string;
|
||||
@IsString()
|
||||
public prop2: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@@ -110,6 +119,43 @@ describe('ValidationPipe', () => {
|
||||
const testObj = { prop1: 'value1' };
|
||||
return expect(target.transform(testObj, metadata)).to.be.rejected;
|
||||
});
|
||||
|
||||
class TestModel2 {
|
||||
@IsString()
|
||||
public prop1: string;
|
||||
|
||||
@IsBoolean()
|
||||
public prop2: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
public optionalProp: string;
|
||||
}
|
||||
class TestModelWithNested {
|
||||
@IsString()
|
||||
prop: string;
|
||||
|
||||
@IsDefined()
|
||||
@Type(() => TestModel2)
|
||||
@ValidateNested()
|
||||
test: TestModel2;
|
||||
}
|
||||
it('should flatten nested errors', async () => {
|
||||
try {
|
||||
const model = new TestModelWithNested();
|
||||
model.test = new TestModel2();
|
||||
await target.transform(model, {
|
||||
type: 'body',
|
||||
metatype: TestModelWithNested,
|
||||
});
|
||||
} catch (err) {
|
||||
expect(err.getResponse().message).to.be.eql([
|
||||
'prop must be a string',
|
||||
'test.prop1 must be a string',
|
||||
'test.prop2 must be a boolean value',
|
||||
]);
|
||||
}
|
||||
});
|
||||
});
|
||||
describe('when validation transforms', () => {
|
||||
it('should return a TestModel instance', async () => {
|
||||
@@ -119,6 +165,62 @@ describe('ValidationPipe', () => {
|
||||
TestModel,
|
||||
);
|
||||
});
|
||||
describe('when input is a query parameter (number)', () => {
|
||||
it('should parse to number', async () => {
|
||||
target = new ValidationPipe({ transform: true });
|
||||
const value = '3.14';
|
||||
|
||||
expect(
|
||||
await target.transform(value, {
|
||||
metatype: Number,
|
||||
data: 'test',
|
||||
type: 'query',
|
||||
}),
|
||||
).to.be.equal(+value);
|
||||
});
|
||||
});
|
||||
describe('when input is a path parameter (number)', () => {
|
||||
it('should parse to number', async () => {
|
||||
target = new ValidationPipe({ transform: true });
|
||||
const value = '3.14';
|
||||
|
||||
expect(
|
||||
await target.transform(value, {
|
||||
metatype: Number,
|
||||
data: 'test',
|
||||
type: 'param',
|
||||
}),
|
||||
).to.be.equal(+value);
|
||||
});
|
||||
});
|
||||
describe('when input is a query parameter (boolean)', () => {
|
||||
it('should parse to boolean', async () => {
|
||||
target = new ValidationPipe({ transform: true });
|
||||
const value = 'true';
|
||||
|
||||
expect(
|
||||
await target.transform(value, {
|
||||
metatype: Boolean,
|
||||
data: 'test',
|
||||
type: 'query',
|
||||
}),
|
||||
).to.be.true;
|
||||
});
|
||||
});
|
||||
describe('when input is a path parameter (boolean)', () => {
|
||||
it('should parse to boolean', async () => {
|
||||
target = new ValidationPipe({ transform: true });
|
||||
const value = 'true';
|
||||
|
||||
expect(
|
||||
await target.transform(value, {
|
||||
metatype: Boolean,
|
||||
data: 'test',
|
||||
type: 'param',
|
||||
}),
|
||||
).to.be.true;
|
||||
});
|
||||
});
|
||||
describe('when validation strips', () => {
|
||||
it('should return a TestModel without extra properties', async () => {
|
||||
target = new ValidationPipe({ whitelist: true });
|
||||
@@ -276,4 +378,22 @@ describe('ValidationPipe', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('option: "errorHttpStatusCode"', () => {
|
||||
describe('when validation fails', () => {
|
||||
beforeEach(() => {
|
||||
target = new ValidationPipe({
|
||||
errorHttpStatusCode: HttpStatus.UNPROCESSABLE_ENTITY,
|
||||
});
|
||||
});
|
||||
it('should throw an error', async () => {
|
||||
const testObj = { prop1: 'value1' };
|
||||
try {
|
||||
await target.transform(testObj, metadata);
|
||||
} catch (err) {
|
||||
expect(err).to.be.instanceOf(UnprocessableEntityException);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
63
packages/common/utils/http-error-by-code.util.ts
Normal file
63
packages/common/utils/http-error-by-code.util.ts
Normal file
@@ -0,0 +1,63 @@
|
||||
import { HttpStatus } from '../enums';
|
||||
import {
|
||||
BadGatewayException,
|
||||
BadRequestException,
|
||||
ConflictException,
|
||||
ForbiddenException,
|
||||
GatewayTimeoutException,
|
||||
GoneException,
|
||||
ImATeapotException,
|
||||
InternalServerErrorException,
|
||||
MethodNotAllowedException,
|
||||
NotAcceptableException,
|
||||
NotFoundException,
|
||||
NotImplementedException,
|
||||
PayloadTooLargeException,
|
||||
RequestTimeoutException,
|
||||
ServiceUnavailableException,
|
||||
UnauthorizedException,
|
||||
UnprocessableEntityException,
|
||||
UnsupportedMediaTypeException,
|
||||
} from '../exceptions';
|
||||
import { Type } from '../interfaces';
|
||||
|
||||
export type ErrorHttpStatusCode =
|
||||
| HttpStatus.BAD_GATEWAY
|
||||
| HttpStatus.BAD_REQUEST
|
||||
| HttpStatus.CONFLICT
|
||||
| HttpStatus.FORBIDDEN
|
||||
| HttpStatus.GATEWAY_TIMEOUT
|
||||
| HttpStatus.GONE
|
||||
| HttpStatus.I_AM_A_TEAPOT
|
||||
| HttpStatus.INTERNAL_SERVER_ERROR
|
||||
| HttpStatus.METHOD_NOT_ALLOWED
|
||||
| HttpStatus.NOT_ACCEPTABLE
|
||||
| HttpStatus.NOT_FOUND
|
||||
| HttpStatus.NOT_IMPLEMENTED
|
||||
| HttpStatus.PAYLOAD_TOO_LARGE
|
||||
| HttpStatus.REQUEST_TIMEOUT
|
||||
| HttpStatus.SERVICE_UNAVAILABLE
|
||||
| HttpStatus.UNAUTHORIZED
|
||||
| HttpStatus.UNPROCESSABLE_ENTITY
|
||||
| HttpStatus.UNSUPPORTED_MEDIA_TYPE;
|
||||
|
||||
export const HttpErrorByCode: Record<ErrorHttpStatusCode, Type<unknown>> = {
|
||||
[HttpStatus.BAD_GATEWAY]: BadGatewayException,
|
||||
[HttpStatus.BAD_REQUEST]: BadRequestException,
|
||||
[HttpStatus.CONFLICT]: ConflictException,
|
||||
[HttpStatus.FORBIDDEN]: ForbiddenException,
|
||||
[HttpStatus.GATEWAY_TIMEOUT]: GatewayTimeoutException,
|
||||
[HttpStatus.GONE]: GoneException,
|
||||
[HttpStatus.I_AM_A_TEAPOT]: ImATeapotException,
|
||||
[HttpStatus.INTERNAL_SERVER_ERROR]: InternalServerErrorException,
|
||||
[HttpStatus.METHOD_NOT_ALLOWED]: MethodNotAllowedException,
|
||||
[HttpStatus.NOT_ACCEPTABLE]: NotAcceptableException,
|
||||
[HttpStatus.NOT_FOUND]: NotFoundException,
|
||||
[HttpStatus.NOT_IMPLEMENTED]: NotImplementedException,
|
||||
[HttpStatus.PAYLOAD_TOO_LARGE]: PayloadTooLargeException,
|
||||
[HttpStatus.REQUEST_TIMEOUT]: RequestTimeoutException,
|
||||
[HttpStatus.SERVICE_UNAVAILABLE]: ServiceUnavailableException,
|
||||
[HttpStatus.UNAUTHORIZED]: UnauthorizedException,
|
||||
[HttpStatus.UNPROCESSABLE_ENTITY]: UnprocessableEntityException,
|
||||
[HttpStatus.UNSUPPORTED_MEDIA_TYPE]: UnsupportedMediaTypeException,
|
||||
};
|
||||
@@ -31,7 +31,7 @@ Nest is a framework for building efficient, scalable <a href="http://nodejs.org"
|
||||
## Philosophy
|
||||
|
||||
<p>In recent years, thanks to Node.js, JavaScript has become the “lingua franca” of the web for both front and backend applications, giving rise to awesome projects like <a href="https://angular.io/" target="_blank">Angular</a>, <a href="https://github.com/facebook/react" target="_blank">React</a> and <a href="https://github.com/vuejs/vue" target="_blank">Vue</a> which improve developer productivity and enable the construction of fast, testable, extensible frontend applications. However, on the server-side, while there are a lot of superb libraries, helpers and tools for Node, none of them effectively solve the main problem - the architecture.</p>
|
||||
<p>Nest aims to provide an application architecture out of the box which allows for effortless creation of highly testable, scalable, loosely coupled and easily maintainable applications.</p>
|
||||
<p>Nest aims to provide an application architecture out of the box which allows for effortless creation of highly testable, scalable, loosely coupled and easily maintainable applications. The architecture is heavily inspired by Angular.</p>
|
||||
|
||||
## Getting started
|
||||
|
||||
|
||||
@@ -3,8 +3,9 @@ import { RuntimeException } from './runtime.exception';
|
||||
export class UnknownElementException extends RuntimeException {
|
||||
constructor(name?: string) {
|
||||
super(
|
||||
`Nest could not find ${name ||
|
||||
'given'} element (this provider does not exist in the current context)`,
|
||||
`Nest could not find ${
|
||||
name || 'given'
|
||||
} element (this provider does not exist in the current context)`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,8 +109,9 @@ export const INVALID_CLASS_SCOPE_MESSAGE = (
|
||||
text: TemplateStringsArray,
|
||||
name: string | undefined,
|
||||
) =>
|
||||
`${name ||
|
||||
'This class'} is marked as a scoped provider. Request and transient-scoped providers can't be used in combination with "get()" method. Please, use "resolve()" instead.`;
|
||||
`${
|
||||
name || 'This class'
|
||||
} is marked as a scoped provider. Request and transient-scoped providers can't be used in combination with "get()" method. Please, use "resolve()" instead.`;
|
||||
|
||||
export const INVALID_MIDDLEWARE_CONFIGURATION = `An invalid middleware configuration has been passed inside the module 'configure()' method.`;
|
||||
export const UNKNOWN_REQUEST_MAPPING = `An invalid controller has been detected. Perhaps, one of your controllers is missing @Controller() decorator.`;
|
||||
|
||||
@@ -7,6 +7,6 @@ export class ExternalExceptionFilter<T = any, R = any> {
|
||||
if (exception instanceof Error && !(exception instanceof HttpException)) {
|
||||
ExternalExceptionFilter.logger.error(exception.message, exception.stack);
|
||||
}
|
||||
return (exception as any) as R;
|
||||
throw exception;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,7 +178,11 @@ export class ExternalContextCreator {
|
||||
return this.transformToResult(result);
|
||||
};
|
||||
return options.filters
|
||||
? this.externalErrorProxy.createProxy(target, exceptionFilter)
|
||||
? this.externalErrorProxy.createProxy(
|
||||
target,
|
||||
exceptionFilter,
|
||||
contextType,
|
||||
)
|
||||
: target;
|
||||
}
|
||||
|
||||
|
||||
@@ -138,12 +138,7 @@ export class NestApplicationContext implements INestApplicationContext {
|
||||
}
|
||||
|
||||
signals = signals
|
||||
.map((signal: string) =>
|
||||
signal
|
||||
.toString()
|
||||
.toUpperCase()
|
||||
.trim(),
|
||||
)
|
||||
.map((signal: string) => signal.toString().toUpperCase().trim())
|
||||
// filter out the signals which is already listening to
|
||||
.filter(signal => !this.activeShutdownSignals.includes(signal));
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nestjs/core",
|
||||
"version": "7.0.2",
|
||||
"version": "7.0.5",
|
||||
"description": "Nest - modern, fast, powerful node.js web framework (@core)",
|
||||
"author": "Kamil Mysliwiec",
|
||||
"license": "MIT",
|
||||
|
||||
@@ -313,7 +313,9 @@ export class DependenciesScanner {
|
||||
if (!providersKeys.includes(type as string)) {
|
||||
return this.container.addProvider(provider as any, token);
|
||||
}
|
||||
const providerToken = `${type as string} (UUID: ${randomStringGenerator()})`;
|
||||
const providerToken = `${
|
||||
type as string
|
||||
} (UUID: ${randomStringGenerator()})`;
|
||||
|
||||
let scope = (provider as ClassProvider | FactoryProvider).scope;
|
||||
if (isNil(scope) && (provider as ClassProvider).useClass) {
|
||||
|
||||
@@ -13,8 +13,11 @@ describe('ExternalExceptionsHandler', () => {
|
||||
describe('next', () => {
|
||||
it('should method returns expected stream with message when exception is unknown', async () => {
|
||||
const error = new Error();
|
||||
const result = await handler.next(error, null);
|
||||
expect(result).to.be.eql(error);
|
||||
try {
|
||||
await handler.next(error, null);
|
||||
} catch (err) {
|
||||
expect(err).to.be.eql(error);
|
||||
}
|
||||
});
|
||||
describe('when "invokeCustomFilters" returns value', () => {
|
||||
const observable$ = of(true);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { ForbiddenException } from '@nestjs/common';
|
||||
import { CUSTOM_ROUTE_AGRS_METADATA } from '@nestjs/common/constants';
|
||||
import { RouteParamtypes } from '@nestjs/common/enums/route-paramtypes.enum';
|
||||
import { expect } from 'chai';
|
||||
@@ -86,7 +87,7 @@ describe('ExternalContextCreator', () => {
|
||||
} catch (e) {
|
||||
err = e;
|
||||
}
|
||||
expect(err).to.be.undefined;
|
||||
expect(err).to.be.instanceOf(ForbiddenException);
|
||||
});
|
||||
});
|
||||
describe('when can activate', () => {
|
||||
|
||||
@@ -31,7 +31,7 @@ Nest is a framework for building efficient, scalable <a href="http://nodejs.org"
|
||||
## Philosophy
|
||||
|
||||
<p>In recent years, thanks to Node.js, JavaScript has become the “lingua franca” of the web for both front and backend applications, giving rise to awesome projects like <a href="https://angular.io/" target="_blank">Angular</a>, <a href="https://github.com/facebook/react" target="_blank">React</a> and <a href="https://github.com/vuejs/vue" target="_blank">Vue</a> which improve developer productivity and enable the construction of fast, testable, extensible frontend applications. However, on the server-side, while there are a lot of superb libraries, helpers and tools for Node, none of them effectively solve the main problem - the architecture.</p>
|
||||
<p>Nest aims to provide an application architecture out of the box which allows for effortless creation of highly testable, scalable, loosely coupled and easily maintainable applications.</p>
|
||||
<p>Nest aims to provide an application architecture out of the box which allows for effortless creation of highly testable, scalable, loosely coupled and easily maintainable applications. The architecture is heavily inspired by Angular.</p>
|
||||
|
||||
## Getting started
|
||||
|
||||
|
||||
@@ -64,6 +64,7 @@ export class ClientGrpcProxy extends ClientProxy implements ClientGrpc {
|
||||
if (!clientRef) {
|
||||
throw new InvalidGrpcServiceException();
|
||||
}
|
||||
|
||||
const maxSendMessageLengthKey = 'grpc.max_send_message_length';
|
||||
const maxReceiveMessageLengthKey = 'grpc.max_receive_message_length';
|
||||
const maxMessageLengthOptions = {
|
||||
@@ -78,6 +79,14 @@ export class ClientGrpcProxy extends ClientProxy implements ClientGrpc {
|
||||
GRPC_DEFAULT_MAX_RECEIVE_MESSAGE_LENGTH,
|
||||
),
|
||||
};
|
||||
const maxMetadataSize = this.getOptionsProp(
|
||||
this.options,
|
||||
'maxMetadataSize',
|
||||
-1,
|
||||
);
|
||||
if (maxMetadataSize > 0) {
|
||||
maxMessageLengthOptions['grpc.max_metadata_size'] = maxMetadataSize;
|
||||
}
|
||||
|
||||
const keepaliveOptions = this.getKeepaliveOptions();
|
||||
const options: Record<string, unknown> = isObject(this.options)
|
||||
|
||||
@@ -32,6 +32,7 @@ export interface GrpcOptions {
|
||||
url?: string;
|
||||
maxSendMessageLength?: number;
|
||||
maxReceiveMessageLength?: number;
|
||||
maxMetadataSize?: number;
|
||||
keepalive?: {
|
||||
keepaliveTimeMs?: number;
|
||||
keepaliveTimeoutMs?: number;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nestjs/microservices",
|
||||
"version": "7.0.2",
|
||||
"version": "7.0.5",
|
||||
"description": "Nest - modern, fast, powerful node.js web framework (@microservices)",
|
||||
"author": "Kamil Mysliwiec",
|
||||
"license": "MIT",
|
||||
|
||||
@@ -325,7 +325,7 @@ export class ServerGrpc extends Server implements CustomTransportStrategy {
|
||||
}
|
||||
|
||||
public createClient(): any {
|
||||
const server = new grpcPackage.Server({
|
||||
const grpcOptions = {
|
||||
'grpc.max_send_message_length': this.getOptionsProp(
|
||||
this.options,
|
||||
'maxSendMessageLength',
|
||||
@@ -336,7 +336,16 @@ export class ServerGrpc extends Server implements CustomTransportStrategy {
|
||||
'maxReceiveMessageLength',
|
||||
GRPC_DEFAULT_MAX_RECEIVE_MESSAGE_LENGTH,
|
||||
),
|
||||
});
|
||||
};
|
||||
const maxMetadataSize = this.getOptionsProp(
|
||||
this.options,
|
||||
'maxMetadataSize',
|
||||
-1,
|
||||
);
|
||||
if (maxMetadataSize > 0) {
|
||||
grpcOptions['grpc.max_metadata_size'] = maxMetadataSize;
|
||||
}
|
||||
const server = new grpcPackage.Server(grpcOptions);
|
||||
const credentials = this.getOptionsProp(this.options, 'credentials');
|
||||
server.bind(
|
||||
this.url,
|
||||
|
||||
@@ -16,7 +16,7 @@ class TestClientProxy extends ClientProxy {
|
||||
public async close() {}
|
||||
}
|
||||
|
||||
describe('ClientProxy', function() {
|
||||
describe('ClientProxy', function () {
|
||||
this.retries(10);
|
||||
|
||||
let client: TestClientProxy;
|
||||
|
||||
@@ -4,7 +4,7 @@ import { empty } from 'rxjs';
|
||||
import * as sinon from 'sinon';
|
||||
import { ClientRMQ } from '../../client/client-rmq';
|
||||
|
||||
describe('ClientRMQ', function() {
|
||||
describe('ClientRMQ', function () {
|
||||
this.retries(10);
|
||||
|
||||
let client: ClientRMQ;
|
||||
|
||||
@@ -31,7 +31,7 @@ Nest is a framework for building efficient, scalable <a href="http://nodejs.org"
|
||||
## Philosophy
|
||||
|
||||
<p>In recent years, thanks to Node.js, JavaScript has become the “lingua franca” of the web for both front and backend applications, giving rise to awesome projects like <a href="https://angular.io/" target="_blank">Angular</a>, <a href="https://github.com/facebook/react" target="_blank">React</a> and <a href="https://github.com/vuejs/vue" target="_blank">Vue</a> which improve developer productivity and enable the construction of fast, testable, extensible frontend applications. However, on the server-side, while there are a lot of superb libraries, helpers and tools for Node, none of them effectively solve the main problem - the architecture.</p>
|
||||
<p>Nest aims to provide an application architecture out of the box which allows for effortless creation of highly testable, scalable, loosely coupled and easily maintainable applications.</p>
|
||||
<p>Nest aims to provide an application architecture out of the box which allows for effortless creation of highly testable, scalable, loosely coupled and easily maintainable applications. The architecture is heavily inspired by Angular.</p>
|
||||
|
||||
## Getting started
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nestjs/platform-express",
|
||||
"version": "7.0.2",
|
||||
"version": "7.0.5",
|
||||
"description": "Nest - modern, fast, powerful node.js web framework (@platform-express)",
|
||||
"author": "Kamil Mysliwiec",
|
||||
"license": "MIT",
|
||||
|
||||
@@ -31,7 +31,7 @@ Nest is a framework for building efficient, scalable <a href="http://nodejs.org"
|
||||
## Philosophy
|
||||
|
||||
<p>In recent years, thanks to Node.js, JavaScript has become the “lingua franca” of the web for both front and backend applications, giving rise to awesome projects like <a href="https://angular.io/" target="_blank">Angular</a>, <a href="https://github.com/facebook/react" target="_blank">React</a> and <a href="https://github.com/vuejs/vue" target="_blank">Vue</a> which improve developer productivity and enable the construction of fast, testable, extensible frontend applications. However, on the server-side, while there are a lot of superb libraries, helpers and tools for Node, none of them effectively solve the main problem - the architecture.</p>
|
||||
<p>Nest aims to provide an application architecture out of the box which allows for effortless creation of highly testable, scalable, loosely coupled and easily maintainable applications.</p>
|
||||
<p>Nest aims to provide an application architecture out of the box which allows for effortless creation of highly testable, scalable, loosely coupled and easily maintainable applications. The architecture is heavily inspired by Angular.</p>
|
||||
|
||||
## Getting started
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nestjs/platform-fastify",
|
||||
"version": "7.0.2",
|
||||
"version": "7.0.5",
|
||||
"description": "Nest - modern, fast, powerful node.js web framework (@platform-fastify)",
|
||||
"author": "Kamil Mysliwiec",
|
||||
"license": "MIT",
|
||||
@@ -17,7 +17,7 @@
|
||||
"access": "public"
|
||||
},
|
||||
"dependencies": {
|
||||
"fastify": "2.12.1",
|
||||
"fastify": "2.13.0",
|
||||
"fastify-cors": "3.0.2",
|
||||
"fastify-formbody": "3.1.0",
|
||||
"path-to-regexp": "3.2.0",
|
||||
|
||||
@@ -31,7 +31,7 @@ Nest is a framework for building efficient, scalable <a href="http://nodejs.org"
|
||||
## Philosophy
|
||||
|
||||
<p>In recent years, thanks to Node.js, JavaScript has become the “lingua franca” of the web for both front and backend applications, giving rise to awesome projects like <a href="https://angular.io/" target="_blank">Angular</a>, <a href="https://github.com/facebook/react" target="_blank">React</a> and <a href="https://github.com/vuejs/vue" target="_blank">Vue</a> which improve developer productivity and enable the construction of fast, testable, extensible frontend applications. However, on the server-side, while there are a lot of superb libraries, helpers and tools for Node, none of them effectively solve the main problem - the architecture.</p>
|
||||
<p>Nest aims to provide an application architecture out of the box which allows for effortless creation of highly testable, scalable, loosely coupled and easily maintainable applications.</p>
|
||||
<p>Nest aims to provide an application architecture out of the box which allows for effortless creation of highly testable, scalable, loosely coupled and easily maintainable applications. The architecture is heavily inspired by Angular.</p>
|
||||
|
||||
## Getting started
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nestjs/platform-socket.io",
|
||||
"version": "7.0.2",
|
||||
"version": "7.0.5",
|
||||
"description": "Nest - modern, fast, powerful node.js web framework (@platform-socket.io)",
|
||||
"author": "Kamil Mysliwiec",
|
||||
"license": "MIT",
|
||||
|
||||
@@ -31,7 +31,7 @@ Nest is a framework for building efficient, scalable <a href="http://nodejs.org"
|
||||
## Philosophy
|
||||
|
||||
<p>In recent years, thanks to Node.js, JavaScript has become the “lingua franca” of the web for both front and backend applications, giving rise to awesome projects like <a href="https://angular.io/" target="_blank">Angular</a>, <a href="https://github.com/facebook/react" target="_blank">React</a> and <a href="https://github.com/vuejs/vue" target="_blank">Vue</a> which improve developer productivity and enable the construction of fast, testable, extensible frontend applications. However, on the server-side, while there are a lot of superb libraries, helpers and tools for Node, none of them effectively solve the main problem - the architecture.</p>
|
||||
<p>Nest aims to provide an application architecture out of the box which allows for effortless creation of highly testable, scalable, loosely coupled and easily maintainable applications.</p>
|
||||
<p>Nest aims to provide an application architecture out of the box which allows for effortless creation of highly testable, scalable, loosely coupled and easily maintainable applications. The architecture is heavily inspired by Angular.</p>
|
||||
|
||||
## Getting started
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nestjs/platform-ws",
|
||||
"version": "7.0.2",
|
||||
"version": "7.0.5",
|
||||
"description": "Nest - modern, fast, powerful node.js web framework (@platform-ws)",
|
||||
"author": "Kamil Mysliwiec",
|
||||
"license": "MIT",
|
||||
|
||||
@@ -31,7 +31,7 @@ Nest is a framework for building efficient, scalable <a href="http://nodejs.org"
|
||||
## Philosophy
|
||||
|
||||
<p>In recent years, thanks to Node.js, JavaScript has become the “lingua franca” of the web for both front and backend applications, giving rise to awesome projects like <a href="https://angular.io/" target="_blank">Angular</a>, <a href="https://github.com/facebook/react" target="_blank">React</a> and <a href="https://github.com/vuejs/vue" target="_blank">Vue</a> which improve developer productivity and enable the construction of fast, testable, extensible frontend applications. However, on the server-side, while there are a lot of superb libraries, helpers and tools for Node, none of them effectively solve the main problem - the architecture.</p>
|
||||
<p>Nest aims to provide an application architecture out of the box which allows for effortless creation of highly testable, scalable, loosely coupled and easily maintainable applications.</p>
|
||||
<p>Nest aims to provide an application architecture out of the box which allows for effortless creation of highly testable, scalable, loosely coupled and easily maintainable applications. The architecture is heavily inspired by Angular.</p>
|
||||
|
||||
## Getting started
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nestjs/testing",
|
||||
"version": "7.0.2",
|
||||
"version": "7.0.5",
|
||||
"description": "Nest - modern, fast, powerful node.js web framework (@testing)",
|
||||
"author": "Kamil Mysliwiec",
|
||||
"license": "MIT",
|
||||
|
||||
@@ -31,7 +31,7 @@ Nest is a framework for building efficient, scalable <a href="http://nodejs.org"
|
||||
## Philosophy
|
||||
|
||||
<p>In recent years, thanks to Node.js, JavaScript has become the “lingua franca” of the web for both front and backend applications, giving rise to awesome projects like <a href="https://angular.io/" target="_blank">Angular</a>, <a href="https://github.com/facebook/react" target="_blank">React</a> and <a href="https://github.com/vuejs/vue" target="_blank">Vue</a> which improve developer productivity and enable the construction of fast, testable, extensible frontend applications. However, on the server-side, while there are a lot of superb libraries, helpers and tools for Node, none of them effectively solve the main problem - the architecture.</p>
|
||||
<p>Nest aims to provide an application architecture out of the box which allows for effortless creation of highly testable, scalable, loosely coupled and easily maintainable applications.</p>
|
||||
<p>Nest aims to provide an application architecture out of the box which allows for effortless creation of highly testable, scalable, loosely coupled and easily maintainable applications. The architecture is heavily inspired by Angular.</p>
|
||||
|
||||
## Getting started
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nestjs/websockets",
|
||||
"version": "7.0.2",
|
||||
"version": "7.0.5",
|
||||
"description": "Nest - modern, fast, powerful node.js web framework (@websockets)",
|
||||
"author": "Kamil Mysliwiec",
|
||||
"license": "MIT",
|
||||
|
||||
@@ -23,12 +23,9 @@ describe('Cats', () => {
|
||||
});
|
||||
|
||||
it(`/GET cats`, () => {
|
||||
return request(app.getHttpServer())
|
||||
.get('/cats')
|
||||
.expect(200)
|
||||
.expect({
|
||||
data: catsService.findAll(),
|
||||
});
|
||||
return request(app.getHttpServer()).get('/cats').expect(200).expect({
|
||||
data: catsService.findAll(),
|
||||
});
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
|
||||
3827
sample/01-cats-app/package-lock.json
generated
3827
sample/01-cats-app/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -19,34 +19,34 @@
|
||||
"test:e2e": "jest --config ./e2e/jest-e2e.json"
|
||||
},
|
||||
"dependencies": {
|
||||
"@nestjs/common": "^7.0.1",
|
||||
"@nestjs/core": "^7.0.1",
|
||||
"@nestjs/platform-express": "7.0.1",
|
||||
"@nestjs/common": "7.0.5",
|
||||
"@nestjs/core": "7.0.5",
|
||||
"@nestjs/platform-express": "7.0.5",
|
||||
"class-transformer": "0.2.3",
|
||||
"class-validator": "0.11.0",
|
||||
"class-validator": "0.11.1",
|
||||
"reflect-metadata": "0.1.13",
|
||||
"rimraf": "3.0.2",
|
||||
"rxjs": "6.5.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nestjs/cli": "7.0.0",
|
||||
"@nestjs/cli": "7.0.2",
|
||||
"@nestjs/schematics": "7.0.0",
|
||||
"@nestjs/testing": "7.0.1",
|
||||
"@nestjs/testing": "7.0.5",
|
||||
"@types/express": "4.17.3",
|
||||
"@types/jest": "25.1.4",
|
||||
"@types/node": "10.17.3",
|
||||
"@types/supertest": "2.0.8",
|
||||
"jest": "25.1.0",
|
||||
"prettier": "1.19.1",
|
||||
"jest": "25.2.1",
|
||||
"prettier": "2.0.2",
|
||||
"supertest": "4.0.2",
|
||||
"ts-jest": "25.2.1",
|
||||
"ts-loader": "6.2.1",
|
||||
"ts-node": "8.6.2",
|
||||
"ts-loader": "6.2.2",
|
||||
"ts-node": "8.8.1",
|
||||
"tsconfig-paths": "3.9.0",
|
||||
"@typescript-eslint/eslint-plugin": "2.23.0",
|
||||
"@typescript-eslint/parser": "2.23.0",
|
||||
"@typescript-eslint/eslint-plugin": "2.25.0",
|
||||
"@typescript-eslint/parser": "2.25.0",
|
||||
"eslint": "6.8.0",
|
||||
"eslint-config-prettier": "6.10.0",
|
||||
"eslint-config-prettier": "6.10.1",
|
||||
"eslint-plugin-import": "2.20.1",
|
||||
"typescript": "3.7.2"
|
||||
},
|
||||
|
||||
@@ -1,13 +1,5 @@
|
||||
import {
|
||||
Body,
|
||||
Controller,
|
||||
ForbiddenException,
|
||||
Get,
|
||||
HttpException,
|
||||
Param,
|
||||
Post,
|
||||
UseGuards,
|
||||
} from '@nestjs/common';
|
||||
import { Body, Controller, Get, Param, Post, UseGuards } from '@nestjs/common';
|
||||
import { Roles } from '../common/decorators/roles.decorator';
|
||||
import { RolesGuard } from '../common/guards/roles.guard';
|
||||
import { ParseIntPipe } from '../common/pipes/parse-int.pipe';
|
||||
import { CatsService } from './cats.service';
|
||||
@@ -20,42 +12,13 @@ export class CatsController {
|
||||
constructor(private readonly catsService: CatsService) {}
|
||||
|
||||
@Post()
|
||||
@Roles('admin')
|
||||
async create(@Body() createCatDto: CreateCatDto) {
|
||||
this.catsService.create(createCatDto);
|
||||
}
|
||||
|
||||
@Get()
|
||||
async findAll(): Promise<Cat[]> {
|
||||
if (false) {
|
||||
/*
|
||||
{
|
||||
"statusCode": 401,
|
||||
"message": "sfafsa"
|
||||
}
|
||||
*/
|
||||
throw new HttpException('sfafsa', 401);
|
||||
}
|
||||
if (true) {
|
||||
/**
|
||||
* {
|
||||
"statusCode": 403,
|
||||
"error": "Forbidden",
|
||||
"message": "sfafsa"
|
||||
}
|
||||
*/
|
||||
const err = new ForbiddenException();
|
||||
console.log(err.message);
|
||||
throw err;
|
||||
}
|
||||
if (false) {
|
||||
/**
|
||||
* {
|
||||
"statusCode": 403,
|
||||
"error": "Forbidden",
|
||||
}
|
||||
*/
|
||||
throw new ForbiddenException();
|
||||
}
|
||||
return this.catsService.findAll();
|
||||
}
|
||||
|
||||
|
||||
3576
sample/02-gateways/package-lock.json
generated
3576
sample/02-gateways/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -19,13 +19,13 @@
|
||||
"test:e2e": "echo 'No e2e tests implemented yet.'"
|
||||
},
|
||||
"dependencies": {
|
||||
"@nestjs/common": "7.0.1",
|
||||
"@nestjs/core": "7.0.1",
|
||||
"@nestjs/platform-express": "7.0.1",
|
||||
"@nestjs/platform-socket.io": "7.0.1",
|
||||
"@nestjs/websockets": "7.0.1",
|
||||
"@nestjs/common": "7.0.5",
|
||||
"@nestjs/core": "7.0.5",
|
||||
"@nestjs/platform-express": "7.0.5",
|
||||
"@nestjs/platform-socket.io": "7.0.5",
|
||||
"@nestjs/websockets": "7.0.5",
|
||||
"class-transformer": "0.2.3",
|
||||
"class-validator": "0.11.0",
|
||||
"class-validator": "0.11.1",
|
||||
"reflect-metadata": "0.1.13",
|
||||
"rimraf": "3.0.2",
|
||||
"rxjs": "6.5.4",
|
||||
@@ -34,24 +34,24 @@
|
||||
"devDependencies": {
|
||||
"@types/socket.io": "2.1.3",
|
||||
"@types/socket.io-redis": "1.0.25",
|
||||
"@types/ws": "7.2.2",
|
||||
"@nestjs/cli": "7.0.0",
|
||||
"@types/ws": "7.2.3",
|
||||
"@nestjs/cli": "7.0.2",
|
||||
"@nestjs/schematics": "7.0.0",
|
||||
"@nestjs/testing": "7.0.1",
|
||||
"@nestjs/testing": "7.0.5",
|
||||
"@types/express": "4.17.3",
|
||||
"@types/node": "7.10.9",
|
||||
"@types/supertest": "2.0.8",
|
||||
"jest": "25.1.0",
|
||||
"prettier": "1.19.1",
|
||||
"jest": "25.2.1",
|
||||
"prettier": "2.0.2",
|
||||
"supertest": "4.0.2",
|
||||
"ts-jest": "25.2.1",
|
||||
"ts-loader": "6.2.1",
|
||||
"ts-node": "8.6.2",
|
||||
"ts-loader": "6.2.2",
|
||||
"ts-node": "8.8.1",
|
||||
"tsconfig-paths": "3.9.0",
|
||||
"@typescript-eslint/eslint-plugin": "2.23.0",
|
||||
"@typescript-eslint/parser": "2.23.0",
|
||||
"@typescript-eslint/eslint-plugin": "2.25.0",
|
||||
"@typescript-eslint/parser": "2.25.0",
|
||||
"eslint": "6.8.0",
|
||||
"eslint-config-prettier": "6.10.0",
|
||||
"eslint-config-prettier": "6.10.1",
|
||||
"eslint-plugin-import": "2.20.1",
|
||||
"typescript": "3.7.2"
|
||||
}
|
||||
|
||||
3594
sample/03-microservices/package-lock.json
generated
3594
sample/03-microservices/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -19,35 +19,35 @@
|
||||
"test:e2e": "echo 'No e2e tests implemented yet.'"
|
||||
},
|
||||
"dependencies": {
|
||||
"@nestjs/common": "7.0.1",
|
||||
"@nestjs/core": "7.0.1",
|
||||
"@nestjs/microservices": "7.0.1",
|
||||
"@nestjs/platform-express": "7.0.1",
|
||||
"@nestjs/common": "7.0.5",
|
||||
"@nestjs/core": "7.0.5",
|
||||
"@nestjs/microservices": "7.0.5",
|
||||
"@nestjs/platform-express": "7.0.5",
|
||||
"class-transformer": "0.2.3",
|
||||
"class-validator": "0.11.0",
|
||||
"class-validator": "0.11.1",
|
||||
"reflect-metadata": "0.1.13",
|
||||
"rimraf": "3.0.2",
|
||||
"rxjs": "6.5.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nestjs/cli": "7.0.0",
|
||||
"@nestjs/cli": "7.0.2",
|
||||
"@nestjs/schematics": "7.0.0",
|
||||
"@nestjs/testing": "7.0.1",
|
||||
"@nestjs/testing": "7.0.5",
|
||||
"@types/amqplib": "0.5.13",
|
||||
"@types/express": "4.17.3",
|
||||
"@types/node": "12.12.21",
|
||||
"@types/node": "12.12.31",
|
||||
"@types/supertest": "2.0.8",
|
||||
"jest": "25.1.0",
|
||||
"prettier": "1.19.1",
|
||||
"jest": "25.2.1",
|
||||
"prettier": "2.0.2",
|
||||
"supertest": "4.0.2",
|
||||
"ts-jest": "25.2.1",
|
||||
"ts-loader": "6.2.1",
|
||||
"ts-node": "8.6.2",
|
||||
"ts-loader": "6.2.2",
|
||||
"ts-node": "8.8.1",
|
||||
"tsconfig-paths": "3.9.0",
|
||||
"@typescript-eslint/eslint-plugin": "2.23.0",
|
||||
"@typescript-eslint/parser": "2.23.0",
|
||||
"@typescript-eslint/eslint-plugin": "2.25.0",
|
||||
"@typescript-eslint/parser": "2.25.0",
|
||||
"eslint": "6.8.0",
|
||||
"eslint-config-prettier": "6.10.0",
|
||||
"eslint-config-prettier": "6.10.1",
|
||||
"eslint-plugin-import": "2.20.1",
|
||||
"typescript": "3.7.2"
|
||||
}
|
||||
|
||||
3264
sample/04-grpc/package-lock.json
generated
3264
sample/04-grpc/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -20,35 +20,35 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@grpc/proto-loader": "0.5.3",
|
||||
"@nestjs/common": "7.0.1",
|
||||
"@nestjs/core": "7.0.1",
|
||||
"@nestjs/microservices": "7.0.1",
|
||||
"@nestjs/common": "7.0.5",
|
||||
"@nestjs/core": "7.0.5",
|
||||
"@nestjs/microservices": "7.0.5",
|
||||
"class-transformer": "0.2.3",
|
||||
"class-validator": "0.11.0",
|
||||
"class-validator": "0.11.1",
|
||||
"grpc": "1.24.2",
|
||||
"reflect-metadata": "0.1.13",
|
||||
"rimraf": "3.0.2",
|
||||
"rxjs": "6.5.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nestjs/cli": "7.0.0",
|
||||
"@nestjs/cli": "7.0.2",
|
||||
"@nestjs/schematics": "7.0.0",
|
||||
"@nestjs/testing": "7.0.1",
|
||||
"@nestjs/testing": "7.0.5",
|
||||
"@types/express": "4.17.3",
|
||||
"@types/node": "10.17.3",
|
||||
"@types/supertest": "2.0.8",
|
||||
"@types/ws": "7.2.2",
|
||||
"jest": "25.1.0",
|
||||
"prettier": "1.19.1",
|
||||
"@types/ws": "7.2.3",
|
||||
"jest": "25.2.1",
|
||||
"prettier": "2.0.2",
|
||||
"supertest": "4.0.2",
|
||||
"ts-jest": "25.2.1",
|
||||
"ts-loader": "6.2.1",
|
||||
"ts-node": "8.6.2",
|
||||
"ts-loader": "6.2.2",
|
||||
"ts-node": "8.8.1",
|
||||
"tsconfig-paths": "3.9.0",
|
||||
"@typescript-eslint/eslint-plugin": "2.23.0",
|
||||
"@typescript-eslint/parser": "2.23.0",
|
||||
"@typescript-eslint/eslint-plugin": "2.25.0",
|
||||
"@typescript-eslint/parser": "2.25.0",
|
||||
"eslint": "6.8.0",
|
||||
"eslint-config-prettier": "6.10.0",
|
||||
"eslint-config-prettier": "6.10.1",
|
||||
"eslint-plugin-import": "2.20.1",
|
||||
"typescript": "3.7.2"
|
||||
}
|
||||
|
||||
3227
sample/05-sql-typeorm/package-lock.json
generated
3227
sample/05-sql-typeorm/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -19,9 +19,9 @@
|
||||
"test:e2e": "echo 'No e2e tests implemented yet.'"
|
||||
},
|
||||
"dependencies": {
|
||||
"@nestjs/common": "7.0.1",
|
||||
"@nestjs/core": "7.0.1",
|
||||
"@nestjs/platform-express": "7.0.1",
|
||||
"@nestjs/common": "7.0.5",
|
||||
"@nestjs/core": "7.0.5",
|
||||
"@nestjs/platform-express": "7.0.5",
|
||||
"@nestjs/typeorm": "7.0.0",
|
||||
"mysql": "2.18.1",
|
||||
"reflect-metadata": "0.1.13",
|
||||
@@ -30,24 +30,24 @@
|
||||
"typeorm": "0.2.24"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nestjs/cli": "7.0.0",
|
||||
"@nestjs/cli": "7.0.2",
|
||||
"@nestjs/schematics": "7.0.0",
|
||||
"@nestjs/testing": "7.0.1",
|
||||
"@nestjs/testing": "7.0.5",
|
||||
"@types/express": "4.17.3",
|
||||
"@types/node": "7.10.9",
|
||||
"@types/supertest": "2.0.8",
|
||||
"@types/ws": "7.2.2",
|
||||
"jest": "25.1.0",
|
||||
"prettier": "1.19.1",
|
||||
"@types/ws": "7.2.3",
|
||||
"jest": "25.2.1",
|
||||
"prettier": "2.0.2",
|
||||
"supertest": "4.0.2",
|
||||
"ts-jest": "25.2.1",
|
||||
"ts-loader": "6.2.1",
|
||||
"ts-node": "8.6.2",
|
||||
"ts-loader": "6.2.2",
|
||||
"ts-node": "8.8.1",
|
||||
"tsconfig-paths": "3.9.0",
|
||||
"@typescript-eslint/eslint-plugin": "2.23.0",
|
||||
"@typescript-eslint/parser": "2.23.0",
|
||||
"@typescript-eslint/eslint-plugin": "2.25.0",
|
||||
"@typescript-eslint/parser": "2.25.0",
|
||||
"eslint": "6.8.0",
|
||||
"eslint-config-prettier": "6.10.0",
|
||||
"eslint-config-prettier": "6.10.1",
|
||||
"eslint-plugin-import": "2.20.1",
|
||||
"typescript": "3.7.2"
|
||||
}
|
||||
|
||||
3617
sample/06-mongoose/package-lock.json
generated
3617
sample/06-mongoose/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -19,35 +19,35 @@
|
||||
"test:e2e": "echo 'No e2e tests implemented yet.'"
|
||||
},
|
||||
"dependencies": {
|
||||
"@nestjs/common": "7.0.1",
|
||||
"@nestjs/core": "7.0.1",
|
||||
"@nestjs/platform-express": "7.0.1",
|
||||
"@nestjs/common": "7.0.5",
|
||||
"@nestjs/core": "7.0.5",
|
||||
"@nestjs/platform-express": "7.0.5",
|
||||
"@nestjs/mongoose": "6.4.0",
|
||||
"mongoose": "5.9.4",
|
||||
"mongoose": "5.9.6",
|
||||
"reflect-metadata": "0.1.13",
|
||||
"rimraf": "3.0.2",
|
||||
"rxjs": "6.5.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/mongoose": "5.7.6",
|
||||
"@nestjs/cli": "7.0.0",
|
||||
"@types/mongoose": "5.7.7",
|
||||
"@nestjs/cli": "7.0.2",
|
||||
"@nestjs/schematics": "7.0.0",
|
||||
"@nestjs/testing": "7.0.1",
|
||||
"@nestjs/testing": "7.0.5",
|
||||
"@types/express": "4.17.3",
|
||||
"@types/node": "12.12.21",
|
||||
"@types/node": "12.12.31",
|
||||
"@types/supertest": "2.0.8",
|
||||
"@types/ws": "7.2.2",
|
||||
"jest": "25.1.0",
|
||||
"prettier": "1.19.1",
|
||||
"@types/ws": "7.2.3",
|
||||
"jest": "25.2.1",
|
||||
"prettier": "2.0.2",
|
||||
"supertest": "4.0.2",
|
||||
"ts-jest": "25.2.1",
|
||||
"ts-loader": "6.2.1",
|
||||
"ts-node": "8.6.2",
|
||||
"ts-loader": "6.2.2",
|
||||
"ts-node": "8.8.1",
|
||||
"tsconfig-paths": "3.9.0",
|
||||
"@typescript-eslint/eslint-plugin": "2.23.0",
|
||||
"@typescript-eslint/parser": "2.23.0",
|
||||
"@typescript-eslint/eslint-plugin": "2.25.0",
|
||||
"@typescript-eslint/parser": "2.25.0",
|
||||
"eslint": "6.8.0",
|
||||
"eslint-config-prettier": "6.10.0",
|
||||
"eslint-config-prettier": "6.10.1",
|
||||
"eslint-plugin-import": "2.20.1",
|
||||
"typescript": "3.7.2"
|
||||
}
|
||||
|
||||
3591
sample/07-sequelize/package-lock.json
generated
3591
sample/07-sequelize/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user