Compare commits

..

129 Commits

Author SHA1 Message Date
Kamil Myśliwiec
b039ac9f6d test(common): add test for flattening children errors (validation) 2020-03-26 17:52:39 +01:00
Kamil Mysliwiec
15f3ee9ad6 Merge pull request #4427 from nestjs/renovate/nestjs-graphql-7.x
fix(deps): update dependency @nestjs/graphql to v7.1.1
2020-03-26 15:51:28 +01:00
Kamil Myśliwiec
e4a8cfbfa9 Merge branch 'Dominic-Preap-master' 2020-03-26 15:50:40 +01:00
Kamil Mysliwiec
749ab49153 Merge pull request #4404 from Dominic-Preap/master
feat(common): add exception code option in validation pipe
2020-03-26 14:22:36 +01:00
Kamil Myśliwiec
b9a9d58bd1 test(common): add unit tests (status code) 2020-03-26 14:21:20 +01:00
Kamil Myśliwiec
f829f9c25f refactor(): rename to http error status code (validation pipe) 2020-03-26 14:21:04 +01:00
Renovate Bot
8fad078b5c fix(deps): update dependency @nestjs/graphql to v7.1.1 2020-03-26 13:18:14 +00:00
Kamil Myśliwiec
abbe2d9700 Merge branch 'master' of https://github.com/Dominic-Preap/nest into Dominic-Preap-master 2020-03-26 14:12:00 +01:00
Kamil Mysliwiec
9d87d17ae3 Merge pull request #4230 from dot-i/add-grpc-max-metadata-option
feat(microservices): implement server grpc max metadata size option
2020-03-26 14:11:09 +01:00
Kamil Mysliwiec
b417928177 Merge pull request #4424 from nestjs/renovate/jest-monorepo
chore(deps): update dependency jest to v25.2.1
2020-03-26 14:10:12 +01:00
Kamil Mysliwiec
75799a31dc Merge pull request #4425 from nestjs/renovate/nestjs-graphql-7.x
fix(deps): update dependency @nestjs/graphql to v7.1.0
2020-03-26 14:10:06 +01:00
Kamil Mysliwiec
fb194199ad Merge pull request #4426 from nestjs/renovate/nestjs-swagger-4.x
fix(deps): update dependency @nestjs/swagger to v4.5.1
2020-03-26 14:10:01 +01:00
Kamil Myśliwiec
356fcd74a8 Merge branch 'master' of https://github.com/nestjs/nest 2020-03-26 14:09:09 +01:00
Kamil Myśliwiec
af8164ff5c fix(core): pass context type to external filter creator 2020-03-26 14:05:35 +01:00
Renovate Bot
e9dcd8fc84 fix(deps): update dependency @nestjs/swagger to v4.5.1 2020-03-26 12:21:11 +00:00
Renovate Bot
93313f505a fix(deps): update dependency @nestjs/graphql to v7.1.0 2020-03-26 09:59:26 +00:00
Renovate Bot
05b3dee522 chore(deps): update dependency jest to v25.2.1 2020-03-26 09:48:15 +00:00
Kamil Mysliwiec
447f341d28 Merge pull request #4417 from nestjs/renovate/nats-1.x
chore(deps): update dependency nats to v1.4.8
2020-03-26 08:40:10 +01:00
Kamil Mysliwiec
dff909bd99 Merge pull request #4419 from nestjs/renovate/jest-monorepo
chore(deps): update dependency jest to v25.2.0
2020-03-26 08:39:48 +01:00
Renovate Bot
4635a35fc8 chore(deps): update dependency jest to v25.2.0 2020-03-25 18:41:58 +00:00
Renovate Bot
6c54451121 chore(deps): update dependency nats to v1.4.8 2020-03-25 15:35:08 +00:00
Dominic Preap
3e270a3285 fix(common): update http-error-by-code 2020-03-25 10:21:31 +00:00
Kamil Myśliwiec
1c1d4e9ce2 Merge branch 'master' of https://github.com/nestjs/nest 2020-03-25 08:48:12 +01:00
Kamil Myśliwiec
f7b48a3e18 fix(common): update wrong comments in the http exception classes 2020-03-25 08:47:56 +01:00
Kamil Mysliwiec
6d0bbc8255 Merge pull request #4413 from nestjs/renovate/node-12.x
chore(deps): update dependency @types/node to v12.12.31
2020-03-25 08:21:25 +01:00
Renovate Bot
87abfaf036 chore(deps): update dependency @types/node to v12.12.31 2020-03-25 06:37:48 +00:00
Kamil Mysliwiec
89f6a69cf8 Merge pull request #4405 from nestjs/renovate/nats-1.x
chore(deps): update dependency nats to v1.4.6
2020-03-24 21:34:34 +01:00
Nico Francois
4b3d476571 feat(microservices): implement server grpc max metadata size option 2020-03-24 16:35:32 +01:00
Renovate Bot
14075d9591 chore(deps): update dependency nats to v1.4.6 2020-03-24 15:21:12 +00:00
Dominic Preap
0691c5c11d fix(common): update graphql pipe unit testing 2020-03-24 12:36:18 +00:00
Dominic Preap
08c005054c fix(common): update parse-array.pipe unit testing 2020-03-24 12:05:28 +00:00
Dominic Preap
c2f6b2d413 feat(common): add exception code option in validation pipe 2020-03-24 11:29:39 +00:00
Kamil Mysliwiec
831dac8e8a Merge pull request #4399 from nestjs/renovate/webpack-4.x
chore(deps): update dependency webpack to v4.42.1
2020-03-24 12:01:54 +01:00
Kamil Mysliwiec
c7b70ee096 Merge pull request #4398 from nestjs/renovate/lint-staged-10.x
chore(deps): update dependency lint-staged to v10.0.9
2020-03-24 11:59:40 +01:00
Kamil Mysliwiec
de58066618 Merge pull request #4400 from nestjs/renovate/nestjs-graphql-7.x
fix(deps): update dependency @nestjs/graphql to v7.0.15
2020-03-24 10:29:25 +01:00
Renovate Bot
acd6923ed9 fix(deps): update dependency @nestjs/graphql to v7.0.15 2020-03-24 09:08:15 +00:00
Kamil Mysliwiec
6d6715322f Merge pull request #4397 from nestjs/renovate/prettier-2.x
chore(deps): update dependency prettier to v2.0.2
2020-03-24 08:24:31 +01:00
Renovate Bot
c47f160322 chore(deps): update dependency webpack to v4.42.1 2020-03-24 06:36:19 +00:00
Renovate Bot
9b5779de73 chore(deps): update dependency lint-staged to v10.0.9 2020-03-24 05:11:05 +00:00
Renovate Bot
d3d01ccde9 chore(deps): update dependency prettier to v2.0.2 2020-03-23 23:05:20 +00:00
Kamil Mysliwiec
c978fc2caa Merge pull request #4396 from nestjs/renovate/mongoose-5.x
fix(deps): update dependency mongoose to v5.9.6
2020-03-23 22:30:08 +01:00
Kamil Mysliwiec
2ee05ecd79 Merge pull request #4394 from nestjs/renovate/typescript-eslint-monorepo
chore(deps): update typescript-eslint monorepo to v2.25.0
2020-03-23 22:29:32 +01:00
Renovate Bot
41cc8bab79 fix(deps): update dependency mongoose to v5.9.6 2020-03-23 20:48:06 +00:00
Renovate Bot
3a08a26d20 chore(deps): update typescript-eslint monorepo to v2.25.0 2020-03-23 17:21:44 +00:00
Kamil Mysliwiec
35b79eb10e Merge pull request #4389 from nestjs/renovate/nestjs-graphql-7.x
fix(deps): update dependency @nestjs/graphql to v7.0.14
2020-03-23 09:54:38 +01:00
Renovate Bot
8a3d82c054 fix(deps): update dependency @nestjs/graphql to v7.0.14 2020-03-23 08:32:27 +00:00
Kamil Mysliwiec
b3e1fa7867 Merge pull request #4384 from MickL/patch-1
sample(): update webpack-hmr.config.js
2020-03-23 08:26:45 +01:00
Kamil Mysliwiec
b368f074bb Merge pull request #4386 from nestjs/renovate/ts-loader-6.x
chore(deps): update dependency ts-loader to v6.2.2
2020-03-23 08:14:32 +01:00
Kamil Mysliwiec
3a09bf70ab Merge pull request #4387 from kaznovac/patch-2
fix(common): minor typo fix in dependencies.decorator
2020-03-23 08:14:05 +01:00
Marko Kaznovac
fe888916f4 fix(common): minor typo fix in dependencies.decorator 2020-03-23 01:14:51 +01:00
Renovate Bot
2e30be8a28 chore(deps): update dependency ts-loader to v6.2.2 2020-03-22 16:15:19 +00:00
Mick Lawitzke
a276847de0 Update webpack-hmr.config.js
Use existing variables instead of overwriting them with hardcoded ones
2020-03-22 17:01:28 +01:00
Kamil Mysliwiec
00658ca30e Merge pull request #4383 from nestjs/renovate/nestjs-graphql-7.x
fix(deps): update dependency @nestjs/graphql to v7.0.13
2020-03-22 16:25:53 +01:00
Renovate Bot
c368fe4255 fix(deps): update dependency @nestjs/graphql to v7.0.13 2020-03-22 13:08:29 +00:00
Kamil Mysliwiec
5f7874fd61 Merge pull request #4377 from nestjs/renovate/nest-monorepo
fix(deps): update nest monorepo to v7.0.5
2020-03-22 12:30:25 +01:00
Renovate Bot
c2e9646cd6 fix(deps): update nest monorepo to v7.0.5 2020-03-22 11:18:07 +00:00
Kamil Myśliwiec
0e5b402a6f refactor(): update to the latest version of prettier 2020-03-22 12:10:49 +01:00
Kamil Mysliwiec
3dae6178b7 Merge pull request #4381 from nestjs/renovate/eslint-config-prettier-6.x
chore(deps): update dependency eslint-config-prettier to v6.10.1
2020-03-22 12:07:13 +01:00
Kamil Myśliwiec
6b3c932193 chore(@nestjs) publish v7.0.5 release 2020-03-22 12:06:07 +01:00
Kamil Myśliwiec
4a8b385fb1 Merge branch 'master' of https://github.com/nestjs/nest 2020-03-22 11:42:11 +01:00
Kamil Myśliwiec
b068f41e08 fix(common): parse array pipe should allow only nil values #4380 2020-03-22 11:41:54 +01:00
Renovate Bot
d40ecde991 chore(deps): update dependency eslint-config-prettier to v6.10.1 2020-03-22 10:28:51 +00:00
Kamil Mysliwiec
02f7d9795a Merge pull request #4376 from nestjs/renovate/prettier-2.x
chore(deps): update dependency prettier to v2
2020-03-22 11:19:48 +01:00
Kamil Mysliwiec
9242745e62 Merge pull request #4379 from nestjs/renovate/ts-node-8.x
chore(deps): update dependency ts-node to v8.8.1
2020-03-22 11:19:38 +01:00
Kamil Mysliwiec
2f3b39faa1 Merge pull request #4378 from nestjs/renovate/nestjs-graphql-7.x
fix(deps): update dependency @nestjs/graphql to v7.0.12
2020-03-22 11:19:05 +01:00
Renovate Bot
7954d75daf chore(deps): update dependency ts-node to v8.8.1 2020-03-22 02:27:33 +00:00
Renovate Bot
b46afb4413 chore(deps): update dependency prettier to v2 2020-03-21 23:32:39 +00:00
Renovate Bot
de104f7407 fix(deps): update dependency @nestjs/graphql to v7.0.12 2020-03-21 22:10:02 +00:00
Kamil Myśliwiec
96515c749e Merge branch 'master' of https://github.com/nestjs/nest 2020-03-21 22:08:44 +01:00
Kamil Myśliwiec
7064f145cf fix(core): fix broken external exception filter tests 2020-03-21 22:07:56 +01:00
Kamil Mysliwiec
e9f5211404 Merge pull request #4372 from nestjs/renovate/babel-monorepo
chore(deps): update dependency @babel/runtime to v7.9.2
2020-03-21 21:58:10 +01:00
Kamil Mysliwiec
a011ca7e6e Merge pull request #4375 from nestjs/renovate/swagger-ui-express-4.x
fix(deps): update dependency swagger-ui-express to v4.1.4
2020-03-21 21:58:03 +01:00
Kamil Myśliwiec
7248dd9add chore(@nestjs) publish v7.0.4 release 2020-03-21 21:32:07 +01:00
Kamil Myśliwiec
7999e592c4 fix(core): rethrow exception (external filter) 2020-03-21 21:30:53 +01:00
Renovate Bot
9e2d683dd0 fix(deps): update dependency swagger-ui-express to v4.1.4 2020-03-21 20:27:17 +00:00
Renovate Bot
a6e73b7b27 chore(deps): update dependency @babel/runtime to v7.9.2 2020-03-21 14:19:27 +00:00
Kamil Mysliwiec
f7d0ebb3bf Merge pull request #4371 from nestjs/renovate/nestjs-graphql-7.x
fix(deps): update dependency @nestjs/graphql to v7.0.11
2020-03-21 11:09:39 +01:00
Renovate Bot
dd33623711 fix(deps): update dependency @nestjs/graphql to v7.0.11 2020-03-21 09:53:40 +00:00
Kamil Myśliwiec
98cf199a4c Merge branch 'master' of https://github.com/nestjs/nest 2020-03-21 10:49:01 +01:00
Kamil Myśliwiec
4035426ce3 refactor(sample): rename recipe to recipe.model 2020-03-21 10:48:52 +01:00
Kamil Mysliwiec
18a54786d4 Merge pull request #4366 from nestjs/renovate/cache-manager-3.x
chore(deps): update dependency cache-manager to v3.2.1
2020-03-21 10:24:34 +01:00
Kamil Mysliwiec
af203b761a Merge pull request #4363 from nestjs/renovate/babel-monorepo
chore(deps): update babel monorepo to v7.9.0
2020-03-21 10:23:28 +01:00
Renovate Bot
06e5381b7c chore(deps): update dependency cache-manager to v3.2.1 2020-03-20 22:07:42 +00:00
Kamil Mysliwiec
f2b22856e2 Merge pull request #4365 from nestjs/renovate/mongoose-5.x
chore(deps): update dependency @types/mongoose to v5.7.7
2020-03-20 22:06:48 +01:00
Renovate Bot
e9611e4430 chore(deps): update dependency @types/mongoose to v5.7.7 2020-03-20 16:22:32 +00:00
Renovate Bot
429a1dc974 chore(deps): update babel monorepo to v7.9.0 2020-03-20 15:59:21 +00:00
Vadim Goldenko
70b7813915 feat(common): prepend nested validation errors with parent prop 2020-03-20 16:41:55 +03:00
Vadim Goldenko
41381dcd42 feat(common): add nested validation errors parse 2020-03-20 15:58:36 +03:00
Kamil Mysliwiec
32d2172461 Merge pull request #4357 from nestjs/renovate/fastify-2.x
fix(deps): update dependency fastify to v2.13.0
2020-03-20 10:15:39 +01:00
Kamil Mysliwiec
5bebd05be2 Merge pull request #4353 from nestjs/renovate/artillery-1.x
chore(deps): update dependency artillery to v1.6.0
2020-03-20 10:10:41 +01:00
Kamil Mysliwiec
e6d644bc8a Merge pull request #4355 from nestjs/renovate/coveralls-3.x
chore(deps): update dependency coveralls to v3.0.11
2020-03-20 10:10:32 +01:00
Renovate Bot
46477638a9 fix(deps): update dependency fastify to v2.13.0 2020-03-20 08:56:42 +00:00
Renovate Bot
7548e288ee chore(deps): update dependency coveralls to v3.0.11 2020-03-19 17:48:26 +00:00
Renovate Bot
e83a1fed77 chore(deps): update dependency artillery to v1.6.0 2020-03-19 10:51:22 +00:00
Kamil Mysliwiec
539c3312da Merge pull request #4352 from nestjs/renovate/nestjs-graphql-7.x
fix(deps): update dependency @nestjs/graphql to v7.0.10
2020-03-19 11:06:11 +01:00
Renovate Bot
015d419601 fix(deps): update dependency @nestjs/graphql to v7.0.10 2020-03-19 09:57:06 +00:00
Kamil Mysliwiec
31c9b0b990 Merge pull request #4348 from nestjs/renovate/nest-monorepo
chore(deps): update dependency @nestjs/cli to v7.0.2
2020-03-19 09:40:52 +01:00
Renovate Bot
a8dcaae673 chore(deps): update dependency @nestjs/cli to v7.0.2 2020-03-19 08:10:46 +00:00
Kamil Mysliwiec
1912732a43 Merge pull request #4350 from nestjs/renovate/ws-7.x
chore(deps): update dependency @types/ws to v7.2.3
2020-03-19 08:42:39 +01:00
Kamil Mysliwiec
2e8305cc15 Merge pull request #4345 from nestjs/renovate/class-validator-0.x
fix(deps): update dependency class-validator to v0.11.1
2020-03-19 08:42:12 +01:00
Kamil Mysliwiec
0781e09f92 Merge pull request #4346 from nestjs/renovate/nestjs-graphql-7.x
fix(deps): update dependency @nestjs/graphql to v7.0.9
2020-03-19 08:41:57 +01:00
Kamil Mysliwiec
578588d1f9 Merge pull request #4349 from nestjs/renovate/fast-json-stringify-1.x
fix(deps): update dependency fast-json-stringify to v1.18.0
2020-03-19 08:41:34 +01:00
Kamil Mysliwiec
456b34bc60 Merge pull request #4351 from nestjs/renovate/ts-node-8.x
chore(deps): update dependency ts-node to v8.7.0
2020-03-19 08:41:14 +01:00
Renovate Bot
49059c01bd chore(deps): update dependency ts-node to v8.7.0 2020-03-18 21:24:43 +00:00
Renovate Bot
5d1076b527 chore(deps): update dependency @types/ws to v7.2.3 2020-03-18 20:34:27 +00:00
Renovate Bot
3812864353 fix(deps): update dependency fast-json-stringify to v1.18.0 2020-03-18 18:50:30 +00:00
Renovate Bot
6b96700a17 fix(deps): update dependency @nestjs/graphql to v7.0.9 2020-03-18 13:01:34 +00:00
Kamil Mysliwiec
4ffb16fb8c Merge pull request #4342 from nestjs/renovate/mocha-7.x
chore(deps): update dependency mocha to v7.1.1
2020-03-18 11:31:43 +01:00
Renovate Bot
a6a45d056e fix(deps): update dependency class-validator to v0.11.1 2020-03-18 10:20:41 +00:00
Renovate Bot
f0fdcfcd89 chore(deps): update dependency mocha to v7.1.1 2020-03-18 09:49:21 +00:00
Kamil Mysliwiec
1069de9a00 Merge pull request #4333 from nestjs/renovate/nest-monorepo
fix(deps): update nest monorepo to v7.0.3
2020-03-17 11:36:29 +01:00
Renovate Bot
854c602b27 fix(deps): update nest monorepo to v7.0.3 2020-03-17 08:46:12 +00:00
Kamil Myśliwiec
62a8fa3848 chore(): publish 7.0.3 release 2020-03-17 09:34:35 +01:00
Kamil Myśliwiec
f815474b6d chore(@nestjs) publish v7.0.3 release 2020-03-17 09:33:58 +01:00
Kamil Myśliwiec
a5271dde02 fix(common): revert implicit type conversion (validation pipe) 2020-03-17 09:31:41 +01:00
Kamil Mysliwiec
243e3a2151 Merge pull request #4330 from nestjs/renovate/mongoose-5.x
fix(deps): update dependency mongoose to v5.9.5
2020-03-17 09:26:22 +01:00
Renovate Bot
07a076c156 fix(deps): update dependency mongoose to v5.9.5 2020-03-16 22:07:44 +00:00
Kamil Mysliwiec
cde810c391 Update Readme.md 2020-03-16 10:15:29 +01:00
Kamil Mysliwiec
8324e149cc Merge pull request #4326 from nestjs/renovate/nestjs-graphql-7.x
fix(deps): update dependency @nestjs/graphql to v7.0.6
2020-03-16 10:06:36 +01:00
Renovate Bot
484cbd0c2c fix(deps): update dependency @nestjs/graphql to v7.0.6 2020-03-16 08:51:55 +00:00
Kamil Mysliwiec
5ffcce26b4 Merge pull request #4324 from nestjs/renovate/nestjs-graphql-7.x
fix(deps): update dependency @nestjs/graphql to v7.0.5
2020-03-16 08:13:31 +01:00
Renovate Bot
e1ec7ef47a fix(deps): update dependency @nestjs/graphql to v7.0.5 2020-03-15 19:03:05 +00:00
Kamil Myśliwiec
35c88bf5a1 Merge branch 'master' of https://github.com/nestjs/nest 2020-03-15 20:01:49 +01:00
Kamil Myśliwiec
2df93e9046 sample(): add nest cli to code-first sample 2020-03-15 20:01:37 +01:00
Kamil Mysliwiec
6d56bab026 Merge pull request #4323 from nestjs/renovate/nestjs-graphql-7.x
fix(deps): update dependency @nestjs/graphql to v7.0.4
2020-03-15 19:23:46 +01:00
Renovate Bot
30c20ec0b9 fix(deps): update dependency @nestjs/graphql to v7.0.4 2020-03-15 14:56:47 +00:00
Kamil Mysliwiec
90cbb7892c Merge pull request #4322 from nestjs/renovate/nest-monorepo
fix(deps): update nest monorepo to v7.0.2
2020-03-15 14:45:39 +01:00
Kamil Myśliwiec
e89f27b954 sample(): revert cats controller 2020-03-15 14:33:53 +01:00
Renovate Bot
e1d303d019 fix(deps): update nest monorepo to v7.0.2 2020-03-15 13:17:22 +00:00
149 changed files with 44726 additions and 61622 deletions

View File

@@ -1,4 +1,5 @@
{
"singleQuote": true,
"arrowParens": "avoid",
"trailingComma": "all"
}

View File

@@ -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

View File

@@ -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 () => {

View File

@@ -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`, () => {

View File

@@ -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`, () => {

View File

@@ -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 () => {

View File

@@ -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)`, () => {

View File

@@ -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);
});
});

View File

@@ -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 () => {

View File

@@ -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 () => {

View File

@@ -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 () => {

View File

@@ -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/*)`, () => {

View File

@@ -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 () => {

View File

@@ -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 () => {

View File

@@ -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 () => {

View File

@@ -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);
}
});

View File

@@ -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);
}
});

View File

@@ -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);
});

View File

@@ -49,7 +49,7 @@ describe('MQTT transport', () => {
.expect(200, '15');
});
it(`/POST (concurrent)`, function() {
it(`/POST (concurrent)`, function () {
return request(server)
.post('/concurrent')
.send([

View File

@@ -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 => {

View File

@@ -49,7 +49,7 @@ describe('REDIS transport', () => {
.expect(200, '15');
});
it(`/POST (concurrent)`, function() {
it(`/POST (concurrent)`, function () {
this.retries(10);
return request(server)

View File

@@ -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 => {

View File

@@ -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);

View File

@@ -3,5 +3,5 @@
"packages": [
"packages/*"
],
"version": "7.0.2"
"version": "7.0.5"
}

1621
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -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",

View File

@@ -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

View File

@@ -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>

View File

@@ -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,
);
}

View File

@@ -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,
);
}

View File

@@ -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,
);
}

View File

@@ -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,
);
}

View File

@@ -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,

View File

@@ -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,
);
}

View File

@@ -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,

View File

@@ -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,

View File

@@ -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,

View File

@@ -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,

View File

@@ -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,

View File

@@ -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,
);
}

View File

@@ -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,

View File

@@ -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,

View File

@@ -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,

View File

@@ -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,

View File

@@ -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,
);
}

View File

@@ -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,

View File

@@ -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,

View File

@@ -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",

View File

@@ -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;
}

View File

@@ -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));
}
/**

View File

@@ -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));
}
/**

View File

@@ -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)) {

View File

@@ -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,
};
}
}

View File

@@ -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);
});
});
});

View File

@@ -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);
}
});
});
});
});

View 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,
};

View File

@@ -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

View File

@@ -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)`,
);
}
}

View File

@@ -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.`;

View File

@@ -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;
}
}

View File

@@ -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;
}

View File

@@ -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));

View File

@@ -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",

View File

@@ -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) {

View File

@@ -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);

View File

@@ -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', () => {

View File

@@ -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

View File

@@ -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)

View File

@@ -32,6 +32,7 @@ export interface GrpcOptions {
url?: string;
maxSendMessageLength?: number;
maxReceiveMessageLength?: number;
maxMetadataSize?: number;
keepalive?: {
keepaliveTimeMs?: number;
keepaliveTimeoutMs?: number;

View File

@@ -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",

View File

@@ -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,

View File

@@ -16,7 +16,7 @@ class TestClientProxy extends ClientProxy {
public async close() {}
}
describe('ClientProxy', function() {
describe('ClientProxy', function () {
this.retries(10);
let client: TestClientProxy;

View File

@@ -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;

View File

@@ -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

View File

@@ -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",

View File

@@ -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

View File

@@ -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",

View File

@@ -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

View File

@@ -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",

View File

@@ -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

View File

@@ -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",

View File

@@ -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

View File

@@ -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",

View File

@@ -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

View File

@@ -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",

View File

@@ -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 () => {

File diff suppressed because it is too large Load Diff

View File

@@ -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"
},

View File

@@ -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();
}

File diff suppressed because it is too large Load Diff

View File

@@ -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"
}

File diff suppressed because it is too large Load Diff

View File

@@ -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"
}

File diff suppressed because it is too large Load Diff

View File

@@ -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"
}

File diff suppressed because it is too large Load Diff

View File

@@ -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"
}

File diff suppressed because it is too large Load Diff

View File

@@ -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"
}

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