Compare commits

..

367 Commits

Author SHA1 Message Date
Kamil Myśliwiec
969a35bc51 chore: update error message 2024-12-18 12:06:36 +01:00
Kamil Myśliwiec
bc1a992918 Merge branch '11.0.0' into chore/express-v5 2024-12-12 13:21:30 +01:00
Kamil Myśliwiec
0354e5e946 test: update container method name 2024-12-12 10:51:28 +01:00
Kamil Myśliwiec
3da69f8467 test: update container method name 2024-12-12 10:34:22 +01:00
Kamil Myśliwiec
2c6bf94a81 style: fix eslint errors 2024-12-12 10:14:28 +01:00
Kamil Myśliwiec
18b1bcec29 chore: address todos, remove deprecated 2024-12-12 10:07:06 +01:00
Kamil Myśliwiec
41234f68cf Merge branch '11.0.0' into chore/express-v5 2024-12-12 09:44:09 +01:00
Kamil Myśliwiec
5d3c284b86 chore(microservices): dont reference mqtt pkg 2024-12-12 09:43:51 +01:00
Kamil Myśliwiec
3e55791401 Merge branch '11.0.0' into chore/express-v5 2024-12-05 14:53:03 +01:00
Kamil Myśliwiec
6a84d6e25e fix(core): set distance to max, dont override on calc 2024-12-05 14:52:08 +01:00
Kamil Myśliwiec
121494ac4e Merge branch '11.0.0' into chore/express-v5 2024-12-05 14:15:45 +01:00
Kamil Myśliwiec
648b438df1 Merge branch '11.0.0' of https://github.com/nestjs/nest into 11.0.0 2024-12-05 14:15:24 +01:00
Kamil Myśliwiec
8bb562301f fix(core): set global modules distance to -1 2024-12-05 14:13:48 +01:00
Kamil Mysliwiec
c341a02243 Merge pull request #14267 from flovouin/fix-shutdown-hooks-order
Fix shutdown hooks order
2024-12-04 10:37:49 +01:00
Flo
3080787d9b fix(core): call shutdown hooks in reverse distance order 2024-12-03 16:56:13 +01:00
Kamil Myśliwiec
d2a45f3e25 chore: use optional group wrapped splat param 2024-12-03 12:34:37 +01:00
Kamil Myśliwiec
700a85d211 chore: update package.json 2024-11-28 14:06:38 +01:00
Kamil Myśliwiec
7197cc1a8a feat: add normalize path to http adapter 2024-11-28 14:06:15 +01:00
Kamil Myśliwiec
7f142e9399 feat: add legacy route converter, update tests 2024-11-28 11:28:56 +01:00
Kamil Myśliwiec
4f008fabd2 Merge branch '11.0.0' into chore/express-v5 2024-11-27 15:10:12 +01:00
Kamil Myśliwiec
f9c578680c style: address lint errors 2024-11-27 13:34:42 +01:00
Kamil Mysliwiec
6f7d470389 Merge pull request #14213 from mag123c/feature/14070-add-error-message-file-validator
feat(common): add error messages for file validators
2024-11-27 13:32:21 +01:00
Kamil Myśliwiec
95bd1ce678 Merge branch 'notusertelken-feature/mqtt-raw-output' into 11.0.0 2024-11-27 12:52:33 +01:00
Kamil Myśliwiec
43804c7c40 chore: resolve conflicts 2024-11-27 12:52:09 +01:00
Kamil Myśliwiec
5ca5c74c24 ci: use node 20.18 as the maintenance version 2024-11-27 12:39:49 +01:00
Kamil Myśliwiec
6e0f891f48 style: address lint errors and warnings 2024-11-27 12:18:43 +01:00
Kamil Myśliwiec
ca76e698f4 test(microservices): fix client mqtt unit test (use endasync) 2024-11-27 12:18:27 +01:00
Kamil Myśliwiec
d606466b37 Merge branch 'master' into 11.0.0 2024-11-27 12:03:56 +01:00
Kamil Myśliwiec
bedf1fa2a6 chore(@nestjs) publish v10.4.11 release 2024-11-27 12:01:46 +01:00
Kamil Myśliwiec
96e3e79acc fix(grpc): schedule messages forwarding after the current event loop 2024-11-27 11:50:50 +01:00
Kamil Myśliwiec
e411d80d4d chore: remove a leftover 2024-11-27 11:06:07 +01:00
Kamil Myśliwiec
ca70f0754c chore(deps): update package.json 2024-11-27 11:05:18 +01:00
Kamil Myśliwiec
cf17e4d521 chore: mqtt updates, integration test improvements 2024-11-27 11:04:51 +01:00
Kamil Mysliwiec
9fb542968b Merge pull request #14223 from nestjs/renovate/nest-monorepo
chore(deps): update nest monorepo
2024-11-27 10:57:53 +01:00
renovate[bot]
e6fe92ce79 chore(deps): update nest monorepo 2024-11-27 09:57:12 +00:00
Kamil Mysliwiec
2df0c754da Merge pull request #14222 from nestjs/renovate/nest-monorepo
chore(deps): update nest monorepo
2024-11-27 10:48:24 +01:00
renovate[bot]
a119a1a9c1 chore(deps): update nest monorepo 2024-11-27 09:30:26 +00:00
Kamil Myśliwiec
74e318c930 test: add not null assertion 2024-11-27 10:23:47 +01:00
Kamil Myśliwiec
5ebe4b93b3 chore(@nestjs) publish v10.4.10 release 2024-11-27 10:18:59 +01:00
Kamil Myśliwiec
74789282d1 chore: update minimum node version 2024-11-27 10:06:57 +01:00
Kamil Myśliwiec
e2893f951c chore: add non null assertions 2024-11-27 10:06:07 +01:00
Kamil Mysliwiec
4a9a3d86c2 Merge pull request #14221 from nestjs/renovate/mysql-8.x
chore(deps): update mysql docker tag to v8.4.3
2024-11-27 10:00:48 +01:00
Kamil Mysliwiec
1cf339c5be Merge pull request #14220 from nestjs/renovate/webpack-5.x
chore(deps): update dependency webpack to v5.96.1
2024-11-27 10:00:36 +01:00
Kamil Mysliwiec
2c2d766502 Merge pull request #14219 from nestjs/renovate/nodemon-3.x
chore(deps): update dependency nodemon to v3.1.7
2024-11-27 10:00:28 +01:00
Kamil Myśliwiec
170f2e0754 Merge branch 'master' into 11.0.0 2024-11-27 09:59:29 +01:00
Kamil Myśliwiec
dbeaa0b316 sample: fix mongoose model mock 2024-11-27 09:59:11 +01:00
mag123c
11f8a4a216 feat(common): add error messages for file validators 2024-11-27 17:58:35 +09:00
Kamil Mysliwiec
5396c8c6f0 Merge pull request #14218 from nestjs/renovate/confluentinc-cp-zookeeper-7.x
chore(deps): update confluentinc/cp-zookeeper docker tag to v7.7.1
2024-11-27 09:57:33 +01:00
renovate[bot]
13092aeac0 chore(deps): update dependency webpack to v5.96.1 2024-11-27 08:57:32 +00:00
Kamil Mysliwiec
6aa6d47c25 Merge pull request #14217 from nestjs/renovate/confluentinc-cp-kafka-7.x
chore(deps): update confluentinc/cp-kafka docker tag to v7.7.1
2024-11-27 09:57:25 +01:00
renovate[bot]
38bea6e544 chore(deps): update dependency nodemon to v3.1.7 2024-11-27 08:57:12 +00:00
Kamil Mysliwiec
42a443ee9a Merge pull request #14216 from nestjs/renovate/rimraf-5.x
fix(deps): update dependency rimraf to v5.0.10
2024-11-27 09:56:34 +01:00
Kamil Mysliwiec
f39cffe8ea Merge pull request #14215 from nestjs/renovate/dotenv-16.x
fix(deps): update dependency dotenv to v16.4.5
2024-11-27 09:56:24 +01:00
Kamil Mysliwiec
f97c8bc586 Merge pull request #14214 from nestjs/renovate/grpc-reflection-1.x
fix(deps): update dependency @grpc/reflection to v1.0.4
2024-11-27 09:56:03 +01:00
Kamil Myśliwiec
d27628aafa chore: resolve conflicts 2024-11-27 09:55:20 +01:00
Kamil Myśliwiec
339be465fe chore: resolve conflicts 2024-11-27 09:49:01 +01:00
renovate[bot]
ca78cbe447 chore(deps): update mysql docker tag to v8.4.3 2024-11-27 08:48:24 +00:00
renovate[bot]
9e21f093d8 chore(deps): update confluentinc/cp-zookeeper docker tag to v7.7.1 2024-11-27 08:47:12 +00:00
renovate[bot]
619db30f16 chore(deps): update confluentinc/cp-kafka docker tag to v7.7.1 2024-11-27 08:46:59 +00:00
renovate[bot]
9174dd647e fix(deps): update dependency rimraf to v5.0.10 2024-11-27 08:46:41 +00:00
Kamil Myśliwiec
f95758d88d sample: replace findByIdAndRemove with findByIdAndDelete 2024-11-27 09:43:57 +01:00
renovate[bot]
7854ceb1db fix(deps): update dependency dotenv to v16.4.5 2024-11-27 08:41:58 +00:00
renovate[bot]
d8343a22cc fix(deps): update dependency @grpc/reflection to v1.0.4 2024-11-27 08:41:19 +00:00
Kamil Mysliwiec
0ca42ba500 Merge pull request #14205 from nestjs/chore/eslint-v9
chore(dev-deps): upgrade to eslint v9
2024-11-27 09:41:08 +01:00
Kamil Myśliwiec
356469bfcc ci: run spec and packages lint in parallel 2024-11-27 09:29:39 +01:00
Kamil Mysliwiec
38ab78272f Merge pull request #12940 from nestjs/renovate/mongoose-8.x
fix(deps): update dependency mongoose to v8.8.3
2024-11-27 09:27:18 +01:00
Kamil Myśliwiec
a41781ac14 ci: update lint integration script 2024-11-27 09:06:43 +01:00
renovate[bot]
45f3322832 fix(deps): update dependency mongoose to v8.8.3 2024-11-27 07:57:35 +00:00
Kamil Mysliwiec
9bbc4dbab3 Merge pull request #14207 from nestjs/renovate/dotenv-8.x
chore(deps): update dependency @types/dotenv to v8.2.3
2024-11-27 08:50:19 +01:00
Kamil Mysliwiec
b46508793e Merge pull request #14208 from nestjs/renovate/node-20.x
chore(deps): update dependency @types/node to v20.17.8
2024-11-27 08:50:10 +01:00
Kamil Mysliwiec
feb75da3ce Merge pull request #14209 from nestjs/renovate/amqplib-0.x
chore(deps): update dependency amqplib to v0.10.5
2024-11-27 08:50:02 +01:00
Kamil Myśliwiec
4895e3bac1 ci: increase max old space size for lint scripts 2024-11-27 08:49:25 +01:00
renovate[bot]
46db58c196 chore(deps): update dependency amqplib to v0.10.5 2024-11-27 07:47:07 +00:00
renovate[bot]
638d4666fb chore(deps): update dependency @types/node to v20.17.8 2024-11-27 07:46:32 +00:00
Kamil Mysliwiec
91190b4175 Merge pull request #14212 from nestjs/renovate/npm-webpack-vulnerability
chore(deps): update dependency webpack to v5.94.0 [security]
2024-11-27 08:43:07 +01:00
renovate[bot]
d1a76abe21 chore(deps): update dependency @types/dotenv to v8.2.3 2024-11-27 07:42:51 +00:00
renovate[bot]
055709dd3a chore(deps): update dependency webpack to v5.94.0 [security] 2024-11-27 07:40:26 +00:00
Kamil Mysliwiec
f80b00793c Merge pull request #14210 from nestjs/renovate/husky-9.x
chore(deps): update dependency husky to v9.1.7
2024-11-27 08:39:07 +01:00
Kamil Myśliwiec
ab79649b91 ci: run lint sequentially in ci 2024-11-27 08:38:14 +01:00
Kamil Myśliwiec
f94ef9044f test: ignore floating request promises (done cb) 2024-11-27 08:37:58 +01:00
Kamil Mysliwiec
b876e6b60d Merge pull request #14211 from nestjs/renovate/nest-monorepo
chore(deps): update nest monorepo
2024-11-27 08:30:17 +01:00
renovate[bot]
a7392981cf chore(deps): update nest monorepo 2024-11-27 07:27:07 +00:00
renovate[bot]
afb889dd21 chore(deps): update dependency husky to v9.1.7 2024-11-27 07:22:52 +00:00
Kamil Mysliwiec
8da7ebcbfd Merge pull request #14206 from nestjs/dependabot/npm_and_yarn/mongoose-8.8.3
chore(deps-dev): bump mongoose from 8.8.1 to 8.8.3
2024-11-27 08:15:28 +01:00
dependabot[bot]
c90553bb05 chore(deps-dev): bump mongoose from 8.8.1 to 8.8.3
Bumps [mongoose](https://github.com/Automattic/mongoose) from 8.8.1 to 8.8.3.
- [Release notes](https://github.com/Automattic/mongoose/releases)
- [Changelog](https://github.com/Automattic/mongoose/blob/master/CHANGELOG.md)
- [Commits](https://github.com/Automattic/mongoose/compare/8.8.1...8.8.3)

---
updated-dependencies:
- dependency-name: mongoose
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-27 00:39:08 +00:00
Kamil Myśliwiec
93150409b9 test: error messages for node above v20 (json socket) 2024-11-26 15:22:51 +01:00
Kamil Myśliwiec
7e774b12a5 ci: use active node version for lint 2024-11-26 15:12:49 +01:00
Kamil Myśliwiec
2e0de4a9e1 ci: update node versions matrix 2024-11-26 15:06:21 +01:00
Kamil Myśliwiec
e8bc2580e7 chore: minore fixes 2024-11-26 14:56:42 +01:00
Kamil Myśliwiec
7d3e5c1a38 build: use strict null checks part 5 2024-11-26 14:39:51 +01:00
Kamil Myśliwiec
5b220df118 build: use strict null checks part 4 2024-11-26 14:03:07 +01:00
Kamil Myśliwiec
b94b0b910e build: use strict null checks part 3 2024-11-26 13:49:07 +01:00
Kamil Myśliwiec
22008976ec build: use strict null checks part 2 2024-11-26 13:36:33 +01:00
Kamil Myśliwiec
cfe0f47e8a Merge branch 'chore/eslint-v9' of https://github.com/nestjs/nest into chore/eslint-v9 2024-11-26 12:47:16 +01:00
Kamil Myśliwiec
10fdf16c47 build: use strict null checks part 1 2024-11-26 12:46:59 +01:00
Kamil Mysliwiec
5662fc1ac9 Merge branch '11.0.0' into chore/eslint-v9 2024-11-26 12:00:34 +01:00
Kamil Myśliwiec
38367e8e88 style: address spec lint errors 2024-11-26 11:57:05 +01:00
Kamil Myśliwiec
8829b8d1d7 style: address packages lint errors 2024-11-26 10:38:31 +01:00
Kamil Myśliwiec
236b633a76 style: address integration tests lint errors 2024-11-26 09:39:20 +01:00
Kamil Mysliwiec
8102325bd2 Merge pull request #14204 from sapenlei/fix/non-shared-server-close
fix(websockets): ensure non-shared servers call close method
2024-11-26 08:19:50 +01:00
sapen
bba5fde16e fix(websockets): ensure non-shared servers call close method 2024-11-26 11:11:58 +08:00
Kamil Myśliwiec
416830c392 chore(@nestjs) publish v10.4.9 release 2024-11-25 15:34:51 +01:00
Kamil Mysliwiec
9286733482 Merge pull request #13923 from DylanVeldra/fix-tenant-context-payload
fix(core): merge req context with tenant payload in the request instance
2024-11-25 15:01:51 +01:00
Kamil Mysliwiec
81597f7ed9 Merge branch 'master' into fix-tenant-context-payload 2024-11-25 14:38:47 +01:00
Kamil Myśliwiec
84b8744f90 refactor: methods order, types in e2e test 2024-11-25 14:34:28 +01:00
Kamil Mysliwiec
95c8547b68 Merge pull request #14185 from sapenlei/fix/prevent-socketio-server-close
fix(websockets): Prevent HTTP server early close in Socket.IO shutdown
2024-11-25 14:31:18 +01:00
Kamil Myśliwiec
ae0517b364 Merge branch 'master' of https://github.com/nestjs/nest 2024-11-25 14:28:56 +01:00
Kamil Myśliwiec
8ffae006c8 sample: revert microservices sample local updates 2024-11-25 14:28:44 +01:00
Kamil Mysliwiec
f7248e2d8d Merge pull request #14181 from nestjs/fix/validation-pipe-swc-enum-bug
fix(common): fallback to empty string for enums when validating (swc builder)
2024-11-25 14:12:13 +01:00
Kamil Mysliwiec
edf574a29e Merge pull request #14200 from nestjs/feat/allow-queue-per-handler
feat(microservices): support nats queue per handler
2024-11-25 14:12:02 +01:00
Kamil Myśliwiec
25ad5b4b80 refactor(core): tiny improvements 2024-11-25 14:11:38 +01:00
Kamil Mysliwiec
3324703b88 Merge pull request #13804 from patrickacioli/fix-lazy-transient-provider
fix(core): dependencies not resolving for transient lazy providers
2024-11-25 14:10:06 +01:00
Kamil Myśliwiec
ab660c7edd test: add unit test 2024-11-25 13:48:54 +01:00
Kamil Myśliwiec
21279a9c49 feat(microservices): support nats queue per handler 2024-11-25 13:42:24 +01:00
Kamil Mysliwiec
59374c9b8c Merge pull request #13797 from patrickacioli/fix-fastify-global-route-prefix
fix(fastify-adapter): middleware not executed when root path is excluded
2024-11-25 13:37:55 +01:00
sapen
3b5cb562a1 test(websockets): Add integration test for Socket.IO HTTP server shutdown 2024-11-22 20:14:02 +08:00
Kamil Mysliwiec
43cf5723a3 Merge pull request #14184 from nestjs/feat/include-error-cause-ws
feat(websockets): include exception cause to associate error with req
2024-11-22 11:33:20 +01:00
Kamil Mysliwiec
b04895aed2 Merge pull request #14182 from nestjs/feat/intrinsic-exception
feat(common): introduce intrinsic exception
2024-11-22 11:32:18 +01:00
Kamil Mysliwiec
67e30e2f1f Merge pull request #14192 from nestjs/renovate/npm-webpack-vulnerability
chore(deps): update dependency webpack to v5.94.0 [security]
2024-11-22 11:31:18 +01:00
sapen
f650c22af8 fix(websockets): Revert type 2024-11-22 15:45:08 +08:00
renovate[bot]
2b90f44621 chore(deps): update dependency webpack to v5.94.0 [security] 2024-11-22 07:27:42 +00:00
Kamil Mysliwiec
3cf1130eaa Merge pull request #14191 from nestjs/dependabot/npm_and_yarn/light-my-request-6.3.0
chore(deps): bump light-my-request from 6.1.0 to 6.3.0
2024-11-22 08:24:47 +01:00
dependabot[bot]
646c663366 chore(deps): bump light-my-request from 6.1.0 to 6.3.0
Bumps [light-my-request](https://github.com/fastify/light-my-request) from 6.1.0 to 6.3.0.
- [Release notes](https://github.com/fastify/light-my-request/releases)
- [Commits](https://github.com/fastify/light-my-request/compare/v6.1.0...v6.3.0)

---
updated-dependencies:
- dependency-name: light-my-request
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-22 00:26:01 +00:00
Kamil Mysliwiec
f39fdacf8a Merge pull request #14188 from nestjs/dependabot/npm_and_yarn/sample/30-event-emitter/cross-spawn-7.0.6
chore(deps): bump cross-spawn from 7.0.3 to 7.0.6 in /sample/30-event-emitter
2024-11-21 14:37:45 +01:00
dependabot[bot]
7fe2f43d28 chore(deps): bump cross-spawn in /sample/30-event-emitter
Bumps [cross-spawn](https://github.com/moxystudio/node-cross-spawn) from 7.0.3 to 7.0.6.
- [Changelog](https://github.com/moxystudio/node-cross-spawn/blob/master/CHANGELOG.md)
- [Commits](https://github.com/moxystudio/node-cross-spawn/compare/v7.0.3...v7.0.6)

---
updated-dependencies:
- dependency-name: cross-spawn
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-21 13:19:30 +00:00
Kamil Mysliwiec
180a3e6bd3 Merge pull request #14187 from nestjs/dependabot/npm_and_yarn/sample/34-using-esm-packages/multi-c29acd3782
chore(deps): bump cookie and @nestjs/platform-express in /sample/34-using-esm-packages
2024-11-21 14:18:28 +01:00
Kamil Mysliwiec
afbba2d318 Merge pull request #14189 from nestjs/dependabot/npm_and_yarn/sample/19-auth-jwt/cross-spawn-7.0.6
chore(deps): bump cross-spawn from 7.0.3 to 7.0.6 in /sample/19-auth-jwt
2024-11-21 14:18:19 +01:00
Kamil Myśliwiec
f80984fb78 test: update integration test 2024-11-21 14:17:57 +01:00
dependabot[bot]
e3e9636dcc chore(deps): bump cross-spawn from 7.0.3 to 7.0.6 in /sample/19-auth-jwt
Bumps [cross-spawn](https://github.com/moxystudio/node-cross-spawn) from 7.0.3 to 7.0.6.
- [Changelog](https://github.com/moxystudio/node-cross-spawn/blob/master/CHANGELOG.md)
- [Commits](https://github.com/moxystudio/node-cross-spawn/compare/v7.0.3...v7.0.6)

---
updated-dependencies:
- dependency-name: cross-spawn
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-21 13:14:40 +00:00
Kamil Mysliwiec
a4ddd867e6 Merge pull request #14186 from nestjs/dependabot/npm_and_yarn/sample/31-graphql-federation-code-first/posts-application/cross-spawn-7.0.6
chore(deps): bump cross-spawn from 7.0.3 to 7.0.6 in /sample/31-graphql-federation-code-first/posts-application
2024-11-21 14:13:14 +01:00
dependabot[bot]
f99353f45e chore(deps): bump cookie and @nestjs/platform-express
Bumps [cookie](https://github.com/jshttp/cookie) to 0.7.1 and updates ancestor dependency [@nestjs/platform-express](https://github.com/nestjs/nest/tree/HEAD/packages/platform-express). These dependencies need to be updated together.


Updates `cookie` from 0.6.0 to 0.7.1
- [Release notes](https://github.com/jshttp/cookie/releases)
- [Commits](https://github.com/jshttp/cookie/compare/v0.6.0...v0.7.1)

Updates `@nestjs/platform-express` from 10.4.4 to 10.4.8
- [Release notes](https://github.com/nestjs/nest/releases)
- [Commits](https://github.com/nestjs/nest/commits/v10.4.8/packages/platform-express)

---
updated-dependencies:
- dependency-name: cookie
  dependency-type: indirect
- dependency-name: "@nestjs/platform-express"
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-21 11:49:11 +00:00
dependabot[bot]
f3c0fcde5b chore(deps): bump cross-spawn
Bumps [cross-spawn](https://github.com/moxystudio/node-cross-spawn) from 7.0.3 to 7.0.6.
- [Changelog](https://github.com/moxystudio/node-cross-spawn/blob/master/CHANGELOG.md)
- [Commits](https://github.com/moxystudio/node-cross-spawn/compare/v7.0.3...v7.0.6)

---
updated-dependencies:
- dependency-name: cross-spawn
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-21 11:49:11 +00:00
Kamil Mysliwiec
29cc21c7b7 Merge pull request #14183 from nestjs/dependabot/npm_and_yarn/sample/32-graphql-federation-schema-first/posts-application/cross-spawn-7.0.6
chore(deps): bump cross-spawn from 7.0.3 to 7.0.6 in /sample/32-graphql-federation-schema-first/posts-application
2024-11-21 12:47:07 +01:00
Kamil Myśliwiec
5c7724b649 test: update integration test 2024-11-21 12:46:20 +01:00
Kamil Myśliwiec
a3dbbecd61 feat: add cause factory to allow controlling the cause shape 2024-11-21 12:42:40 +01:00
sapen
40dbb27519 fix(websockets): Prevent HTTP server early close in Socket.IO shutdown 2024-11-21 19:20:26 +08:00
Kamil Myśliwiec
db95f2009d test: add missing unit tests, update typo 2024-11-21 12:06:35 +01:00
Kamil Myśliwiec
9020d759ca chore: export error payload interface 2024-11-21 11:35:24 +01:00
Kamil Myśliwiec
9a2b04947e chore: include pattern too 2024-11-21 11:35:02 +01:00
Kamil Myśliwiec
24983c8893 Merge branch 'feat/intrinsic-exception' into feat/include-error-cause-ws 2024-11-21 11:33:24 +01:00
Kamil Myśliwiec
a077ea51c1 Merge branch '11.0.0' into feat/intrinsic-exception 2024-11-21 10:43:36 +01:00
Kamil Myśliwiec
03a61e9728 chore: revert apply decorators signature (regression) 2024-11-21 10:41:37 +01:00
dependabot[bot]
2111a40e47 chore(deps): bump cross-spawn
Bumps [cross-spawn](https://github.com/moxystudio/node-cross-spawn) from 7.0.3 to 7.0.6.
- [Changelog](https://github.com/moxystudio/node-cross-spawn/blob/master/CHANGELOG.md)
- [Commits](https://github.com/moxystudio/node-cross-spawn/compare/v7.0.3...v7.0.6)

---
updated-dependencies:
- dependency-name: cross-spawn
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-21 09:32:47 +00:00
Kamil Mysliwiec
440e9cf6a3 Merge pull request #14176 from nestjs/dependabot/npm_and_yarn/sample/32-graphql-federation-schema-first/users-application/cross-spawn-7.0.6
chore(deps): bump cross-spawn from 7.0.3 to 7.0.6 in /sample/32-graphql-federation-schema-first/users-application
2024-11-21 10:31:30 +01:00
Kamil Myśliwiec
c5e5b9072c feat(websockets): include exception cause to associate error with req 2024-11-21 10:30:26 +01:00
Kamil Myśliwiec
f99617dd6b feat(common): introduce intrinsic exception 2024-11-21 10:09:43 +01:00
Kamil Mysliwiec
f76a69341e Update packages/common/pipes/validation.pipe.ts 2024-11-21 09:48:21 +01:00
Kamil Myśliwiec
a3acefffda fix(common): fallback to empty string for enums when validating (swc) 2024-11-21 09:38:42 +01:00
Kamil Mysliwiec
73dea121d7 Merge pull request #14179 from nestjs/dependabot/npm_and_yarn/types/mocha-10.0.10
chore(deps-dev): bump @types/mocha from 10.0.9 to 10.0.10
2024-11-21 08:20:48 +01:00
Kamil Mysliwiec
a1732f5b3d Merge pull request #14175 from micalevisk/fix-issue-14154
fix(common,core): align the logic of optional provider
2024-11-21 08:20:34 +01:00
dependabot[bot]
76e73c26d5 chore(deps-dev): bump @types/mocha from 10.0.9 to 10.0.10
Bumps [@types/mocha](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/mocha) from 10.0.9 to 10.0.10.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/mocha)

---
updated-dependencies:
- dependency-name: "@types/mocha"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-21 00:23:58 +00:00
dependabot[bot]
62e3bd5a16 chore(deps): bump cross-spawn
Bumps [cross-spawn](https://github.com/moxystudio/node-cross-spawn) from 7.0.3 to 7.0.6.
- [Changelog](https://github.com/moxystudio/node-cross-spawn/blob/master/CHANGELOG.md)
- [Commits](https://github.com/moxystudio/node-cross-spawn/compare/v7.0.3...v7.0.6)

---
updated-dependencies:
- dependency-name: cross-spawn
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-20 14:45:08 +00:00
Kamil Mysliwiec
45f4612ed5 Merge pull request #14174 from nestjs/dependabot/npm_and_yarn/sample/22-graphql-prisma/cross-spawn-7.0.6
chore(deps): bump cross-spawn from 7.0.3 to 7.0.6 in /sample/22-graphql-prisma
2024-11-20 15:43:53 +01:00
Micael Levi L. Cavalcante
aabde1aadb fix(common,core): align the logic of optional provider 2024-11-20 09:43:11 -04:00
Micael Levi L. Cavalcante
de6f7ca20e test(common): improve test suite for getInjectionProviders 2024-11-20 09:40:33 -04:00
dependabot[bot]
33be15afd5 chore(deps): bump cross-spawn in /sample/22-graphql-prisma
Bumps [cross-spawn](https://github.com/moxystudio/node-cross-spawn) from 7.0.3 to 7.0.6.
- [Changelog](https://github.com/moxystudio/node-cross-spawn/blob/master/CHANGELOG.md)
- [Commits](https://github.com/moxystudio/node-cross-spawn/compare/v7.0.3...v7.0.6)

---
updated-dependencies:
- dependency-name: cross-spawn
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-20 13:30:43 +00:00
Kamil Mysliwiec
48a74b338b Merge pull request #14173 from nestjs/dependabot/npm_and_yarn/sample/28-sse/cross-spawn-7.0.6
chore(deps): bump cross-spawn from 7.0.3 to 7.0.6 in /sample/28-sse
2024-11-20 14:27:26 +01:00
Kamil Myśliwiec
5064d9b4a4 Merge branch 'pacyL2K19-test/sample-12-graphql-schema-first' 2024-11-20 12:56:23 +01:00
Kamil Myśliwiec
d98524ab9c chore: minor formatting changes 2024-11-20 12:56:10 +01:00
Kamil Myśliwiec
ddf99c39d0 Merge branch 'martinvysnovsky-test-sample-mongoose' 2024-11-20 12:53:04 +01:00
Kamil Myśliwiec
691e7d448e chore: minor formatting changes 2024-11-20 12:52:50 +01:00
Kamil Myśliwiec
518879b3d6 Merge branch 'test-sample-mongoose' of https://github.com/martinvysnovsky/nest into martinvysnovsky-test-sample-mongoose 2024-11-20 12:50:39 +01:00
Kamil Myśliwiec
b770d7d9b2 Merge branch 'master' of https://github.com/nestjs/nest 2024-11-20 12:49:16 +01:00
Kamil Myśliwiec
8b978e3028 Merge branch 'Yansb-test/sample-01-cats-app' 2024-11-20 12:49:03 +01:00
Kamil Myśliwiec
0f25e83229 style: minor formatting changes 2024-11-20 12:48:53 +01:00
Kamil Myśliwiec
f3ec5f22fa Merge branch 'test/sample-01-cats-app' of https://github.com/Yansb/nest into Yansb-test/sample-01-cats-app 2024-11-20 12:48:06 +01:00
dependabot[bot]
467697599f chore(deps): bump cross-spawn from 7.0.3 to 7.0.6 in /sample/28-sse
Bumps [cross-spawn](https://github.com/moxystudio/node-cross-spawn) from 7.0.3 to 7.0.6.
- [Changelog](https://github.com/moxystudio/node-cross-spawn/blob/master/CHANGELOG.md)
- [Commits](https://github.com/moxystudio/node-cross-spawn/compare/v7.0.3...v7.0.6)

---
updated-dependencies:
- dependency-name: cross-spawn
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-20 11:47:13 +00:00
Kamil Mysliwiec
1dafb5fdce Merge pull request #14165 from nestjs/dependabot/npm_and_yarn/typescript-eslint/parser-8.15.0
chore(deps-dev): bump @typescript-eslint/parser from 8.14.0 to 8.15.0
2024-11-20 12:46:02 +01:00
Kamil Myśliwiec
212d07fcbf refactor(common): improve apply decorators types 2024-11-20 12:45:29 +01:00
Kamil Mysliwiec
71e8acec39 Merge pull request #14163 from nestjs/fix/grpc-client-streaming-bug
fix(microservices): grpc client streaming bugs
2024-11-20 11:11:51 +01:00
Kamil Mysliwiec
6094701679 Merge pull request #12954 from gunb0s/feature/nestjs-kafka-emit-batch
feat: emit batch
2024-11-20 11:11:43 +01:00
Kamil Mysliwiec
bdc9b4409a Merge pull request #14142 from nestjs/feat/microservice-client-server-additions
feat(microservices): add status, unwrap, on, and other features
2024-11-20 11:04:50 +01:00
Kamil Myśliwiec
c66d1fb5f7 fix: add type constraints and assertions 2024-11-20 10:41:37 +01:00
Kamil Mysliwiec
99b5a5bbfe Merge pull request #14171 from nestjs/dependabot/npm_and_yarn/sample/11-swagger/cross-spawn-7.0.6
chore(deps): bump cross-spawn from 7.0.3 to 7.0.6 in /sample/11-swagger
2024-11-20 10:39:37 +01:00
Kamil Mysliwiec
1531e6a767 Merge pull request #14172 from nestjs/dependabot/npm_and_yarn/sample/35-use-esm-package-after-node22/multi-c29acd3782
chore(deps): bump cookie and @nestjs/platform-express in /sample/35-use-esm-package-after-node22
2024-11-20 10:36:36 +01:00
dependabot[bot]
3fa80a9dab chore(deps): bump cookie and @nestjs/platform-express
Bumps [cookie](https://github.com/jshttp/cookie) to 0.7.1 and updates ancestor dependency [@nestjs/platform-express](https://github.com/nestjs/nest/tree/HEAD/packages/platform-express). These dependencies need to be updated together.


Updates `cookie` from 0.6.0 to 0.7.1
- [Release notes](https://github.com/jshttp/cookie/releases)
- [Commits](https://github.com/jshttp/cookie/compare/v0.6.0...v0.7.1)

Updates `@nestjs/platform-express` from 10.4.4 to 10.4.8
- [Release notes](https://github.com/nestjs/nest/releases)
- [Commits](https://github.com/nestjs/nest/commits/v10.4.8/packages/platform-express)

---
updated-dependencies:
- dependency-name: cookie
  dependency-type: indirect
- dependency-name: "@nestjs/platform-express"
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-20 09:27:05 +00:00
Kamil Mysliwiec
439516d7dc Merge pull request #14051 from micalevisk/add-esm-only-sample
chore: add sample on how to use esm on cjs
2024-11-20 10:26:00 +01:00
dependabot[bot]
22c4e9cae3 chore(deps): bump cross-spawn from 7.0.3 to 7.0.6 in /sample/11-swagger
Bumps [cross-spawn](https://github.com/moxystudio/node-cross-spawn) from 7.0.3 to 7.0.6.
- [Changelog](https://github.com/moxystudio/node-cross-spawn/blob/master/CHANGELOG.md)
- [Commits](https://github.com/moxystudio/node-cross-spawn/compare/v7.0.3...v7.0.6)

---
updated-dependencies:
- dependency-name: cross-spawn
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-20 09:22:40 +00:00
Kamil Mysliwiec
9356509274 Update packages/microservices/server/server-nats.ts
Co-authored-by: Rick Dutour Geerling <rick@trilon.io>
2024-11-20 10:22:02 +01:00
Kamil Mysliwiec
2dda578d9a Merge pull request #14170 from nestjs/dependabot/npm_and_yarn/sample/24-serve-static/cross-spawn-7.0.6
chore(deps): bump cross-spawn from 7.0.3 to 7.0.6 in /sample/24-serve-static
2024-11-20 10:21:33 +01:00
Kamil Myśliwiec
b65c41c5a8 fix: use proxy, drain buffer before execution 2024-11-20 10:21:10 +01:00
dependabot[bot]
f0c3cef7d4 chore(deps): bump cross-spawn in /sample/24-serve-static
Bumps [cross-spawn](https://github.com/moxystudio/node-cross-spawn) from 7.0.3 to 7.0.6.
- [Changelog](https://github.com/moxystudio/node-cross-spawn/blob/master/CHANGELOG.md)
- [Commits](https://github.com/moxystudio/node-cross-spawn/compare/v7.0.3...v7.0.6)

---
updated-dependencies:
- dependency-name: cross-spawn
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-20 08:24:47 +00:00
Kamil Mysliwiec
e2e70c1bc3 Merge pull request #14169 from nestjs/dependabot/npm_and_yarn/sample/15-mvc/cross-spawn-7.0.6
chore(deps): bump cross-spawn from 7.0.3 to 7.0.6 in /sample/15-mvc
2024-11-20 09:23:39 +01:00
dependabot[bot]
70c18e9e7b chore(deps-dev): bump @typescript-eslint/parser from 8.14.0 to 8.15.0
Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 8.14.0 to 8.15.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v8.15.0/packages/parser)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/parser"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-20 07:42:35 +00:00
dependabot[bot]
102718ad1b chore(deps): bump cross-spawn from 7.0.3 to 7.0.6 in /sample/15-mvc
Bumps [cross-spawn](https://github.com/moxystudio/node-cross-spawn) from 7.0.3 to 7.0.6.
- [Changelog](https://github.com/moxystudio/node-cross-spawn/blob/master/CHANGELOG.md)
- [Commits](https://github.com/moxystudio/node-cross-spawn/compare/v7.0.3...v7.0.6)

---
updated-dependencies:
- dependency-name: cross-spawn
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-20 07:42:00 +00:00
Kamil Mysliwiec
02d26a6fd7 Merge pull request #14164 from nestjs/dependabot/npm_and_yarn/sample/01-cats-app/cross-spawn-7.0.6
chore(deps): bump cross-spawn from 7.0.3 to 7.0.6 in /sample/01-cats-app
2024-11-20 08:40:13 +01:00
Kamil Mysliwiec
8279fb5319 Merge pull request #14167 from nestjs/dependabot/npm_and_yarn/typescript-eslint/eslint-plugin-8.15.0
chore(deps-dev): bump @typescript-eslint/eslint-plugin from 8.14.0 to 8.15.0
2024-11-20 08:40:05 +01:00
dependabot[bot]
d4e5743c9b chore(deps-dev): bump @typescript-eslint/eslint-plugin
Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 8.14.0 to 8.15.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v8.15.0/packages/eslint-plugin)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/eslint-plugin"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-19 00:49:10 +00:00
dependabot[bot]
b1e33ece5d chore(deps): bump cross-spawn from 7.0.3 to 7.0.6 in /sample/01-cats-app
Bumps [cross-spawn](https://github.com/moxystudio/node-cross-spawn) from 7.0.3 to 7.0.6.
- [Changelog](https://github.com/moxystudio/node-cross-spawn/blob/master/CHANGELOG.md)
- [Commits](https://github.com/moxystudio/node-cross-spawn/compare/v7.0.3...v7.0.6)

---
updated-dependencies:
- dependency-name: cross-spawn
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-18 22:46:40 +00:00
Micael Levi L. Cavalcante
e15d73190d chore: add sample on how to use esm with nodejs experimental flag 2024-11-18 11:30:39 -04:00
Kamil Myśliwiec
4564503936 fix: use valid reference for the cancel event constant 2024-11-18 15:27:45 +01:00
Kamil Mysliwiec
129fe79f6b Update packages/microservices/server/server-rmq.ts
Co-authored-by: Rick Dutour Geerling <rick@trilon.io>
2024-11-18 15:26:15 +01:00
Kamil Mysliwiec
4f55f88bff Update packages/microservices/server/server-nats.ts
Co-authored-by: Rick Dutour Geerling <rick@trilon.io>
2024-11-18 15:26:07 +01:00
Kamil Myśliwiec
30a6b52c50 fix(microservices): grpc client streaming bugs #14094 #13818 2024-11-18 15:23:44 +01:00
Kamil Mysliwiec
397390083f Merge pull request #13278 from johaven/feat-webdav-methods
feat(core,common,platform-fastify): add webdav http methods support
2024-11-18 13:16:35 +01:00
Kamil Myśliwiec
bc31b5cff5 test: update tcp config opts type 2024-11-18 13:14:59 +01:00
Kamil Mysliwiec
fb6025eb76 Merge pull request #13990 from Tony133/feat/upgrade-fastify-v5
feat(platform-fastify): added support for Fastify v5
2024-11-18 12:46:08 +01:00
Kamil Myśliwiec
3267135f2d chore: resolve merge conflicts 2024-11-18 12:45:34 +01:00
Kamil Mysliwiec
234d8d5600 Merge pull request #13924 from alinowrouzii/feat-microservices/nats-gracefull-shutdown
feat(microservices): add gracefull shutdown option for nats server
2024-11-18 12:33:48 +01:00
Kamil Mysliwiec
774ccbe1b2 Merge pull request #12622 from jmcdo29/feat/async-microservce-config
feat: allow for microservice options to come from the di container
2024-11-18 12:18:57 +01:00
Kamil Mysliwiec
ad97a73ab2 Merge branch '11.0.0' into feat-microservices/nats-gracefull-shutdown 2024-11-18 12:18:16 +01:00
Kamil Mysliwiec
00bb6309c1 Merge pull request #13407 from MegaSpaceHamlet/multer-error-fieldname
Multer error fieldname
2024-11-18 12:09:40 +01:00
Kamil Myśliwiec
c239f9a037 refactor: replace inline as any calls with untyped vars 2024-11-18 10:33:51 +01:00
Kamil Mysliwiec
a669981c81 Merge pull request #14121 from nestjs/feat/logger-additions
feat(common): json logger and a few other improvements
2024-11-18 10:09:57 +01:00
Kamil Myśliwiec
47941ba4d9 test: update outdated unit test 2024-11-18 09:56:13 +01:00
Kamil Mysliwiec
e89bb8e4a2 Merge pull request #14127 from CodyTseng/feat-ws-message-preprocessor
feat(ws): introduce message parser for ws adapter
2024-11-18 09:52:52 +01:00
Kamil Mysliwiec
ca86bf6374 Merge pull request #14129 from EeeasyCode/fix/issue-#13931
fix: rabbitmq bindings and auto-generated queues
2024-11-18 09:52:00 +01:00
Kamil Myśliwiec
09a193337a Merge branch 'ReneZeidler-fix-get-all-and-merge' into 11.0.0 2024-11-18 09:51:35 +01:00
Kamil Mysliwiec
bc19f81729 Merge pull request #14161 from nestjs/dependabot/npm_and_yarn/sample/25-dynamic-modules/cross-spawn-7.0.5
chore(deps): bump cross-spawn from 7.0.3 to 7.0.5 in /sample/25-dynamic-modules
2024-11-18 09:50:43 +01:00
Kamil Myśliwiec
33ef121d6b chore: a few improvements 2024-11-18 09:49:48 +01:00
dependabot[bot]
989075e6c1 chore(deps): bump cross-spawn in /sample/25-dynamic-modules
Bumps [cross-spawn](https://github.com/moxystudio/node-cross-spawn) from 7.0.3 to 7.0.5.
- [Changelog](https://github.com/moxystudio/node-cross-spawn/blob/master/CHANGELOG.md)
- [Commits](https://github.com/moxystudio/node-cross-spawn/compare/v7.0.3...v7.0.5)

---
updated-dependencies:
- dependency-name: cross-spawn
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-18 08:17:48 +00:00
Kamil Mysliwiec
c60428a6fd Merge pull request #14159 from nestjs/dependabot/npm_and_yarn/sample/33-graphql-mercurius/cross-spawn-7.0.5
chore(deps): bump cross-spawn from 7.0.3 to 7.0.5 in /sample/33-graphql-mercurius
2024-11-18 09:16:06 +01:00
Kamil Mysliwiec
d2ac397115 Merge pull request #13388 from AlexRMU/master
Сorrection of `Reflector` types
2024-11-18 09:14:09 +01:00
Kamil Myśliwiec
9129e4f858 refactor: remove redundant conditions 2024-11-18 09:10:34 +01:00
Kamil Myśliwiec
f37dafc132 chore: pass error instance to logger error method 2024-11-18 09:08:47 +01:00
Kamil Mysliwiec
3ad835c05d Merge pull request #14110 from wenlong-chen/fix-global-module-distance
fix(core): calculate module distance after bindGlobalScope
2024-11-18 08:18:34 +01:00
Kamil Mysliwiec
e965b4a141 Merge pull request #14111 from wenlong-chen/fix-module-destroy-order
fix(core): Order of module destroy should be the reverse of module init
2024-11-18 08:18:16 +01:00
Kamil Mysliwiec
92e2db8d99 Merge pull request #13632 from nestjs/renovate/npm-mysql2-vulnerability
fix(deps): update dependency mysql2 to v3.9.8 [security]
2024-11-18 08:16:45 +01:00
dependabot[bot]
5911ed245e chore(deps): bump cross-spawn in /sample/33-graphql-mercurius
Bumps [cross-spawn](https://github.com/moxystudio/node-cross-spawn) from 7.0.3 to 7.0.5.
- [Changelog](https://github.com/moxystudio/node-cross-spawn/blob/master/CHANGELOG.md)
- [Commits](https://github.com/moxystudio/node-cross-spawn/compare/v7.0.3...v7.0.5)

---
updated-dependencies:
- dependency-name: cross-spawn
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-18 07:15:19 +00:00
Kamil Mysliwiec
1b4decf75e Merge pull request #14151 from nestjs/dependabot/npm_and_yarn/sample/27-scheduling/cross-spawn-7.0.5
chore(deps): bump cross-spawn from 7.0.3 to 7.0.5 in /sample/27-scheduling
2024-11-18 08:13:39 +01:00
Kamil Mysliwiec
36756dd194 Merge pull request #14153 from micalevisk/patch-1
chore: shallow cloning `wrk` repository on benchmark setup
2024-11-18 08:13:18 +01:00
Kamil Mysliwiec
27193cc99f Merge pull request #14155 from webdiscus/cli-color-to-ansis
build(sample): replace cli-color with smaller and faster ansis
2024-11-18 08:13:08 +01:00
Micael Levi L. Cavalcante
194732f4aa chore: shallow cloning wrk repository on benchmarking setup 2024-11-17 12:41:46 -04:00
biodiscus
3559e0c1f2 build(sample): replace cli-color with smaller and faster ansis 2024-11-17 17:01:47 +01:00
dependabot[bot]
2e4ebe4870 chore(deps): bump cross-spawn in /sample/27-scheduling
Bumps [cross-spawn](https://github.com/moxystudio/node-cross-spawn) from 7.0.3 to 7.0.5.
- [Changelog](https://github.com/moxystudio/node-cross-spawn/blob/master/CHANGELOG.md)
- [Commits](https://github.com/moxystudio/node-cross-spawn/compare/v7.0.3...v7.0.5)

---
updated-dependencies:
- dependency-name: cross-spawn
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-16 21:17:27 +00:00
Kamil Mysliwiec
7d62aad5fc Merge pull request #14146 from nestjs/dependabot/npm_and_yarn/sample/28-sse/multi-c29acd3782
chore(deps): bump cookie and @nestjs/platform-express in /sample/28-sse
2024-11-16 22:16:21 +01:00
Kamil Mysliwiec
ef8f64cf42 Merge pull request #14149 from nestjs/dependabot/npm_and_yarn/sample/32-graphql-federation-schema-first/gateway/cross-spawn-7.0.5
chore(deps): bump cross-spawn from 7.0.3 to 7.0.5 in /sample/32-graphql-federation-schema-first/gateway
2024-11-16 22:16:13 +01:00
Kamil Mysliwiec
afa667509f Merge pull request #12995 from nestjs/renovate/supertest-6.x
chore(deps): update dependency supertest to v6.3.4
2024-11-16 22:15:59 +01:00
renovate[bot]
dc09280634 chore(deps): update dependency supertest to v6.3.4 2024-11-16 20:31:33 +00:00
dependabot[bot]
8115930ec8 chore(deps): bump cookie and @nestjs/platform-express in /sample/28-sse
Bumps [cookie](https://github.com/jshttp/cookie) to 0.7.1 and updates ancestor dependency [@nestjs/platform-express](https://github.com/nestjs/nest/tree/HEAD/packages/platform-express). These dependencies need to be updated together.


Updates `cookie` from 0.6.0 to 0.7.1
- [Release notes](https://github.com/jshttp/cookie/releases)
- [Commits](https://github.com/jshttp/cookie/compare/v0.6.0...v0.7.1)

Updates `@nestjs/platform-express` from 10.4.4 to 10.4.8
- [Release notes](https://github.com/nestjs/nest/releases)
- [Commits](https://github.com/nestjs/nest/commits/v10.4.8/packages/platform-express)

---
updated-dependencies:
- dependency-name: cookie
  dependency-type: indirect
- dependency-name: "@nestjs/platform-express"
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-16 20:27:58 +00:00
Kamil Mysliwiec
8fc1c9786a Merge pull request #12815 from nestjs/renovate/node-20.x
chore(deps): update dependency @types/node to v20.17.6
2024-11-16 21:26:57 +01:00
renovate[bot]
2b9f2fd493 chore(deps): update dependency @types/node to v20.17.6 2024-11-16 20:20:53 +00:00
renovate[bot]
2867dff697 fix(deps): update dependency mysql2 to v3.9.8 [security] 2024-11-16 20:18:43 +00:00
dependabot[bot]
ee7eb9d48d chore(deps): bump cross-spawn
Bumps [cross-spawn](https://github.com/moxystudio/node-cross-spawn) from 7.0.3 to 7.0.5.
- [Changelog](https://github.com/moxystudio/node-cross-spawn/blob/master/CHANGELOG.md)
- [Commits](https://github.com/moxystudio/node-cross-spawn/compare/v7.0.3...v7.0.5)

---
updated-dependencies:
- dependency-name: cross-spawn
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-16 20:13:01 +00:00
Kamil Mysliwiec
f38a07719a Merge pull request #14147 from nestjs/chore/upgrade-deps
chore: upgrade deps
2024-11-16 21:11:51 +01:00
Kamil Myśliwiec
af8cd7e4c9 sample: update grpc example 2024-11-16 20:49:36 +01:00
Kamil Myśliwiec
c800b06a22 ci: update node version for eslint workflow 2024-11-16 20:38:48 +01:00
Kamil Myśliwiec
f00192f4f1 chore: regenerate package-lock 2024-11-16 20:32:25 +01:00
Kamil Myśliwiec
b8ddf4fa59 chore: revert markdown-table 2024-11-16 20:29:41 +01:00
Kamil Myśliwiec
a9954025dd style(lint): update eslint rules 2024-11-16 20:26:21 +01:00
Kamil Myśliwiec
0d9b7c85db sample: updateg grpc options type 2024-11-16 20:25:42 +01:00
Kamil Myśliwiec
d9a592d899 chore: update package json 2024-11-16 20:01:52 +01:00
Kamil Myśliwiec
ef24801fcc chore: upgrade deps 2024-11-16 20:00:50 +01:00
Kamil Mysliwiec
bde210677f Merge pull request #14144 from nestjs/dependabot/npm_and_yarn/sample/33-graphql-mercurius/multi-ba981ebd23
chore(deps): bump cookie, light-my-request and @nestjs/platform-fastify in /sample/33-graphql-mercurius
2024-11-15 15:29:41 +01:00
Kamil Myśliwiec
d35006a0d3 chore: update readmes 2024-11-15 14:55:07 +01:00
dependabot[bot]
29a80ba8ab chore(deps): bump cookie, light-my-request and @nestjs/platform-fastify
Bumps [cookie](https://github.com/jshttp/cookie) to 0.7.2 and updates ancestor dependencies [cookie](https://github.com/jshttp/cookie), [light-my-request](https://github.com/fastify/light-my-request) and [@nestjs/platform-fastify](https://github.com/nestjs/nest/tree/HEAD/packages/platform-fastify). These dependencies need to be updated together.


Updates `cookie` from 0.5.0 to 0.7.2
- [Release notes](https://github.com/jshttp/cookie/releases)
- [Commits](https://github.com/jshttp/cookie/compare/v0.5.0...v0.7.2)

Updates `light-my-request` from 5.11.0 to 5.14.0
- [Release notes](https://github.com/fastify/light-my-request/releases)
- [Commits](https://github.com/fastify/light-my-request/compare/v5.11.0...v5.14.0)

Updates `@nestjs/platform-fastify` from 10.3.2 to 10.4.8
- [Release notes](https://github.com/nestjs/nest/releases)
- [Commits](https://github.com/nestjs/nest/commits/v10.4.8/packages/platform-fastify)

---
updated-dependencies:
- dependency-name: cookie
  dependency-type: indirect
- dependency-name: light-my-request
  dependency-type: indirect
- dependency-name: "@nestjs/platform-fastify"
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-15 13:53:10 +00:00
Kamil Myśliwiec
3c5180d2d5 chore(@nestjs) publish v10.4.8 release 2024-11-15 14:51:54 +01:00
Kamil Mysliwiec
a7b73e3107 Merge pull request #14143 from nestjs/feat/expose-listening-stream
feat(core): expose listening stream from http adapter host
2024-11-15 14:40:16 +01:00
Kamil Mysliwiec
491ed77f22 Merge pull request #14059 from v-sum/fix-disregarded-rmq-client-options
fix(microservices): include discarded rmq client options
2024-11-15 14:32:46 +01:00
Kamil Myśliwiec
e64ab182ba refactor(core): replace internal init with an inline promise 2024-11-15 14:32:09 +01:00
Kamil Mysliwiec
dade6d5889 Merge pull request #14139 from mksony/chore/ensure-application-init-before-accepting-sigterm
chore(core): defer application shutdown until init finishes
2024-11-15 14:31:03 +01:00
Kamil Mysliwiec
49dc36d9e5 Merge pull request #14132 from nestjs/fix/mqtt-microservices-qos2
fix(microservices): no messages emitted with mqtt when qos set
2024-11-15 14:30:42 +01:00
Kamil Mysliwiec
831d29553d Merge pull request #14133 from nestjs/fix/flaky-durable-provider
fix(core): flaky durable provider, remove instance on error
2024-11-15 14:30:28 +01:00
Kamil Mysliwiec
feb2135373 Merge pull request #14123 from micalevisk/feat/narrow-nest-factories-methods
feat(core)!: type narrowing valid entry module for nestjs factories
2024-11-15 13:29:54 +01:00
Kamil Mysliwiec
9ea618e0a8 Update packages/core/nest-factory.ts 2024-11-15 13:29:35 +01:00
Kamil Myśliwiec
259b5dd828 fix: remove duplicated client redis message handler 2024-11-15 13:27:04 +01:00
Kamil Myśliwiec
66c3ab23ee sample: update grpc client options type 2024-11-15 12:48:22 +01:00
Kamil Myśliwiec
f2b6cc0e93 fix: fix minor type issues, broken imports 2024-11-15 11:50:09 +01:00
Kamil Myśliwiec
1a076fc4cb feat(core): expose listening stream from http adapter host 2024-11-15 11:23:16 +01:00
Kamil Myśliwiec
f983f03665 fix: update broken import paths 2024-11-15 10:19:26 +01:00
Kamil Mysliwiec
9a48dc123e Merge pull request #14131 from nestjs/feat/number-exception-create-body
feat(common): allow passing number to http error createBody
2024-11-15 10:18:14 +01:00
Kamil Mysliwiec
07adf37156 Merge pull request #14122 from nestjs/feat/parse-date-pipe
feat(common): add ParseDatePipe, add tsdoc to other pipes
2024-11-15 10:17:52 +01:00
Kamil Mysliwiec
ea92f5fb3a Merge pull request #14134 from nestjs/feat/add-max-tcp-message-length
feat(microservices): add max tcp packet buffer length
2024-11-15 10:17:28 +01:00
Kamil Myśliwiec
3dfc7fc68e feat(microservices): add status, unwrap, on, and other features 2024-11-15 10:03:05 +01:00
Max Karacsony
5c6986f0c7 chore(core): defer application shutdown until init finishes 2024-11-14 13:50:07 +01:00
codytseng
33e32d9d5d feat(ws): allow setting message parser in constructor 2024-11-13 09:58:32 +08:00
codytseng
2ab99739cd refactor(ws): rename to message parser and move json parse logic inside 2024-11-13 09:57:29 +08:00
Kamil Myśliwiec
9ae6a4c19f feat(microservices): add max tcp packet buffer length 2024-11-12 13:37:14 +01:00
Kamil Myśliwiec
229d97f018 fix(core): flaky durable provider, remove instance on error #13953 2024-11-12 13:23:51 +01:00
Kamil Myśliwiec
1fe4dc2cad fix(microservices): no messages emitted with mqtt when qos set #14079 2024-11-12 12:35:25 +01:00
Kamil Myśliwiec
35846843e1 feat(common): allow passing number to http error create body #12787 2024-11-12 11:12:41 +01:00
Kamil Mysliwiec
945d134b66 Merge pull request #14126 from EeeasyCode/issue-#14093
fix(common): type narrowing context parameter on createParamDecorator's callback
2024-11-12 09:36:52 +01:00
Khan / 이창민
e231f9887e fix: rabbitmq bindings and auto-generated queues 2024-11-11 15:31:19 +09:00
Khan / 이창민
2874478b95 fix: import to use direct file path 2024-11-11 00:05:24 +09:00
codytseng
de13eec632 feat: introduce message preprocessor for ws adapter 2024-11-10 16:14:07 +08:00
Khan / 이창민
e9d57dd795 fix: type narrowing ctx 2024-11-10 16:31:29 +09:00
Micael Levi L. Cavalcante
3cdaaf0bed feat(core): type narrowing valid entry module for nestjs factories 2024-11-09 06:50:47 -04:00
Kamil Myśliwiec
676461ff4e test: add unit tests, minor updates 2024-11-08 15:49:24 +01:00
Kamil Myśliwiec
cd7079bcc0 feat(common): add parse date pipe, add tsdoc to other pipes 2024-11-08 15:28:13 +01:00
Kamil Myśliwiec
66c4810b0f style: fix linter issues 2024-11-08 14:29:42 +01:00
Kamil Myśliwiec
23e602b712 style: fix linter issues 2024-11-08 14:09:58 +01:00
Kamil Myśliwiec
e767bd364e feat: produce a parseable json when colors off and compact on 2024-11-08 13:49:42 +01:00
Kamil Mysliwiec
bcda8fd791 Merge pull request #14115 from Tony133/chore/update-fastify-view-options-interface
chore(fastify): update fastify view options interface
2024-11-08 12:26:59 +01:00
Kamil Mysliwiec
fb32ef6d46 Merge pull request #14116 from Tony133/chore/update-fastify-static-options-interface
refactor(fastify): update fastify static options interface
2024-11-08 12:26:29 +01:00
Kamil Mysliwiec
51a03bbcf2 Merge pull request #14113 from nestjs/feat/context-select-options
feat(core): allow overriding abortOnError for the select method
2024-11-08 11:44:11 +01:00
Kamil Mysliwiec
f191f0f1fd Merge pull request #14112 from nestjs/fix/instance-method-call
fix(microservices): use instance refs for target handler callbacks
2024-11-08 11:43:06 +01:00
Kamil Mysliwiec
84bf5706e2 Merge pull request #14097 from clkamp/wip-distance-order
fix(core): revisit dependencies w/ possibly higher distance
2024-11-08 11:42:49 +01:00
Kamil Myśliwiec
03d8bcc21c feat: add pid to log object 2024-11-08 11:32:08 +01:00
Kamil Myśliwiec
e75eb1d14a feat(common): json logger and a few other improvements 2024-11-08 11:21:37 +01:00
Tony133
790bafa46e refactor(): update fastify static options interface 2024-11-07 21:15:39 +01:00
Tony133
f13e32ad33 chore: update fastify view options interface 2024-11-07 21:12:38 +01:00
Antonio Tripodi
1ed97489e3 Merge branch 'master' into feat/upgrade-fastify-v5 2024-11-07 18:39:10 +01:00
Tony133
7de7320550 chore: upgrade dependencies for nest v11.x 2024-11-07 18:37:41 +01:00
Kamil Mysliwiec
3081f544f4 Merge pull request #14114 from micalevisk/fix-issue-13733
fix(common)!: drop broken support for promises on `exports` of modules
2024-11-07 14:10:35 +01:00
Micael Levi L. Cavalcante
5bc7f91d90 fix(common): drop broken support for promises on exports of modules 2024-11-07 08:49:14 -04:00
Kamil Mysliwiec
6ea78d52fb Merge pull request #13628 from tomflorentin/master
chore(class-transformer): plainToClass is deprectated and replaced with plainToInstance
2024-11-07 12:38:37 +01:00
Kamil Myśliwiec
38bfa9a13a feat(core): allow overriding abort on error for select method 2024-11-07 12:18:12 +01:00
Wenlong Chen
34c2ccabe8 fix(core): Order of module destroy should be the reverse of module init 2024-11-06 21:08:35 +08:00
Kamil Mysliwiec
0f38439aa6 Merge pull request #12761 from PieterScheffers/tcp-use-random-port
Be able to use a random port for the TCP server
2024-11-06 13:22:30 +01:00
Kamil Mysliwiec
5cdea22c39 Merge pull request #13468 from nestjs/revert-13467-revert-13283-fix/unnecessary-call
fix(microservices): delete unnecessary call of grpcClient.start
2024-11-06 12:54:35 +01:00
Kamil Mysliwiec
fd563c0ae9 Merge pull request #12735 from micalevisk/feat/narrow-inject
feat(common)!: type narrowing allowed injection tokens for `@Inject()`
2024-11-06 12:53:08 +01:00
Kamil Mysliwiec
9b690d95a2 Merge branch '11.0.0' into master 2024-11-06 12:51:14 +01:00
Kamil Mysliwiec
6228af1444 Merge pull request #13336 from nestjs/feat/module-opaque-keys
feat(core): introduce different module opaque key factories
2024-11-06 12:49:55 +01:00
Kamil Mysliwiec
8d0a3cd457 Merge pull request #12893 from Hareloo/12864-default-number-query-param-bug
fix(common): when transforming undefined numeric values
2024-11-06 12:49:48 +01:00
Kamil Mysliwiec
c63717db9d Merge pull request #12764 from kmw14641/kmw14641-bugfix/class-serializer-interceptor
fix(common): apply options to plaintoclass in classserializerinterceptor
2024-11-06 12:48:37 +01:00
Kamil Mysliwiec
9cb84e78f8 Update packages/microservices/server/server-tcp.ts
Co-authored-by: Gil Tichon <gil.tichon@lemonade.com>
2024-11-06 12:47:19 +01:00
Wenlong Chen
5ccc88fe8a fix(core): Calculate module distance after bindGlobalScope 2024-11-06 19:02:17 +08:00
Johaven
af4e1d0a33 Merge branch 'nestjs:master' into feat-webdav-methods 2024-11-02 00:22:06 +01:00
Christian Lütke Stetzkamp
2c8982a2c7 fix(core): revisit dependencies w/ possibly higher distance 2024-10-29 15:33:44 +01:00
Vasile Sumanschi
9cd43532ae fix(microservices): include discarded rmq client options
all other properties, beside 'connectionOptions', from the socketOptions object ( of type AmqpConnectionManagerSocketOptions )
were being discarded on the creation of the AmqpConnectionManager client
https://github.com/nestjs/nest/blob/master/packages/microservices/external/rmq-url.interface.ts#L47
https://github.com/jwalton/node-amqp-connection-manager/blob/v4.1.14/src/AmqpConnectionManager.ts#L46

https://github.com/nestjs/nest/issues/5788#issuecomment-2373361313
2024-10-09 01:17:27 +03:00
Johaven
e1c1945a45 fix(platform-fastify): uppercase methods 2024-10-08 13:49:56 +02:00
Johaven
0d5ad26268 Merge branch 'nestjs:master' into feat-webdav-methods 2024-10-08 13:42:54 +02:00
Micael Levi L. Cavalcante
aff30bf63d chore: support skip npm script execution depending on require nodejs 2024-10-02 18:03:17 -04:00
Micael Levi L. Cavalcante
0dafaaa0b9 chore: add sample on how to use esm on cjs 2024-10-01 09:35:05 -04:00
Johaven
bc36e3c32a Merge branch 'nestjs:master' into feat-webdav-methods 2024-09-19 10:12:45 +02:00
Tony133
5f45310ab6 feat(platform-fastify): added compatibility for fastify version 5.x 2024-09-17 22:58:29 +02:00
Johaven
96bf1d9bb7 Merge branch 'nestjs:master' into feat-webdav-methods 2024-09-16 14:39:48 +02:00
Ali Nowrouzi
d20a1e580f feat(microservices): add gracefull shutdown option for nats server 2024-08-28 22:30:10 +03:30
DylanVeldra
6dba4debb9 fix(core): merge req context with tenant payload in the request instance 2024-08-18 17:11:49 +02:00
Johaven
09cfc8279f Merge branch 'nestjs:master' into feat-webdav-methods 2024-08-15 13:23:01 +02:00
Martin Vyšňovský
3e061e9b14 feat(06-mongoose): add update method 2024-08-14 13:07:18 +02:00
Martin Vyšňovský
d0b2835293 test(06-mongoose): add missing tests for service 2024-08-14 13:03:15 +02:00
Martin Vyšňovský
2da82286d2 test(06-mongoose): refactor tests for service 2024-08-14 13:01:09 +02:00
Martin Vyšňovský
3c6a295037 test(06-mongoose): add missing tests for controller 2024-08-14 12:51:28 +02:00
Martin Vyšňovský
3117b241c1 test(06-mongoose): refactor tests for controller 2024-08-14 12:51:28 +02:00
Martin Vyšňovský
f0527d08fc chore(deps): update @nestjs/mongoose in 06-mongoose sample 2024-08-14 12:24:23 +02:00
Johaven
b90e19f15f Merge branch 'nestjs:master' into feat-webdav-methods 2024-08-13 15:05:28 +02:00
johaven
b62b9255cf feat(core,common,platform-fastify): add webdav http methods support 2024-08-12 11:18:40 +02:00
Patrick Acioli
daf0f88366 fix(core): dependencies not resolving for transient lazy providers 2024-07-19 03:01:48 -03:00
Patrick Acioli
91beaf7bc2 fix(core): dependencies not resolving for transient lazy providers 2024-07-19 02:46:52 -03:00
Patrick Acioli
ba761c1488 fix(fastify-adapter): middleware not executed when root path is excluded 2024-07-17 20:45:44 -03:00
Tom Florentin
3fd4220052 plain to class deprectated 2024-05-29 11:09:42 +02:00
Kamil Mysliwiec
7d5adfcc1f Revert "Revert "fix(microservice) Delete unnecessary call of grpcClient.start"" 2024-04-19 09:14:09 +02:00
MegaSpaceHamlet
ef12d355ff refactor(platform-express): modify error arg type
Add the possible `field` property to the `error` arg in
`transformExecption`.
2024-04-08 16:58:33 -04:00
Alex
52b2c72124 Improving types 2024-04-03 12:26:16 +05:00
Alex
1ccc7f9d91 Сorrection of Reflector types 2024-04-02 16:01:17 +05:00
MegaSpaceHamlet
50e1d705c3 feat(platform-express): multer errors show 'field'
Multer errors may include a 'field' property for certain errors. Pass it
along into the error message.
2024-03-30 22:43:51 -04:00
Kamil Myśliwiec
b3f85e9c04 test: update module compiler test 2024-03-19 10:52:31 +01:00
Kamil Myśliwiec
c4a905b996 chore: update comment to suggest switching to a different algorithm 2024-03-19 09:37:58 +01:00
Kamil Myśliwiec
094c35cf79 refactor: update types to better reflect dynamic metadata shape 2024-03-19 09:35:43 +01:00
Kamil Mysliwiec
30110d49e0 Update packages/core/injector/compiler.ts
Co-authored-by: Vinicius Lourenço <12551007+H4ad@users.noreply.github.com>
2024-03-19 09:33:04 +01:00
Kamil Myśliwiec
fb72a8ec9f feat(core): introduce different module opaque key factories 2024-03-18 10:12:56 +01:00
cain
0f00a347a6 test: test for emit-batch 2024-03-12 14:58:19 +09:00
cain
14cffb328a fix: modify access modifier 2023-12-21 15:57:49 +09:00
cain
cb8e04dd62 feat: add block wrapping return 2023-12-21 10:26:48 +09:00
cain
069676fd84 feat: emit batch 2023-12-20 16:59:46 +09:00
Hareloo
0d7a768b89 fix(common): when transforming undefined numeric values
Transforming numeric values in validationpipe is incorrect when value is undefined

closes #12864
2023-12-06 20:52:48 +02:00
pacyL2K19
86826a651a test(sample-12): add e2e tests 2023-11-25 19:10:02 +02:00
pacyL2K19
bb520c073e test(sample-12): add unit tests to increase test coverage 2023-11-25 19:10:02 +02:00
pacyL2K19
992b18e12a test(sample-12): add unit test to the cat-owner resolver field 2023-11-25 19:10:02 +02:00
pacyL2K19
d073083757 test(sample-12): add unit tests to the cats.resolver 2023-11-25 19:10:02 +02:00
pacyL2K19
1a80a9c6cd test(sample-12): setup testing environment - write unit tests for cats.service.ts file 2023-11-25 19:09:59 +02:00
kmw14641
ed8699769d fix(common): apply options to plaintoclass in classserializerinterceptor
fixed issue that with type option which is not already converted,
any other option cannot be applied to plainToClass

Closes #12763
2023-11-17 00:59:04 +09:00
Pieter Scheffers
0cbc15405d refactor: Use TCP_DEFAULT_PORT as default instead of using a boolean check 2023-11-16 11:26:44 +01:00
Micael Levi L. Cavalcante
c47be164f3 ci: switch to shallow cloning of 'wrk' repository 2023-11-14 15:46:35 -04:00
Micael Levi L. Cavalcante
61791e5115 feat(common): narrow allowed injection tokens for @Inject() 2023-11-14 15:46:32 -04:00
Jay McDoniel
2f2252264b feat: allow for microservice options to come from the di container
Microservices are now able to be created by getting their options
from within the DI container itself. This has been a long requested
feature of developers and I finally had some time to work through how
we could possibly let this happen.
2023-10-20 17:08:35 -07:00
René Zeidler
d04886d816 fix(core): fix type and return value of Reflector#getAllAndMerge
When only a single metadata value is present in the list of targets for
`Reflector#getAllAndMerge`, that value gets wrapped in an array if it is
not already an array or an object.
Previously, single values were returned as is, so the method could
actually return any value. Now the method always returns an array or an
object as indicated by its return type.
This also fixes the return type of both `getAll` and `getAllAndMerge`
when using the strongly typed `ReflectableDecorator<T>`.

Fixes #12231
2023-08-21 10:44:28 +02:00
yansb
c032e83e4d test(sample-01): improved tests 2022-12-01 08:23:18 -03:00
yansb
5c9bcc85ef test(sample-01): added controller create cat unit test 2022-11-30 21:50:16 -03:00
yansb
7ec3eb235d test(sample-01): added service unit tests 2022-11-30 21:14:15 -03:00
Manuel Herrera
cdf2aa5b06 feat(microservices): fixed mqtt serializer tests 2022-01-21 19:20:52 -03:00
Manuel Herrera
5b40b2fe81 feat(microservices): replaced empty options object with undefined 2022-01-21 19:09:34 -03:00
Manuel Herrera
5baba4b3e2 feat(microservices): raw output to publish and dispatch on mqtt client 2022-01-21 18:58:23 -03:00
Manuel Herrera
0ba8946bcd feat(microservices): removed rawOutputPackets from MqttOptions interface 2022-01-20 13:54:56 -03:00
Manuel Herrera
b8ac795804 feat(microservices): removed rawOutput and moved stringify to serializer 2022-01-20 10:24:16 -03:00
Manuel Herrera
8617ee9952 feat(microservices): added MqttOption for passing raw output to pub 2022-01-19 22:30:22 -03:00
606 changed files with 59927 additions and 43980 deletions

View File

@@ -6,16 +6,16 @@ parameters:
default: false
legacy-node-version:
type: string
default: '14.21.3'
default: '18.20'
maintenance-node-version:
type: string
default: '16.20'
default: '20.18'
active-node-version:
type: string
default: '18.17'
default: '22.11'
current-node-version:
type: string
default: '20.5'
default: '23.3'
aliases:
- &restore-cache
@@ -121,14 +121,14 @@ jobs:
lint:
working_directory: ~/nest
docker:
- image: cimg/node:<< pipeline.parameters.maintenance-node-version >>
- image: cimg/node:<< pipeline.parameters.active-node-version >>
steps:
- checkout
- *restore-cache
- *install-deps
- run:
name: Lint
command: npm run lint
command: npm run lint:ci
integration_tests:
working_directory: ~/nest

View File

@@ -6,8 +6,8 @@ cd "$(dirname "$0")"
cd /tmp/
sudo apt-get install build-essential libssl-dev git -y
git clone https://github.com/wg/wrk.git wrk
git clone --depth=1 https://github.com/wg/wrk.git wrk
cd wrk
sudo make
# move the executable to somewhere in your PATH, ex:
sudo cp wrk /usr/local/bin
sudo cp wrk /usr/local/bin

View File

@@ -1,3 +0,0 @@
**/node_modules/**
*.d.ts
*.js

View File

@@ -1,47 +0,0 @@
module.exports = {
root: true,
env: {
node: true,
},
plugins: ['@typescript-eslint/eslint-plugin'],
extends: [
'plugin:@typescript-eslint/recommended',
'prettier',
],
overrides: [
{
files: ['**/*.ts'],
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.json',
sourceType: 'module',
},
rules: {
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/ban-types': 'off',
'@typescript-eslint/no-array-constructor': 'off',
},
},
{
files: ['**/*.spec.ts', 'integration/**/*.ts'],
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.spec.json',
sourceType: 'module',
},
rules: {
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/ban-types': 'off',
'@typescript-eslint/no-empty-function': 'off',
},
}
]
};

1
.gitignore vendored
View File

@@ -50,3 +50,4 @@ build/config\.gypi
.npmrc
pnpm-lock.yaml
/.history

55
eslint.config.mjs Normal file
View File

@@ -0,0 +1,55 @@
// @ts-check
import eslint from '@eslint/js';
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
import globals from 'globals';
import tseslint from 'typescript-eslint';
export default tseslint.config(
{
ignores: ['node_modules', '**/node_modules/**', '**/*.js', '**/*.d.ts'],
},
eslint.configs.recommended,
...tseslint.configs.recommendedTypeChecked,
eslintPluginPrettierRecommended,
{
languageOptions: {
globals: {
...globals.node,
...globals.jest,
},
ecmaVersion: 5,
sourceType: 'module',
parserOptions: {
project: ['tsconfig.json', 'tsconfig.spec.json'],
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
},
},
{
rules: {
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-function-type': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/no-unused-expressions': 'off',
'@typescript-eslint/no-require-imports': 'off',
'@typescript-eslint/no-unused-vars': 'off',
"@typescript-eslint/no-misused-promises": [
"error",
{
"checksVoidReturn": false,
"checksConditionals": false
}
],
"@typescript-eslint/require-await": "off",
'@typescript-eslint/prefer-promise-reject-errors': 'off',
'@typescript-eslint/no-base-to-string': 'off',
'@typescript-eslint/unbound-method': 'off',
'@typescript-eslint/only-throw-error': 'off',
},
},
);

View File

@@ -4,6 +4,7 @@ import * as chaiAsPromised from 'chai-as-promised';
import * as sinon from 'sinon';
import { BarService } from '../src/bar.service';
import { FooService } from '../src/foo.service';
chai.use(chaiAsPromised);
const { expect } = chai;

View File

@@ -10,6 +10,7 @@
"target": "ES2021",
"sourceMap": true,
"allowJs": true,
"strictNullChecks": true,
"outDir": "./dist",
"paths": {
"@nestjs/common": ["../../packages/common"],
@@ -32,7 +33,8 @@
},
"include": [
"src/**/*",
"e2e/**/*"
"e2e/**/*",
"test/**/*"
],
"exclude": [
"node_modules",

View File

@@ -10,6 +10,7 @@
"target": "ES2021",
"sourceMap": true,
"allowJs": true,
"strictNullChecks": true,
"outDir": "./dist",
"paths": {
"@nestjs/common": ["../../packages/common"],

View File

@@ -17,17 +17,17 @@ export class WebhooksExplorer {
const { name } = this.discoveryService.getMetadataByDecorator(
Webhook,
wrapper,
);
)!;
return {
name,
handlers: this.metadataScanner
.getAllMethodNames(wrapper.metatype.prototype)
.getAllMethodNames(wrapper.metatype!.prototype)
.map(methodName => {
const { event } = this.discoveryService.getMetadataByDecorator(
WebhookHandler,
wrapper,
methodName,
);
)!;
return {
methodName,
event,

View File

@@ -10,6 +10,7 @@
"target": "ES2021",
"sourceMap": true,
"allowJs": true,
"strictNullChecks": true,
"outDir": "./dist",
"paths": {
"@nestjs/common": ["../../packages/common"],

View File

@@ -25,8 +25,9 @@ services:
- "9001:9001"
restart: always
mysql:
image: mysql:8.3.0
image: mysql:8.4.3
environment:
MYSQL_ROOT_HOST: '%'
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: test
ports:
@@ -50,7 +51,7 @@ services:
zookeeper:
container_name: test-zookeeper
hostname: zookeeper
image: confluentinc/cp-zookeeper:7.5.3
image: confluentinc/cp-zookeeper:7.7.1
ports:
- "2181:2181"
environment:
@@ -59,7 +60,7 @@ services:
kafka:
container_name: test-kafka
hostname: kafka
image: confluentinc/cp-kafka:7.5.3
image: confluentinc/cp-kafka:7.7.1
depends_on:
- zookeeper
ports:

View File

@@ -7,4 +7,4 @@ async function bootstrap() {
app.useGlobalPipes(new ValidationPipe());
await app.listen(3000);
}
bootstrap();
void bootstrap();

View File

@@ -35,7 +35,7 @@ export class RecipesResolver {
@Args('newRecipeData') newRecipeData: NewRecipeInput,
): Promise<Recipe> {
const recipe = await this.recipesService.create(newRecipeData);
pubSub.publish('recipeAdded', { recipeAdded: recipe });
void pubSub.publish('recipeAdded', { recipeAdded: recipe });
return recipe;
}

View File

@@ -10,6 +10,7 @@
"target": "ES2021",
"sourceMap": true,
"allowJs": true,
"strictNullChecks": true,
"outDir": "./dist",
"paths": {
"@nestjs/common": ["../../packages/common"],

View File

@@ -42,7 +42,7 @@ describe('GraphQL request scoped', () => {
],
},
})
.end((err, res) => {
.end(err => {
if (err) return end(err);
end();
});

View File

@@ -20,6 +20,6 @@ export class CatsRequestScopedService {
}
findOneById(id: number): Cat {
return this.cats.find(cat => cat.id === id);
return this.cats.find(cat => cat.id === id)!;
}
}

View File

@@ -27,8 +27,8 @@ export class CatsResolvers {
@Mutation('createCat')
async create(@Args() args: Cat): Promise<Cat> {
const createdCat = await this.catsService.create(args);
pubSub.publish('catCreated', { catCreated: createdCat });
const createdCat = this.catsService.create(args);
void pubSub.publish('catCreated', { catCreated: createdCat });
return createdCat;
}

View File

@@ -20,6 +20,6 @@ export class CatsService {
}
findOneById(id: number): Cat {
return this.cats.find(cat => cat.id === id);
return this.cats.find(cat => cat.id === id)!;
}
}

View File

@@ -5,4 +5,4 @@ async function bootstrap() {
const app = await NestFactory.create(AppModule);
await app.listen(3000);
}
bootstrap();
void bootstrap();

View File

@@ -10,6 +10,7 @@
"target": "ES2021",
"sourceMap": true,
"allowJs": true,
"strictNullChecks": true,
"outDir": "./dist",
"paths": {
"@nestjs/common": ["../../packages/common"],

View File

@@ -50,6 +50,16 @@ class TestController {
return RETURN_VALUE;
}
@Get('legacy-wildcard/overview')
testLegacyWildcard() {
return RETURN_VALUE;
}
@Get('splat-wildcard/overview')
testSplatWildcard() {
return RETURN_VALUE;
}
@Get('overview/:id')
overviewById() {
return RETURN_VALUE;
@@ -64,10 +74,17 @@ class TestModule {
configure(consumer: MiddlewareConsumer) {
consumer
.apply((req, res, next) => res.end(MIDDLEWARE_VALUE))
.exclude('test', 'overview/:id', 'wildcard/(.*)', {
path: 'middleware',
method: RequestMethod.POST,
})
.exclude(
'test',
'overview/:id',
'wildcard/*',
'legacy-wildcard/(.*)',
'splat-wildcard/*splat',
{
path: 'middleware',
method: RequestMethod.POST,
},
)
.forRoutes('*');
}
}
@@ -126,6 +143,18 @@ describe('Exclude middleware (fastify)', () => {
.expect(200, RETURN_VALUE);
});
it(`should exclude "/legacy-wildcard/overview" endpoint (by wildcard, legacy syntax)`, () => {
return request(app.getHttpServer())
.get('/legacy-wildcard/overview')
.expect(200, RETURN_VALUE);
});
it(`should exclude "/splat-wildcard/overview" endpoint (by wildcard, new syntax)`, () => {
return request(app.getHttpServer())
.get('/splat-wildcard/overview')
.expect(200, RETURN_VALUE);
});
afterEach(async () => {
await app.close();
});

View File

@@ -41,6 +41,16 @@ class TestController {
return RETURN_VALUE;
}
@Get('legacy-wildcard/overview')
testLegacyWildcard() {
return RETURN_VALUE;
}
@Get('splat-wildcard/overview')
testSplatWildcard() {
return RETURN_VALUE;
}
@Get('overview/:id')
overviewById() {
return RETURN_VALUE;
@@ -60,12 +70,19 @@ class TestModule {
configure(consumer: MiddlewareConsumer) {
consumer
.apply((req, res, next) => res.send(MIDDLEWARE_VALUE))
.exclude('test', 'overview/:id', 'wildcard/(.*)', {
path: 'middleware',
method: RequestMethod.POST,
})
.exclude(
'test',
'overview/:id',
'wildcard/*',
'legacy-wildcard/(.*)',
'splat-wildcard/*splat',
{
path: 'middleware',
method: RequestMethod.POST,
},
)
.exclude('multiple/exclude')
.forRoutes('*');
.forRoutes('*path');
}
}
@@ -116,6 +133,18 @@ describe('Exclude middleware', () => {
.expect(200, RETURN_VALUE);
});
it(`should exclude "/legacy-wildcard/overview" endpoint (by wildcard, legacy syntax)`, () => {
return request(app.getHttpServer())
.get('/legacy-wildcard/overview')
.expect(200, RETURN_VALUE);
});
it(`should exclude "/splat-wildcard/overview" endpoint (by wildcard, new syntax)`, () => {
return request(app.getHttpServer())
.get('/splat-wildcard/overview')
.expect(200, RETURN_VALUE);
});
it(`should exclude "/multiple/exclude" endpoint`, () => {
return request(app.getHttpServer())
.get('/multiple/exclude')

View File

@@ -3,10 +3,11 @@ import { ExpressAdapter } from '@nestjs/platform-express';
import { Test } from '@nestjs/testing';
import * as express from 'express';
import * as request from 'supertest';
import { App } from 'supertest/types';
import { AppModule } from '../src/app.module';
describe('Hello world (express instance)', () => {
let server;
let server: App;
let app: INestApplication;
beforeEach(async () => {

View File

@@ -48,7 +48,7 @@ export class HeaderInterceptor {
const ctx = context.switchToHttp();
const res = ctx.getResponse();
for (const key in this.headers) {
if (this.headers.hasOwnProperty(key)) {
if (Object.prototype.hasOwnProperty.call(this.headers, key)) {
res.header(key, this.headers[key]);
}
}

View File

@@ -8,9 +8,9 @@ import {
RequestMethod,
} from '@nestjs/common';
import { Test } from '@nestjs/testing';
import { Response } from 'express';
import * as request from 'supertest';
import { AppModule } from '../src/app.module';
import { Response } from 'express';
const INCLUDED_VALUE = 'test_included';
const RETURN_VALUE = 'test';

View File

@@ -15,6 +15,8 @@ import {
} from '@nestjs/platform-fastify';
import { Test } from '@nestjs/testing';
import { expect } from 'chai';
import { FastifyRequest } from 'fastify';
import * as request from 'supertest';
import { AppModule } from '../src/app.module';
describe('Middleware (FastifyAdapter)', () => {
@@ -35,6 +37,11 @@ describe('Middleware (FastifyAdapter)', () => {
return RETURN_VALUE;
}
@Get('legacy_style_wildcard/wildcard_nested')
legacy_style_wildcard() {
return RETURN_VALUE;
}
@Get('test')
test() {
return RETURN_VALUE;
@@ -74,9 +81,13 @@ describe('Middleware (FastifyAdapter)', () => {
.apply((req, res, next) => res.end(INCLUDED_VALUE))
.forRoutes({ path: 'tests/included', method: RequestMethod.POST })
.apply((req, res, next) => res.end(REQ_URL_VALUE))
.forRoutes('req/url/(.*)')
.forRoutes('req/url/*')
.apply((req, res, next) => res.end(WILDCARD_VALUE))
.forRoutes('express_style_wildcard/*', 'tests/(.*)')
.forRoutes(
'express_style_wildcard/*',
'tests/*path',
'legacy_style_wildcard/(.*)',
)
.apply((req, res, next) => res.end(QUERY_VALUE))
.forRoutes('query')
.apply((req, res, next) => next())
@@ -85,7 +96,7 @@ describe('Middleware (FastifyAdapter)', () => {
.forRoutes(TestController)
.apply((req, res, next) => res.end(RETURN_VALUE))
.exclude({ path: QUERY_VALUE, method: -1 as any })
.forRoutes('(.*)');
.forRoutes('*');
}
}
@@ -99,7 +110,7 @@ describe('Middleware (FastifyAdapter)', () => {
await app.init();
});
it(`forRoutes((.*))`, () => {
it(`forRoutes(*)`, () => {
return app
.inject({
method: 'GET',
@@ -141,7 +152,7 @@ describe('Middleware (FastifyAdapter)', () => {
.then(({ payload }) => expect(payload).to.be.eql(QUERY_VALUE));
});
it(`forRoutes(tests/(.*))`, () => {
it(`forRoutes(tests/*path)`, () => {
return app
.inject({
method: 'GET',
@@ -159,6 +170,15 @@ describe('Middleware (FastifyAdapter)', () => {
.then(({ payload }) => expect(payload).to.be.eql(WILDCARD_VALUE));
});
it(`forRoutes(legacy_style_wildcard/*)`, () => {
return app
.inject({
method: 'GET',
url: '/legacy_style_wildcard/wildcard_nested',
})
.then(({ payload }) => expect(payload).to.be.eql(WILDCARD_VALUE));
});
it(`forRoutes(req/url/)`, () => {
const reqUrl = '/test';
return app
@@ -398,4 +418,133 @@ describe('Middleware (FastifyAdapter)', () => {
await app.close();
});
});
describe('should have data attached in middleware', () => {
@Controller()
class DataController {
@Get('data')
async data(@Req() req: FastifyRequest['raw']) {
return {
success: true,
extras: req?.['raw']?.extras,
pong: req?.['raw']?.headers?.ping,
};
}
@Get('pong')
async pong(@Req() req: FastifyRequest['raw']) {
return { success: true, pong: req?.['raw']?.headers?.ping };
}
@Get('')
async rootPath(@Req() req: FastifyRequest['raw']) {
return { success: true, root: true };
}
}
@Module({
controllers: [DataController],
})
class DataModule implements NestModule {
configure(consumer: MiddlewareConsumer) {
consumer
.apply((req, res, next) => {
req.extras = { data: 'Data attached in middleware' };
req.headers['ping'] = 'pong';
next();
})
.forRoutes('*');
}
}
beforeEach(async () => {
app = (
await Test.createTestingModule({
imports: [DataModule],
}).compile()
).createNestApplication<NestFastifyApplication>(new FastifyAdapter());
});
it(`GET forRoutes('*') with global prefix`, async () => {
app.setGlobalPrefix('/api');
await app.init();
await app.getHttpAdapter().getInstance().ready();
return app
.inject({
method: 'GET',
url: '/api/pong',
})
.then(({ payload }) =>
expect(payload).to.be.eql(
JSON.stringify({
success: true,
pong: 'pong',
}),
),
);
});
it(`GET forRoutes('*') without prefix config`, async () => {
await app.init();
await app.getHttpAdapter().getInstance().ready();
return app
.inject({
method: 'GET',
url: '/pong',
})
.then(({ payload }) =>
expect(payload).to.be.eql(
JSON.stringify({
success: true,
pong: 'pong',
}),
),
);
});
it(`GET forRoutes('*') with global prefix and exclude patterns`, async () => {
app.setGlobalPrefix('/api', { exclude: ['/'] });
await app.init();
await app.getHttpAdapter().getInstance().ready();
await request(app.getHttpServer())
.get('/')
.expect(200, { success: true, root: true });
});
it(`GET forRoutes('*') with global prefix and global prefix options`, async () => {
app.setGlobalPrefix('/api', { exclude: ['/'] });
await app.init();
await app.getHttpAdapter().getInstance().ready();
await request(app.getHttpServer())
.get('/api/data')
.expect(200, {
success: true,
extras: { data: 'Data attached in middleware' },
pong: 'pong',
});
await request(app.getHttpServer())
.get('/')
.expect(200, { success: true, root: true });
});
it(`GET forRoutes('*') with global prefix that not starts with /`, async () => {
app.setGlobalPrefix('api');
await app.init();
await app.getHttpAdapter().getInstance().ready();
await request(app.getHttpServer())
.get('/api/data')
.expect(200, {
success: true,
extras: { data: 'Data attached in middleware' },
pong: 'pong',
});
await request(app.getHttpServer()).get('/').expect(404);
});
afterEach(async () => {
await app.close();
});
});
});

View File

@@ -26,6 +26,11 @@ class TestController {
return RETURN_VALUE;
}
@Get('legacy-wildcard/overview')
legacyWildcard() {
return RETURN_VALUE;
}
@Get('exclude')
exclude() {
return EXCLUDE_VALUE;
@@ -40,7 +45,7 @@ class TestModule {
configure(consumer: MiddlewareConsumer) {
consumer
.apply((req, res, next) => res.send(WILDCARD_VALUE))
.forRoutes('tests/*')
.forRoutes('tests/*path', 'legacy-wildcard/*')
.apply((req, res, next) => res.send(SCOPED_VALUE))
.exclude('exclude')
.forRoutes(TestController)
@@ -86,6 +91,13 @@ describe('Middleware', () => {
.expect(200, WILDCARD_VALUE);
});
it(`forRoutes(legacy-wildcard/*)`, async () => {
app = await createApp();
return request(app.getHttpServer())
.get('/legacy-wildcard/overview')
.expect(200, WILDCARD_VALUE);
});
afterEach(async () => {
await app.close();
});

View File

@@ -18,7 +18,7 @@ export class HostArrayController {
@Get('async')
async asyncGreeting(@HostParam('tenant') tenant: string): Promise<string> {
return `${await this.hostService.greeting()} tenant=${tenant}`;
return `${this.hostService.greeting()} tenant=${tenant}`;
}
@Get('stream')

View File

@@ -18,7 +18,7 @@ export class HostController {
@Get('async')
async asyncGreeting(@HostParam('tenant') tenant: string): Promise<string> {
return `${await this.hostService.greeting()} tenant=${tenant}`;
return `${this.hostService.greeting()} tenant=${tenant}`;
}
@Get('stream')

View File

@@ -10,6 +10,7 @@
"target": "ES2021",
"sourceMap": true,
"allowJs": true,
"strictNullChecks": true,
"outDir": "./dist",
"paths": {
"@nestjs/common": ["../../packages/common"],

View File

@@ -23,10 +23,7 @@ describe('BeforeApplicationShutdown', () => {
it('should sort modules by distance (topological sort) - DESC order', async () => {
@Injectable()
class BB implements BeforeApplicationShutdown {
public field: string;
async beforeApplicationShutdown() {
this.field = 'b-field';
}
beforeApplicationShutdown = Sinon.spy();
}
@Module({
@@ -37,12 +34,8 @@ describe('BeforeApplicationShutdown', () => {
@Injectable()
class AA implements BeforeApplicationShutdown {
public field: string;
constructor(private bb: BB) {}
async beforeApplicationShutdown() {
this.field = this.bb.field + '_a-field';
}
beforeApplicationShutdown = Sinon.spy();
}
@Module({
imports: [B],
@@ -58,7 +51,11 @@ describe('BeforeApplicationShutdown', () => {
await app.init();
await app.close();
const instance = module.get(AA);
expect(instance.field).to.equal('b-field_a-field');
const aa = module.get(AA);
const bb = module.get(BB);
Sinon.assert.callOrder(
aa.beforeApplicationShutdown,
bb.beforeApplicationShutdown,
);
});
});

View File

@@ -23,10 +23,7 @@ describe('OnApplicationShutdown', () => {
it('should sort modules by distance (topological sort) - DESC order', async () => {
@Injectable()
class BB implements OnApplicationShutdown {
public field: string;
async onApplicationShutdown() {
this.field = 'b-field';
}
onApplicationShutdown = Sinon.spy();
}
@Module({
@@ -37,12 +34,8 @@ describe('OnApplicationShutdown', () => {
@Injectable()
class AA implements OnApplicationShutdown {
public field: string;
constructor(private bb: BB) {}
async onApplicationShutdown() {
this.field = this.bb.field + '_a-field';
}
onApplicationShutdown = Sinon.spy();
}
@Module({
imports: [B],
@@ -58,7 +51,8 @@ describe('OnApplicationShutdown', () => {
await app.init();
await app.close();
const instance = module.get(AA);
expect(instance.field).to.equal('b-field_a-field');
const aa = module.get(AA);
const bb = module.get(BB);
Sinon.assert.callOrder(aa.onApplicationShutdown, bb.onApplicationShutdown);
});
});

View File

@@ -43,10 +43,7 @@ describe('OnModuleDestroy', () => {
it('should sort modules by distance (topological sort) - DESC order', async () => {
@Injectable()
class BB implements OnModuleDestroy {
public field: string;
async onModuleDestroy() {
this.field = 'b-field';
}
onModuleDestroy = Sinon.spy();
}
@Module({
@@ -57,13 +54,10 @@ describe('OnModuleDestroy', () => {
@Injectable()
class AA implements OnModuleDestroy {
public field: string;
constructor(private bb: BB) {}
async onModuleDestroy() {
this.field = this.bb.field + '_a-field';
}
onModuleDestroy = Sinon.spy();
}
@Module({
imports: [B],
providers: [AA],
@@ -78,7 +72,8 @@ describe('OnModuleDestroy', () => {
await app.init();
await app.close();
const instance = module.get(AA);
expect(instance.field).to.equal('b-field_a-field');
const aa = module.get(AA);
const bb = module.get(BB);
Sinon.assert.callOrder(aa.onModuleDestroy, bb.onModuleDestroy);
});
});

View File

@@ -39,11 +39,39 @@ describe('OnModuleInit', () => {
});
it('should sort modules by distance (topological sort) - DESC order', async () => {
@Injectable()
class CC implements OnModuleInit {
public field: string;
async onModuleInit() {
this.field = 'c-field';
}
}
@Module({})
class C {
static forRoot() {
return {
module: C,
global: true,
providers: [
{
provide: CC,
useValue: new CC(),
},
],
exports: [CC],
};
}
}
@Injectable()
class BB implements OnModuleInit {
public field: string;
constructor(private cc: CC) {}
async onModuleInit() {
this.field = 'b-field';
this.field = this.cc.field + '_b-field';
}
}
@@ -68,14 +96,19 @@ describe('OnModuleInit', () => {
})
class A {}
@Module({
imports: [A, C.forRoot()],
})
class AppModule {}
const module = await Test.createTestingModule({
imports: [A],
imports: [AppModule],
}).compile();
const app = module.createNestApplication();
await app.init();
const instance = module.get(AA);
expect(instance.field).to.equal('b-field_a-field');
expect(instance.field).to.equal('c-field_b-field_a-field');
});
});

View File

@@ -39,4 +39,4 @@ async function bootstrap() {
process.kill(process.pid, SIGNAL);
}
bootstrap();
void bootstrap();

View File

@@ -10,6 +10,7 @@
"target": "ES2021",
"sourceMap": true,
"allowJs": true,
"strictNullChecks": true,
"outDir": "./dist",
"paths": {
"@nestjs/common": ["../../packages/common"],

View File

@@ -6,7 +6,7 @@ export class CircularModule {
const a = {
module: CircularModule,
providers: [InputService],
b: null,
b: null as any,
};
a.b = a;
return a;

View File

@@ -10,6 +10,7 @@
"target": "ES2021",
"sourceMap": true,
"allowJs": true,
"strictNullChecks": true,
"outDir": "./dist",
"paths": {
"@nestjs/common": ["../../packages/common"],

View File

@@ -1,8 +1,8 @@
import { Controller } from '@nestjs/common';
import { MessagePattern, Payload } from '@nestjs/microservices';
import { ExternalSvcService } from './external-svc.service';
import { CreateExternalSvcDto } from './dto/create-external-svc.dto';
import { UpdateExternalSvcDto } from './dto/update-external-svc.dto';
import { ExternalSvcService } from './external-svc.service';
@Controller()
export class ExternalSvcController {

View File

@@ -10,6 +10,7 @@
"target": "ES2021",
"sourceMap": true,
"allowJs": true,
"strictNullChecks": true,
"outDir": "./dist",
"paths": {
"@nestjs/common": ["../../packages/common"],

View File

@@ -2,12 +2,11 @@ import { INestApplication } from '@nestjs/common';
import { Test } from '@nestjs/testing';
import * as chai from 'chai';
import { expect } from 'chai';
import chaiAsPromised = require('chai-as-promised');
import { AppModule } from '../src/app.module';
import chaiAsPromised = require('chai-as-promised');
chai.use(chaiAsPromised);
describe('Lazy imports', () => {
let server;
let app: INestApplication;
beforeEach(async () => {
@@ -16,7 +15,6 @@ describe('Lazy imports', () => {
}).compile();
app = module.createNestApplication();
server = app.getHttpAdapter().getInstance();
});
it(`should allow imports of global modules`, async () => {

View File

@@ -0,0 +1,32 @@
import { INestApplication } from '@nestjs/common';
import { Test } from '@nestjs/testing';
import { TransientLazyModule } from '../src/transient.module';
import { LazyController } from '../src/lazy.controller';
import * as chai from 'chai';
import { expect } from 'chai';
import * as request from 'supertest';
describe('Lazy Transient providers', () => {
let app: INestApplication;
beforeEach(async () => {
const module = await Test.createTestingModule({
controllers: [LazyController],
}).compile();
app = module.createNestApplication();
await app.init();
});
it('should not recreate dependencies for default scope', async () => {
const resultOne = await request(app.getHttpServer()).get('/lazy/transient');
const resultTwo = await request(app.getHttpServer()).get('/lazy/transient');
expect(resultOne.text).to.be.equal('Hi! Counter is 1');
expect(resultOne.statusCode).to.be.equal(200);
expect(resultTwo.text).to.be.equal('Hi! Counter is 2');
expect(resultTwo.statusCode).to.be.equal(200);
});
});

View File

@@ -3,7 +3,13 @@ import { GlobalService } from './global.module';
@Injectable()
export class EagerService {
private counter = 0;
constructor(public globalService: GlobalService) {}
sayHello() {
this.counter++;
return 'Hi! Counter is ' + this.counter;
}
}
@Module({

View File

@@ -0,0 +1,18 @@
import { Controller, Get } from '@nestjs/common';
import { LazyModuleLoader } from '@nestjs/core';
@Controller('lazy')
export class LazyController {
constructor(private lazyLoadModule: LazyModuleLoader) {}
@Get('transient')
async exec() {
const { TransientLazyModule } = await import('./transient.module');
const moduleRef = await this.lazyLoadModule.load(() => TransientLazyModule);
const { TransientService } = await import('./transient.service');
const _service = await moduleRef.resolve(TransientService);
return _service.eager();
}
}

View File

@@ -5,4 +5,4 @@ async function bootstrap() {
const app = await NestFactory.create(AppModule);
await app.listen(3000);
}
bootstrap();
void bootstrap();

View File

@@ -0,0 +1,11 @@
import { Module } from '@nestjs/common';
import { GlobalService } from './global.module';
import { EagerService } from './eager.module';
import { TransientService } from './transient.service';
@Module({
imports: [],
providers: [TransientService, GlobalService, EagerService],
exports: [TransientService],
})
export class TransientLazyModule {}

View File

@@ -0,0 +1,11 @@
import { Injectable, Scope } from '@nestjs/common';
import { EagerService } from './eager.module';
@Injectable({ scope: Scope.TRANSIENT })
export class TransientService {
constructor(private eagerService: EagerService) {}
eager() {
return this.eagerService.sayHello();
}
}

View File

@@ -0,0 +1,41 @@
{
"compilerOptions": {
"module": "commonjs",
"declaration": false,
"noImplicitAny": false,
"removeComments": true,
"noLib": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "ES2021",
"sourceMap": true,
"allowJs": true,
"strictNullChecks": true,
"outDir": "./dist",
"paths": {
"@nestjs/common": ["../../packages/common"],
"@nestjs/common/*": ["../../packages/common/*"],
"@nestjs/core": ["../../packages/core"],
"@nestjs/core/*": ["../../packages/core/*"],
"@nestjs/microservices": ["../../packages/microservices"],
"@nestjs/microservices/*": ["../../packages/microservices/*"],
"@nestjs/websockets": ["../../packages/websockets"],
"@nestjs/websockets/*": ["../../packages/websockets/*"],
"@nestjs/testing": ["../../packages/testing"],
"@nestjs/testing/*": ["../../packages/testing/*"],
"@nestjs/platform-express": ["../../packages/platform-express"],
"@nestjs/platform-express/*": ["../../packages/platform-express/*"],
"@nestjs/platform-socket.io": ["../../packages/platform-socket.io"],
"@nestjs/platform-socket.io/*": ["../../packages/platform-socket.io/*"],
"@nestjs/platform-ws": ["../../packages/platform-ws"],
"@nestjs/platform-ws/*": ["../../packages/platform-ws/*"]
}
},
"include": [
"src/**/*",
"e2e/**/*"
],
"exclude": [
"node_modules",
]
}

View File

@@ -100,7 +100,7 @@ describe.skip('Kafka concurrent', function () {
}
}
if (topicMetadata && topicMetadata.topics.length > 0) {
if (topicMetadata! && topicMetadata.topics.length > 0) {
// we have topics, how many partitions do they have?
for (const topic of topicMetadata.topics) {
if (topic.partitions.length < numbersOfServers) {

View File

@@ -2,10 +2,11 @@ import { INestApplication } from '@nestjs/common';
import { Transport } from '@nestjs/microservices';
import { Test } from '@nestjs/testing';
import * as request from 'supertest';
import { App } from 'supertest/types';
import { DisconnectedClientController } from '../src/disconnected.controller';
describe('Disconnected client', () => {
let server;
let server: App;
let app: INestApplication;
beforeEach(async () => {

View File

@@ -180,7 +180,7 @@ describe('GRPC transport', () => {
stream.on('error', err => {
if (err.code !== GRPC.status.CANCELLED) {
reject(err);
reject(err as Error);
}
});

View File

@@ -91,7 +91,7 @@ describe.skip('Kafka transport', function () {
});
it(`/POST (async event notification)`, done => {
request(server)
void request(server)
.post('/notify')
.send()
.end(() => {
@@ -123,7 +123,7 @@ describe.skip('Kafka transport', function () {
});
it(`/POST (sync command create user) Concurrency Test`, async () => {
const promises = [];
const promises = [] as Array<Promise<any>>;
for (let concurrencyKey = 0; concurrencyKey < 100; concurrencyKey++) {
const innerUserDto = JSON.parse(JSON.stringify(userDto));
innerUserDto.name += `+${concurrencyKey}`;

View File

@@ -75,7 +75,7 @@ describe('MQTT transport', () => {
}).timeout(5000);
it(`/POST (event notification)`, done => {
request(server)
void request(server)
.post('/notify')
.send([1, 2, 3, 4, 5])
.end(() => {
@@ -87,7 +87,7 @@ describe('MQTT transport', () => {
});
it(`/POST (wildcard EVENT #)`, done => {
request(server)
void request(server)
.post('/wildcard-event')
.send([1, 2, 3, 4, 5])
.end(() => {
@@ -106,7 +106,7 @@ describe('MQTT transport', () => {
});
it(`/POST (wildcard EVENT +)`, done => {
request(server)
void request(server)
.post('/wildcard-event2')
.send([1, 2, 3, 4, 5])
.end(() => {
@@ -125,7 +125,7 @@ describe('MQTT transport', () => {
});
it(`/POST (shared wildcard EVENT #)`, done => {
request(server)
void request(server)
.post('/shared-wildcard-event')
.send([1, 2, 3, 4, 5])
.end(() => {
@@ -144,7 +144,7 @@ describe('MQTT transport', () => {
});
it(`/POST (shared wildcard EVENT +)`, done => {
request(server)
void request(server)
.post('/shared-wildcard-event2')
.send([1, 2, 3, 4, 5])
.end(() => {

View File

@@ -84,7 +84,7 @@ describe('NATS transport', () => {
});
it(`/POST (event notification)`, done => {
request(server)
void request(server)
.post('/notify')
.send([1, 2, 3, 4, 5])
.end(() => {

View File

@@ -78,7 +78,7 @@ describe('REDIS transport', () => {
});
it(`/POST (event notification)`, done => {
request(server)
void request(server)
.post('/notify')
.send([1, 2, 3, 4, 5])
.end(() => {

View File

@@ -85,7 +85,7 @@ describe('RabbitMQ transport', () => {
}).timeout(10000);
it(`/POST (event notification)`, done => {
request(server)
void request(server)
.post('/notify')
.send([1, 2, 3, 4, 5])
.end(() => {

View File

@@ -0,0 +1,98 @@
import {
Controller,
INestMicroservice,
Injectable,
Module,
} from '@nestjs/common';
import { NestFactory } from '@nestjs/core';
import {
AsyncOptions,
ClientTCP,
ClientsModule,
MessagePattern,
MicroserviceOptions,
Payload,
TcpOptions,
Transport,
} from '@nestjs/microservices';
import { expect } from 'chai';
let port: number;
do {
port = Math.round(Math.random() * 10000);
} while (port < 1000);
@Injectable()
class RpcOptionsProvider {
getOptions(): TcpOptions {
return {
transport: Transport.TCP,
options: {
port,
host: '0.0.0.0',
},
};
}
}
@Controller()
class RpcController {
@MessagePattern({ cmd: 'sum' })
sumPayload(@Payload() payload: number[]) {
return payload.reduce((a, b) => a + b, 0);
}
}
@Module({
imports: [
ClientsModule.register([
{
name: 'RPC_CLIENT',
transport: Transport.TCP,
options: {
port,
host: '0.0.0.0',
},
},
]),
],
controllers: [RpcController],
providers: [RpcOptionsProvider],
})
class RpcModule {}
describe('RPC Async transport', () => {
let app: INestMicroservice;
let client: ClientTCP;
beforeEach(async () => {
app = await NestFactory.createMicroservice<
AsyncOptions<MicroserviceOptions>
>(RpcModule, {
logger: false,
inject: [RpcOptionsProvider],
useFactory: (optionsProvider: RpcOptionsProvider) =>
optionsProvider.getOptions(),
});
await app.listen();
client = app.get('RPC_CLIENT', { strict: false });
});
it(`/POST`, done => {
let retData = 0;
client.send({ cmd: 'sum' }, [1, 2, 3, 4, 5]).subscribe({
next: val => (retData += val),
error: done,
complete: () => {
expect(retData).to.eq(15);
done();
},
});
});
afterEach(async () => {
await app.close();
});
});

View File

@@ -2,11 +2,11 @@ import { INestApplication } from '@nestjs/common';
import { Transport } from '@nestjs/microservices';
import { Test } from '@nestjs/testing';
import { expect } from 'chai';
import * as fs from 'fs';
import * as path from 'path';
import * as request from 'supertest';
import { AppController } from '../src/tcp-tls/app.controller';
import { ApplicationModule } from '../src/tcp-tls/app.module';
import * as fs from 'fs';
import * as path from 'path';
describe('RPC TLS transport', () => {
let server;
@@ -109,7 +109,7 @@ describe('RPC TLS transport', () => {
});
it(`/POST (event notification)`, done => {
request(server)
void request(server)
.post('/notify')
.send([1, 2, 3, 4, 5])
.end(() => {

View File

@@ -94,7 +94,7 @@ describe('RPC transport', () => {
});
it(`/POST (event notification)`, done => {
request(server)
void request(server)
.post('/notify')
.send([1, 2, 3, 4, 5])
.end(() => {

View File

@@ -7,7 +7,7 @@ import {
} from '@nestjs/common';
import { ClientProxyFactory } from '@nestjs/microservices';
import { Observable, throwError } from 'rxjs';
import { catchError } from 'rxjs/operators';
import { catchError, tap } from 'rxjs/operators';
@Controller()
export class DisconnectedClientController {
@@ -24,12 +24,16 @@ export class DisconnectedClientController {
return throwError(() =>
code === 'ECONNREFUSED' ||
code === 'CONN_ERR' ||
code === 'ENOTFOUND' ||
code === 'CONNECTION_REFUSED' ||
error.message === 'Connection is closed.'
error.message.includes('Connection is closed.')
? new RequestTimeoutException('ECONNREFUSED')
: new InternalServerErrorException(),
);
}),
tap({
error: () => client.close(),
}),
);
}
}

View File

@@ -2,15 +2,15 @@ import { Body, Controller, HttpCode, Post, Query } from '@nestjs/common';
import {
Client,
ClientGrpc,
ClientGrpcProxy,
GrpcMethod,
GrpcStreamCall,
GrpcStreamMethod,
Transport,
ClientGrpcProxy,
RpcException,
Transport,
} from '@nestjs/microservices';
import { join } from 'path';
import { Observable, of, catchError, from, mergeMap } from 'rxjs';
import { catchError, from, mergeMap, Observable, of } from 'rxjs';
class ErrorHandlingProxy extends ClientGrpcProxy {
serializeError(err) {
@@ -81,7 +81,7 @@ export class GrpcController {
});
},
error: err => {
reject(err);
reject(err as Error);
},
});
});

View File

@@ -17,7 +17,7 @@ import { SumDto } from './dto/sum.dto';
*/
const explicitPartitioner = () => {
return ({ message }: PartitionerArgs) => {
return parseFloat(message.headers.toPartition.toString());
return parseFloat(message.headers!.toPartition!.toString());
};
};

View File

@@ -5,4 +5,4 @@ async function bootstrap() {
const app = await NestFactory.create(ApplicationModule);
await app.listen(3000);
}
bootstrap();
void bootstrap();

View File

@@ -138,7 +138,7 @@ export class MqttController {
}
@MessagePattern('wildcard-message/#')
wildcardMessageHandler(data: number[]): number {
wildcardMessageHandler(data: number[]): number | undefined {
if ((data as any).response) {
return;
}
@@ -186,7 +186,7 @@ export class MqttController {
}
@MessagePattern('$share/test-group/shared-wildcard-message/#')
sharedWildcardMessageHandler(data: number[]): number {
sharedWildcardMessageHandler(data: number[]): number | undefined {
if ((data as any).response) {
return;
}

View File

@@ -1,13 +1,13 @@
import { Module, Injectable } from '@nestjs/common';
import { AppController } from './app.controller';
import { Injectable, Module } from '@nestjs/common';
import {
ClientsModule,
Transport,
ClientsModuleOptionsFactory,
ClientOptions,
ClientsModule,
ClientsModuleOptionsFactory,
ClientTCP,
RpcException,
Transport,
} from '@nestjs/microservices';
import { AppController } from './app.controller';
import * as fs from 'fs';
import * as path from 'path';

View File

@@ -10,6 +10,7 @@
"target": "ES2021",
"sourceMap": true,
"allowJs": true,
"strictNullChecks": true,
"outDir": "./dist",
"paths": {
"@nestjs/common": ["../../packages/common"],

View File

@@ -10,6 +10,7 @@
"target": "ES2021",
"sourceMap": true,
"allowJs": true,
"strictNullChecks": true,
"outDir": "./dist",
"paths": {
"@nestjs/common": ["../../packages/common"],
@@ -32,7 +33,8 @@
},
"include": [
"src/**/*",
"e2e/**/*"
"e2e/**/*",
"test/**/*"
],
"exclude": [
"node_modules",

View File

@@ -5,4 +5,4 @@ async function bootstrap() {
const app = await NestFactory.create(ApplicationModule);
await app.listen(3001);
}
bootstrap();
void bootstrap();

View File

@@ -10,6 +10,7 @@
"target": "ES2021",
"sourceMap": true,
"allowJs": true,
"strictNullChecks": true,
"outDir": "./dist",
"paths": {
"@nestjs/common": ["../../packages/common"],

View File

@@ -11,6 +11,7 @@
"sourceMap": true,
"allowJs": true,
"outDir": "./dist",
"strictNullChecks": true,
"paths": {
"@nestjs/common": ["../../../packages/common"],
"@nestjs/common/*": ["../../../packages/common/*"],
@@ -20,8 +21,8 @@
"@nestjs/microservices/*": ["../../../packages/microservices/*"],
"@nestjs/websockets": ["../../../packages/websockets"],
"@nestjs/websockets/*": ["../../../packages/websockets/*"],
"@nestjs/testing": ["../../../packages/websockets"],
"@nestjs/testing/*": ["../../../packages/websockets/*"],
"@nestjs/testing": ["../../../packages/testing"],
"@nestjs/testing/*": ["../../../packages/testing/*"],
"@nestjs/platform-express": ["../../../packages/platform-express"],
"@nestjs/platform-express/*": ["../../../packages/platform-express/*"],
"@nestjs/platform-socket.io": ["../../../packages/platform-socket.io"],

View File

@@ -11,6 +11,7 @@
"sourceMap": true,
"allowJs": true,
"outDir": "./dist",
"strictNullChecks": true,
"paths": {
"@nestjs/common": ["../../../packages/common"],
"@nestjs/common/*": ["../../../packages/common/*"],
@@ -20,8 +21,8 @@
"@nestjs/microservices/*": ["../../../packages/microservices/*"],
"@nestjs/websockets": ["../../../packages/websockets"],
"@nestjs/websockets/*": ["../../../packages/websockets/*"],
"@nestjs/testing": ["../../../packages/websockets"],
"@nestjs/testing/*": ["../../../packages/websockets/*"],
"@nestjs/testing": ["../../../packages/testing"],
"@nestjs/testing/*": ["../../../packages/testing/*"],
"@nestjs/platform-express": ["../../../packages/platform-express"],
"@nestjs/platform-express/*": ["../../../packages/platform-express/*"],
"@nestjs/platform-socket.io": ["../../../packages/platform-socket.io"],

View File

@@ -127,7 +127,7 @@ describe('Global prefix', () => {
await request(server)
.get('/api/test/params')
.expect(200, { '0': 'params', tenantId: 'test' });
.expect(200, { tenantId: 'test', path: ['params'] });
});
it(`should execute middleware only once`, async () => {

View File

@@ -16,24 +16,30 @@ export class AppModule {
.apply((req, res, next) => res.status(201).end(MIDDLEWARE_VALUE))
.forRoutes({ path: MIDDLEWARE_VALUE, method: RequestMethod.POST })
.apply((req, res, next) => res.end(MIDDLEWARE_PARAM_VALUE))
.forRoutes({ path: MIDDLEWARE_VALUE + '/*', method: RequestMethod.GET })
.forRoutes({
path: MIDDLEWARE_VALUE + '/*path',
method: RequestMethod.GET,
})
.apply((req, res, next) => res.status(201).end(MIDDLEWARE_PARAM_VALUE))
.forRoutes({ path: MIDDLEWARE_VALUE + '/*', method: RequestMethod.POST })
.forRoutes({
path: MIDDLEWARE_VALUE + '/*path',
method: RequestMethod.POST,
})
.apply((req, res, next) => {
req.extras = { data: 'Data attached in middleware' };
next();
})
.forRoutes({ path: '*', method: RequestMethod.GET })
.forRoutes({ path: '*path', method: RequestMethod.GET })
.apply((req, res, next) => {
req.middlewareParams = req.params;
next();
})
.forRoutes({ path: '*', method: RequestMethod.GET })
.forRoutes({ path: '*path', method: RequestMethod.GET })
.apply((req, res, next) => {
this.count += 1;
req.count = this.count;
next();
})
.forRoutes('*');
.forRoutes('*path');
}
}

View File

@@ -11,6 +11,7 @@
"sourceMap": true,
"allowJs": true,
"outDir": "./dist",
"strictNullChecks": true,
"paths": {
"@nestjs/common": ["../../../packages/common"],
"@nestjs/common/*": ["../../../packages/common/*"],
@@ -20,8 +21,8 @@
"@nestjs/microservices/*": ["../../../packages/microservices/*"],
"@nestjs/websockets": ["../../../packages/websockets"],
"@nestjs/websockets/*": ["../../../packages/websockets/*"],
"@nestjs/testing": ["../../../packages/websockets"],
"@nestjs/testing/*": ["../../../packages/websockets/*"],
"@nestjs/testing": ["../../../packages/testing"],
"@nestjs/testing/*": ["../../../packages/testing/*"],
"@nestjs/platform-express": ["../../../packages/platform-express"],
"@nestjs/platform-express/*": ["../../../packages/platform-express/*"],
"@nestjs/platform-socket.io": ["../../../packages/platform-socket.io"],

View File

@@ -1,9 +1,9 @@
import { INestApplication } from '@nestjs/common';
import { ExpressAdapter } from '@nestjs/platform-express';
import { Test, TestingModule } from '@nestjs/testing';
import { expect } from 'chai';
import * as express from 'express';
import { AppModule } from '../src/app.module';
import { INestApplication } from '@nestjs/common';
describe('Listen (Express Application)', () => {
let testModule: TestingModule;
@@ -17,7 +17,7 @@ describe('Listen (Express Application)', () => {
});
afterEach(async () => {
app.close();
await app.close();
});
it('should resolve with httpServer on success', async () => {

View File

@@ -16,7 +16,7 @@ describe('Listen (Fastify Application)', () => {
});
afterEach(async () => {
app.close();
await app.close();
});
it('should resolve with httpServer on success', async () => {

View File

@@ -0,0 +1,41 @@
{
"compilerOptions": {
"module": "commonjs",
"declaration": false,
"noImplicitAny": false,
"removeComments": true,
"noLib": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "ES2021",
"sourceMap": true,
"allowJs": true,
"outDir": "./dist",
"strictNullChecks": true,
"paths": {
"@nestjs/common": ["../../../packages/common"],
"@nestjs/common/*": ["../../../packages/common/*"],
"@nestjs/core": ["../../../packages/core"],
"@nestjs/core/*": ["../../../packages/core/*"],
"@nestjs/microservices": ["../../../packages/microservices"],
"@nestjs/microservices/*": ["../../../packages/microservices/*"],
"@nestjs/websockets": ["../../../packages/websockets"],
"@nestjs/websockets/*": ["../../../packages/websockets/*"],
"@nestjs/testing": ["../../../packages/testing"],
"@nestjs/testing/*": ["../../../packages/testing/*"],
"@nestjs/platform-express": ["../../../packages/platform-express"],
"@nestjs/platform-express/*": ["../../../packages/platform-express/*"],
"@nestjs/platform-socket.io": ["../../../packages/platform-socket.io"],
"@nestjs/platform-socket.io/*": ["../../../packages/platform-socket.io/*"],
"@nestjs/platform-ws": ["../../../packages/platform-ws"],
"@nestjs/platform-ws/*": ["../../../packages/platform-ws/*"]
}
},
"include": [
"src/**/*",
"e2e/**/*"
],
"exclude": [
"node_modules",
]
}

View File

@@ -7,7 +7,7 @@ export class ExpressController {
getRawBody(@Req() req: RawBodyRequest<Request>) {
return {
parsed: req.body,
raw: req.rawBody.toString(),
raw: req.rawBody!.toString(),
};
}
}

View File

@@ -7,7 +7,7 @@ export class FastifyController {
getRawBody(@Req() req: RawBodyRequest<FastifyRequest>) {
return {
parsed: req.body,
raw: req.rawBody.toString(),
raw: req.rawBody!.toString(),
};
}
}

View File

@@ -11,6 +11,7 @@
"sourceMap": true,
"allowJs": true,
"outDir": "./dist",
"strictNullChecks": true,
"paths": {
"@nestjs/common": ["../../../packages/common"],
"@nestjs/common/*": ["../../../packages/common/*"],
@@ -20,8 +21,8 @@
"@nestjs/microservices/*": ["../../../packages/microservices/*"],
"@nestjs/websockets": ["../../../packages/websockets"],
"@nestjs/websockets/*": ["../../../packages/websockets/*"],
"@nestjs/testing": ["../../../packages/websockets"],
"@nestjs/testing/*": ["../../../packages/websockets/*"],
"@nestjs/testing": ["../../../packages/testing"],
"@nestjs/testing/*": ["../../../packages/testing/*"],
"@nestjs/platform-express": ["../../../packages/platform-express"],
"@nestjs/platform-express/*": ["../../../packages/platform-express/*"],
"@nestjs/platform-socket.io": ["../../../packages/platform-socket.io"],

View File

@@ -6,7 +6,7 @@ export class AppController {
@Sse('sse')
sse(): Observable<MessageEvent> {
return interval(1000).pipe(
map(_ => ({ data: { hello: 'world' } }) as MessageEvent),
map(() => ({ data: { hello: 'world' } }) as MessageEvent),
);
}
}

View File

@@ -21,8 +21,8 @@
"@nestjs/microservices/*": ["../../../packages/microservices/*"],
"@nestjs/websockets": ["../../../packages/websockets"],
"@nestjs/websockets/*": ["../../../packages/websockets/*"],
"@nestjs/testing": ["../../../packages/websockets"],
"@nestjs/testing/*": ["../../../packages/websockets/*"],
"@nestjs/testing": ["../../../packages/testing"],
"@nestjs/testing/*": ["../../../packages/testing/*"],
"@nestjs/platform-express": ["../../../packages/platform-express"],
"@nestjs/platform-express/*": ["../../../packages/platform-express/*"],
"@nestjs/platform-socket.io": ["../../../packages/platform-socket.io"],

View File

@@ -1,14 +1,14 @@
import { clc } from '@nestjs/common/utils/cli-colors.util';
import { repl } from '@nestjs/core';
import { ReplContext } from '@nestjs/core/repl/repl-context';
import {
HelpReplFn,
DebugReplFn,
GetReplFn,
HelpReplFn,
MethodsReplFn,
ResolveReplFn,
SelectReplFn,
DebugReplFn,
MethodsReplFn,
} from '@nestjs/core/repl/native-functions';
import { ReplContext } from '@nestjs/core/repl/repl-context';
import { expect } from 'chai';
import * as sinon from 'sinon';
import { AppModule } from '../src/app.module';
@@ -34,7 +34,7 @@ describe('REPL', () => {
server.context;
let outputText = '';
sinon.stub(process.stdout, 'write').callsFake(text => {
outputText += text;
outputText += text as string;
return true;
});
server.emit('line', 'get(UsersService)');
@@ -63,7 +63,7 @@ ${PROMPT}`);
server.context;
let outputText = '';
sinon.stub(process.stdout, 'write').callsFake(text => {
outputText += text;
outputText += text as string;
return true;
});
server.emit('line', '$(UsersService)');
@@ -92,7 +92,7 @@ ${PROMPT}`);
let outputText = '';
sinon.stub(process.stdout, 'write').callsFake(text => {
outputText += text;
outputText += text as string;
return true;
});
server.emit('line', 'debug(UsersModule)');
@@ -115,7 +115,7 @@ ${PROMPT}`,
let outputText = '';
sinon.stub(process.stdout, 'write').callsFake(text => {
outputText += text;
outputText += text as string;
return true;
});
server.emit('line', 'methods("UsersRepository")');
@@ -153,7 +153,7 @@ ${PROMPT}`,
).fnDefinition;
let outputText = '';
sinon.stub(process.stdout, 'write').callsFake(text => {
outputText += text;
outputText += text as string;
return true;
});
@@ -172,7 +172,7 @@ ${PROMPT}`);
).fnDefinition;
let outputText = '';
sinon.stub(process.stdout, 'write').callsFake(text => {
outputText += text;
outputText += text as string;
return true;
});
@@ -191,7 +191,7 @@ ${PROMPT}`);
).fnDefinition;
let outputText = '';
sinon.stub(process.stdout, 'write').callsFake(text => {
outputText += text;
outputText += text as string;
return true;
});
@@ -210,7 +210,7 @@ ${PROMPT}`);
).fnDefinition;
let outputText = '';
sinon.stub(process.stdout, 'write').callsFake(text => {
outputText += text;
outputText += text as string;
return true;
});
@@ -229,7 +229,7 @@ ${PROMPT}`);
).fnDefinition;
let outputText = '';
sinon.stub(process.stdout, 'write').callsFake(text => {
outputText += text;
outputText += text as string;
return true;
});
@@ -248,7 +248,7 @@ ${PROMPT}`);
).fnDefinition;
let outputText = '';
sinon.stub(process.stdout, 'write').callsFake(text => {
outputText += text;
outputText += text as string;
return true;
});

View File

@@ -10,6 +10,7 @@
"target": "ES2021",
"sourceMap": true,
"allowJs": true,
"strictNullChecks": true,
"outDir": "./dist",
"paths": {
"@nestjs/common": ["../../packages/common"],

View File

@@ -48,19 +48,19 @@ describe('Circular request scope', () => {
await new Promise(resolve => performHttpCall(resolve));
});
it(`should create controller for each request`, async () => {
it(`should create controller for each request`, () => {
expect(HelloController.COUNTER).to.be.eql(3);
});
it(`should create service for each request`, async () => {
it(`should create service for each request`, () => {
expect(UsersService.COUNTER).to.be.eql(3);
});
it(`should create service for each request`, async () => {
it(`should create service for each request`, () => {
expect(HelloService.COUNTER).to.be.eql(3);
});
it(`should create provider for each inquirer`, async () => {
it(`should create provider for each inquirer`, () => {
expect(Meta.COUNTER).to.be.eql(3);
});
});

View File

@@ -39,7 +39,7 @@ describe('Circular transient scope', () => {
const performHttpCall = end =>
request(server)
.get('/hello')
.end((err, res) => {
.end(err => {
if (err) return end(err);
end();
});

View File

@@ -27,10 +27,14 @@ describe('Durable providers', () => {
tenantId: number,
end: (err?: any) => void,
endpoint = '/durable',
opts: {
forceError: boolean;
} = { forceError: false },
) =>
request(server)
.get(endpoint)
.set({ ['x-tenant-id']: tenantId })
.set({ ['x-tenant-id']: String(tenantId) })
.set({ ['x-force-error']: opts.forceError ? 'true' : 'false' })
.end((err, res) => {
if (err) return end(err);
end(res);
@@ -84,6 +88,42 @@ describe('Durable providers', () => {
);
expect(result.body).deep.equal({ tenantId: '3' });
});
it(`should return the same tenantId both from durable request scoped service and non-durable request scoped service`, async () => {
let result: request.Response;
result = await new Promise<request.Response>(resolve =>
performHttpCall(1, resolve, '/durable/request-context'),
);
expect(result.body).deep.equal({
durableService: '1',
nonDurableService: '1',
});
result = await new Promise<request.Response>(resolve =>
performHttpCall(2, resolve, '/durable/request-context'),
);
expect(result.body).deep.equal({
durableService: '2',
nonDurableService: '2',
});
});
it(`should not cache durable providers that throw errors`, async () => {
let result: request.Response;
result = await new Promise<request.Response>(resolve =>
performHttpCall(10, resolve, '/durable/echo', { forceError: true }),
);
expect(result.statusCode).equal(412);
// The second request should be successful
result = await new Promise<request.Response>(resolve =>
performHttpCall(10, resolve, '/durable/echo'),
);
expect(result.body).deep.equal({ tenantId: '10' });
});
});
after(async () => {

View File

@@ -47,29 +47,29 @@ describe('Request scope (microservices)', () => {
if (err) return end(err);
end();
});
await new Promise(resolve => performHttpCall(resolve));
await new Promise(resolve => performHttpCall(resolve));
await new Promise(resolve => performHttpCall(resolve));
await new Promise<any>(resolve => performHttpCall(resolve));
await new Promise<any>(resolve => performHttpCall(resolve));
await new Promise<any>(resolve => performHttpCall(resolve));
});
it(`should create controller for each request`, async () => {
it(`should create controller for each request`, () => {
expect(HelloController.COUNTER).to.be.eql(3);
});
it(`should create service for each request`, async () => {
it(`should create service for each request`, () => {
expect(UsersService.COUNTER).to.be.eql(3);
});
it(`should share static provider across requests`, async () => {
it(`should share static provider across requests`, () => {
expect(Meta.COUNTER).to.be.eql(1);
});
it(`should create request scoped interceptor for each request`, async () => {
it(`should create request scoped interceptor for each request`, () => {
expect(Interceptor.COUNTER).to.be.eql(3);
expect(Interceptor.REQUEST_SCOPED_DATA).to.deep.equal([1, 1, 1]);
});
it(`should create request scoped guard for each request`, async () => {
it(`should create request scoped guard for each request`, () => {
expect(Guard.COUNTER).to.be.eql(3);
expect(Guard.REQUEST_SCOPED_DATA).to.deep.equal([1, 1, 1]);
});

View File

@@ -24,16 +24,16 @@ describe('Request scope (modules propagation)', () => {
const performHttpCall = end =>
request(server)
.get('/hello')
.end((err, res) => {
.end(err => {
if (err) return end(err);
end();
});
await new Promise(resolve => performHttpCall(resolve));
await new Promise(resolve => performHttpCall(resolve));
await new Promise(resolve => performHttpCall(resolve));
await new Promise<any>(resolve => performHttpCall(resolve));
await new Promise<any>(resolve => performHttpCall(resolve));
await new Promise<any>(resolve => performHttpCall(resolve));
});
it(`should not fail`, async () => {
it(`should not fail`, () => {
expect(RequestChainService.COUNTER).to.be.eql(3);
});
});

View File

@@ -40,38 +40,38 @@ describe('Request scope', () => {
const performHttpCall = end =>
request(server)
.get('/hello')
.end((err, res) => {
.end(err => {
if (err) return end(err);
end();
});
await new Promise(resolve => performHttpCall(resolve));
await new Promise(resolve => performHttpCall(resolve));
await new Promise(resolve => performHttpCall(resolve));
await new Promise<any>(resolve => performHttpCall(resolve));
await new Promise<any>(resolve => performHttpCall(resolve));
await new Promise<any>(resolve => performHttpCall(resolve));
});
it(`should create controller for each request`, async () => {
it(`should create controller for each request`, () => {
expect(HelloController.COUNTER).to.be.eql(3);
});
it(`should create service for each request`, async () => {
it(`should create service for each request`, () => {
expect(UsersService.COUNTER).to.be.eql(3);
});
it(`should share static provider across requests`, async () => {
it(`should share static provider across requests`, () => {
expect(Meta.COUNTER).to.be.eql(1);
});
it(`should create request scoped pipe for each request`, async () => {
it(`should create request scoped pipe for each request`, () => {
expect(UserByIdPipe.COUNTER).to.be.eql(3);
expect(UserByIdPipe.REQUEST_SCOPED_DATA).to.deep.equal([1, 1, 1]);
});
it(`should create request scoped interceptor for each request`, async () => {
it(`should create request scoped interceptor for each request`, () => {
expect(Interceptor.COUNTER).to.be.eql(3);
expect(Interceptor.REQUEST_SCOPED_DATA).to.deep.equal([1, 1, 1]);
});
it(`should create request scoped guard for each request`, async () => {
it(`should create request scoped guard for each request`, () => {
expect(Guard.COUNTER).to.be.eql(3);
expect(Guard.REQUEST_SCOPED_DATA).to.deep.equal([1, 1, 1]);
});

View File

@@ -41,36 +41,36 @@ describe('Transient scope', () => {
const performHttpCall = end =>
request(server)
.get('/hello')
.end((err, res) => {
.end(err => {
if (err) return end(err);
end();
});
await new Promise(resolve => performHttpCall(resolve));
await new Promise(resolve => performHttpCall(resolve));
await new Promise(resolve => performHttpCall(resolve));
await new Promise<any>(resolve => performHttpCall(resolve));
await new Promise<any>(resolve => performHttpCall(resolve));
await new Promise<any>(resolve => performHttpCall(resolve));
});
it(`should create controller for each request`, async () => {
it(`should create controller for each request`, () => {
expect(HelloController.COUNTER).to.be.eql(3);
});
it(`should create service for each request`, async () => {
it(`should create service for each request`, () => {
expect(UsersService.COUNTER).to.be.eql(3);
});
it(`should create provider for each inquirer`, async () => {
it(`should create provider for each inquirer`, () => {
expect(Meta.COUNTER).to.be.eql(7);
});
it(`should create transient pipe for each controller (3 requests, 1 static)`, async () => {
it(`should create transient pipe for each controller (3 requests, 1 static)`, () => {
expect(UserByIdPipe.COUNTER).to.be.eql(4);
});
it(`should create transient interceptor for each controller (3 requests, 1 static)`, async () => {
it(`should create transient interceptor for each controller (3 requests, 1 static)`, () => {
expect(Interceptor.COUNTER).to.be.eql(4);
});
it(`should create transient guard for each controller (3 requests, 1 static)`, async () => {
it(`should create transient guard for each controller (3 requests, 1 static)`, () => {
expect(Guard.COUNTER).to.be.eql(4);
});
});

View File

@@ -1,23 +1,35 @@
import { ContextId, ContextIdStrategy, HostComponentInfo } from '@nestjs/core';
import { Request } from 'express';
export type TenantContext = {
tenantId: string;
forceError?: boolean;
};
const tenants = new Map<string, ContextId>();
export class DurableContextIdStrategy implements ContextIdStrategy {
attach(contextId: ContextId, request: Request) {
const tenantId = request.headers['x-tenant-id'] as string;
const forceError = request.headers['x-force-error'] === 'true';
let tenantSubTreeId: ContextId;
if (tenants.has(tenantId)) {
tenantSubTreeId = tenants.get(tenantId);
tenantSubTreeId = tenants.get(tenantId)!;
} else {
tenantSubTreeId = { id: +tenantId } as ContextId;
tenants.set(tenantId, tenantSubTreeId);
}
const payload: TenantContext = { tenantId };
if (forceError) {
payload.forceError = true;
}
return {
resolve: (info: HostComponentInfo) =>
info.isTreeDurable ? tenantSubTreeId : contextId,
payload: { tenantId },
payload,
};
}
}

View File

@@ -1,9 +1,13 @@
import { Controller, Get } from '@nestjs/common';
import { DurableService } from './durable.service';
import { NonDurableService } from './non-durable.service';
@Controller('durable')
export class DurableController {
constructor(private readonly durableService: DurableService) {}
constructor(
private readonly durableService: DurableService,
private readonly nonDurableService: NonDurableService,
) {}
@Get()
greeting(): string {
@@ -12,6 +16,16 @@ export class DurableController {
@Get('echo')
echo() {
return this.durableService.requestPayload;
return {
tenantId: this.durableService.getTenantId(),
};
}
@Get('request-context')
getRequestContext() {
return {
durableService: this.durableService.getTenantId(),
nonDurableService: this.nonDurableService.getTenantId(),
};
}
}

View File

@@ -3,11 +3,13 @@ import { APP_GUARD } from '@nestjs/core';
import { DurableController } from './durable.controller';
import { DurableGuard } from './durable.guard';
import { DurableService } from './durable.service';
import { NonDurableService } from './non-durable.service';
@Module({
controllers: [DurableController],
providers: [
DurableService,
NonDurableService,
{
provide: APP_GUARD,
useClass: DurableGuard,

View File

@@ -1,14 +1,28 @@
import { Inject, Injectable, Scope } from '@nestjs/common';
import {
Inject,
Injectable,
PreconditionFailedException,
Scope,
} from '@nestjs/common';
import { REQUEST } from '@nestjs/core';
import { TenantContext } from './durable-context-id.strategy';
@Injectable({ scope: Scope.REQUEST, durable: true })
export class DurableService {
public instanceCounter = 0;
constructor(@Inject(REQUEST) public readonly requestPayload: unknown) {}
constructor(@Inject(REQUEST) private readonly requestPayload: TenantContext) {
if (requestPayload.forceError) {
throw new PreconditionFailedException('Forced error');
}
}
greeting() {
++this.instanceCounter;
return `Hello world! Counter: ${this.instanceCounter}`;
}
getTenantId() {
return this.requestPayload.tenantId;
}
}

View File

@@ -0,0 +1,14 @@
import { Inject, Injectable, Scope } from '@nestjs/common';
import { REQUEST } from '@nestjs/core';
import { TenantContext } from './durable-context-id.strategy';
@Injectable()
export class NonDurableService {
constructor(
@Inject(REQUEST) private readonly requestPayload: TenantContext,
) {}
getTenantId() {
return this.requestPayload.tenantId;
}
}

View File

@@ -10,7 +10,7 @@ import { Observable } from 'rxjs';
@Injectable({ scope: Scope.REQUEST })
export class Guard implements CanActivate {
static COUNTER = 0;
static REQUEST_SCOPED_DATA = [];
static REQUEST_SCOPED_DATA = [] as number[];
constructor(@Inject('REQUEST_ID') private readonly requestId: number) {
Guard.COUNTER++;

View File

@@ -11,7 +11,7 @@ import { Observable } from 'rxjs';
@Injectable({ scope: Scope.REQUEST })
export class Interceptor implements NestInterceptor {
static COUNTER = 0;
static REQUEST_SCOPED_DATA = [];
static REQUEST_SCOPED_DATA = [] as number[];
constructor(@Inject('REQUEST_ID') private readonly requestId: number) {
Interceptor.COUNTER++;

View File

@@ -9,7 +9,7 @@ import { UsersService } from './users.service';
@Injectable()
export class UserByIdPipe implements PipeTransform<string> {
static COUNTER = 0;
static REQUEST_SCOPED_DATA = [];
static REQUEST_SCOPED_DATA = [] as number[];
constructor(
@Inject('REQUEST_ID') private readonly requestId: number,

Some files were not shown because too many files have changed in this diff Show More