mirror of
https://github.com/nestjs/nest.git
synced 2026-02-22 23:41:40 +00:00
Compare commits
350 Commits
v6.4.0
...
BrunnerLiv
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3c1a6a2f97 | ||
|
|
09ce572d8f | ||
|
|
3671a1b359 | ||
|
|
e2e27aff62 | ||
|
|
86a03124db | ||
|
|
ba26e3adf6 | ||
|
|
4d60d51b8d | ||
|
|
13ca0cd62e | ||
|
|
f61f21848a | ||
|
|
89ae259bef | ||
|
|
f89220eaed | ||
|
|
a53abc92c6 | ||
|
|
7a2183238b | ||
|
|
12426621fe | ||
|
|
4cd5aef606 | ||
|
|
296e8fe58d | ||
|
|
f2f825eeca | ||
|
|
b1d5a1bb7d | ||
|
|
af152d18a4 | ||
|
|
851a860c79 | ||
|
|
5d243ad231 | ||
|
|
fa1515a3f2 | ||
|
|
bb06006c94 | ||
|
|
88ef07e21b | ||
|
|
9ff5180a81 | ||
|
|
6d6d0f953d | ||
|
|
cde2d2112a | ||
|
|
e2548f34b5 | ||
|
|
4b5245d984 | ||
|
|
cb08895ee0 | ||
|
|
b5729ce521 | ||
|
|
321337eb8a | ||
|
|
1b59a8e0b4 | ||
|
|
0c444c68bb | ||
|
|
1d34dbaa2e | ||
|
|
ecf2f18785 | ||
|
|
17eb1d989c | ||
|
|
baa20004fc | ||
|
|
53554b3636 | ||
|
|
d093655da8 | ||
|
|
614a1e5669 | ||
|
|
ec96ac30ab | ||
|
|
f8237bde81 | ||
|
|
3bd21ce20d | ||
|
|
738e00ebb0 | ||
|
|
9edd0444e5 | ||
|
|
b840b1974c | ||
|
|
63262c38f6 | ||
|
|
e76786b1b1 | ||
|
|
68721a2539 | ||
|
|
591f7c7f97 | ||
|
|
0c726ded81 | ||
|
|
e3204d6799 | ||
|
|
d790dcf5d8 | ||
|
|
29596af7f0 | ||
|
|
4966ab880e | ||
|
|
58e25644d1 | ||
|
|
f55f32de0e | ||
|
|
a42be64668 | ||
|
|
9e1895d5ae | ||
|
|
d561e28fa7 | ||
|
|
3ccab0b47e | ||
|
|
ac21698128 | ||
|
|
cc80ce5dfd | ||
|
|
15a6d8e5fe | ||
|
|
14b0769011 | ||
|
|
98322161fb | ||
|
|
50083ce836 | ||
|
|
b147bc38ad | ||
|
|
74c48b6490 | ||
|
|
64e07ffd95 | ||
|
|
d3df1ce269 | ||
|
|
e963ffe07c | ||
|
|
fb81ae054a | ||
|
|
9f9455246b | ||
|
|
b7b5f6bf35 | ||
|
|
81ccfa8a63 | ||
|
|
2d527059b5 | ||
|
|
98bc2da6c0 | ||
|
|
2ff8a6378f | ||
|
|
62492813d1 | ||
|
|
8f5adebd00 | ||
|
|
c81a5b19f8 | ||
|
|
04681fcba1 | ||
|
|
0771207d78 | ||
|
|
5667872a52 | ||
|
|
39c67db000 | ||
|
|
10b717300d | ||
|
|
5f63041637 | ||
|
|
c41545ad13 | ||
|
|
39e7845f73 | ||
|
|
06861628eb | ||
|
|
ef46fc435a | ||
|
|
dde610bc54 | ||
|
|
931c8eec1c | ||
|
|
202a572ea4 | ||
|
|
f7bcb9283a | ||
|
|
ae577d4c5a | ||
|
|
65f44cf019 | ||
|
|
01da02560f | ||
|
|
4b0441e691 | ||
|
|
33cd414123 | ||
|
|
c7a63f37bf | ||
|
|
a28a821d73 | ||
|
|
d5429a4c58 | ||
|
|
222d7c9f53 | ||
|
|
d5c3b0542a | ||
|
|
a11098fba6 | ||
|
|
73ae49d10c | ||
|
|
75e3de119f | ||
|
|
692d78056d | ||
|
|
be25bc0e28 | ||
|
|
8d3b2a98c8 | ||
|
|
a0a04a719c | ||
|
|
a92b82ef38 | ||
|
|
9c5deef5ec | ||
|
|
2038b45d04 | ||
|
|
27e8ca7c5e | ||
|
|
ef01ec7abc | ||
|
|
b9852f68d0 | ||
|
|
8ea7de969b | ||
|
|
ac3537b973 | ||
|
|
0b05561201 | ||
|
|
a873457a3d | ||
|
|
62c5ce66f3 | ||
|
|
5e77c94c81 | ||
|
|
72238a1e0d | ||
|
|
921f542e45 | ||
|
|
1e573f6228 | ||
|
|
9e0fec0880 | ||
|
|
b3dffe398f | ||
|
|
521533e81a | ||
|
|
305fb4a464 | ||
|
|
547dcf810f | ||
|
|
54d94f8e3e | ||
|
|
ced03a041d | ||
|
|
05efc140db | ||
|
|
f1f1ecc66b | ||
|
|
6bb2765d2f | ||
|
|
3b982aab48 | ||
|
|
3dda0a9cb5 | ||
|
|
75cbb373be | ||
|
|
8f7b56e9d5 | ||
|
|
186976f950 | ||
|
|
e9dae8a1a8 | ||
|
|
84a37fec81 | ||
|
|
17e9e4acc7 | ||
|
|
0c4efab305 | ||
|
|
97bc3c66bc | ||
|
|
b501fd6e7f | ||
|
|
8dbb01c398 | ||
|
|
ed6448ac23 | ||
|
|
c9cf78d421 | ||
|
|
88cb1495d3 | ||
|
|
69c0357f22 | ||
|
|
a665aa8f74 | ||
|
|
25db843b7f | ||
|
|
a0a51302ed | ||
|
|
b3edf20a2d | ||
|
|
855dc056b8 | ||
|
|
5287c51779 | ||
|
|
c5e54bf509 | ||
|
|
f288c2bfe3 | ||
|
|
c568d9d3b4 | ||
|
|
7cf343449b | ||
|
|
a15380864f | ||
|
|
e29fb08d45 | ||
|
|
2b2d5782b8 | ||
|
|
c6890e59e6 | ||
|
|
2b2c78a46b | ||
|
|
623555d018 | ||
|
|
72ca19b973 | ||
|
|
00adefad42 | ||
|
|
4585670b96 | ||
|
|
0dcd010bc9 | ||
|
|
865b0317fa | ||
|
|
ad549e7846 | ||
|
|
694360cdbd | ||
|
|
8838e814fb | ||
|
|
16b3fb7e1c | ||
|
|
3aa52d43c4 | ||
|
|
7e964b973e | ||
|
|
842d2617c7 | ||
|
|
1985ebb52c | ||
|
|
38d56c2c50 | ||
|
|
d3a1c3ff7e | ||
|
|
9cef5fa108 | ||
|
|
fa57cca223 | ||
|
|
eff133265e | ||
|
|
a0803904be | ||
|
|
e69d709f59 | ||
|
|
9db1c013ff | ||
|
|
a5ebf54618 | ||
|
|
fc6b35fe13 | ||
|
|
d613799453 | ||
|
|
0d29b63c07 | ||
|
|
54a2890946 | ||
|
|
404e2a4fb1 | ||
|
|
6195174748 | ||
|
|
3e121891dd | ||
|
|
4fceae6bec | ||
|
|
370d0f76af | ||
|
|
fc99ccdb30 | ||
|
|
c94322d094 | ||
|
|
dd19f15b89 | ||
|
|
bfe182d965 | ||
|
|
8ed4cce9f7 | ||
|
|
0db528e2aa | ||
|
|
32a8f90c71 | ||
|
|
c0f70fd769 | ||
|
|
d5b2bee830 | ||
|
|
525e642286 | ||
|
|
9df178f12a | ||
|
|
8660043776 | ||
|
|
6ff7a7f266 | ||
|
|
7eafc150f0 | ||
|
|
9eef47c4bf | ||
|
|
51987bb43b | ||
|
|
fdfe0ed02e | ||
|
|
c06bbbed97 | ||
|
|
e834118914 | ||
|
|
ef199730c1 | ||
|
|
6980da363b | ||
|
|
f899064410 | ||
|
|
7a50e50dbf | ||
|
|
7c8f9d901c | ||
|
|
9a8de91bb9 | ||
|
|
6c22219605 | ||
|
|
6a031f0d63 | ||
|
|
d5f86c5ba4 | ||
|
|
b55367646c | ||
|
|
b7986bcaf0 | ||
|
|
94781480ed | ||
|
|
aa1d192b6a | ||
|
|
4bc15d483c | ||
|
|
1b84dda4de | ||
|
|
db5bbece3a | ||
|
|
9fd16f7478 | ||
|
|
a0fd983ce1 | ||
|
|
445717cf15 | ||
|
|
f92892423f | ||
|
|
9830b0071c | ||
|
|
f582625bcf | ||
|
|
e0d2209a06 | ||
|
|
b89133c2e7 | ||
|
|
6bbfd7b54f | ||
|
|
5ed1edf262 | ||
|
|
64e69cd2b5 | ||
|
|
aabe0295c6 | ||
|
|
6a6c62d430 | ||
|
|
fded926042 | ||
|
|
fc3dd675fa | ||
|
|
744a070658 | ||
|
|
ef4ab89b0d | ||
|
|
3774fed640 | ||
|
|
6ff7859976 | ||
|
|
8718f4763e | ||
|
|
4cbebed909 | ||
|
|
b1388b136c | ||
|
|
499c94792a | ||
|
|
c93d7e4ab0 | ||
|
|
2ec291cf4c | ||
|
|
e25e3c1e92 | ||
|
|
2655d19aa5 | ||
|
|
da45d58982 | ||
|
|
82db8a3743 | ||
|
|
bc71cb4eca | ||
|
|
35fff662df | ||
|
|
531073957f | ||
|
|
41e4e853f6 | ||
|
|
9166d40ade | ||
|
|
8a9af18e3b | ||
|
|
9b5ddceb1f | ||
|
|
704230eb56 | ||
|
|
d150650a7a | ||
|
|
6f6d8a4a12 | ||
|
|
cbcdeb2e5f | ||
|
|
978dd180b4 | ||
|
|
8b84c63f19 | ||
|
|
573d53d6a6 | ||
|
|
c0641abf40 | ||
|
|
f3314a280d | ||
|
|
5f7605a264 | ||
|
|
a2b61f3622 | ||
|
|
6a38c24ffc | ||
|
|
6b322e725e | ||
|
|
b25754da3f | ||
|
|
5044deaf85 | ||
|
|
140a9f28ef | ||
|
|
b72fdf80b8 | ||
|
|
a2ad323b1e | ||
|
|
c2e7d7b28f | ||
|
|
292cf57cba | ||
|
|
bb5b881fc3 | ||
|
|
96e48ce3d0 | ||
|
|
38a2649ffb | ||
|
|
8a59c4841b | ||
|
|
6ca85a3b33 | ||
|
|
1d96cd4e1c | ||
|
|
f55c27d3b1 | ||
|
|
d528c1054e | ||
|
|
42a288eef0 | ||
|
|
3c8875468d | ||
|
|
378fdcd58c | ||
|
|
9deb0df42d | ||
|
|
1318641259 | ||
|
|
3c34111770 | ||
|
|
987012610d | ||
|
|
8a80de3017 | ||
|
|
a70e5369a4 | ||
|
|
fd8e490d34 | ||
|
|
ccb69d728b | ||
|
|
609878628c | ||
|
|
40cd722eaf | ||
|
|
724ddd8d23 | ||
|
|
73e573fdbb | ||
|
|
68d84d95bb | ||
|
|
acbeb1cd33 | ||
|
|
3d4b423fd6 | ||
|
|
92ad5d26f4 | ||
|
|
ace9a237ed | ||
|
|
1ea450d511 | ||
|
|
29953ab96d | ||
|
|
3b28b51bc2 | ||
|
|
90a0c3b0f5 | ||
|
|
a4383966e1 | ||
|
|
e4121d6eb4 | ||
|
|
670c33e8b4 | ||
|
|
5ef764abb5 | ||
|
|
7a93b0d91f | ||
|
|
7be5d14642 | ||
|
|
88f9473ad7 | ||
|
|
e46169aeaa | ||
|
|
791b1ceaa6 | ||
|
|
0d2f78542d | ||
|
|
90e92cdb9e | ||
|
|
a0b04c71dc | ||
|
|
a9aac4560c | ||
|
|
3715946e16 | ||
|
|
da63a3fd18 | ||
|
|
0fb20e1e53 | ||
|
|
2487ab855e | ||
|
|
eccd5d2b0c | ||
|
|
e8a66ea35b | ||
|
|
093ccfe7b7 | ||
|
|
8bd4fe2718 | ||
|
|
dd6d28972a | ||
|
|
2bd0535cf8 | ||
|
|
4a7bb39c94 | ||
|
|
fb7f79383d |
58
.travis.yml
58
.travis.yml
@@ -1,24 +1,56 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- "8"
|
||||
- "10"
|
||||
- "11"
|
||||
|
||||
cache:
|
||||
directories:
|
||||
- "node_modules"
|
||||
|
||||
git:
|
||||
depth: 5
|
||||
addons:
|
||||
firefox: "latest"
|
||||
before_script:
|
||||
- export DISPLAY=:99.0
|
||||
- sh -e /etc/init.d/xvfb start
|
||||
|
||||
before_install:
|
||||
- npm i -g npm@latest
|
||||
|
||||
install:
|
||||
- npm ci
|
||||
- npm run build:dev
|
||||
script:
|
||||
- npm run lint
|
||||
- npm test
|
||||
after_success: npm run coverage
|
||||
|
||||
jobs:
|
||||
include:
|
||||
- state: "Test"
|
||||
name: "Unit Test Node v12"
|
||||
script: npm test
|
||||
node_js: 12
|
||||
after_success: npm run coverage
|
||||
|
||||
- state: "Test"
|
||||
name: "Unit Test Node v10"
|
||||
script: npm test
|
||||
node_js: 10
|
||||
|
||||
- state: "Test"
|
||||
name: "Unit Test Node v8"
|
||||
script: npm test
|
||||
node_js: 8
|
||||
|
||||
- state: "Test"
|
||||
name: "Integration Test"
|
||||
install: skip
|
||||
before_install: skip
|
||||
before_script: skip
|
||||
addons: skip
|
||||
script:
|
||||
sudo service mysql stop &&
|
||||
bash ./scripts/prepare.sh &&
|
||||
npm run integration-test
|
||||
node_js: 12
|
||||
|
||||
- stage: "Test"
|
||||
name: "Lint"
|
||||
script: npm run lint
|
||||
node_js: 12
|
||||
|
||||
- stage: "Test"
|
||||
name: "Build samples"
|
||||
script: npm run build:samples
|
||||
node_js: 12
|
||||
|
||||
|
||||
7
CONTRIBUTING.md
Normal file → Executable file
7
CONTRIBUTING.md
Normal file → Executable file
@@ -29,7 +29,7 @@ Stack Overflow is a much better place to ask questions since:
|
||||
|
||||
To save your and our time, we will systematically close all issues that are requests for general support and redirect people to Stack Overflow.
|
||||
|
||||
If you would like to chat about the question in real-time, you can reach out via [our gitter channel][gitter].
|
||||
If you would like to chat about the question in real-time, you can reach out via [our discord channel][discord].
|
||||
|
||||
## <a name="issue"></a> Found a Bug?
|
||||
|
||||
@@ -206,8 +206,7 @@ To ensure consistency throughout the source code, keep these rules in mind as yo
|
||||
|
||||
* All features or bug fixes **must be tested** by one or more specs (unit-tests).
|
||||
* We follow [Google's JavaScript Style Guide][js-style-guide], but wrap all code at
|
||||
**100 characters**. An automated formatter is available, see
|
||||
[DEVELOPER.md](docs/DEVELOPER.md#clang-format).
|
||||
**100 characters**. An automated formatter is available (`npm run format`).
|
||||
|
||||
## <a name="commit"></a> Commit Message Guidelines
|
||||
|
||||
@@ -320,7 +319,7 @@ changes to be accepted, the CLA must be signed. It's a quick process, we promise
|
||||
[corporate-cla]: http://code.google.com/legal/corporate-cla-v1.0.html
|
||||
[dev-doc]: https://github.com/nestjs/nest/blob/master/docs/DEVELOPER.md
|
||||
[github]: https://github.com/nestjs/nest
|
||||
[gitter]: https://gitter.im/nestjs/nestjs
|
||||
[discord]: https://discordapp.com/invite/G7Qnnhy
|
||||
[individual-cla]: http://code.google.com/legal/individual-cla-v1.0.html
|
||||
[js-style-guide]: https://google.github.io/styleguide/jsguide.html
|
||||
[jsfiddle]: http://jsfiddle.net
|
||||
|
||||
31
Readme.md
31
Readme.md
@@ -7,7 +7,7 @@
|
||||
[linux-image]: https://img.shields.io/travis/nestjs/nest/master.svg?label=linux
|
||||
[linux-url]: https://travis-ci.org/nestjs/nest
|
||||
|
||||
<p align="center">A progressive <a href="http://nodejs.org" target="_blank">Node.js</a> framework for building efficient and scalable server-side applications, heavily inspired by <a href="https://angular.io" target="blank">Angular</a>.</p>
|
||||
<p align="center">A progressive <a href="http://nodejs.org" target="_blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
|
||||
<p align="center">
|
||||
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
|
||||
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
|
||||
@@ -15,7 +15,6 @@
|
||||
<a href="https://travis-ci.org/nestjs/nest" target="_blank"><img src="https://api.travis-ci.org/nestjs/nest.svg?branch=master" alt="Travis" /></a>
|
||||
<a href="https://travis-ci.org/nestjs/nest" target="_blank"><img src="https://img.shields.io/travis/nestjs/nest/master.svg?label=linux" alt="Linux" /></a>
|
||||
<a href="https://coveralls.io/github/nestjs/nest?branch=master" target="_blank"><img src="https://coveralls.io/repos/github/nestjs/nest/badge.svg?branch=master#9" alt="Coverage" /></a>
|
||||
<a href="https://gitter.im/nestjs/nestjs?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=body_badge" target="_blank"><img src="https://badges.gitter.im/nestjs/nestjs.svg" alt="Gitter" /></a>
|
||||
<a href="https://discord.gg/G7Qnnhy" target="_blank"><img src="https://img.shields.io/badge/discord-online-brightgreen.svg" alt="Discord"/></a>
|
||||
<a href="https://opencollective.com/nest#backer" target="_blank"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
|
||||
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
|
||||
@@ -61,25 +60,23 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
|
||||
|
||||
#### Sponsors
|
||||
|
||||
<a href="https://www.swingdev.io" target="_blank"><img src="https://nestjs.com/img/swingdev-logo.svg#1" width="125" valign="middle" /> </a> <a href="https://blueanchor.io/" target="_blank"><img src="https://nestjs.com/img/blueanchor.png" width="180" valign="middle" /></a>
|
||||
<a href="https://www.novologic.com/" target="_blank"><img src="https://nestjs.com/img/novologic.png" width="130" valign="middle" /></a>
|
||||
<a href="https://scal.io" target="_blank"><img src="https://nestjs.com/img/scalio-logo.svg" width="100" valign="middle" /></a> <a href="http://angularity.io" target="_blank"><img src="http://angularity.io/media/logo.svg" height="26" valign="middle" /></a> <!--<a href="https://keycdn.com"><img src="https://nestjs.com/img/keycdn.svg" height="30" /></a> --> <a href="https://hostpresto.com" target="_blank"><img src="https://nestjs.com/img/hostpresto.png" height="30" valign="middle" /></a>
|
||||
|
||||
<a href="https://genuinebee.com/" target="_blank"><img src="https://nestjs.com/img/genuinebee.svg" height="36" valign="middle" /></a> <a href="http://architectnow.net/" target="_blank"><img src="https://nestjs.com/img/architectnow.png" height="24" valign="middle" /></a> <a href="https://quander.io/" target="_blank"><img src="https://nestjs.com/img/quander.png" height="28" valign="middle" /></a> <a href="https://mantro.net/" target="_blank"><img src="https://nestjs.com/img/mantro-logo.svg" height="20" valign="middle" /></a> <a href="https://triplebyte.com/" target="_blank"><img src="https://nestjs.com/img/triplebyte.png" height="30" valign="middle" /></a>
|
||||
<a href="https://ever.co/" target="_blank"><img src="https://nestjs.com/img/ever-logo.png" height="20" valign="middle" /></a>
|
||||
<a href="https://buddy.works/" target="_blank"><img src="https://nestjs.com/img/buddy-logo.svg" height="35" valign="middle" /></a>
|
||||
<a href="https://blokt.com" target="_blank"><img src="https://nestjs.com/img/blokt-logo.png" height="31" valign="middle" /></a>
|
||||
<a href="https://reposit.co.uk/" target="_blank"><img src="https://nestjs.com/img/reposit-logo.png" height="28" valign="middle" /></a> <a href="https://yakaz.com/" target="_blank"><img src="https://nestjs.com/img/yakaz.png" width="80" valign="middle" /></a>
|
||||
<a href="https://nearpod.com/" target="_blank"><img src="https://nestjs.com/img/nearpod-logo.svg" width="120" valign="middle" /></a>
|
||||
<a href="https://clay.global/" target="_blank"><img src="https://nestjs.com/img/clay-logo.svg" width="90" valign="middle" /></a>
|
||||
<a href="https://firesticktricks.com" target="_blank"><img src="https://nestjs.com/img/firesticktricks-logo.png" width="145" valign="middle" /></a>
|
||||
<a href="http://xtremis.com/" target="_blank"><img src="https://nestjs.com/img/logo-xtremis.svg" width="145" valign="middle" /></a>
|
||||
|
||||
<a href="https://www.swingdev.io" target="_blank"><img src="https://nestjs.com/img/swingdev-logo.svg#1" width="110" valign="middle" /> </a> <a href="https://blueanchor.io/" target="_blank"><img src="https://nestjs.com/img/blueanchor.png" width="150" valign="middle" /></a>
|
||||
<a href="https://www.novologic.com/" target="_blank"><img src="https://nestjs.com/img/novologic.png" width="110" valign="middle" /></a>
|
||||
<a href="https://scal.io" target="_blank"><img src="https://nestjs.com/img/scalio-logo.svg" width="80" valign="middle" /></a> <a href="http://angularity.io" target="_blank"><img src="http://angularity.io/media/logo.svg" height="22" valign="middle" /></a> <!--<a href="https://keycdn.com"><img src="https://nestjs.com/img/keycdn.svg" height="30" /></a> --> <a href="https://hostpresto.com" target="_blank"><img src="https://nestjs.com/img/hostpresto.png" height="24" valign="middle" /></a>
|
||||
<a href="https://ever.co/" target="_blank"><img src="https://nestjs.com/img/ever-logo.png" height="14" valign="middle" /></a>
|
||||
<a href="https://buddy.works/" target="_blank"><img src="https://nestjs.com/img/buddy-logo.svg" height="25" valign="middle" /></a>
|
||||
<a href="https://blokt.com" target="_blank"><img src="https://nestjs.com/img/blokt-logo.png" height="25" valign="middle" /></a> <a href="https://genuinebee.com/" target="_blank"><img src="https://nestjs.com/img/genuinebee.svg" height="24" valign="middle" /></a> <a href="http://architectnow.net/" target="_blank"><img src="https://nestjs.com/img/architectnow.png" height="20" valign="middle" /></a> <a href="https://quander.io/" target="_blank"><img src="https://nestjs.com/img/quander.png" height="22" valign="middle" /></a> <a href="https://mantro.net/" target="_blank"><img src="https://nestjs.com/img/mantro-logo.svg" height="19" valign="middle" /></a> <a href="https://triplebyte.com/" target="_blank"><img src="https://nestjs.com/img/triplebyte.png" height="20" valign="middle" /></a>
|
||||
<a href="https://reposit.co.uk/" target="_blank"><img src="https://nestjs.com/img/reposit-logo.png" height="18" valign="middle" /></a> <a href="https://yakaz.com/" target="_blank"><img src="https://nestjs.com/img/yakaz.png" width="70" valign="middle" /></a>
|
||||
<a href="https://nearpod.com/" target="_blank"><img src="https://nestjs.com/img/nearpod-logo.svg" width="100" valign="middle" /></a>
|
||||
<a href="https://clay.global/" target="_blank"><img src="https://nestjs.com/img/clay-logo.svg" width="75" valign="middle" /></a>
|
||||
<a href="https://firesticktricks.com" target="_blank"><img src="https://nestjs.com/img/firesticktricks-logo.png" width="120" valign="middle" /></a>
|
||||
<a href="https://www.codeguesser.co.uk" target="_blank"><img src="https://nestjs.com/img/codeguesser-logo.svg" width="120" valign="middle" /></a>
|
||||
<a href="https://tekhattan.com" target="_blank"><img src="https://nestjs.com/img/tekhattan-logo.png" width="110" valign="middle" /></a>
|
||||
|
||||
|
||||
## Backers
|
||||
|
||||
<a href="https://opencollective.com/nest" target="_blank"><img src="https://opencollective.com/nest/backers.svg?width=1600"></a>
|
||||
<a href="https://opencollective.com/nest" target="_blank"><img src="https://opencollective.com/nest/backers.svg?width=1000"></a>
|
||||
|
||||
## Stay in touch
|
||||
|
||||
|
||||
123
gulpfile.js
123
gulpfile.js
@@ -1,117 +1,16 @@
|
||||
const fs = require('fs');
|
||||
'use strict';
|
||||
/**
|
||||
* Load the TypeScript compiler, then load the TypeScript gulpfile which simply loads all
|
||||
* the tasks. The tasks are really inside tools/gulp/tasks.
|
||||
*/
|
||||
|
||||
const path = require('path');
|
||||
const gulp = require('gulp');
|
||||
const ts = require('gulp-typescript');
|
||||
const sourcemaps = require('gulp-sourcemaps');
|
||||
const clean = require('gulp-clean');
|
||||
const deleteEmpty = require('delete-empty');
|
||||
|
||||
const packages = {
|
||||
common: ts.createProject('packages/common/tsconfig.json'),
|
||||
core: ts.createProject('packages/core/tsconfig.json'),
|
||||
microservices: ts.createProject('packages/microservices/tsconfig.json'),
|
||||
websockets: ts.createProject('packages/websockets/tsconfig.json'),
|
||||
testing: ts.createProject('packages/testing/tsconfig.json'),
|
||||
'platform-express': ts.createProject(
|
||||
'packages/platform-express/tsconfig.json',
|
||||
),
|
||||
'platform-fastify': ts.createProject(
|
||||
'packages/platform-fastify/tsconfig.json',
|
||||
),
|
||||
'platform-socket.io': ts.createProject(
|
||||
'packages/platform-socket.io/tsconfig.json',
|
||||
),
|
||||
'platform-ws': ts.createProject('packages/platform-ws/tsconfig.json'),
|
||||
};
|
||||
const modules = Object.keys(packages);
|
||||
const source = 'packages';
|
||||
const distId = process.argv.indexOf('--dist');
|
||||
const dist = distId < 0 ? source : process.argv[distId + 1];
|
||||
const projectDir = __dirname;
|
||||
const tsconfigPath = path.join(projectDir, 'tools/gulp/tsconfig.json');
|
||||
|
||||
gulp.task('default', function() {
|
||||
modules.forEach(module => {
|
||||
gulp.watch(
|
||||
[`${source}/${module}/**/*.ts`, `${source}/${module}/*.ts`],
|
||||
[module],
|
||||
);
|
||||
});
|
||||
require('ts-node').register({
|
||||
project: tsconfigPath
|
||||
});
|
||||
|
||||
gulp.task('copy-misc', function() {
|
||||
return gulp
|
||||
.src(['Readme.md', 'LICENSE', '.npmignore'])
|
||||
.pipe(gulp.dest(`${source}/common`))
|
||||
.pipe(gulp.dest(`${source}/core`))
|
||||
.pipe(gulp.dest(`${source}/microservices`))
|
||||
.pipe(gulp.dest(`${source}/websockets`))
|
||||
.pipe(gulp.dest(`${source}/testing`))
|
||||
.pipe(gulp.dest(`${source}/platform-fastify`))
|
||||
.pipe(gulp.dest(`${source}/platform-express`))
|
||||
.pipe(gulp.dest(`${source}/platform-ws`))
|
||||
.pipe(gulp.dest(`${source}/platform-socket.io`));
|
||||
});
|
||||
|
||||
gulp.task('clean:output', function() {
|
||||
return gulp
|
||||
.src(
|
||||
[`${source}/**/*.js`, `${source}/**/*.d.ts`, `${source}/**/*.js.map`],
|
||||
{
|
||||
read: false,
|
||||
},
|
||||
)
|
||||
.pipe(clean());
|
||||
});
|
||||
|
||||
gulp.task('clean:dirs', function(done) {
|
||||
deleteEmpty.sync(`${source}/`);
|
||||
done();
|
||||
});
|
||||
|
||||
gulp.task('clean:bundle', gulp.series('clean:output', 'clean:dirs'));
|
||||
|
||||
modules.forEach(module => {
|
||||
gulp.task(module, () => {
|
||||
return packages[module]
|
||||
.src()
|
||||
.pipe(packages[module]())
|
||||
.pipe(gulp.dest(`${dist}/${module}`));
|
||||
});
|
||||
});
|
||||
|
||||
modules.forEach(module => {
|
||||
gulp.task(module + ':dev', () => {
|
||||
return packages[module]
|
||||
.src()
|
||||
.pipe(sourcemaps.init())
|
||||
.pipe(packages[module]())
|
||||
.pipe(
|
||||
sourcemaps.mapSources(sourcePath => './' + sourcePath.split('/').pop()),
|
||||
)
|
||||
.pipe(sourcemaps.write('.'))
|
||||
.pipe(gulp.dest(`${dist}/${module}`));
|
||||
});
|
||||
});
|
||||
|
||||
gulp.task('common:dev', gulp.series(modules.map(module => module + ':dev')));
|
||||
gulp.task('build', gulp.series(modules));
|
||||
gulp.task('build:dev', gulp.series('common:dev'));
|
||||
|
||||
function getFolders(dir) {
|
||||
return fs.readdirSync(dir).filter(function(file) {
|
||||
return fs.statSync(path.join(dir, file)).isDirectory();
|
||||
});
|
||||
}
|
||||
gulp.task('move', function() {
|
||||
const getDirs = base => getFolders(base).map(path => `${base}/${path}`);
|
||||
|
||||
const examplesDirs = getDirs('sample');
|
||||
const integrationDirs = getDirs('integration');
|
||||
const directories = examplesDirs.concat(integrationDirs);
|
||||
|
||||
let stream = gulp.src(['node_modules/@nestjs/**/*']);
|
||||
|
||||
directories.forEach(dir => {
|
||||
stream = stream.pipe(gulp.dest(dir + '/node_modules/@nestjs'));
|
||||
});
|
||||
return stream;
|
||||
});
|
||||
require('./tools/gulp/gulpfile');
|
||||
@@ -23,7 +23,7 @@ services:
|
||||
- "9001:9001"
|
||||
restart: always
|
||||
mysql:
|
||||
image: mysql:5.7.26
|
||||
image: mysql:5.7.27
|
||||
environment:
|
||||
MYSQL_ROOT_PASSWORD: root
|
||||
MYSQL_DATABASE: test
|
||||
|
||||
1664
integration/graphql/package-lock.json
generated
1664
integration/graphql/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -9,21 +9,21 @@
|
||||
"start:prod": "node dist/main.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@nestjs/common": "6.3.2",
|
||||
"@nestjs/core": "6.3.2",
|
||||
"@nestjs/graphql": "6.2.4",
|
||||
"apollo-server-express": "2.6.7",
|
||||
"graphql": "14.4.1",
|
||||
"@nestjs/common": "6.5.3",
|
||||
"@nestjs/core": "6.5.3",
|
||||
"@nestjs/graphql": "6.4.2",
|
||||
"apollo-server-express": "2.8.1",
|
||||
"graphql": "14.5.0",
|
||||
"graphql-tools": "4.0.5",
|
||||
"reflect-metadata": "0.1.13",
|
||||
"rxjs": "6.5.2",
|
||||
"subscriptions-transport-ws": "0.9.16",
|
||||
"typescript": "3.5.2",
|
||||
"ws": "7.0.1"
|
||||
"typescript": "3.5.3",
|
||||
"ws": "7.1.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "7.10.6",
|
||||
"@types/node": "7.10.7",
|
||||
"ts-node": "8.3.0",
|
||||
"tslint": "5.18.0"
|
||||
"tslint": "5.19.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,8 @@
|
||||
"target": "es6",
|
||||
"sourceMap": true,
|
||||
"allowJs": true,
|
||||
"outDir": "./dist"
|
||||
"outDir": "./dist",
|
||||
"skipLibCheck": true
|
||||
},
|
||||
"include": [
|
||||
"src/**/*"
|
||||
|
||||
122
integration/hello-world/package-lock.json
generated
122
integration/hello-world/package-lock.json
generated
@@ -5,9 +5,9 @@
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
"@nestjs/common": {
|
||||
"version": "6.3.2",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/common/-/common-6.3.2.tgz",
|
||||
"integrity": "sha512-4g8hlQ2cCM0ze9K1w+7OYhTVGL6PuC7tXAgFM14MOTeKVAUz2QrJveGNE0hagDTKFagx9FvwF3B7ZSOIohw7aA==",
|
||||
"version": "6.5.3",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/common/-/common-6.5.3.tgz",
|
||||
"integrity": "sha512-8d39grIMrUYGKM46BFWxB6csQFCu1S2aK7azPivg7gTRVSbvR84cVd6tgRVM0LwFpqQrtn3Q6G6Pa8FSk7Kh1w==",
|
||||
"requires": {
|
||||
"axios": "0.19.0",
|
||||
"cli-color": "1.4.0",
|
||||
@@ -15,9 +15,9 @@
|
||||
}
|
||||
},
|
||||
"@nestjs/core": {
|
||||
"version": "6.3.2",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/core/-/core-6.3.2.tgz",
|
||||
"integrity": "sha512-dmHvk/IPlJcDKWZsBF2SMePO0NpkovMUU6VrAX9KzI1Y81foH/gfWzFaBhYX6GydPqVVFrYk23zt8yqvGWAZgA==",
|
||||
"version": "6.5.3",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/core/-/core-6.5.3.tgz",
|
||||
"integrity": "sha512-ZhYfH49sVmUUw02qsaGozCFOOehlEABakYzRShyDDq30/2+ek3KpE0DfvA9tXlzX2KVrac2qDTBxMOPoJ+zY+g==",
|
||||
"requires": {
|
||||
"@nuxtjs/opencollective": "0.2.2",
|
||||
"fast-safe-stringify": "2.0.6",
|
||||
@@ -28,9 +28,9 @@
|
||||
}
|
||||
},
|
||||
"@nestjs/microservices": {
|
||||
"version": "6.3.2",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/microservices/-/microservices-6.3.2.tgz",
|
||||
"integrity": "sha512-daEzZ4L+BpMmu9KDFUgdU7+HgeVug//qrHlVTrdqCjyNd4vgZFgXrHGNOOFWYdZCwyY2I9qrL+XEv3pz3VeXyA==",
|
||||
"version": "6.5.3",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/microservices/-/microservices-6.5.3.tgz",
|
||||
"integrity": "sha512-T9zZf61myahenI4c0qhcYnhnx49L+zL9+8W6fc+LPTarbt1HJDu6iyj6fh2BzewakwNLJRyGMJ9YCYlXhFuvlA==",
|
||||
"requires": {
|
||||
"iterare": "1.2.0",
|
||||
"json-socket": "0.3.0",
|
||||
@@ -38,17 +38,17 @@
|
||||
}
|
||||
},
|
||||
"@nestjs/testing": {
|
||||
"version": "6.3.2",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/testing/-/testing-6.3.2.tgz",
|
||||
"integrity": "sha512-BlXpA5KWok7AxwDzWn/yaOhqhAYDxUE17e+hanPEUxGkCInQIc750lG/M6ZF6aQNg1llxHquYyVKJLvzhdZqBA==",
|
||||
"version": "6.5.3",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/testing/-/testing-6.5.3.tgz",
|
||||
"integrity": "sha512-W8tPhkNVhmX+jaDu4R7WUOtIl0PK3ZDso434rEm/b1+S6ZRgAKwNVHWM/rwIuTi5+erPTEULtTsZgrXFrzC1sA==",
|
||||
"requires": {
|
||||
"optional": "0.1.4"
|
||||
}
|
||||
},
|
||||
"@nestjs/websockets": {
|
||||
"version": "6.3.2",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/websockets/-/websockets-6.3.2.tgz",
|
||||
"integrity": "sha512-ZOYbcqeBKMWXqZwBb06XejbNtVu0+X/jwKgL5SYJTs1kmnsCmRvmDzDEeMvx5Ign0cr3tF8SSOW6ysntdnIxXQ==",
|
||||
"version": "6.5.3",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/websockets/-/websockets-6.5.3.tgz",
|
||||
"integrity": "sha512-YrCvmLHTW0OBusTiUOPrG0PNrw/3Gatty/bh3ro5cEoiovcaJxGSMsTC+JSVXqPwRJjEtoHMCr5Qje2rAepIzQ==",
|
||||
"requires": {
|
||||
"iterare": "1.2.0"
|
||||
}
|
||||
@@ -64,20 +64,25 @@
|
||||
}
|
||||
},
|
||||
"@types/node": {
|
||||
"version": "7.10.6",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-7.10.6.tgz",
|
||||
"integrity": "sha512-d0BOAicT0tEdbdVQlLGOVul1kvg6YvbaADRCThGCz5NJ0e9r00SofcR1x69hmlCyrHuB6jd4cKzL9bMLjPnpAA==",
|
||||
"version": "7.10.7",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-7.10.7.tgz",
|
||||
"integrity": "sha512-4I7+hXKyq7e1deuzX9udu0hPIYqSSkdKXtjow6fMnQ3OR9qkxIErGHbGY08YrfZJrCS1ajK8lOuzd0k3n2WM4A==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/validator": {
|
||||
"version": "10.11.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/validator/-/validator-10.11.2.tgz",
|
||||
"integrity": "sha512-k/ju1RsdP5ACFUWebqsyEy0avP5uNJCs2p3pmTHzOZdd4gMSAJTq7iUEHFY3tt3emBrPTm6oGvfZ4SzcqOgLPQ=="
|
||||
},
|
||||
"abstract-logging": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/abstract-logging/-/abstract-logging-1.0.0.tgz",
|
||||
"integrity": "sha1-i33q/TEFWbwo93ck3RuzAXcnjBs="
|
||||
},
|
||||
"ajv": {
|
||||
"version": "6.10.0",
|
||||
"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.10.0.tgz",
|
||||
"integrity": "sha512-nffhOpkymDECQyR0mnsUtoCE8RlX38G0rYP+wgLWFyZuUyuuojSSvi/+euOiQBIn63whYwYVIIH1TvE3tu4OEg==",
|
||||
"version": "6.10.2",
|
||||
"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.10.2.tgz",
|
||||
"integrity": "sha512-TXtUUEYHuaTEbLZWIKUr5pmBuhDLy+8KYtPYdcV8qC+pOZL+NKqYwvWSRrVXHn+ZmRRAu8vJTAznH7Oag6RVRw==",
|
||||
"requires": {
|
||||
"fast-deep-equal": "^2.0.1",
|
||||
"fast-json-stable-stringify": "^2.0.0",
|
||||
@@ -171,12 +176,13 @@
|
||||
"integrity": "sha512-qsP+0xoavpOlJHuYsQJsN58HXSl8Jvveo+T37rEvCEeRfMWoytAyR0Ua/YsFgpM6AZYZ/og2PJwArwzJl1aXtQ=="
|
||||
},
|
||||
"class-validator": {
|
||||
"version": "0.9.1",
|
||||
"resolved": "https://registry.npmjs.org/class-validator/-/class-validator-0.9.1.tgz",
|
||||
"integrity": "sha512-3wApflrd3ywVZyx4jaasGoFt8pmo4aGLPPAEKCKCsTRWVGPilahD88q3jQjRQwja50rl9a7rsP5LAxJYwGK8/Q==",
|
||||
"version": "0.10.0",
|
||||
"resolved": "https://registry.npmjs.org/class-validator/-/class-validator-0.10.0.tgz",
|
||||
"integrity": "sha512-RvjxRlvoCvM/ojUq11j78ISpReGdBoMErdmDk1e27aQZK6ppSXq751UE6jB9JI7ayEnL6Nnmllzn/HXVSu3dmg==",
|
||||
"requires": {
|
||||
"@types/validator": "10.11.2",
|
||||
"google-libphonenumber": "^3.1.6",
|
||||
"validator": "10.4.0"
|
||||
"validator": "11.1.0"
|
||||
}
|
||||
},
|
||||
"cli-color": {
|
||||
@@ -255,9 +261,9 @@
|
||||
}
|
||||
},
|
||||
"deepmerge": {
|
||||
"version": "3.3.0",
|
||||
"resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-3.3.0.tgz",
|
||||
"integrity": "sha512-GRQOafGHwMHpjPx9iCvTgpu9NojZ49q794EEL94JVEw6VaeA8XTUyBKvAkOOjBX9oJNiV6G3P+T+tihFjo2TqA=="
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.0.0.tgz",
|
||||
"integrity": "sha512-YZ1rOP5+kHor4hMAH+HRQnBQHg+wvS1un1hAOuIcxcBy0hzcUf6Jg2a1w65kpoOUnurOfZbERwjI1TfZxNjcww=="
|
||||
},
|
||||
"delayed-stream": {
|
||||
"version": "1.0.0",
|
||||
@@ -347,12 +353,12 @@
|
||||
"integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I="
|
||||
},
|
||||
"fast-json-stringify": {
|
||||
"version": "1.15.3",
|
||||
"resolved": "https://registry.npmjs.org/fast-json-stringify/-/fast-json-stringify-1.15.3.tgz",
|
||||
"integrity": "sha512-p+ucnySTbrUQ9M7u8ygFIxrmpG8B+8O4/PvLDdh+RqMMgj/h6OoDb7U2lP+kqg3PDclQBFbSIArRhkorFwZLLg==",
|
||||
"version": "1.15.4",
|
||||
"resolved": "https://registry.npmjs.org/fast-json-stringify/-/fast-json-stringify-1.15.4.tgz",
|
||||
"integrity": "sha512-lsGTxL0OIGjGSUXgWUOdSgjCL/xMyMvMudfGN3D1zOLEv44fYZ1ZXmMyCON5XdpaiZN6nCXmU7GQg7fbXfPG4g==",
|
||||
"requires": {
|
||||
"ajv": "^6.8.1",
|
||||
"deepmerge": "^3.0.0"
|
||||
"deepmerge": "^4.0.0"
|
||||
}
|
||||
},
|
||||
"fast-redact": {
|
||||
@@ -366,19 +372,19 @@
|
||||
"integrity": "sha512-q8BZ89jjc+mz08rSxROs8VsrBBcn1SIw1kq9NjolL509tkABRk9io01RAjSaEv1Xb2uFLt8VtRiZbGp5H8iDtg=="
|
||||
},
|
||||
"fastify": {
|
||||
"version": "2.6.0",
|
||||
"resolved": "https://registry.npmjs.org/fastify/-/fastify-2.6.0.tgz",
|
||||
"integrity": "sha512-3GxGV2P8731o2S5T6ng5NMJ9S7vFpZA4mk2mJEbMbhQ5aj1HhNGBOe39TYa2gWRrJVJuXxYYYIlY/5cFhiHpNg==",
|
||||
"version": "2.7.1",
|
||||
"resolved": "https://registry.npmjs.org/fastify/-/fastify-2.7.1.tgz",
|
||||
"integrity": "sha512-ScKPXD84lkdCgz7q0zjyBr1aLxKbXRt9HYL3XIt/L8ZD2f3fAcsLEyQ2/rHxLUzLGjPlEjIvprWUL3RZvlLRLw==",
|
||||
"requires": {
|
||||
"abstract-logging": "^1.0.0",
|
||||
"ajv": "^6.9.2",
|
||||
"ajv": "^6.10.2",
|
||||
"avvio": "^6.1.1",
|
||||
"fast-json-stringify": "^1.15.0",
|
||||
"find-my-way": "^2.0.0",
|
||||
"flatstr": "^1.0.12",
|
||||
"light-my-request": "^3.2.0",
|
||||
"light-my-request": "^3.4.1",
|
||||
"middie": "^4.0.1",
|
||||
"pino": "^5.11.1",
|
||||
"pino": "^5.13.1",
|
||||
"proxy-addr": "^2.0.4",
|
||||
"readable-stream": "^3.1.1",
|
||||
"rfdc": "^1.1.2",
|
||||
@@ -440,9 +446,9 @@
|
||||
"integrity": "sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ="
|
||||
},
|
||||
"google-libphonenumber": {
|
||||
"version": "3.2.2",
|
||||
"resolved": "https://registry.npmjs.org/google-libphonenumber/-/google-libphonenumber-3.2.2.tgz",
|
||||
"integrity": "sha512-ubjGeosYPeusjYbUHy76lCniGTTI0k1rIFc+uKBX+jHQLDmWOSUtlFUxaeoLJ+Y+PAMM6dWp+C1HjHx5BI8kEw=="
|
||||
"version": "3.2.3",
|
||||
"resolved": "https://registry.npmjs.org/google-libphonenumber/-/google-libphonenumber-3.2.3.tgz",
|
||||
"integrity": "sha512-8n4JyRptifaIRlHANKRlfqLR8fANm7+Q+1qvDuUsUeStSLtLGTVsZWe1llWDfgWTm1y07cEUyiRuNIv6cs2ovg=="
|
||||
},
|
||||
"has-flag": {
|
||||
"version": "3.0.0",
|
||||
@@ -485,9 +491,9 @@
|
||||
"integrity": "sha512-jc8ZbUnYIWdxERFWQKVgwSLkGSe+kyzvmYxwNaRgx/c8NNyuHes4UHnPM3LUrAFXUx1BhNJ94n1h/KCRlbvV0g=="
|
||||
},
|
||||
"light-my-request": {
|
||||
"version": "3.4.0",
|
||||
"resolved": "https://registry.npmjs.org/light-my-request/-/light-my-request-3.4.0.tgz",
|
||||
"integrity": "sha512-zIEl4lKwATE5uPmxEZkVIIAr/JGrHEngf9MDZ7a1TodLZ93kROYkKkoqSCmQIJ01FXrzyYMnmtemBO/b1HFt0Q==",
|
||||
"version": "3.4.1",
|
||||
"resolved": "https://registry.npmjs.org/light-my-request/-/light-my-request-3.4.1.tgz",
|
||||
"integrity": "sha512-E1zMvRWjqsaCS60dTkD7c//xKV1KOFD2zo92Ru3o3e95lCfQSDCC9aS8MZm1V+zXaA/SeKDwK9gvrfaCseTusg==",
|
||||
"requires": {
|
||||
"ajv": "^6.8.1",
|
||||
"readable-stream": "^3.1.1"
|
||||
@@ -589,16 +595,16 @@
|
||||
"integrity": "sha512-ZOtfhPttCrqp2M1PBBH4X13XlvnfhIwD7yCLx+GoGoXRPQyxGOTdQMpIzPSPKXAJT/JQrdfFrgdJOyAzvgpQ9A=="
|
||||
},
|
||||
"pino": {
|
||||
"version": "5.12.6",
|
||||
"resolved": "https://registry.npmjs.org/pino/-/pino-5.12.6.tgz",
|
||||
"integrity": "sha512-LM5ug2b27uymIIkaBw54ncF+9DSf8S4z1uzw+Y5I94dRu3Z+lFuB13j0kg1InAeyxy+CsLGnWHKy9+zgTreFOg==",
|
||||
"version": "5.13.1",
|
||||
"resolved": "https://registry.npmjs.org/pino/-/pino-5.13.1.tgz",
|
||||
"integrity": "sha512-IxusG28L0g50uuf21kZELypdFOeNrJ/kRhktdi7LtdZQWCxLliMxG5iOrGUQ/ng7MiJ4XqXi/hfyXwZeKc1MxA==",
|
||||
"requires": {
|
||||
"fast-redact": "^1.4.4",
|
||||
"fast-safe-stringify": "^2.0.6",
|
||||
"flatstr": "^1.0.9",
|
||||
"pino-std-serializers": "^2.3.0",
|
||||
"quick-format-unescaped": "^3.0.2",
|
||||
"sonic-boom": "^0.7.3"
|
||||
"sonic-boom": "^0.7.5"
|
||||
}
|
||||
},
|
||||
"pino-std-serializers": {
|
||||
@@ -699,11 +705,11 @@
|
||||
"integrity": "sha512-TcZvGMMy9vodEFSse30lWinkj+JgOBvPn8wRItpQRSayhc+4ssDs335uklkfvQQJgL/WvmHLVj4Ycv2s7QCQMg=="
|
||||
},
|
||||
"sonic-boom": {
|
||||
"version": "0.7.4",
|
||||
"resolved": "https://registry.npmjs.org/sonic-boom/-/sonic-boom-0.7.4.tgz",
|
||||
"integrity": "sha512-8JRAJg0RxZtFLQMxolwETvWd2JSlH3ZGo/Z4xPxMbpqF14xCgVYPVeFCFOR3zyr3pcfG82QDVj6537Sx5ZWdNw==",
|
||||
"version": "0.7.5",
|
||||
"resolved": "https://registry.npmjs.org/sonic-boom/-/sonic-boom-0.7.5.tgz",
|
||||
"integrity": "sha512-1pKrnAV6RfvntPnarY71tpthFTM3pWZWWQdghZY8ARjtDPGzG/inxqSuRwQY/7V1woUjfyxPb437zn4p5phgnQ==",
|
||||
"requires": {
|
||||
"flatstr": "^1.0.9"
|
||||
"flatstr": "^1.0.12"
|
||||
}
|
||||
},
|
||||
"source-map": {
|
||||
@@ -836,9 +842,9 @@
|
||||
"integrity": "sha512-MAM5dBMJCJNKs9E7JXo4CXRAansRfG0nlJxW7Wf6GZzSOvH31zClSaHdIMWLehe/EGMBkqeC55rrkaOr5Oo7Nw=="
|
||||
},
|
||||
"typescript": {
|
||||
"version": "3.5.2",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.5.2.tgz",
|
||||
"integrity": "sha512-7KxJovlYhTX5RaRbUdkAXN1KUZ8PwWlTzQdHV6xNqvuFOs7+WBo10TQUqT19Q/Jz2hk5v9TQDIhyLhhJY4p5AA=="
|
||||
"version": "3.5.3",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.5.3.tgz",
|
||||
"integrity": "sha512-ACzBtm/PhXBDId6a6sDJfroT2pOWt/oOnk4/dElG5G33ZL776N3Y6/6bKZJBFpd+b05F3Ct9qDjMeJmRWtE2/g=="
|
||||
},
|
||||
"uri-js": {
|
||||
"version": "4.2.2",
|
||||
@@ -859,9 +865,9 @@
|
||||
"integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA=="
|
||||
},
|
||||
"validator": {
|
||||
"version": "10.4.0",
|
||||
"resolved": "https://registry.npmjs.org/validator/-/validator-10.4.0.tgz",
|
||||
"integrity": "sha512-Q/wBy3LB1uOyssgNlXSRmaf22NxjvDNZM2MtIQ4jaEOAB61xsh1TQxsq1CgzUMBV1lDrVMogIh8GjG1DYW0zLg=="
|
||||
"version": "11.1.0",
|
||||
"resolved": "https://registry.npmjs.org/validator/-/validator-11.1.0.tgz",
|
||||
"integrity": "sha512-qiQ5ktdO7CD6C/5/mYV4jku/7qnqzjrxb3C/Q5wR3vGGinHTgJZN/TdFT3ZX4vXhX2R1PXx42fB1cn5W+uJ4lg=="
|
||||
},
|
||||
"yn": {
|
||||
"version": "3.1.0",
|
||||
|
||||
@@ -7,20 +7,20 @@
|
||||
"start": "ts-node src/main"
|
||||
},
|
||||
"dependencies": {
|
||||
"@nestjs/common": "6.3.2",
|
||||
"@nestjs/core": "6.3.2",
|
||||
"@nestjs/microservices": "6.3.2",
|
||||
"@nestjs/testing": "6.3.2",
|
||||
"@nestjs/websockets": "6.3.2",
|
||||
"@nestjs/common": "6.5.3",
|
||||
"@nestjs/core": "6.5.3",
|
||||
"@nestjs/microservices": "6.5.3",
|
||||
"@nestjs/testing": "6.5.3",
|
||||
"@nestjs/websockets": "6.5.3",
|
||||
"class-transformer": "0.2.3",
|
||||
"class-validator": "0.9.1",
|
||||
"fastify": "2.6.0",
|
||||
"class-validator": "0.10.0",
|
||||
"fastify": "2.7.1",
|
||||
"reflect-metadata": "0.1.13",
|
||||
"rxjs": "6.5.2",
|
||||
"typescript": "3.5.2"
|
||||
"typescript": "3.5.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "7.10.6",
|
||||
"@types/node": "7.10.7",
|
||||
"supertest": "4.0.2",
|
||||
"ts-node": "8.3.0"
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { Injectable, OnApplicationShutdown } from '@nestjs/common';
|
||||
import { Test } from '@nestjs/testing';
|
||||
import { expect } from 'chai';
|
||||
import * as Sinon from 'sinon';
|
||||
import { Injectable, OnApplicationShutdown, ShutdownSignal } from '@nestjs/common';
|
||||
import { spawn, spawnSync } from 'child_process';
|
||||
import { spawnSync } from 'child_process';
|
||||
import { join } from 'path';
|
||||
import * as Sinon from 'sinon';
|
||||
|
||||
@Injectable()
|
||||
class TestInjectable implements OnApplicationShutdown {
|
||||
@@ -23,26 +23,41 @@ describe('OnApplicationShutdown', () => {
|
||||
});
|
||||
|
||||
it('should call onApplicationShutdown if any shutdown signal gets invoked', done => {
|
||||
const result = spawnSync('ts-node', [join(__dirname, '../src/main.ts'), 'SIGHUP']);
|
||||
expect(result.stdout.toString().trim()).to.be.eq('Signal SIGHUP');
|
||||
const result = spawnSync('ts-node', [
|
||||
join(__dirname, '../src/main.ts'),
|
||||
'SIGHUP',
|
||||
]);
|
||||
expect(result.stdout.toString().trim() === 'Signal SIGHUP').to.be.true;
|
||||
done();
|
||||
});
|
||||
}).timeout(5000);
|
||||
|
||||
it('should call onApplicationShutdown if a specific shutdown signal gets invoked', done => {
|
||||
const result = spawnSync('ts-node', [join(__dirname, '../src/main.ts'), 'SIGINT', 'SIGINT']);
|
||||
const result = spawnSync('ts-node', [
|
||||
join(__dirname, '../src/main.ts'),
|
||||
'SIGINT',
|
||||
'SIGINT',
|
||||
]);
|
||||
expect(result.stdout.toString().trim()).to.be.eq('Signal SIGINT');
|
||||
done();
|
||||
});
|
||||
}).timeout(5000);
|
||||
|
||||
it('should ignore system signals which are not specified', done => {
|
||||
const result = spawnSync('ts-node', [join(__dirname, '../src/main.ts'), 'SIGINT', 'SIGHUP']);
|
||||
const result = spawnSync('ts-node', [
|
||||
join(__dirname, '../src/main.ts'),
|
||||
'SIGINT',
|
||||
'SIGHUP',
|
||||
]);
|
||||
expect(result.stdout.toString().trim()).to.be.eq('');
|
||||
done();
|
||||
});
|
||||
}).timeout(5000);
|
||||
|
||||
it('should ignore system signals if "enableShutdownHooks" was not called', done => {
|
||||
const result = spawnSync('ts-node', [join(__dirname, '../src/main.ts'), 'SIGINT', 'NONE']);
|
||||
const result = spawnSync('ts-node', [
|
||||
join(__dirname, '../src/main.ts'),
|
||||
'SIGINT',
|
||||
'NONE',
|
||||
]);
|
||||
expect(result.stdout.toString().trim()).to.be.eq('');
|
||||
done();
|
||||
});
|
||||
}).timeout(5000);
|
||||
});
|
||||
|
||||
50
integration/hooks/package-lock.json
generated
50
integration/hooks/package-lock.json
generated
@@ -5,9 +5,9 @@
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
"@nestjs/common": {
|
||||
"version": "6.3.2",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/common/-/common-6.3.2.tgz",
|
||||
"integrity": "sha512-4g8hlQ2cCM0ze9K1w+7OYhTVGL6PuC7tXAgFM14MOTeKVAUz2QrJveGNE0hagDTKFagx9FvwF3B7ZSOIohw7aA==",
|
||||
"version": "6.5.3",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/common/-/common-6.5.3.tgz",
|
||||
"integrity": "sha512-8d39grIMrUYGKM46BFWxB6csQFCu1S2aK7azPivg7gTRVSbvR84cVd6tgRVM0LwFpqQrtn3Q6G6Pa8FSk7Kh1w==",
|
||||
"requires": {
|
||||
"axios": "0.19.0",
|
||||
"cli-color": "1.4.0",
|
||||
@@ -15,9 +15,9 @@
|
||||
}
|
||||
},
|
||||
"@nestjs/core": {
|
||||
"version": "6.3.2",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/core/-/core-6.3.2.tgz",
|
||||
"integrity": "sha512-dmHvk/IPlJcDKWZsBF2SMePO0NpkovMUU6VrAX9KzI1Y81foH/gfWzFaBhYX6GydPqVVFrYk23zt8yqvGWAZgA==",
|
||||
"version": "6.5.3",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/core/-/core-6.5.3.tgz",
|
||||
"integrity": "sha512-ZhYfH49sVmUUw02qsaGozCFOOehlEABakYzRShyDDq30/2+ek3KpE0DfvA9tXlzX2KVrac2qDTBxMOPoJ+zY+g==",
|
||||
"requires": {
|
||||
"@nuxtjs/opencollective": "0.2.2",
|
||||
"fast-safe-stringify": "2.0.6",
|
||||
@@ -38,11 +38,16 @@
|
||||
}
|
||||
},
|
||||
"@types/node": {
|
||||
"version": "7.10.6",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-7.10.6.tgz",
|
||||
"integrity": "sha512-d0BOAicT0tEdbdVQlLGOVul1kvg6YvbaADRCThGCz5NJ0e9r00SofcR1x69hmlCyrHuB6jd4cKzL9bMLjPnpAA==",
|
||||
"version": "7.10.7",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-7.10.7.tgz",
|
||||
"integrity": "sha512-4I7+hXKyq7e1deuzX9udu0hPIYqSSkdKXtjow6fMnQ3OR9qkxIErGHbGY08YrfZJrCS1ajK8lOuzd0k3n2WM4A==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/validator": {
|
||||
"version": "10.11.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/validator/-/validator-10.11.2.tgz",
|
||||
"integrity": "sha512-k/ju1RsdP5ACFUWebqsyEy0avP5uNJCs2p3pmTHzOZdd4gMSAJTq7iUEHFY3tt3emBrPTm6oGvfZ4SzcqOgLPQ=="
|
||||
},
|
||||
"ansi-regex": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz",
|
||||
@@ -99,12 +104,13 @@
|
||||
"integrity": "sha512-qsP+0xoavpOlJHuYsQJsN58HXSl8Jvveo+T37rEvCEeRfMWoytAyR0Ua/YsFgpM6AZYZ/og2PJwArwzJl1aXtQ=="
|
||||
},
|
||||
"class-validator": {
|
||||
"version": "0.9.1",
|
||||
"resolved": "https://registry.npmjs.org/class-validator/-/class-validator-0.9.1.tgz",
|
||||
"integrity": "sha512-3wApflrd3ywVZyx4jaasGoFt8pmo4aGLPPAEKCKCsTRWVGPilahD88q3jQjRQwja50rl9a7rsP5LAxJYwGK8/Q==",
|
||||
"version": "0.10.0",
|
||||
"resolved": "https://registry.npmjs.org/class-validator/-/class-validator-0.10.0.tgz",
|
||||
"integrity": "sha512-RvjxRlvoCvM/ojUq11j78ISpReGdBoMErdmDk1e27aQZK6ppSXq751UE6jB9JI7ayEnL6Nnmllzn/HXVSu3dmg==",
|
||||
"requires": {
|
||||
"@types/validator": "10.11.2",
|
||||
"google-libphonenumber": "^3.1.6",
|
||||
"validator": "10.4.0"
|
||||
"validator": "11.1.0"
|
||||
}
|
||||
},
|
||||
"cli-color": {
|
||||
@@ -301,9 +307,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"google-libphonenumber": {
|
||||
"version": "3.2.2",
|
||||
"resolved": "https://registry.npmjs.org/google-libphonenumber/-/google-libphonenumber-3.2.2.tgz",
|
||||
"integrity": "sha512-ubjGeosYPeusjYbUHy76lCniGTTI0k1rIFc+uKBX+jHQLDmWOSUtlFUxaeoLJ+Y+PAMM6dWp+C1HjHx5BI8kEw=="
|
||||
"version": "3.2.3",
|
||||
"resolved": "https://registry.npmjs.org/google-libphonenumber/-/google-libphonenumber-3.2.3.tgz",
|
||||
"integrity": "sha512-8n4JyRptifaIRlHANKRlfqLR8fANm7+Q+1qvDuUsUeStSLtLGTVsZWe1llWDfgWTm1y07cEUyiRuNIv6cs2ovg=="
|
||||
},
|
||||
"has-flag": {
|
||||
"version": "3.0.0",
|
||||
@@ -561,9 +567,9 @@
|
||||
"integrity": "sha512-MAM5dBMJCJNKs9E7JXo4CXRAansRfG0nlJxW7Wf6GZzSOvH31zClSaHdIMWLehe/EGMBkqeC55rrkaOr5Oo7Nw=="
|
||||
},
|
||||
"typescript": {
|
||||
"version": "3.5.2",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.5.2.tgz",
|
||||
"integrity": "sha512-7KxJovlYhTX5RaRbUdkAXN1KUZ8PwWlTzQdHV6xNqvuFOs7+WBo10TQUqT19Q/Jz2hk5v9TQDIhyLhhJY4p5AA=="
|
||||
"version": "3.5.3",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.5.3.tgz",
|
||||
"integrity": "sha512-ACzBtm/PhXBDId6a6sDJfroT2pOWt/oOnk4/dElG5G33ZL776N3Y6/6bKZJBFpd+b05F3Ct9qDjMeJmRWtE2/g=="
|
||||
},
|
||||
"util-deprecate": {
|
||||
"version": "1.0.2",
|
||||
@@ -577,9 +583,9 @@
|
||||
"integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA=="
|
||||
},
|
||||
"validator": {
|
||||
"version": "10.4.0",
|
||||
"resolved": "https://registry.npmjs.org/validator/-/validator-10.4.0.tgz",
|
||||
"integrity": "sha512-Q/wBy3LB1uOyssgNlXSRmaf22NxjvDNZM2MtIQ4jaEOAB61xsh1TQxsq1CgzUMBV1lDrVMogIh8GjG1DYW0zLg=="
|
||||
"version": "11.1.0",
|
||||
"resolved": "https://registry.npmjs.org/validator/-/validator-11.1.0.tgz",
|
||||
"integrity": "sha512-qiQ5ktdO7CD6C/5/mYV4jku/7qnqzjrxb3C/Q5wR3vGGinHTgJZN/TdFT3ZX4vXhX2R1PXx42fB1cn5W+uJ4lg=="
|
||||
},
|
||||
"yn": {
|
||||
"version": "3.1.0",
|
||||
|
||||
@@ -7,16 +7,16 @@
|
||||
"start": "ts-node src/main"
|
||||
},
|
||||
"dependencies": {
|
||||
"@nestjs/common": "6.3.2",
|
||||
"@nestjs/core": "6.3.2",
|
||||
"@nestjs/common": "6.5.3",
|
||||
"@nestjs/core": "6.5.3",
|
||||
"class-transformer": "0.2.3",
|
||||
"class-validator": "0.9.1",
|
||||
"class-validator": "0.10.0",
|
||||
"reflect-metadata": "0.1.13",
|
||||
"rxjs": "6.5.2",
|
||||
"typescript": "3.5.2"
|
||||
"typescript": "3.5.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "7.10.6",
|
||||
"@types/node": "7.10.7",
|
||||
"supertest": "4.0.2",
|
||||
"ts-node": "8.3.0"
|
||||
}
|
||||
|
||||
68
integration/injector/package-lock.json
generated
68
integration/injector/package-lock.json
generated
@@ -5,9 +5,9 @@
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
"@nestjs/common": {
|
||||
"version": "6.3.2",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/common/-/common-6.3.2.tgz",
|
||||
"integrity": "sha512-4g8hlQ2cCM0ze9K1w+7OYhTVGL6PuC7tXAgFM14MOTeKVAUz2QrJveGNE0hagDTKFagx9FvwF3B7ZSOIohw7aA==",
|
||||
"version": "6.5.3",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/common/-/common-6.5.3.tgz",
|
||||
"integrity": "sha512-8d39grIMrUYGKM46BFWxB6csQFCu1S2aK7azPivg7gTRVSbvR84cVd6tgRVM0LwFpqQrtn3Q6G6Pa8FSk7Kh1w==",
|
||||
"requires": {
|
||||
"axios": "0.19.0",
|
||||
"cli-color": "1.4.0",
|
||||
@@ -15,9 +15,9 @@
|
||||
}
|
||||
},
|
||||
"@nestjs/core": {
|
||||
"version": "6.3.2",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/core/-/core-6.3.2.tgz",
|
||||
"integrity": "sha512-dmHvk/IPlJcDKWZsBF2SMePO0NpkovMUU6VrAX9KzI1Y81foH/gfWzFaBhYX6GydPqVVFrYk23zt8yqvGWAZgA==",
|
||||
"version": "6.5.3",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/core/-/core-6.5.3.tgz",
|
||||
"integrity": "sha512-ZhYfH49sVmUUw02qsaGozCFOOehlEABakYzRShyDDq30/2+ek3KpE0DfvA9tXlzX2KVrac2qDTBxMOPoJ+zY+g==",
|
||||
"requires": {
|
||||
"@nuxtjs/opencollective": "0.2.2",
|
||||
"fast-safe-stringify": "2.0.6",
|
||||
@@ -28,9 +28,9 @@
|
||||
}
|
||||
},
|
||||
"@nestjs/microservices": {
|
||||
"version": "6.3.2",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/microservices/-/microservices-6.3.2.tgz",
|
||||
"integrity": "sha512-daEzZ4L+BpMmu9KDFUgdU7+HgeVug//qrHlVTrdqCjyNd4vgZFgXrHGNOOFWYdZCwyY2I9qrL+XEv3pz3VeXyA==",
|
||||
"version": "6.5.3",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/microservices/-/microservices-6.5.3.tgz",
|
||||
"integrity": "sha512-T9zZf61myahenI4c0qhcYnhnx49L+zL9+8W6fc+LPTarbt1HJDu6iyj6fh2BzewakwNLJRyGMJ9YCYlXhFuvlA==",
|
||||
"requires": {
|
||||
"iterare": "1.2.0",
|
||||
"json-socket": "0.3.0",
|
||||
@@ -38,17 +38,17 @@
|
||||
}
|
||||
},
|
||||
"@nestjs/testing": {
|
||||
"version": "6.3.2",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/testing/-/testing-6.3.2.tgz",
|
||||
"integrity": "sha512-BlXpA5KWok7AxwDzWn/yaOhqhAYDxUE17e+hanPEUxGkCInQIc750lG/M6ZF6aQNg1llxHquYyVKJLvzhdZqBA==",
|
||||
"version": "6.5.3",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/testing/-/testing-6.5.3.tgz",
|
||||
"integrity": "sha512-W8tPhkNVhmX+jaDu4R7WUOtIl0PK3ZDso434rEm/b1+S6ZRgAKwNVHWM/rwIuTi5+erPTEULtTsZgrXFrzC1sA==",
|
||||
"requires": {
|
||||
"optional": "0.1.4"
|
||||
}
|
||||
},
|
||||
"@nestjs/websockets": {
|
||||
"version": "6.3.2",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/websockets/-/websockets-6.3.2.tgz",
|
||||
"integrity": "sha512-ZOYbcqeBKMWXqZwBb06XejbNtVu0+X/jwKgL5SYJTs1kmnsCmRvmDzDEeMvx5Ign0cr3tF8SSOW6ysntdnIxXQ==",
|
||||
"version": "6.5.3",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/websockets/-/websockets-6.5.3.tgz",
|
||||
"integrity": "sha512-YrCvmLHTW0OBusTiUOPrG0PNrw/3Gatty/bh3ro5cEoiovcaJxGSMsTC+JSVXqPwRJjEtoHMCr5Qje2rAepIzQ==",
|
||||
"requires": {
|
||||
"iterare": "1.2.0"
|
||||
}
|
||||
@@ -64,11 +64,16 @@
|
||||
}
|
||||
},
|
||||
"@types/node": {
|
||||
"version": "7.10.6",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-7.10.6.tgz",
|
||||
"integrity": "sha512-d0BOAicT0tEdbdVQlLGOVul1kvg6YvbaADRCThGCz5NJ0e9r00SofcR1x69hmlCyrHuB6jd4cKzL9bMLjPnpAA==",
|
||||
"version": "7.10.7",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-7.10.7.tgz",
|
||||
"integrity": "sha512-4I7+hXKyq7e1deuzX9udu0hPIYqSSkdKXtjow6fMnQ3OR9qkxIErGHbGY08YrfZJrCS1ajK8lOuzd0k3n2WM4A==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/validator": {
|
||||
"version": "10.11.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/validator/-/validator-10.11.2.tgz",
|
||||
"integrity": "sha512-k/ju1RsdP5ACFUWebqsyEy0avP5uNJCs2p3pmTHzOZdd4gMSAJTq7iUEHFY3tt3emBrPTm6oGvfZ4SzcqOgLPQ=="
|
||||
},
|
||||
"ansi-regex": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz",
|
||||
@@ -125,12 +130,13 @@
|
||||
"integrity": "sha512-qsP+0xoavpOlJHuYsQJsN58HXSl8Jvveo+T37rEvCEeRfMWoytAyR0Ua/YsFgpM6AZYZ/og2PJwArwzJl1aXtQ=="
|
||||
},
|
||||
"class-validator": {
|
||||
"version": "0.9.1",
|
||||
"resolved": "https://registry.npmjs.org/class-validator/-/class-validator-0.9.1.tgz",
|
||||
"integrity": "sha512-3wApflrd3ywVZyx4jaasGoFt8pmo4aGLPPAEKCKCsTRWVGPilahD88q3jQjRQwja50rl9a7rsP5LAxJYwGK8/Q==",
|
||||
"version": "0.10.0",
|
||||
"resolved": "https://registry.npmjs.org/class-validator/-/class-validator-0.10.0.tgz",
|
||||
"integrity": "sha512-RvjxRlvoCvM/ojUq11j78ISpReGdBoMErdmDk1e27aQZK6ppSXq751UE6jB9JI7ayEnL6Nnmllzn/HXVSu3dmg==",
|
||||
"requires": {
|
||||
"@types/validator": "10.11.2",
|
||||
"google-libphonenumber": "^3.1.6",
|
||||
"validator": "10.4.0"
|
||||
"validator": "11.1.0"
|
||||
}
|
||||
},
|
||||
"cli-color": {
|
||||
@@ -327,9 +333,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"google-libphonenumber": {
|
||||
"version": "3.2.2",
|
||||
"resolved": "https://registry.npmjs.org/google-libphonenumber/-/google-libphonenumber-3.2.2.tgz",
|
||||
"integrity": "sha512-ubjGeosYPeusjYbUHy76lCniGTTI0k1rIFc+uKBX+jHQLDmWOSUtlFUxaeoLJ+Y+PAMM6dWp+C1HjHx5BI8kEw=="
|
||||
"version": "3.2.3",
|
||||
"resolved": "https://registry.npmjs.org/google-libphonenumber/-/google-libphonenumber-3.2.3.tgz",
|
||||
"integrity": "sha512-8n4JyRptifaIRlHANKRlfqLR8fANm7+Q+1qvDuUsUeStSLtLGTVsZWe1llWDfgWTm1y07cEUyiRuNIv6cs2ovg=="
|
||||
},
|
||||
"has-flag": {
|
||||
"version": "3.0.0",
|
||||
@@ -592,9 +598,9 @@
|
||||
"integrity": "sha512-MAM5dBMJCJNKs9E7JXo4CXRAansRfG0nlJxW7Wf6GZzSOvH31zClSaHdIMWLehe/EGMBkqeC55rrkaOr5Oo7Nw=="
|
||||
},
|
||||
"typescript": {
|
||||
"version": "3.5.2",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.5.2.tgz",
|
||||
"integrity": "sha512-7KxJovlYhTX5RaRbUdkAXN1KUZ8PwWlTzQdHV6xNqvuFOs7+WBo10TQUqT19Q/Jz2hk5v9TQDIhyLhhJY4p5AA=="
|
||||
"version": "3.5.3",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.5.3.tgz",
|
||||
"integrity": "sha512-ACzBtm/PhXBDId6a6sDJfroT2pOWt/oOnk4/dElG5G33ZL776N3Y6/6bKZJBFpd+b05F3Ct9qDjMeJmRWtE2/g=="
|
||||
},
|
||||
"util-deprecate": {
|
||||
"version": "1.0.2",
|
||||
@@ -608,9 +614,9 @@
|
||||
"integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA=="
|
||||
},
|
||||
"validator": {
|
||||
"version": "10.4.0",
|
||||
"resolved": "https://registry.npmjs.org/validator/-/validator-10.4.0.tgz",
|
||||
"integrity": "sha512-Q/wBy3LB1uOyssgNlXSRmaf22NxjvDNZM2MtIQ4jaEOAB61xsh1TQxsq1CgzUMBV1lDrVMogIh8GjG1DYW0zLg=="
|
||||
"version": "11.1.0",
|
||||
"resolved": "https://registry.npmjs.org/validator/-/validator-11.1.0.tgz",
|
||||
"integrity": "sha512-qiQ5ktdO7CD6C/5/mYV4jku/7qnqzjrxb3C/Q5wR3vGGinHTgJZN/TdFT3ZX4vXhX2R1PXx42fB1cn5W+uJ4lg=="
|
||||
},
|
||||
"yn": {
|
||||
"version": "3.1.0",
|
||||
|
||||
@@ -7,19 +7,19 @@
|
||||
"start": "ts-node src/main"
|
||||
},
|
||||
"dependencies": {
|
||||
"@nestjs/common": "6.3.2",
|
||||
"@nestjs/core": "6.3.2",
|
||||
"@nestjs/microservices": "6.3.2",
|
||||
"@nestjs/testing": "6.3.2",
|
||||
"@nestjs/websockets": "6.3.2",
|
||||
"@nestjs/common": "6.5.3",
|
||||
"@nestjs/core": "6.5.3",
|
||||
"@nestjs/microservices": "6.5.3",
|
||||
"@nestjs/testing": "6.5.3",
|
||||
"@nestjs/websockets": "6.5.3",
|
||||
"class-transformer": "0.2.3",
|
||||
"class-validator": "0.9.1",
|
||||
"class-validator": "0.10.0",
|
||||
"reflect-metadata": "0.1.13",
|
||||
"rxjs": "6.5.2",
|
||||
"typescript": "3.5.2"
|
||||
"typescript": "3.5.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "7.10.6",
|
||||
"@types/node": "7.10.7",
|
||||
"supertest": "4.0.2",
|
||||
"ts-node": "8.3.0"
|
||||
}
|
||||
|
||||
@@ -46,7 +46,8 @@ describe('MQTT transport', () => {
|
||||
.expect(200, '15');
|
||||
});
|
||||
|
||||
it(`/POST (concurrent)`, () => {
|
||||
it(`/POST (concurrent)`, function() {
|
||||
this.retries(10);
|
||||
return request(server)
|
||||
.post('/concurrent')
|
||||
.send([
|
||||
@@ -62,7 +63,7 @@ describe('MQTT transport', () => {
|
||||
Array.from({ length: 10 }, (v, k) => k + 91),
|
||||
])
|
||||
.expect(200, 'true');
|
||||
});
|
||||
}).timeout(5000);
|
||||
|
||||
it(`/POST (streaming)`, () => {
|
||||
return request(server)
|
||||
|
||||
@@ -46,7 +46,9 @@ describe('REDIS transport', () => {
|
||||
.expect(200, '15');
|
||||
});
|
||||
|
||||
it(`/POST (concurrent)`, () => {
|
||||
it(`/POST (concurrent)`, function() {
|
||||
this.retries(10);
|
||||
|
||||
return request(server)
|
||||
.post('/concurrent')
|
||||
.send([
|
||||
@@ -62,7 +64,7 @@ describe('REDIS transport', () => {
|
||||
Array.from({ length: 10 }, (v, k) => k + 91),
|
||||
])
|
||||
.expect(200, 'true');
|
||||
});
|
||||
}).timeout(5000);
|
||||
|
||||
it(`/POST (streaming)`, () => {
|
||||
return request(server)
|
||||
|
||||
94
integration/microservices/package-lock.json
generated
94
integration/microservices/package-lock.json
generated
@@ -5,9 +5,9 @@
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
"@nestjs/common": {
|
||||
"version": "6.3.2",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/common/-/common-6.3.2.tgz",
|
||||
"integrity": "sha512-4g8hlQ2cCM0ze9K1w+7OYhTVGL6PuC7tXAgFM14MOTeKVAUz2QrJveGNE0hagDTKFagx9FvwF3B7ZSOIohw7aA==",
|
||||
"version": "6.5.3",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/common/-/common-6.5.3.tgz",
|
||||
"integrity": "sha512-8d39grIMrUYGKM46BFWxB6csQFCu1S2aK7azPivg7gTRVSbvR84cVd6tgRVM0LwFpqQrtn3Q6G6Pa8FSk7Kh1w==",
|
||||
"requires": {
|
||||
"axios": "0.19.0",
|
||||
"cli-color": "1.4.0",
|
||||
@@ -15,9 +15,9 @@
|
||||
}
|
||||
},
|
||||
"@nestjs/core": {
|
||||
"version": "6.3.2",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/core/-/core-6.3.2.tgz",
|
||||
"integrity": "sha512-dmHvk/IPlJcDKWZsBF2SMePO0NpkovMUU6VrAX9KzI1Y81foH/gfWzFaBhYX6GydPqVVFrYk23zt8yqvGWAZgA==",
|
||||
"version": "6.5.3",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/core/-/core-6.5.3.tgz",
|
||||
"integrity": "sha512-ZhYfH49sVmUUw02qsaGozCFOOehlEABakYzRShyDDq30/2+ek3KpE0DfvA9tXlzX2KVrac2qDTBxMOPoJ+zY+g==",
|
||||
"requires": {
|
||||
"@nuxtjs/opencollective": "0.2.2",
|
||||
"fast-safe-stringify": "2.0.6",
|
||||
@@ -28,9 +28,9 @@
|
||||
}
|
||||
},
|
||||
"@nestjs/microservices": {
|
||||
"version": "6.3.2",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/microservices/-/microservices-6.3.2.tgz",
|
||||
"integrity": "sha512-daEzZ4L+BpMmu9KDFUgdU7+HgeVug//qrHlVTrdqCjyNd4vgZFgXrHGNOOFWYdZCwyY2I9qrL+XEv3pz3VeXyA==",
|
||||
"version": "6.5.3",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/microservices/-/microservices-6.5.3.tgz",
|
||||
"integrity": "sha512-T9zZf61myahenI4c0qhcYnhnx49L+zL9+8W6fc+LPTarbt1HJDu6iyj6fh2BzewakwNLJRyGMJ9YCYlXhFuvlA==",
|
||||
"requires": {
|
||||
"iterare": "1.2.0",
|
||||
"json-socket": "0.3.0",
|
||||
@@ -38,28 +38,28 @@
|
||||
}
|
||||
},
|
||||
"@nestjs/platform-express": {
|
||||
"version": "6.3.2",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/platform-express/-/platform-express-6.3.2.tgz",
|
||||
"integrity": "sha512-fQTh+zXDgw7W/30ctVlhOCZVDn8P0Ry1UcxltH2dAmyYDih+gQtWeEMzotwB6MwaAAAo8hQ8nBWWY4vez1dzJQ==",
|
||||
"version": "6.5.3",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/platform-express/-/platform-express-6.5.3.tgz",
|
||||
"integrity": "sha512-c5n4XUbDDmF6MfBGYWM1jtsIDpVsOfOQtf3S0w3IeJNqm7dnmVAvO2Jk+RsYpt50tN4NAXntM3YTuTDqMb9uiA==",
|
||||
"requires": {
|
||||
"body-parser": "1.19.0",
|
||||
"cors": "2.8.5",
|
||||
"express": "4.17.1",
|
||||
"multer": "1.4.1"
|
||||
"multer": "1.4.2"
|
||||
}
|
||||
},
|
||||
"@nestjs/testing": {
|
||||
"version": "6.3.2",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/testing/-/testing-6.3.2.tgz",
|
||||
"integrity": "sha512-BlXpA5KWok7AxwDzWn/yaOhqhAYDxUE17e+hanPEUxGkCInQIc750lG/M6ZF6aQNg1llxHquYyVKJLvzhdZqBA==",
|
||||
"version": "6.5.3",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/testing/-/testing-6.5.3.tgz",
|
||||
"integrity": "sha512-W8tPhkNVhmX+jaDu4R7WUOtIl0PK3ZDso434rEm/b1+S6ZRgAKwNVHWM/rwIuTi5+erPTEULtTsZgrXFrzC1sA==",
|
||||
"requires": {
|
||||
"optional": "0.1.4"
|
||||
}
|
||||
},
|
||||
"@nestjs/websockets": {
|
||||
"version": "6.3.2",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/websockets/-/websockets-6.3.2.tgz",
|
||||
"integrity": "sha512-ZOYbcqeBKMWXqZwBb06XejbNtVu0+X/jwKgL5SYJTs1kmnsCmRvmDzDEeMvx5Ign0cr3tF8SSOW6ysntdnIxXQ==",
|
||||
"version": "6.5.3",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/websockets/-/websockets-6.5.3.tgz",
|
||||
"integrity": "sha512-YrCvmLHTW0OBusTiUOPrG0PNrw/3Gatty/bh3ro5cEoiovcaJxGSMsTC+JSVXqPwRJjEtoHMCr5Qje2rAepIzQ==",
|
||||
"requires": {
|
||||
"iterare": "1.2.0"
|
||||
}
|
||||
@@ -75,11 +75,16 @@
|
||||
}
|
||||
},
|
||||
"@types/node": {
|
||||
"version": "7.10.6",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-7.10.6.tgz",
|
||||
"integrity": "sha512-d0BOAicT0tEdbdVQlLGOVul1kvg6YvbaADRCThGCz5NJ0e9r00SofcR1x69hmlCyrHuB6jd4cKzL9bMLjPnpAA==",
|
||||
"version": "7.10.7",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-7.10.7.tgz",
|
||||
"integrity": "sha512-4I7+hXKyq7e1deuzX9udu0hPIYqSSkdKXtjow6fMnQ3OR9qkxIErGHbGY08YrfZJrCS1ajK8lOuzd0k3n2WM4A==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/validator": {
|
||||
"version": "10.11.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/validator/-/validator-10.11.2.tgz",
|
||||
"integrity": "sha512-k/ju1RsdP5ACFUWebqsyEy0avP5uNJCs2p3pmTHzOZdd4gMSAJTq7iUEHFY3tt3emBrPTm6oGvfZ4SzcqOgLPQ=="
|
||||
},
|
||||
"accepts": {
|
||||
"version": "1.3.7",
|
||||
"resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz",
|
||||
@@ -105,9 +110,9 @@
|
||||
}
|
||||
},
|
||||
"amqp-connection-manager": {
|
||||
"version": "2.3.3",
|
||||
"resolved": "https://registry.npmjs.org/amqp-connection-manager/-/amqp-connection-manager-2.3.3.tgz",
|
||||
"integrity": "sha512-sYp323H2EtW9oopoKyGEdXjXbdzlE5fWyc+w6dvCHKd/sGIersEu2CNz3PE1oGyZmJC/GXRK4AtQCnVi/znYpg==",
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/amqp-connection-manager/-/amqp-connection-manager-3.0.0.tgz",
|
||||
"integrity": "sha512-a5MsUDsG+CqMjwk/WNFSTE0H4pAaWJXw7L24QFa3MeaB+KA05PXoBsppYlIzaIqc1XLWZwjO9J42AFHNrDsVFQ==",
|
||||
"requires": {
|
||||
"promise-breaker": "^5.0.0"
|
||||
}
|
||||
@@ -228,12 +233,13 @@
|
||||
"integrity": "sha512-qsP+0xoavpOlJHuYsQJsN58HXSl8Jvveo+T37rEvCEeRfMWoytAyR0Ua/YsFgpM6AZYZ/og2PJwArwzJl1aXtQ=="
|
||||
},
|
||||
"class-validator": {
|
||||
"version": "0.9.1",
|
||||
"resolved": "https://registry.npmjs.org/class-validator/-/class-validator-0.9.1.tgz",
|
||||
"integrity": "sha512-3wApflrd3ywVZyx4jaasGoFt8pmo4aGLPPAEKCKCsTRWVGPilahD88q3jQjRQwja50rl9a7rsP5LAxJYwGK8/Q==",
|
||||
"version": "0.10.0",
|
||||
"resolved": "https://registry.npmjs.org/class-validator/-/class-validator-0.10.0.tgz",
|
||||
"integrity": "sha512-RvjxRlvoCvM/ojUq11j78ISpReGdBoMErdmDk1e27aQZK6ppSXq751UE6jB9JI7ayEnL6Nnmllzn/HXVSu3dmg==",
|
||||
"requires": {
|
||||
"@types/validator": "10.11.2",
|
||||
"google-libphonenumber": "^3.1.6",
|
||||
"validator": "10.4.0"
|
||||
"validator": "11.1.0"
|
||||
}
|
||||
},
|
||||
"cli-color": {
|
||||
@@ -636,9 +642,9 @@
|
||||
"integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac="
|
||||
},
|
||||
"google-libphonenumber": {
|
||||
"version": "3.2.2",
|
||||
"resolved": "https://registry.npmjs.org/google-libphonenumber/-/google-libphonenumber-3.2.2.tgz",
|
||||
"integrity": "sha512-ubjGeosYPeusjYbUHy76lCniGTTI0k1rIFc+uKBX+jHQLDmWOSUtlFUxaeoLJ+Y+PAMM6dWp+C1HjHx5BI8kEw=="
|
||||
"version": "3.2.3",
|
||||
"resolved": "https://registry.npmjs.org/google-libphonenumber/-/google-libphonenumber-3.2.3.tgz",
|
||||
"integrity": "sha512-8n4JyRptifaIRlHANKRlfqLR8fANm7+Q+1qvDuUsUeStSLtLGTVsZWe1llWDfgWTm1y07cEUyiRuNIv6cs2ovg=="
|
||||
},
|
||||
"has-flag": {
|
||||
"version": "3.0.0",
|
||||
@@ -784,9 +790,9 @@
|
||||
"integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg=="
|
||||
},
|
||||
"multer": {
|
||||
"version": "1.4.1",
|
||||
"resolved": "https://registry.npmjs.org/multer/-/multer-1.4.1.tgz",
|
||||
"integrity": "sha512-zzOLNRxzszwd+61JFuAo0fxdQfvku12aNJgnla0AQ+hHxFmfc/B7jBVuPr5Rmvu46Jze/iJrFpSOsD7afO8SDw==",
|
||||
"version": "1.4.2",
|
||||
"resolved": "https://registry.npmjs.org/multer/-/multer-1.4.2.tgz",
|
||||
"integrity": "sha512-xY8pX7V+ybyUpbYMxtjM9KAiD9ixtg5/JkeKUTD6xilfDv0vzzOFcCp4Ljb1UU3tSOM3VTZtKo63OmzOrGi3Cg==",
|
||||
"requires": {
|
||||
"append-field": "^1.0.0",
|
||||
"busboy": "^0.2.11",
|
||||
@@ -1145,9 +1151,9 @@
|
||||
"integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c="
|
||||
},
|
||||
"typescript": {
|
||||
"version": "3.5.2",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.5.2.tgz",
|
||||
"integrity": "sha512-7KxJovlYhTX5RaRbUdkAXN1KUZ8PwWlTzQdHV6xNqvuFOs7+WBo10TQUqT19Q/Jz2hk5v9TQDIhyLhhJY4p5AA=="
|
||||
"version": "3.5.3",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.5.3.tgz",
|
||||
"integrity": "sha512-ACzBtm/PhXBDId6a6sDJfroT2pOWt/oOnk4/dElG5G33ZL776N3Y6/6bKZJBFpd+b05F3Ct9qDjMeJmRWtE2/g=="
|
||||
},
|
||||
"unpipe": {
|
||||
"version": "1.0.0",
|
||||
@@ -1170,9 +1176,9 @@
|
||||
"integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA=="
|
||||
},
|
||||
"validator": {
|
||||
"version": "10.4.0",
|
||||
"resolved": "https://registry.npmjs.org/validator/-/validator-10.4.0.tgz",
|
||||
"integrity": "sha512-Q/wBy3LB1uOyssgNlXSRmaf22NxjvDNZM2MtIQ4jaEOAB61xsh1TQxsq1CgzUMBV1lDrVMogIh8GjG1DYW0zLg=="
|
||||
"version": "11.1.0",
|
||||
"resolved": "https://registry.npmjs.org/validator/-/validator-11.1.0.tgz",
|
||||
"integrity": "sha512-qiQ5ktdO7CD6C/5/mYV4jku/7qnqzjrxb3C/Q5wR3vGGinHTgJZN/TdFT3ZX4vXhX2R1PXx42fB1cn5W+uJ4lg=="
|
||||
},
|
||||
"vary": {
|
||||
"version": "1.1.2",
|
||||
@@ -1180,9 +1186,9 @@
|
||||
"integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw="
|
||||
},
|
||||
"xtend": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz",
|
||||
"integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68="
|
||||
"version": "4.0.2",
|
||||
"resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz",
|
||||
"integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ=="
|
||||
},
|
||||
"yn": {
|
||||
"version": "3.1.0",
|
||||
|
||||
@@ -7,21 +7,21 @@
|
||||
"start": "ts-node src/main"
|
||||
},
|
||||
"dependencies": {
|
||||
"@nestjs/common": "6.3.2",
|
||||
"@nestjs/core": "6.3.2",
|
||||
"@nestjs/microservices": "6.3.2",
|
||||
"@nestjs/platform-express": "6.3.2",
|
||||
"@nestjs/testing": "6.3.2",
|
||||
"@nestjs/websockets": "6.3.2",
|
||||
"amqp-connection-manager": "2.3.3",
|
||||
"@nestjs/common": "6.5.3",
|
||||
"@nestjs/core": "6.5.3",
|
||||
"@nestjs/microservices": "6.5.3",
|
||||
"@nestjs/platform-express": "6.5.3",
|
||||
"@nestjs/testing": "6.5.3",
|
||||
"@nestjs/websockets": "6.5.3",
|
||||
"amqp-connection-manager": "3.0.0",
|
||||
"class-transformer": "0.2.3",
|
||||
"class-validator": "0.9.1",
|
||||
"class-validator": "0.10.0",
|
||||
"reflect-metadata": "0.1.13",
|
||||
"rxjs": "6.5.2",
|
||||
"typescript": "3.5.2"
|
||||
"typescript": "3.5.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "7.10.6",
|
||||
"@types/node": "7.10.7",
|
||||
"supertest": "4.0.2",
|
||||
"ts-node": "8.3.0"
|
||||
}
|
||||
|
||||
@@ -16,16 +16,17 @@ export class DisconnectedClientController {
|
||||
const client = ClientProxyFactory.create(options);
|
||||
return client.send<number, number[]>({ cmd: 'none' }, [1, 2, 3]).pipe(
|
||||
/*tap(
|
||||
console.log.bind(console, 'data'),
|
||||
console.error.bind(console, 'error'),
|
||||
),*/
|
||||
catchError(({ code }) =>
|
||||
throwError(
|
||||
console.log.bind(console, 'data'),
|
||||
console.error.bind(console, 'error'),
|
||||
),*/
|
||||
catchError(error => {
|
||||
const { code } = error || { code: 'CONN_ERR' };
|
||||
return throwError(
|
||||
code === 'ECONNREFUSED' || code === 'CONN_ERR'
|
||||
? new RequestTimeoutException('ECONNREFUSED')
|
||||
: new InternalServerErrorException(),
|
||||
),
|
||||
),
|
||||
);
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
78
integration/mongoose/package-lock.json
generated
78
integration/mongoose/package-lock.json
generated
@@ -5,18 +5,18 @@
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
"@babel/code-frame": {
|
||||
"version": "7.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.0.0.tgz",
|
||||
"integrity": "sha512-OfC2uemaknXr87bdLUkWog7nYuliM9Ij5HUcajsVcMCpQrcLmtxRbVFTIqmcSkSeYRBFBRxs2FiUqFJDLdiebA==",
|
||||
"version": "7.5.5",
|
||||
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.5.5.tgz",
|
||||
"integrity": "sha512-27d4lZoomVyo51VegxI20xZPuSHusqbQag/ztrBC7wegWoQ1nLREPVSKSW8byhTlzTKyNE4ifaTA6lCp7JjpFw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@babel/highlight": "^7.0.0"
|
||||
}
|
||||
},
|
||||
"@babel/highlight": {
|
||||
"version": "7.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.0.0.tgz",
|
||||
"integrity": "sha512-UFMC4ZeFC48Tpvj7C8UgLvtkaUuovQX+5xNWrsIoMG8o2z+XFKjKaN9iVmS84dPwVN00W4wPmqvYoZF3EGAsfw==",
|
||||
"version": "7.5.0",
|
||||
"resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.5.0.tgz",
|
||||
"integrity": "sha512-7dV4eu9gBxoM0dAnj/BCFDW9LFU0zvTrkq0ugM7pnHEgguOEeOz1so2ZghEdzviYzQEED0r4EAgpsBChKy1TRQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"chalk": "^2.0.0",
|
||||
@@ -25,9 +25,9 @@
|
||||
}
|
||||
},
|
||||
"@nestjs/common": {
|
||||
"version": "6.3.2",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/common/-/common-6.3.2.tgz",
|
||||
"integrity": "sha512-4g8hlQ2cCM0ze9K1w+7OYhTVGL6PuC7tXAgFM14MOTeKVAUz2QrJveGNE0hagDTKFagx9FvwF3B7ZSOIohw7aA==",
|
||||
"version": "6.5.3",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/common/-/common-6.5.3.tgz",
|
||||
"integrity": "sha512-8d39grIMrUYGKM46BFWxB6csQFCu1S2aK7azPivg7gTRVSbvR84cVd6tgRVM0LwFpqQrtn3Q6G6Pa8FSk7Kh1w==",
|
||||
"requires": {
|
||||
"axios": "0.19.0",
|
||||
"cli-color": "1.4.0",
|
||||
@@ -35,9 +35,9 @@
|
||||
}
|
||||
},
|
||||
"@nestjs/core": {
|
||||
"version": "6.3.2",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/core/-/core-6.3.2.tgz",
|
||||
"integrity": "sha512-dmHvk/IPlJcDKWZsBF2SMePO0NpkovMUU6VrAX9KzI1Y81foH/gfWzFaBhYX6GydPqVVFrYk23zt8yqvGWAZgA==",
|
||||
"version": "6.5.3",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/core/-/core-6.5.3.tgz",
|
||||
"integrity": "sha512-ZhYfH49sVmUUw02qsaGozCFOOehlEABakYzRShyDDq30/2+ek3KpE0DfvA9tXlzX2KVrac2qDTBxMOPoJ+zY+g==",
|
||||
"requires": {
|
||||
"@nuxtjs/opencollective": "0.2.2",
|
||||
"fast-safe-stringify": "2.0.6",
|
||||
@@ -72,9 +72,9 @@
|
||||
}
|
||||
},
|
||||
"@types/mongodb": {
|
||||
"version": "3.1.28",
|
||||
"resolved": "https://registry.npmjs.org/@types/mongodb/-/mongodb-3.1.28.tgz",
|
||||
"integrity": "sha512-tG+QqJ/hir2p0069ee28t2O9tlGRJKDq1WFZC2QYMlU47LGdldLL8tepfTq6aFLvP58OpwSoxaJ/qjW93ob1NQ==",
|
||||
"version": "3.3.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/mongodb/-/mongodb-3.3.0.tgz",
|
||||
"integrity": "sha512-YMrve0uBOqFDEiezQk3AfWV73g871/rQTAEb8Y2CSlbySnV/2OyerI1DAOUUJQaIqGEWWaYF6GMPO6wTErLUuw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@types/bson": "*",
|
||||
@@ -82,9 +82,9 @@
|
||||
}
|
||||
},
|
||||
"@types/mongoose": {
|
||||
"version": "5.5.6",
|
||||
"resolved": "https://registry.npmjs.org/@types/mongoose/-/mongoose-5.5.6.tgz",
|
||||
"integrity": "sha512-Duco8iiwOEGB756eIyafsrFbsAxjXQPkb/nplZtbxGOhfmsA90rXjO/GbDsBYbUz5nkGOCRHuNfxOJzoVAMHMg==",
|
||||
"version": "5.5.13",
|
||||
"resolved": "https://registry.npmjs.org/@types/mongoose/-/mongoose-5.5.13.tgz",
|
||||
"integrity": "sha512-k7Kxk5gugsZhkl7euWH1p6lmIdh9W8AsQgX0cO7kaihBie/P3ywU8LFMqo9ey6frdHBlGVaNICTeFZ/pZ6s5Lg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@types/mongodb": "*",
|
||||
@@ -92,9 +92,9 @@
|
||||
}
|
||||
},
|
||||
"@types/node": {
|
||||
"version": "7.10.6",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-7.10.6.tgz",
|
||||
"integrity": "sha512-d0BOAicT0tEdbdVQlLGOVul1kvg6YvbaADRCThGCz5NJ0e9r00SofcR1x69hmlCyrHuB6jd4cKzL9bMLjPnpAA==",
|
||||
"version": "7.10.7",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-7.10.7.tgz",
|
||||
"integrity": "sha512-4I7+hXKyq7e1deuzX9udu0hPIYqSSkdKXtjow6fMnQ3OR9qkxIErGHbGY08YrfZJrCS1ajK8lOuzd0k3n2WM4A==",
|
||||
"dev": true
|
||||
},
|
||||
"ansi-regex": {
|
||||
@@ -315,9 +315,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"esutils": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz",
|
||||
"integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=",
|
||||
"version": "2.0.3",
|
||||
"resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz",
|
||||
"integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==",
|
||||
"dev": true
|
||||
},
|
||||
"event-emitter": {
|
||||
@@ -420,9 +420,9 @@
|
||||
"integrity": "sha512-6hHxsp9e6zQU8nXsP+02HGWXwTkOEw6IROhF2ZA28cYbUk4eJ6QbtZvdqZOdD9YPKghG3apk5eOCvs+tLl3lRg=="
|
||||
},
|
||||
"lodash": {
|
||||
"version": "4.17.11",
|
||||
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz",
|
||||
"integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg=="
|
||||
"version": "4.17.15",
|
||||
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz",
|
||||
"integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A=="
|
||||
},
|
||||
"lru-queue": {
|
||||
"version": "0.1.0",
|
||||
@@ -504,9 +504,9 @@
|
||||
}
|
||||
},
|
||||
"mongoose": {
|
||||
"version": "5.6.2",
|
||||
"resolved": "https://registry.npmjs.org/mongoose/-/mongoose-5.6.2.tgz",
|
||||
"integrity": "sha512-s2FQn/XTlM/yeYxqNPGU8khSA1nPhGiESO7iLdFf8Ntn6lEwgO9KKOIGkRKPk5s+peAOwO34ex6NPX8EWtKgFA==",
|
||||
"version": "5.6.10",
|
||||
"resolved": "https://registry.npmjs.org/mongoose/-/mongoose-5.6.10.tgz",
|
||||
"integrity": "sha512-lxWvF4Vl2118K2nZTj+QAEEmNBCbmUAcmF/roe8d+68Np4RXKEQvmpqm1c3aIlE9AVMp//eKB8IfXr38ZHe0Zw==",
|
||||
"requires": {
|
||||
"async": "2.6.2",
|
||||
"bson": "~1.1.1",
|
||||
@@ -611,9 +611,9 @@
|
||||
}
|
||||
},
|
||||
"resolve": {
|
||||
"version": "1.11.0",
|
||||
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.11.0.tgz",
|
||||
"integrity": "sha512-WL2pBDjqT6pGUNSUzMw00o4T7If+z4H2x3Gz893WoUQ5KW8Vr9txp00ykiP16VBaZF5+j/OcXJHZ9+PCvdiDKw==",
|
||||
"version": "1.12.0",
|
||||
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.12.0.tgz",
|
||||
"integrity": "sha512-B/dOmuoAik5bKcD6s6nXDCjzUKnaDvdkRyAk6rsmsKLipWj4797iothd7jmmUhWTfinVMU+wc56rYKsit2Qy4w==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"path-parse": "^1.0.6"
|
||||
@@ -736,9 +736,9 @@
|
||||
"integrity": "sha512-avfPS28HmGLLc2o4elcc2EIq2FcH++Yo5YxpBZi9Yw93BCTGFthI4HPE4Rpep6vSYQaK8e69PelM44tPj+RaQg=="
|
||||
},
|
||||
"tslint": {
|
||||
"version": "5.18.0",
|
||||
"resolved": "https://registry.npmjs.org/tslint/-/tslint-5.18.0.tgz",
|
||||
"integrity": "sha512-Q3kXkuDEijQ37nXZZLKErssQVnwCV/+23gFEMROi8IlbaBG6tXqLPQJ5Wjcyt/yHPKBC+hD5SzuGaMora+ZS6w==",
|
||||
"version": "5.19.0",
|
||||
"resolved": "https://registry.npmjs.org/tslint/-/tslint-5.19.0.tgz",
|
||||
"integrity": "sha512-1LwwtBxfRJZnUvoS9c0uj8XQtAnyhWr9KlNvDIdB+oXyT+VpsOAaEhEgKi1HrZ8rq0ki/AAnbGSv4KM6/AfVZw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@babel/code-frame": "^7.0.0",
|
||||
@@ -771,9 +771,9 @@
|
||||
"integrity": "sha512-MAM5dBMJCJNKs9E7JXo4CXRAansRfG0nlJxW7Wf6GZzSOvH31zClSaHdIMWLehe/EGMBkqeC55rrkaOr5Oo7Nw=="
|
||||
},
|
||||
"typescript": {
|
||||
"version": "3.5.2",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.5.2.tgz",
|
||||
"integrity": "sha512-7KxJovlYhTX5RaRbUdkAXN1KUZ8PwWlTzQdHV6xNqvuFOs7+WBo10TQUqT19Q/Jz2hk5v9TQDIhyLhhJY4p5AA=="
|
||||
"version": "3.5.3",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.5.3.tgz",
|
||||
"integrity": "sha512-ACzBtm/PhXBDId6a6sDJfroT2pOWt/oOnk4/dElG5G33ZL776N3Y6/6bKZJBFpd+b05F3Ct9qDjMeJmRWtE2/g=="
|
||||
},
|
||||
"uuid": {
|
||||
"version": "3.3.2",
|
||||
|
||||
@@ -9,18 +9,18 @@
|
||||
"start:prod": "node dist/main.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@nestjs/common": "6.3.2",
|
||||
"@nestjs/core": "6.3.2",
|
||||
"@nestjs/common": "6.5.3",
|
||||
"@nestjs/core": "6.5.3",
|
||||
"@nestjs/mongoose": "6.1.2",
|
||||
"mongoose": "5.6.2",
|
||||
"mongoose": "5.6.10",
|
||||
"reflect-metadata": "0.1.13",
|
||||
"rxjs": "6.5.2",
|
||||
"typescript": "3.5.2"
|
||||
"typescript": "3.5.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/mongoose": "5.5.6",
|
||||
"@types/node": "7.10.6",
|
||||
"@types/mongoose": "5.5.13",
|
||||
"@types/node": "7.10.7",
|
||||
"ts-node": "8.3.0",
|
||||
"tslint": "5.18.0"
|
||||
"tslint": "5.19.0"
|
||||
}
|
||||
}
|
||||
|
||||
81
integration/scopes/e2e/msvc-request-scope.spec.ts
Normal file
81
integration/scopes/e2e/msvc-request-scope.spec.ts
Normal file
@@ -0,0 +1,81 @@
|
||||
import { INestApplication } from '@nestjs/common';
|
||||
import { Transport } from '@nestjs/microservices';
|
||||
import { Test } from '@nestjs/testing';
|
||||
import { expect } from 'chai';
|
||||
import * as request from 'supertest';
|
||||
import { Guard } from '../src/msvc/guards/request-scoped.guard';
|
||||
import { HelloController } from '../src/msvc/hello.controller';
|
||||
import { HelloModule } from '../src/msvc/hello.module';
|
||||
import { Interceptor } from '../src/msvc/interceptors/logging.interceptor';
|
||||
import { UsersService } from '../src/msvc/users/users.service';
|
||||
|
||||
class Meta {
|
||||
static COUNTER = 0;
|
||||
constructor() {
|
||||
Meta.COUNTER++;
|
||||
}
|
||||
}
|
||||
|
||||
describe('Request scope (microservices)', () => {
|
||||
let server;
|
||||
let app: INestApplication;
|
||||
|
||||
before(async () => {
|
||||
const module = await Test.createTestingModule({
|
||||
imports: [
|
||||
HelloModule.forRoot({
|
||||
provide: 'META',
|
||||
useClass: Meta,
|
||||
}),
|
||||
],
|
||||
}).compile();
|
||||
|
||||
app = module.createNestApplication();
|
||||
app.connectMicroservice({ transport: Transport.TCP });
|
||||
|
||||
server = app.getHttpServer();
|
||||
await app.init();
|
||||
await app.startAllMicroservicesAsync();
|
||||
});
|
||||
|
||||
describe('when one service is request scoped', () => {
|
||||
before(async () => {
|
||||
const performHttpCall = end =>
|
||||
request(server)
|
||||
.get('/hello')
|
||||
.end((err, res) => {
|
||||
if (err) return end(err);
|
||||
end();
|
||||
});
|
||||
await new Promise(resolve => performHttpCall(resolve));
|
||||
await new Promise(resolve => performHttpCall(resolve));
|
||||
await new Promise(resolve => performHttpCall(resolve));
|
||||
});
|
||||
|
||||
it(`should create controller for each request`, async () => {
|
||||
expect(HelloController.COUNTER).to.be.eql(3);
|
||||
});
|
||||
|
||||
it(`should create service for each request`, async () => {
|
||||
expect(UsersService.COUNTER).to.be.eql(3);
|
||||
});
|
||||
|
||||
it(`should share static provider across requests`, async () => {
|
||||
expect(Meta.COUNTER).to.be.eql(1);
|
||||
});
|
||||
|
||||
it(`should create request scoped interceptor for each request`, async () => {
|
||||
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 () => {
|
||||
expect(Guard.COUNTER).to.be.eql(3);
|
||||
expect(Guard.REQUEST_SCOPED_DATA).to.deep.equal([1, 1, 1]);
|
||||
});
|
||||
});
|
||||
|
||||
after(async () => {
|
||||
await app.close();
|
||||
});
|
||||
});
|
||||
@@ -63,14 +63,17 @@ describe('Request scope', () => {
|
||||
|
||||
it(`should create request scoped pipe for each request`, async () => {
|
||||
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 () => {
|
||||
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 () => {
|
||||
expect(Guard.COUNTER).to.be.eql(3);
|
||||
expect(Guard.REQUEST_SCOPED_DATA).to.deep.equal([1, 1, 1]);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
122
integration/scopes/package-lock.json
generated
122
integration/scopes/package-lock.json
generated
@@ -5,9 +5,9 @@
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
"@nestjs/common": {
|
||||
"version": "6.3.2",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/common/-/common-6.3.2.tgz",
|
||||
"integrity": "sha512-4g8hlQ2cCM0ze9K1w+7OYhTVGL6PuC7tXAgFM14MOTeKVAUz2QrJveGNE0hagDTKFagx9FvwF3B7ZSOIohw7aA==",
|
||||
"version": "6.5.3",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/common/-/common-6.5.3.tgz",
|
||||
"integrity": "sha512-8d39grIMrUYGKM46BFWxB6csQFCu1S2aK7azPivg7gTRVSbvR84cVd6tgRVM0LwFpqQrtn3Q6G6Pa8FSk7Kh1w==",
|
||||
"requires": {
|
||||
"axios": "0.19.0",
|
||||
"cli-color": "1.4.0",
|
||||
@@ -15,9 +15,9 @@
|
||||
}
|
||||
},
|
||||
"@nestjs/core": {
|
||||
"version": "6.3.2",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/core/-/core-6.3.2.tgz",
|
||||
"integrity": "sha512-dmHvk/IPlJcDKWZsBF2SMePO0NpkovMUU6VrAX9KzI1Y81foH/gfWzFaBhYX6GydPqVVFrYk23zt8yqvGWAZgA==",
|
||||
"version": "6.5.3",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/core/-/core-6.5.3.tgz",
|
||||
"integrity": "sha512-ZhYfH49sVmUUw02qsaGozCFOOehlEABakYzRShyDDq30/2+ek3KpE0DfvA9tXlzX2KVrac2qDTBxMOPoJ+zY+g==",
|
||||
"requires": {
|
||||
"@nuxtjs/opencollective": "0.2.2",
|
||||
"fast-safe-stringify": "2.0.6",
|
||||
@@ -28,9 +28,9 @@
|
||||
}
|
||||
},
|
||||
"@nestjs/microservices": {
|
||||
"version": "6.3.2",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/microservices/-/microservices-6.3.2.tgz",
|
||||
"integrity": "sha512-daEzZ4L+BpMmu9KDFUgdU7+HgeVug//qrHlVTrdqCjyNd4vgZFgXrHGNOOFWYdZCwyY2I9qrL+XEv3pz3VeXyA==",
|
||||
"version": "6.5.3",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/microservices/-/microservices-6.5.3.tgz",
|
||||
"integrity": "sha512-T9zZf61myahenI4c0qhcYnhnx49L+zL9+8W6fc+LPTarbt1HJDu6iyj6fh2BzewakwNLJRyGMJ9YCYlXhFuvlA==",
|
||||
"requires": {
|
||||
"iterare": "1.2.0",
|
||||
"json-socket": "0.3.0",
|
||||
@@ -38,17 +38,17 @@
|
||||
}
|
||||
},
|
||||
"@nestjs/testing": {
|
||||
"version": "6.3.2",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/testing/-/testing-6.3.2.tgz",
|
||||
"integrity": "sha512-BlXpA5KWok7AxwDzWn/yaOhqhAYDxUE17e+hanPEUxGkCInQIc750lG/M6ZF6aQNg1llxHquYyVKJLvzhdZqBA==",
|
||||
"version": "6.5.3",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/testing/-/testing-6.5.3.tgz",
|
||||
"integrity": "sha512-W8tPhkNVhmX+jaDu4R7WUOtIl0PK3ZDso434rEm/b1+S6ZRgAKwNVHWM/rwIuTi5+erPTEULtTsZgrXFrzC1sA==",
|
||||
"requires": {
|
||||
"optional": "0.1.4"
|
||||
}
|
||||
},
|
||||
"@nestjs/websockets": {
|
||||
"version": "6.3.2",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/websockets/-/websockets-6.3.2.tgz",
|
||||
"integrity": "sha512-ZOYbcqeBKMWXqZwBb06XejbNtVu0+X/jwKgL5SYJTs1kmnsCmRvmDzDEeMvx5Ign0cr3tF8SSOW6ysntdnIxXQ==",
|
||||
"version": "6.5.3",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/websockets/-/websockets-6.5.3.tgz",
|
||||
"integrity": "sha512-YrCvmLHTW0OBusTiUOPrG0PNrw/3Gatty/bh3ro5cEoiovcaJxGSMsTC+JSVXqPwRJjEtoHMCr5Qje2rAepIzQ==",
|
||||
"requires": {
|
||||
"iterare": "1.2.0"
|
||||
}
|
||||
@@ -64,20 +64,25 @@
|
||||
}
|
||||
},
|
||||
"@types/node": {
|
||||
"version": "7.10.6",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-7.10.6.tgz",
|
||||
"integrity": "sha512-d0BOAicT0tEdbdVQlLGOVul1kvg6YvbaADRCThGCz5NJ0e9r00SofcR1x69hmlCyrHuB6jd4cKzL9bMLjPnpAA==",
|
||||
"version": "7.10.7",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-7.10.7.tgz",
|
||||
"integrity": "sha512-4I7+hXKyq7e1deuzX9udu0hPIYqSSkdKXtjow6fMnQ3OR9qkxIErGHbGY08YrfZJrCS1ajK8lOuzd0k3n2WM4A==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/validator": {
|
||||
"version": "10.11.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/validator/-/validator-10.11.2.tgz",
|
||||
"integrity": "sha512-k/ju1RsdP5ACFUWebqsyEy0avP5uNJCs2p3pmTHzOZdd4gMSAJTq7iUEHFY3tt3emBrPTm6oGvfZ4SzcqOgLPQ=="
|
||||
},
|
||||
"abstract-logging": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/abstract-logging/-/abstract-logging-1.0.0.tgz",
|
||||
"integrity": "sha1-i33q/TEFWbwo93ck3RuzAXcnjBs="
|
||||
},
|
||||
"ajv": {
|
||||
"version": "6.10.0",
|
||||
"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.10.0.tgz",
|
||||
"integrity": "sha512-nffhOpkymDECQyR0mnsUtoCE8RlX38G0rYP+wgLWFyZuUyuuojSSvi/+euOiQBIn63whYwYVIIH1TvE3tu4OEg==",
|
||||
"version": "6.10.2",
|
||||
"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.10.2.tgz",
|
||||
"integrity": "sha512-TXtUUEYHuaTEbLZWIKUr5pmBuhDLy+8KYtPYdcV8qC+pOZL+NKqYwvWSRrVXHn+ZmRRAu8vJTAznH7Oag6RVRw==",
|
||||
"requires": {
|
||||
"fast-deep-equal": "^2.0.1",
|
||||
"fast-json-stable-stringify": "^2.0.0",
|
||||
@@ -171,12 +176,13 @@
|
||||
"integrity": "sha512-qsP+0xoavpOlJHuYsQJsN58HXSl8Jvveo+T37rEvCEeRfMWoytAyR0Ua/YsFgpM6AZYZ/og2PJwArwzJl1aXtQ=="
|
||||
},
|
||||
"class-validator": {
|
||||
"version": "0.9.1",
|
||||
"resolved": "https://registry.npmjs.org/class-validator/-/class-validator-0.9.1.tgz",
|
||||
"integrity": "sha512-3wApflrd3ywVZyx4jaasGoFt8pmo4aGLPPAEKCKCsTRWVGPilahD88q3jQjRQwja50rl9a7rsP5LAxJYwGK8/Q==",
|
||||
"version": "0.10.0",
|
||||
"resolved": "https://registry.npmjs.org/class-validator/-/class-validator-0.10.0.tgz",
|
||||
"integrity": "sha512-RvjxRlvoCvM/ojUq11j78ISpReGdBoMErdmDk1e27aQZK6ppSXq751UE6jB9JI7ayEnL6Nnmllzn/HXVSu3dmg==",
|
||||
"requires": {
|
||||
"@types/validator": "10.11.2",
|
||||
"google-libphonenumber": "^3.1.6",
|
||||
"validator": "10.4.0"
|
||||
"validator": "11.1.0"
|
||||
}
|
||||
},
|
||||
"cli-color": {
|
||||
@@ -255,9 +261,9 @@
|
||||
}
|
||||
},
|
||||
"deepmerge": {
|
||||
"version": "3.3.0",
|
||||
"resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-3.3.0.tgz",
|
||||
"integrity": "sha512-GRQOafGHwMHpjPx9iCvTgpu9NojZ49q794EEL94JVEw6VaeA8XTUyBKvAkOOjBX9oJNiV6G3P+T+tihFjo2TqA=="
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.0.0.tgz",
|
||||
"integrity": "sha512-YZ1rOP5+kHor4hMAH+HRQnBQHg+wvS1un1hAOuIcxcBy0hzcUf6Jg2a1w65kpoOUnurOfZbERwjI1TfZxNjcww=="
|
||||
},
|
||||
"delayed-stream": {
|
||||
"version": "1.0.0",
|
||||
@@ -347,12 +353,12 @@
|
||||
"integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I="
|
||||
},
|
||||
"fast-json-stringify": {
|
||||
"version": "1.15.3",
|
||||
"resolved": "https://registry.npmjs.org/fast-json-stringify/-/fast-json-stringify-1.15.3.tgz",
|
||||
"integrity": "sha512-p+ucnySTbrUQ9M7u8ygFIxrmpG8B+8O4/PvLDdh+RqMMgj/h6OoDb7U2lP+kqg3PDclQBFbSIArRhkorFwZLLg==",
|
||||
"version": "1.15.4",
|
||||
"resolved": "https://registry.npmjs.org/fast-json-stringify/-/fast-json-stringify-1.15.4.tgz",
|
||||
"integrity": "sha512-lsGTxL0OIGjGSUXgWUOdSgjCL/xMyMvMudfGN3D1zOLEv44fYZ1ZXmMyCON5XdpaiZN6nCXmU7GQg7fbXfPG4g==",
|
||||
"requires": {
|
||||
"ajv": "^6.8.1",
|
||||
"deepmerge": "^3.0.0"
|
||||
"deepmerge": "^4.0.0"
|
||||
}
|
||||
},
|
||||
"fast-redact": {
|
||||
@@ -366,19 +372,19 @@
|
||||
"integrity": "sha512-q8BZ89jjc+mz08rSxROs8VsrBBcn1SIw1kq9NjolL509tkABRk9io01RAjSaEv1Xb2uFLt8VtRiZbGp5H8iDtg=="
|
||||
},
|
||||
"fastify": {
|
||||
"version": "2.6.0",
|
||||
"resolved": "https://registry.npmjs.org/fastify/-/fastify-2.6.0.tgz",
|
||||
"integrity": "sha512-3GxGV2P8731o2S5T6ng5NMJ9S7vFpZA4mk2mJEbMbhQ5aj1HhNGBOe39TYa2gWRrJVJuXxYYYIlY/5cFhiHpNg==",
|
||||
"version": "2.7.1",
|
||||
"resolved": "https://registry.npmjs.org/fastify/-/fastify-2.7.1.tgz",
|
||||
"integrity": "sha512-ScKPXD84lkdCgz7q0zjyBr1aLxKbXRt9HYL3XIt/L8ZD2f3fAcsLEyQ2/rHxLUzLGjPlEjIvprWUL3RZvlLRLw==",
|
||||
"requires": {
|
||||
"abstract-logging": "^1.0.0",
|
||||
"ajv": "^6.9.2",
|
||||
"ajv": "^6.10.2",
|
||||
"avvio": "^6.1.1",
|
||||
"fast-json-stringify": "^1.15.0",
|
||||
"find-my-way": "^2.0.0",
|
||||
"flatstr": "^1.0.12",
|
||||
"light-my-request": "^3.2.0",
|
||||
"light-my-request": "^3.4.1",
|
||||
"middie": "^4.0.1",
|
||||
"pino": "^5.11.1",
|
||||
"pino": "^5.13.1",
|
||||
"proxy-addr": "^2.0.4",
|
||||
"readable-stream": "^3.1.1",
|
||||
"rfdc": "^1.1.2",
|
||||
@@ -440,9 +446,9 @@
|
||||
"integrity": "sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ="
|
||||
},
|
||||
"google-libphonenumber": {
|
||||
"version": "3.2.2",
|
||||
"resolved": "https://registry.npmjs.org/google-libphonenumber/-/google-libphonenumber-3.2.2.tgz",
|
||||
"integrity": "sha512-ubjGeosYPeusjYbUHy76lCniGTTI0k1rIFc+uKBX+jHQLDmWOSUtlFUxaeoLJ+Y+PAMM6dWp+C1HjHx5BI8kEw=="
|
||||
"version": "3.2.3",
|
||||
"resolved": "https://registry.npmjs.org/google-libphonenumber/-/google-libphonenumber-3.2.3.tgz",
|
||||
"integrity": "sha512-8n4JyRptifaIRlHANKRlfqLR8fANm7+Q+1qvDuUsUeStSLtLGTVsZWe1llWDfgWTm1y07cEUyiRuNIv6cs2ovg=="
|
||||
},
|
||||
"has-flag": {
|
||||
"version": "3.0.0",
|
||||
@@ -485,9 +491,9 @@
|
||||
"integrity": "sha512-jc8ZbUnYIWdxERFWQKVgwSLkGSe+kyzvmYxwNaRgx/c8NNyuHes4UHnPM3LUrAFXUx1BhNJ94n1h/KCRlbvV0g=="
|
||||
},
|
||||
"light-my-request": {
|
||||
"version": "3.4.0",
|
||||
"resolved": "https://registry.npmjs.org/light-my-request/-/light-my-request-3.4.0.tgz",
|
||||
"integrity": "sha512-zIEl4lKwATE5uPmxEZkVIIAr/JGrHEngf9MDZ7a1TodLZ93kROYkKkoqSCmQIJ01FXrzyYMnmtemBO/b1HFt0Q==",
|
||||
"version": "3.4.1",
|
||||
"resolved": "https://registry.npmjs.org/light-my-request/-/light-my-request-3.4.1.tgz",
|
||||
"integrity": "sha512-E1zMvRWjqsaCS60dTkD7c//xKV1KOFD2zo92Ru3o3e95lCfQSDCC9aS8MZm1V+zXaA/SeKDwK9gvrfaCseTusg==",
|
||||
"requires": {
|
||||
"ajv": "^6.8.1",
|
||||
"readable-stream": "^3.1.1"
|
||||
@@ -589,16 +595,16 @@
|
||||
"integrity": "sha512-ZOtfhPttCrqp2M1PBBH4X13XlvnfhIwD7yCLx+GoGoXRPQyxGOTdQMpIzPSPKXAJT/JQrdfFrgdJOyAzvgpQ9A=="
|
||||
},
|
||||
"pino": {
|
||||
"version": "5.12.6",
|
||||
"resolved": "https://registry.npmjs.org/pino/-/pino-5.12.6.tgz",
|
||||
"integrity": "sha512-LM5ug2b27uymIIkaBw54ncF+9DSf8S4z1uzw+Y5I94dRu3Z+lFuB13j0kg1InAeyxy+CsLGnWHKy9+zgTreFOg==",
|
||||
"version": "5.13.1",
|
||||
"resolved": "https://registry.npmjs.org/pino/-/pino-5.13.1.tgz",
|
||||
"integrity": "sha512-IxusG28L0g50uuf21kZELypdFOeNrJ/kRhktdi7LtdZQWCxLliMxG5iOrGUQ/ng7MiJ4XqXi/hfyXwZeKc1MxA==",
|
||||
"requires": {
|
||||
"fast-redact": "^1.4.4",
|
||||
"fast-safe-stringify": "^2.0.6",
|
||||
"flatstr": "^1.0.9",
|
||||
"pino-std-serializers": "^2.3.0",
|
||||
"quick-format-unescaped": "^3.0.2",
|
||||
"sonic-boom": "^0.7.3"
|
||||
"sonic-boom": "^0.7.5"
|
||||
}
|
||||
},
|
||||
"pino-std-serializers": {
|
||||
@@ -699,11 +705,11 @@
|
||||
"integrity": "sha512-TcZvGMMy9vodEFSse30lWinkj+JgOBvPn8wRItpQRSayhc+4ssDs335uklkfvQQJgL/WvmHLVj4Ycv2s7QCQMg=="
|
||||
},
|
||||
"sonic-boom": {
|
||||
"version": "0.7.4",
|
||||
"resolved": "https://registry.npmjs.org/sonic-boom/-/sonic-boom-0.7.4.tgz",
|
||||
"integrity": "sha512-8JRAJg0RxZtFLQMxolwETvWd2JSlH3ZGo/Z4xPxMbpqF14xCgVYPVeFCFOR3zyr3pcfG82QDVj6537Sx5ZWdNw==",
|
||||
"version": "0.7.5",
|
||||
"resolved": "https://registry.npmjs.org/sonic-boom/-/sonic-boom-0.7.5.tgz",
|
||||
"integrity": "sha512-1pKrnAV6RfvntPnarY71tpthFTM3pWZWWQdghZY8ARjtDPGzG/inxqSuRwQY/7V1woUjfyxPb437zn4p5phgnQ==",
|
||||
"requires": {
|
||||
"flatstr": "^1.0.9"
|
||||
"flatstr": "^1.0.12"
|
||||
}
|
||||
},
|
||||
"source-map": {
|
||||
@@ -836,9 +842,9 @@
|
||||
"integrity": "sha512-MAM5dBMJCJNKs9E7JXo4CXRAansRfG0nlJxW7Wf6GZzSOvH31zClSaHdIMWLehe/EGMBkqeC55rrkaOr5Oo7Nw=="
|
||||
},
|
||||
"typescript": {
|
||||
"version": "3.5.2",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.5.2.tgz",
|
||||
"integrity": "sha512-7KxJovlYhTX5RaRbUdkAXN1KUZ8PwWlTzQdHV6xNqvuFOs7+WBo10TQUqT19Q/Jz2hk5v9TQDIhyLhhJY4p5AA=="
|
||||
"version": "3.5.3",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.5.3.tgz",
|
||||
"integrity": "sha512-ACzBtm/PhXBDId6a6sDJfroT2pOWt/oOnk4/dElG5G33ZL776N3Y6/6bKZJBFpd+b05F3Ct9qDjMeJmRWtE2/g=="
|
||||
},
|
||||
"uri-js": {
|
||||
"version": "4.2.2",
|
||||
@@ -859,9 +865,9 @@
|
||||
"integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA=="
|
||||
},
|
||||
"validator": {
|
||||
"version": "10.4.0",
|
||||
"resolved": "https://registry.npmjs.org/validator/-/validator-10.4.0.tgz",
|
||||
"integrity": "sha512-Q/wBy3LB1uOyssgNlXSRmaf22NxjvDNZM2MtIQ4jaEOAB61xsh1TQxsq1CgzUMBV1lDrVMogIh8GjG1DYW0zLg=="
|
||||
"version": "11.1.0",
|
||||
"resolved": "https://registry.npmjs.org/validator/-/validator-11.1.0.tgz",
|
||||
"integrity": "sha512-qiQ5ktdO7CD6C/5/mYV4jku/7qnqzjrxb3C/Q5wR3vGGinHTgJZN/TdFT3ZX4vXhX2R1PXx42fB1cn5W+uJ4lg=="
|
||||
},
|
||||
"yn": {
|
||||
"version": "3.1.0",
|
||||
|
||||
@@ -7,20 +7,20 @@
|
||||
"start": "ts-node src/main"
|
||||
},
|
||||
"dependencies": {
|
||||
"@nestjs/common": "6.3.2",
|
||||
"@nestjs/core": "6.3.2",
|
||||
"@nestjs/microservices": "6.3.2",
|
||||
"@nestjs/testing": "6.3.2",
|
||||
"@nestjs/websockets": "6.3.2",
|
||||
"@nestjs/common": "6.5.3",
|
||||
"@nestjs/core": "6.5.3",
|
||||
"@nestjs/microservices": "6.5.3",
|
||||
"@nestjs/testing": "6.5.3",
|
||||
"@nestjs/websockets": "6.5.3",
|
||||
"class-transformer": "0.2.3",
|
||||
"class-validator": "0.9.1",
|
||||
"fastify": "2.6.0",
|
||||
"class-validator": "0.10.0",
|
||||
"fastify": "2.7.1",
|
||||
"reflect-metadata": "0.1.13",
|
||||
"rxjs": "6.5.2",
|
||||
"typescript": "3.5.2"
|
||||
"typescript": "3.5.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "7.10.6",
|
||||
"@types/node": "7.10.7",
|
||||
"supertest": "4.0.2",
|
||||
"ts-node": "8.3.0"
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import {
|
||||
CanActivate,
|
||||
ExecutionContext,
|
||||
Inject,
|
||||
Injectable,
|
||||
Scope,
|
||||
} from '@nestjs/common';
|
||||
@@ -9,13 +10,16 @@ import { Observable } from 'rxjs';
|
||||
@Injectable({ scope: Scope.REQUEST })
|
||||
export class Guard implements CanActivate {
|
||||
static COUNTER = 0;
|
||||
constructor() {
|
||||
static REQUEST_SCOPED_DATA = [];
|
||||
|
||||
constructor(@Inject('REQUEST_ID') private requestId: number) {
|
||||
Guard.COUNTER++;
|
||||
}
|
||||
|
||||
canActivate(
|
||||
context: ExecutionContext,
|
||||
): boolean | Promise<boolean> | Observable<boolean> {
|
||||
Guard.REQUEST_SCOPED_DATA.push(this.requestId);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,19 @@
|
||||
import { DynamicModule, Inject, Module, Provider } from '@nestjs/common';
|
||||
import { DynamicModule, Inject, Module, Provider, Scope } from '@nestjs/common';
|
||||
import { HelloController } from './hello.controller';
|
||||
import { HelloService } from './hello.service';
|
||||
import { UsersService } from './users/users.service';
|
||||
|
||||
@Module({
|
||||
controllers: [HelloController],
|
||||
providers: [HelloService, UsersService],
|
||||
providers: [
|
||||
HelloService,
|
||||
UsersService,
|
||||
{
|
||||
provide: 'REQUEST_ID',
|
||||
useFactory: () => 1,
|
||||
scope: Scope.REQUEST,
|
||||
},
|
||||
],
|
||||
})
|
||||
export class HelloModule {
|
||||
constructor(@Inject('META') private readonly meta) {}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import {
|
||||
CallHandler,
|
||||
ExecutionContext,
|
||||
Inject,
|
||||
Injectable,
|
||||
NestInterceptor,
|
||||
Scope,
|
||||
@@ -10,10 +11,14 @@ import { Observable } from 'rxjs';
|
||||
@Injectable({ scope: Scope.REQUEST })
|
||||
export class Interceptor implements NestInterceptor {
|
||||
static COUNTER = 0;
|
||||
constructor() {
|
||||
static REQUEST_SCOPED_DATA = [];
|
||||
|
||||
constructor(@Inject('REQUEST_ID') private requestId: number) {
|
||||
Interceptor.COUNTER++;
|
||||
}
|
||||
|
||||
intercept(context: ExecutionContext, call: CallHandler): Observable<any> {
|
||||
Interceptor.REQUEST_SCOPED_DATA.push(this.requestId);
|
||||
return call.handle();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,25 @@
|
||||
import { ArgumentMetadata, Injectable, PipeTransform } from '@nestjs/common';
|
||||
import {
|
||||
ArgumentMetadata,
|
||||
Inject,
|
||||
Injectable,
|
||||
PipeTransform,
|
||||
} from '@nestjs/common';
|
||||
import { UsersService } from './users.service';
|
||||
|
||||
@Injectable()
|
||||
export class UserByIdPipe implements PipeTransform<string> {
|
||||
static COUNTER = 0;
|
||||
constructor(private readonly usersService: UsersService) {
|
||||
static REQUEST_SCOPED_DATA = [];
|
||||
|
||||
constructor(
|
||||
@Inject('REQUEST_ID') private requestId: number,
|
||||
private readonly usersService: UsersService,
|
||||
) {
|
||||
UserByIdPipe.COUNTER++;
|
||||
}
|
||||
|
||||
transform(value: string, metadata: ArgumentMetadata) {
|
||||
UserByIdPipe.REQUEST_SCOPED_DATA.push(this.requestId);
|
||||
return this.usersService.findById(value);
|
||||
}
|
||||
}
|
||||
|
||||
10
integration/scopes/src/msvc/dto/test.dto.ts
Normal file
10
integration/scopes/src/msvc/dto/test.dto.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { IsString, IsNotEmpty, IsNumber } from 'class-validator';
|
||||
|
||||
export class TestDto {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
string: string;
|
||||
|
||||
@IsNumber()
|
||||
number: number;
|
||||
}
|
||||
25
integration/scopes/src/msvc/guards/request-scoped.guard.ts
Normal file
25
integration/scopes/src/msvc/guards/request-scoped.guard.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import {
|
||||
CanActivate,
|
||||
ExecutionContext,
|
||||
Inject,
|
||||
Injectable,
|
||||
Scope,
|
||||
} from '@nestjs/common';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
@Injectable({ scope: Scope.REQUEST })
|
||||
export class Guard implements CanActivate {
|
||||
static COUNTER = 0;
|
||||
static REQUEST_SCOPED_DATA = [];
|
||||
|
||||
constructor(@Inject('REQUEST_ID') private requestId: number) {
|
||||
Guard.COUNTER++;
|
||||
}
|
||||
|
||||
canActivate(
|
||||
context: ExecutionContext,
|
||||
): boolean | Promise<boolean> | Observable<boolean> {
|
||||
Guard.REQUEST_SCOPED_DATA.push(this.requestId);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
24
integration/scopes/src/msvc/hello.controller.ts
Normal file
24
integration/scopes/src/msvc/hello.controller.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { Controller, UseGuards, UseInterceptors } from '@nestjs/common';
|
||||
import { MessagePattern } from '@nestjs/microservices';
|
||||
import { Guard } from './guards/request-scoped.guard';
|
||||
import { HelloService } from './hello.service';
|
||||
import { Interceptor } from './interceptors/logging.interceptor';
|
||||
import { UsersService } from './users/users.service';
|
||||
|
||||
@Controller()
|
||||
export class HelloController {
|
||||
static COUNTER = 0;
|
||||
constructor(
|
||||
private readonly helloService: HelloService,
|
||||
private readonly usersService: UsersService,
|
||||
) {
|
||||
HelloController.COUNTER++;
|
||||
}
|
||||
|
||||
@UseGuards(Guard)
|
||||
@UseInterceptors(Interceptor)
|
||||
@MessagePattern('test')
|
||||
greeting(): string {
|
||||
return this.helloService.greeting();
|
||||
}
|
||||
}
|
||||
28
integration/scopes/src/msvc/hello.module.ts
Normal file
28
integration/scopes/src/msvc/hello.module.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { DynamicModule, Inject, Module, Provider, Scope } from '@nestjs/common';
|
||||
import { HelloController } from './hello.controller';
|
||||
import { HelloService } from './hello.service';
|
||||
import { HttpController } from './http.controller';
|
||||
import { UsersService } from './users/users.service';
|
||||
|
||||
@Module({
|
||||
controllers: [HelloController, HttpController],
|
||||
providers: [
|
||||
HelloService,
|
||||
UsersService,
|
||||
{
|
||||
provide: 'REQUEST_ID',
|
||||
useFactory: () => 1,
|
||||
scope: Scope.REQUEST,
|
||||
},
|
||||
],
|
||||
})
|
||||
export class HelloModule {
|
||||
constructor(@Inject('META') private readonly meta) {}
|
||||
|
||||
static forRoot(meta: Provider): DynamicModule {
|
||||
return {
|
||||
module: HelloModule,
|
||||
providers: [meta],
|
||||
};
|
||||
}
|
||||
}
|
||||
10
integration/scopes/src/msvc/hello.service.ts
Normal file
10
integration/scopes/src/msvc/hello.service.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { Inject, Injectable, Scope } from '@nestjs/common';
|
||||
|
||||
@Injectable({ scope: Scope.REQUEST })
|
||||
export class HelloService {
|
||||
constructor(@Inject('META') private readonly meta) {}
|
||||
|
||||
greeting(): string {
|
||||
return 'Hello world!';
|
||||
}
|
||||
}
|
||||
13
integration/scopes/src/msvc/http.controller.ts
Normal file
13
integration/scopes/src/msvc/http.controller.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { Controller, Get } from '@nestjs/common';
|
||||
import { ClientProxyFactory, Transport } from '@nestjs/microservices';
|
||||
|
||||
@Controller()
|
||||
export class HttpController {
|
||||
@Get('hello')
|
||||
testMsvc() {
|
||||
const client = ClientProxyFactory.create({
|
||||
transport: Transport.TCP,
|
||||
});
|
||||
return client.send('test', { test: true });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
import {
|
||||
CallHandler,
|
||||
ExecutionContext,
|
||||
Inject,
|
||||
Injectable,
|
||||
NestInterceptor,
|
||||
Scope,
|
||||
} from '@nestjs/common';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
@Injectable({ scope: Scope.REQUEST })
|
||||
export class Interceptor implements NestInterceptor {
|
||||
static COUNTER = 0;
|
||||
static REQUEST_SCOPED_DATA = [];
|
||||
|
||||
constructor(@Inject('REQUEST_ID') private requestId: number) {
|
||||
Interceptor.COUNTER++;
|
||||
}
|
||||
|
||||
intercept(context: ExecutionContext, call: CallHandler): Observable<any> {
|
||||
Interceptor.REQUEST_SCOPED_DATA.push(this.requestId);
|
||||
return call.handle();
|
||||
}
|
||||
}
|
||||
13
integration/scopes/src/msvc/users/users.service.ts
Normal file
13
integration/scopes/src/msvc/users/users.service.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { Inject, Injectable, Scope } from '@nestjs/common';
|
||||
|
||||
@Injectable({ scope: Scope.REQUEST })
|
||||
export class UsersService {
|
||||
static COUNTER = 0;
|
||||
constructor(@Inject('META') private readonly meta) {
|
||||
UsersService.COUNTER++;
|
||||
}
|
||||
|
||||
findById(id: string) {
|
||||
return { id };
|
||||
}
|
||||
}
|
||||
1707
integration/typegraphql/package-lock.json
generated
1707
integration/typegraphql/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -9,24 +9,24 @@
|
||||
"start:prod": "node dist/main.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@nestjs/common": "6.3.2",
|
||||
"@nestjs/core": "6.3.2",
|
||||
"@nestjs/graphql": "6.2.4",
|
||||
"apollo-server-express": "2.6.7",
|
||||
"@nestjs/common": "6.5.3",
|
||||
"@nestjs/core": "6.5.3",
|
||||
"@nestjs/graphql": "6.4.2",
|
||||
"apollo-server-express": "2.8.1",
|
||||
"class-transformer": "0.2.3",
|
||||
"class-validator": "0.9.1",
|
||||
"graphql": "14.4.1",
|
||||
"class-validator": "0.10.0",
|
||||
"graphql": "14.5.0",
|
||||
"graphql-tools": "4.0.5",
|
||||
"reflect-metadata": "0.1.13",
|
||||
"rxjs": "6.5.2",
|
||||
"subscriptions-transport-ws": "0.9.16",
|
||||
"type-graphql": "0.17.4",
|
||||
"typescript": "3.5.2",
|
||||
"ws": "7.0.1"
|
||||
"type-graphql": "0.17.5",
|
||||
"typescript": "3.5.3",
|
||||
"ws": "7.1.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "7.10.6",
|
||||
"@types/node": "7.10.7",
|
||||
"ts-node": "8.3.0",
|
||||
"tslint": "5.18.0"
|
||||
"tslint": "5.19.0"
|
||||
}
|
||||
}
|
||||
|
||||
60
integration/typeorm/package-lock.json
generated
60
integration/typeorm/package-lock.json
generated
@@ -5,18 +5,18 @@
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
"@babel/code-frame": {
|
||||
"version": "7.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.0.0.tgz",
|
||||
"integrity": "sha512-OfC2uemaknXr87bdLUkWog7nYuliM9Ij5HUcajsVcMCpQrcLmtxRbVFTIqmcSkSeYRBFBRxs2FiUqFJDLdiebA==",
|
||||
"version": "7.5.5",
|
||||
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.5.5.tgz",
|
||||
"integrity": "sha512-27d4lZoomVyo51VegxI20xZPuSHusqbQag/ztrBC7wegWoQ1nLREPVSKSW8byhTlzTKyNE4ifaTA6lCp7JjpFw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@babel/highlight": "^7.0.0"
|
||||
}
|
||||
},
|
||||
"@babel/highlight": {
|
||||
"version": "7.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.0.0.tgz",
|
||||
"integrity": "sha512-UFMC4ZeFC48Tpvj7C8UgLvtkaUuovQX+5xNWrsIoMG8o2z+XFKjKaN9iVmS84dPwVN00W4wPmqvYoZF3EGAsfw==",
|
||||
"version": "7.5.0",
|
||||
"resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.5.0.tgz",
|
||||
"integrity": "sha512-7dV4eu9gBxoM0dAnj/BCFDW9LFU0zvTrkq0ugM7pnHEgguOEeOz1so2ZghEdzviYzQEED0r4EAgpsBChKy1TRQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"chalk": "^2.0.0",
|
||||
@@ -25,9 +25,9 @@
|
||||
}
|
||||
},
|
||||
"@nestjs/common": {
|
||||
"version": "6.3.2",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/common/-/common-6.3.2.tgz",
|
||||
"integrity": "sha512-4g8hlQ2cCM0ze9K1w+7OYhTVGL6PuC7tXAgFM14MOTeKVAUz2QrJveGNE0hagDTKFagx9FvwF3B7ZSOIohw7aA==",
|
||||
"version": "6.5.3",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/common/-/common-6.5.3.tgz",
|
||||
"integrity": "sha512-8d39grIMrUYGKM46BFWxB6csQFCu1S2aK7azPivg7gTRVSbvR84cVd6tgRVM0LwFpqQrtn3Q6G6Pa8FSk7Kh1w==",
|
||||
"requires": {
|
||||
"axios": "0.19.0",
|
||||
"cli-color": "1.4.0",
|
||||
@@ -35,9 +35,9 @@
|
||||
}
|
||||
},
|
||||
"@nestjs/core": {
|
||||
"version": "6.3.2",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/core/-/core-6.3.2.tgz",
|
||||
"integrity": "sha512-dmHvk/IPlJcDKWZsBF2SMePO0NpkovMUU6VrAX9KzI1Y81foH/gfWzFaBhYX6GydPqVVFrYk23zt8yqvGWAZgA==",
|
||||
"version": "6.5.3",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/core/-/core-6.5.3.tgz",
|
||||
"integrity": "sha512-ZhYfH49sVmUUw02qsaGozCFOOehlEABakYzRShyDDq30/2+ek3KpE0DfvA9tXlzX2KVrac2qDTBxMOPoJ+zY+g==",
|
||||
"requires": {
|
||||
"@nuxtjs/opencollective": "0.2.2",
|
||||
"fast-safe-stringify": "2.0.6",
|
||||
@@ -48,9 +48,9 @@
|
||||
}
|
||||
},
|
||||
"@nestjs/typeorm": {
|
||||
"version": "6.1.2",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/typeorm/-/typeorm-6.1.2.tgz",
|
||||
"integrity": "sha512-uNLvNTW72h4mypvscBgYgE2q8LHgvrhNzV6YqJgvf0VaGv5fi72hl0Zlfwmvh7h50ysW221mJCraX56yn+Uzxw==",
|
||||
"version": "6.1.3",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/typeorm/-/typeorm-6.1.3.tgz",
|
||||
"integrity": "sha512-860tNwms0d/pnuZNEBZCFl5FjzCGG67V8TYuPIVu66jFK/Hmq2WH/GxiC8L77rWPn/o2O5LSe51lgO95GPysGw==",
|
||||
"requires": {
|
||||
"uuid": "3.3.2"
|
||||
}
|
||||
@@ -78,9 +78,9 @@
|
||||
}
|
||||
},
|
||||
"@types/node": {
|
||||
"version": "7.10.6",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-7.10.6.tgz",
|
||||
"integrity": "sha512-d0BOAicT0tEdbdVQlLGOVul1kvg6YvbaADRCThGCz5NJ0e9r00SofcR1x69hmlCyrHuB6jd4cKzL9bMLjPnpAA==",
|
||||
"version": "7.10.7",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-7.10.7.tgz",
|
||||
"integrity": "sha512-4I7+hXKyq7e1deuzX9udu0hPIYqSSkdKXtjow6fMnQ3OR9qkxIErGHbGY08YrfZJrCS1ajK8lOuzd0k3n2WM4A==",
|
||||
"dev": true
|
||||
},
|
||||
"ansi-regex": {
|
||||
@@ -374,9 +374,9 @@
|
||||
"integrity": "sha512-oftTcaMu/EGrEIu904mWteKIv8vMuOgGYo7EhVJJN00R/EED9DCua/xxHRdYnKtcECzVg7xOWhflvJMnqcFZjw=="
|
||||
},
|
||||
"esutils": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz",
|
||||
"integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=",
|
||||
"version": "2.0.3",
|
||||
"resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz",
|
||||
"integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==",
|
||||
"dev": true
|
||||
},
|
||||
"event-emitter": {
|
||||
@@ -856,9 +856,9 @@
|
||||
"integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg=="
|
||||
},
|
||||
"resolve": {
|
||||
"version": "1.11.0",
|
||||
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.11.0.tgz",
|
||||
"integrity": "sha512-WL2pBDjqT6pGUNSUzMw00o4T7If+z4H2x3Gz893WoUQ5KW8Vr9txp00ykiP16VBaZF5+j/OcXJHZ9+PCvdiDKw==",
|
||||
"version": "1.12.0",
|
||||
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.12.0.tgz",
|
||||
"integrity": "sha512-B/dOmuoAik5bKcD6s6nXDCjzUKnaDvdkRyAk6rsmsKLipWj4797iothd7jmmUhWTfinVMU+wc56rYKsit2Qy4w==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"path-parse": "^1.0.6"
|
||||
@@ -1027,9 +1027,9 @@
|
||||
"integrity": "sha512-avfPS28HmGLLc2o4elcc2EIq2FcH++Yo5YxpBZi9Yw93BCTGFthI4HPE4Rpep6vSYQaK8e69PelM44tPj+RaQg=="
|
||||
},
|
||||
"tslint": {
|
||||
"version": "5.18.0",
|
||||
"resolved": "https://registry.npmjs.org/tslint/-/tslint-5.18.0.tgz",
|
||||
"integrity": "sha512-Q3kXkuDEijQ37nXZZLKErssQVnwCV/+23gFEMROi8IlbaBG6tXqLPQJ5Wjcyt/yHPKBC+hD5SzuGaMora+ZS6w==",
|
||||
"version": "5.19.0",
|
||||
"resolved": "https://registry.npmjs.org/tslint/-/tslint-5.19.0.tgz",
|
||||
"integrity": "sha512-1LwwtBxfRJZnUvoS9c0uj8XQtAnyhWr9KlNvDIdB+oXyT+VpsOAaEhEgKi1HrZ8rq0ki/AAnbGSv4KM6/AfVZw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@babel/code-frame": "^7.0.0",
|
||||
@@ -1095,9 +1095,9 @@
|
||||
}
|
||||
},
|
||||
"typescript": {
|
||||
"version": "3.5.2",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.5.2.tgz",
|
||||
"integrity": "sha512-7KxJovlYhTX5RaRbUdkAXN1KUZ8PwWlTzQdHV6xNqvuFOs7+WBo10TQUqT19Q/Jz2hk5v9TQDIhyLhhJY4p5AA=="
|
||||
"version": "3.5.3",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.5.3.tgz",
|
||||
"integrity": "sha512-ACzBtm/PhXBDId6a6sDJfroT2pOWt/oOnk4/dElG5G33ZL776N3Y6/6bKZJBFpd+b05F3Ct9qDjMeJmRWtE2/g=="
|
||||
},
|
||||
"util-deprecate": {
|
||||
"version": "1.0.2",
|
||||
|
||||
@@ -9,18 +9,18 @@
|
||||
"start:prod": "node dist/main.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@nestjs/common": "6.3.2",
|
||||
"@nestjs/core": "6.3.2",
|
||||
"@nestjs/typeorm": "6.1.2",
|
||||
"@nestjs/common": "6.5.3",
|
||||
"@nestjs/core": "6.5.3",
|
||||
"@nestjs/typeorm": "6.1.3",
|
||||
"mysql": "2.17.1",
|
||||
"reflect-metadata": "0.1.13",
|
||||
"rxjs": "6.5.2",
|
||||
"typeorm": "0.2.18",
|
||||
"typescript": "3.5.2"
|
||||
"typescript": "3.5.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "7.10.6",
|
||||
"@types/node": "7.10.7",
|
||||
"ts-node": "8.3.0",
|
||||
"tslint": "5.18.0"
|
||||
"tslint": "5.19.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@ async function createNestApp(...gateways): Promise<INestApplication> {
|
||||
}
|
||||
|
||||
describe('WebSocketGateway (WsAdapter)', () => {
|
||||
const event = 'push';
|
||||
let ws, ws2, app;
|
||||
|
||||
it(`should handle message (2nd port)`, async () => {
|
||||
@@ -66,7 +65,9 @@ describe('WebSocketGateway (WsAdapter)', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it(`should support 2 different gateways`, async () => {
|
||||
it(`should support 2 different gateways`, async function() {
|
||||
this.retries(10);
|
||||
|
||||
app = await createNestApp(ApplicationGateway, CoreGateway);
|
||||
await app.listenAsync(3000);
|
||||
|
||||
|
||||
68
integration/websockets/package-lock.json
generated
68
integration/websockets/package-lock.json
generated
@@ -5,9 +5,9 @@
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
"@nestjs/common": {
|
||||
"version": "6.3.2",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/common/-/common-6.3.2.tgz",
|
||||
"integrity": "sha512-4g8hlQ2cCM0ze9K1w+7OYhTVGL6PuC7tXAgFM14MOTeKVAUz2QrJveGNE0hagDTKFagx9FvwF3B7ZSOIohw7aA==",
|
||||
"version": "6.5.3",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/common/-/common-6.5.3.tgz",
|
||||
"integrity": "sha512-8d39grIMrUYGKM46BFWxB6csQFCu1S2aK7azPivg7gTRVSbvR84cVd6tgRVM0LwFpqQrtn3Q6G6Pa8FSk7Kh1w==",
|
||||
"requires": {
|
||||
"axios": "0.19.0",
|
||||
"cli-color": "1.4.0",
|
||||
@@ -15,9 +15,9 @@
|
||||
}
|
||||
},
|
||||
"@nestjs/core": {
|
||||
"version": "6.3.2",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/core/-/core-6.3.2.tgz",
|
||||
"integrity": "sha512-dmHvk/IPlJcDKWZsBF2SMePO0NpkovMUU6VrAX9KzI1Y81foH/gfWzFaBhYX6GydPqVVFrYk23zt8yqvGWAZgA==",
|
||||
"version": "6.5.3",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/core/-/core-6.5.3.tgz",
|
||||
"integrity": "sha512-ZhYfH49sVmUUw02qsaGozCFOOehlEABakYzRShyDDq30/2+ek3KpE0DfvA9tXlzX2KVrac2qDTBxMOPoJ+zY+g==",
|
||||
"requires": {
|
||||
"@nuxtjs/opencollective": "0.2.2",
|
||||
"fast-safe-stringify": "2.0.6",
|
||||
@@ -28,9 +28,9 @@
|
||||
}
|
||||
},
|
||||
"@nestjs/microservices": {
|
||||
"version": "6.3.2",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/microservices/-/microservices-6.3.2.tgz",
|
||||
"integrity": "sha512-daEzZ4L+BpMmu9KDFUgdU7+HgeVug//qrHlVTrdqCjyNd4vgZFgXrHGNOOFWYdZCwyY2I9qrL+XEv3pz3VeXyA==",
|
||||
"version": "6.5.3",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/microservices/-/microservices-6.5.3.tgz",
|
||||
"integrity": "sha512-T9zZf61myahenI4c0qhcYnhnx49L+zL9+8W6fc+LPTarbt1HJDu6iyj6fh2BzewakwNLJRyGMJ9YCYlXhFuvlA==",
|
||||
"requires": {
|
||||
"iterare": "1.2.0",
|
||||
"json-socket": "0.3.0",
|
||||
@@ -38,17 +38,17 @@
|
||||
}
|
||||
},
|
||||
"@nestjs/testing": {
|
||||
"version": "6.3.2",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/testing/-/testing-6.3.2.tgz",
|
||||
"integrity": "sha512-BlXpA5KWok7AxwDzWn/yaOhqhAYDxUE17e+hanPEUxGkCInQIc750lG/M6ZF6aQNg1llxHquYyVKJLvzhdZqBA==",
|
||||
"version": "6.5.3",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/testing/-/testing-6.5.3.tgz",
|
||||
"integrity": "sha512-W8tPhkNVhmX+jaDu4R7WUOtIl0PK3ZDso434rEm/b1+S6ZRgAKwNVHWM/rwIuTi5+erPTEULtTsZgrXFrzC1sA==",
|
||||
"requires": {
|
||||
"optional": "0.1.4"
|
||||
}
|
||||
},
|
||||
"@nestjs/websockets": {
|
||||
"version": "6.3.2",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/websockets/-/websockets-6.3.2.tgz",
|
||||
"integrity": "sha512-ZOYbcqeBKMWXqZwBb06XejbNtVu0+X/jwKgL5SYJTs1kmnsCmRvmDzDEeMvx5Ign0cr3tF8SSOW6ysntdnIxXQ==",
|
||||
"version": "6.5.3",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/websockets/-/websockets-6.5.3.tgz",
|
||||
"integrity": "sha512-YrCvmLHTW0OBusTiUOPrG0PNrw/3Gatty/bh3ro5cEoiovcaJxGSMsTC+JSVXqPwRJjEtoHMCr5Qje2rAepIzQ==",
|
||||
"requires": {
|
||||
"iterare": "1.2.0"
|
||||
}
|
||||
@@ -64,11 +64,16 @@
|
||||
}
|
||||
},
|
||||
"@types/node": {
|
||||
"version": "7.10.6",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-7.10.6.tgz",
|
||||
"integrity": "sha512-d0BOAicT0tEdbdVQlLGOVul1kvg6YvbaADRCThGCz5NJ0e9r00SofcR1x69hmlCyrHuB6jd4cKzL9bMLjPnpAA==",
|
||||
"version": "7.10.7",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-7.10.7.tgz",
|
||||
"integrity": "sha512-4I7+hXKyq7e1deuzX9udu0hPIYqSSkdKXtjow6fMnQ3OR9qkxIErGHbGY08YrfZJrCS1ajK8lOuzd0k3n2WM4A==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/validator": {
|
||||
"version": "10.11.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/validator/-/validator-10.11.2.tgz",
|
||||
"integrity": "sha512-k/ju1RsdP5ACFUWebqsyEy0avP5uNJCs2p3pmTHzOZdd4gMSAJTq7iUEHFY3tt3emBrPTm6oGvfZ4SzcqOgLPQ=="
|
||||
},
|
||||
"ansi-regex": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz",
|
||||
@@ -125,12 +130,13 @@
|
||||
"integrity": "sha512-qsP+0xoavpOlJHuYsQJsN58HXSl8Jvveo+T37rEvCEeRfMWoytAyR0Ua/YsFgpM6AZYZ/og2PJwArwzJl1aXtQ=="
|
||||
},
|
||||
"class-validator": {
|
||||
"version": "0.9.1",
|
||||
"resolved": "https://registry.npmjs.org/class-validator/-/class-validator-0.9.1.tgz",
|
||||
"integrity": "sha512-3wApflrd3ywVZyx4jaasGoFt8pmo4aGLPPAEKCKCsTRWVGPilahD88q3jQjRQwja50rl9a7rsP5LAxJYwGK8/Q==",
|
||||
"version": "0.10.0",
|
||||
"resolved": "https://registry.npmjs.org/class-validator/-/class-validator-0.10.0.tgz",
|
||||
"integrity": "sha512-RvjxRlvoCvM/ojUq11j78ISpReGdBoMErdmDk1e27aQZK6ppSXq751UE6jB9JI7ayEnL6Nnmllzn/HXVSu3dmg==",
|
||||
"requires": {
|
||||
"@types/validator": "10.11.2",
|
||||
"google-libphonenumber": "^3.1.6",
|
||||
"validator": "10.4.0"
|
||||
"validator": "11.1.0"
|
||||
}
|
||||
},
|
||||
"cli-color": {
|
||||
@@ -327,9 +333,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"google-libphonenumber": {
|
||||
"version": "3.2.2",
|
||||
"resolved": "https://registry.npmjs.org/google-libphonenumber/-/google-libphonenumber-3.2.2.tgz",
|
||||
"integrity": "sha512-ubjGeosYPeusjYbUHy76lCniGTTI0k1rIFc+uKBX+jHQLDmWOSUtlFUxaeoLJ+Y+PAMM6dWp+C1HjHx5BI8kEw=="
|
||||
"version": "3.2.3",
|
||||
"resolved": "https://registry.npmjs.org/google-libphonenumber/-/google-libphonenumber-3.2.3.tgz",
|
||||
"integrity": "sha512-8n4JyRptifaIRlHANKRlfqLR8fANm7+Q+1qvDuUsUeStSLtLGTVsZWe1llWDfgWTm1y07cEUyiRuNIv6cs2ovg=="
|
||||
},
|
||||
"has-flag": {
|
||||
"version": "3.0.0",
|
||||
@@ -592,9 +598,9 @@
|
||||
"integrity": "sha512-MAM5dBMJCJNKs9E7JXo4CXRAansRfG0nlJxW7Wf6GZzSOvH31zClSaHdIMWLehe/EGMBkqeC55rrkaOr5Oo7Nw=="
|
||||
},
|
||||
"typescript": {
|
||||
"version": "3.5.2",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.5.2.tgz",
|
||||
"integrity": "sha512-7KxJovlYhTX5RaRbUdkAXN1KUZ8PwWlTzQdHV6xNqvuFOs7+WBo10TQUqT19Q/Jz2hk5v9TQDIhyLhhJY4p5AA=="
|
||||
"version": "3.5.3",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.5.3.tgz",
|
||||
"integrity": "sha512-ACzBtm/PhXBDId6a6sDJfroT2pOWt/oOnk4/dElG5G33ZL776N3Y6/6bKZJBFpd+b05F3Ct9qDjMeJmRWtE2/g=="
|
||||
},
|
||||
"util-deprecate": {
|
||||
"version": "1.0.2",
|
||||
@@ -608,9 +614,9 @@
|
||||
"integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA=="
|
||||
},
|
||||
"validator": {
|
||||
"version": "10.4.0",
|
||||
"resolved": "https://registry.npmjs.org/validator/-/validator-10.4.0.tgz",
|
||||
"integrity": "sha512-Q/wBy3LB1uOyssgNlXSRmaf22NxjvDNZM2MtIQ4jaEOAB61xsh1TQxsq1CgzUMBV1lDrVMogIh8GjG1DYW0zLg=="
|
||||
"version": "11.1.0",
|
||||
"resolved": "https://registry.npmjs.org/validator/-/validator-11.1.0.tgz",
|
||||
"integrity": "sha512-qiQ5ktdO7CD6C/5/mYV4jku/7qnqzjrxb3C/Q5wR3vGGinHTgJZN/TdFT3ZX4vXhX2R1PXx42fB1cn5W+uJ4lg=="
|
||||
},
|
||||
"yn": {
|
||||
"version": "3.1.0",
|
||||
|
||||
@@ -7,19 +7,19 @@
|
||||
"start": "ts-node src/main"
|
||||
},
|
||||
"dependencies": {
|
||||
"@nestjs/common": "6.3.2",
|
||||
"@nestjs/core": "6.3.2",
|
||||
"@nestjs/microservices": "6.3.2",
|
||||
"@nestjs/testing": "6.3.2",
|
||||
"@nestjs/websockets": "6.3.2",
|
||||
"@nestjs/common": "6.5.3",
|
||||
"@nestjs/core": "6.5.3",
|
||||
"@nestjs/microservices": "6.5.3",
|
||||
"@nestjs/testing": "6.5.3",
|
||||
"@nestjs/websockets": "6.5.3",
|
||||
"class-transformer": "0.2.3",
|
||||
"class-validator": "0.9.1",
|
||||
"class-validator": "0.10.0",
|
||||
"reflect-metadata": "0.1.13",
|
||||
"rxjs": "6.5.2",
|
||||
"typescript": "3.5.2"
|
||||
"typescript": "3.5.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "7.10.6",
|
||||
"@types/node": "7.10.7",
|
||||
"supertest": "4.0.2",
|
||||
"ts-node": "8.3.0"
|
||||
}
|
||||
|
||||
@@ -3,5 +3,5 @@
|
||||
"packages": [
|
||||
"packages/*"
|
||||
],
|
||||
"version": "6.4.0"
|
||||
"version": "6.5.3"
|
||||
}
|
||||
|
||||
5825
package-lock.json
generated
5825
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
70
package.json
70
package.json
@@ -1,17 +1,18 @@
|
||||
{
|
||||
"name": "@nestjs/core",
|
||||
"version": "6.4.0",
|
||||
"version": "6.5.3",
|
||||
"description": "Modern, fast, powerful node.js web framework",
|
||||
"scripts": {
|
||||
"coverage": "nyc report --reporter=text-lcov | coveralls",
|
||||
"test": "nyc --require ts-node/register mocha packages/**/*.spec.ts --reporter spec --retries 3 --require 'node_modules/reflect-metadata/Reflect.js'",
|
||||
"integration-test": "mocha integration/**/*.spec.ts --reporter spec --require ts-node/register --require 'node_modules/reflect-metadata/Reflect.js'",
|
||||
"integration-test": "mocha \"integration/*/{,!(node_modules)/**/}/*.spec.ts\" --reporter spec --require ts-node/register --require 'node_modules/reflect-metadata/Reflect.js'",
|
||||
"lint": "tslint -p tsconfig.json -c tslint.json \"packages/**/*.ts\" -e \"*.spec.ts\"",
|
||||
"format": "prettier **/**/*.ts --ignore-path ./.prettierignore --write && git status",
|
||||
"clean": "gulp clean:bundle",
|
||||
"build": "npm run clean && gulp build",
|
||||
"prebuild:dev": "rm -rf node_modules/@nestjs",
|
||||
"build:dev": "gulp build --dist node_modules/@nestjs && gulp move",
|
||||
"build:samples": "gulp install:samples && npm run build:dev && gulp build:samples",
|
||||
"postinstall": "opencollective",
|
||||
"prerelease": "gulp copy-misc && gulp build --dist node_modules/@nestjs",
|
||||
"publish": "npm run prerelease && npm run build && ./node_modules/.bin/lerna publish --force-publish --access public --exact -m \"chore(@nestjs) publish %s release\"",
|
||||
@@ -30,38 +31,38 @@
|
||||
"author": "Kamil Mysliwiec",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@grpc/proto-loader": "0.3.0",
|
||||
"@grpc/proto-loader": "0.5.1",
|
||||
"@nestjs/common": "6.1.1",
|
||||
"@nestjs/core": "6.1.1",
|
||||
"@nestjs/microservices": "6.1.1",
|
||||
"@nestjs/testing": "6.1.1",
|
||||
"@nestjs/websockets": "6.1.1",
|
||||
"@nuxtjs/opencollective": "0.2.2",
|
||||
"amqp-connection-manager": "2.3.3",
|
||||
"amqplib": "0.5.3",
|
||||
"apollo-server-express": "2.6.7",
|
||||
"amqp-connection-manager": "3.0.0",
|
||||
"amqplib": "0.5.5",
|
||||
"apollo-server-express": "2.8.1",
|
||||
"axios": "0.19.0",
|
||||
"cache-manager": "2.9.1",
|
||||
"cache-manager": "2.10.0",
|
||||
"class-transformer": "0.2.3",
|
||||
"class-validator": "0.9.1",
|
||||
"class-validator": "0.10.0",
|
||||
"cli-color": "1.4.0",
|
||||
"connect": "3.7.0",
|
||||
"cors": "2.8.5",
|
||||
"engine.io-client": "3.3.2",
|
||||
"express": "4.17.1",
|
||||
"fast-json-stringify": "1.15.3",
|
||||
"fast-json-stringify": "1.15.4",
|
||||
"fast-safe-stringify": "2.0.6",
|
||||
"fastify": "2.6.0",
|
||||
"fastify": "2.7.1",
|
||||
"fastify-cors": "2.1.3",
|
||||
"fastify-formbody": "3.1.0",
|
||||
"fastify-multipart": "1.0.1",
|
||||
"graphql": "14.4.1",
|
||||
"grpc": "1.21.1",
|
||||
"fastify-multipart": "1.0.2",
|
||||
"graphql": "14.5.0",
|
||||
"grpc": "1.23.3",
|
||||
"http2": "3.3.7",
|
||||
"iterare": "1.2.0",
|
||||
"merge-graphql-schemas": "1.5.8",
|
||||
"merge-graphql-schemas": "1.7.0",
|
||||
"mqtt": "3.0.0",
|
||||
"multer": "1.4.1",
|
||||
"multer": "1.4.2",
|
||||
"nats": "1.3.0",
|
||||
"object-hash": "1.3.1",
|
||||
"optional": "0.1.4",
|
||||
@@ -72,37 +73,39 @@
|
||||
"rxjs": "6.5.2",
|
||||
"rxjs-compat": "6.5.2",
|
||||
"socket.io": "2.2.0",
|
||||
"ts-morph": "3.0.0",
|
||||
"uuid": "3.3.2"
|
||||
"ts-morph": "3.1.3",
|
||||
"uuid": "3.3.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/amqplib": "0.5.13",
|
||||
"@types/cache-manager": "1.2.8",
|
||||
"@types/chai": "4.1.7",
|
||||
"@types/chai-as-promised": "7.1.0",
|
||||
"@types/cors": "2.8.5",
|
||||
"@types/express": "4.17.0",
|
||||
"@types/chai": "4.2.0",
|
||||
"@types/chai-as-promised": "7.1.2",
|
||||
"@types/cors": "2.8.6",
|
||||
"@types/express": "4.17.1",
|
||||
"@types/fastify-cors": "2.1.0",
|
||||
"@types/gulp": "4.0.6",
|
||||
"@types/kafka-node": "2.0.8",
|
||||
"@types/mocha": "5.2.7",
|
||||
"@types/node": "10.14.10",
|
||||
"@types/node": "10.14.16",
|
||||
"@types/redis": "2.8.13",
|
||||
"@types/reflect-metadata": "0.0.5",
|
||||
"@types/sinon": "7.0.13",
|
||||
"@types/socket.io": "2.1.2",
|
||||
"@types/ws": "6.0.1",
|
||||
"@types/ws": "6.0.3",
|
||||
"artillery": "1.6.0-28",
|
||||
"awesome-typescript-loader": "5.2.1",
|
||||
"body-parser": "1.19.0",
|
||||
"chai": "4.2.0",
|
||||
"chai-as-promised": "7.1.1",
|
||||
"clang-format": "1.2.4",
|
||||
"concurrently": "4.1.1",
|
||||
"conventional-changelog": "3.1.8",
|
||||
"core-js": "3.1.4",
|
||||
"coveralls": "3.0.4",
|
||||
"concurrently": "4.1.2",
|
||||
"conventional-changelog": "3.1.10",
|
||||
"core-js": "3.2.1",
|
||||
"coveralls": "3.0.6",
|
||||
"csv-write-stream": "2.0.0",
|
||||
"delete-empty": "2.0.0",
|
||||
"delete-empty": "3.0.0",
|
||||
"fancy-log": "1.3.3",
|
||||
"fastify-static": "2.5.0",
|
||||
"gulp": "4.0.1",
|
||||
"gulp-clang-format": "1.0.27",
|
||||
@@ -113,20 +116,19 @@
|
||||
"husky": "1.3.1",
|
||||
"imports-loader": "0.8.0",
|
||||
"json-loader": "0.5.7",
|
||||
"lerna": "3.15.0",
|
||||
"lint-staged": "8.2.1",
|
||||
"memory-usage": "1.2.1",
|
||||
"lerna": "2.11.0",
|
||||
"lint-staged": "9.2.3",
|
||||
"mocha": "3.5.3",
|
||||
"nodemon": "1.19.1",
|
||||
"nyc": "14.1.1",
|
||||
"prettier": "1.18.2",
|
||||
"sinon": "7.3.2",
|
||||
"sinon": "7.4.1",
|
||||
"sinon-chai": "3.3.0",
|
||||
"socket.io-client": "2.2.0",
|
||||
"supertest": "4.0.2",
|
||||
"ts-node": "8.3.0",
|
||||
"tslint": "5.18.0",
|
||||
"typescript": "3.5.2"
|
||||
"tslint": "5.19.0",
|
||||
"typescript": "3.5.3"
|
||||
},
|
||||
"collective": {
|
||||
"type": "opencollective",
|
||||
|
||||
1
packages/common/PACKAGE.md
Normal file
1
packages/common/PACKAGE.md
Normal file
@@ -0,0 +1 @@
|
||||
The common package comes with decorators such as `@Controller()`, `@Injectable()` and so on.
|
||||
@@ -15,7 +15,6 @@
|
||||
<a href="https://travis-ci.org/nestjs/nest" target="_blank"><img src="https://api.travis-ci.org/nestjs/nest.svg?branch=master" alt="Travis" /></a>
|
||||
<a href="https://travis-ci.org/nestjs/nest" target="_blank"><img src="https://img.shields.io/travis/nestjs/nest/master.svg?label=linux" alt="Linux" /></a>
|
||||
<a href="https://coveralls.io/github/nestjs/nest?branch=master" target="_blank"><img src="https://coveralls.io/repos/github/nestjs/nest/badge.svg?branch=master#9" alt="Coverage" /></a>
|
||||
<a href="https://gitter.im/nestjs/nestjs?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=body_badge" target="_blank"><img src="https://badges.gitter.im/nestjs/nestjs.svg" alt="Gitter" /></a>
|
||||
<a href="https://discord.gg/G7Qnnhy" target="_blank"><img src="https://img.shields.io/badge/discord-online-brightgreen.svg" alt="Discord"/></a>
|
||||
<a href="https://opencollective.com/nest#backer" target="_blank"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
|
||||
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Binds parameter decorators to the method
|
||||
* Useful when the language doesn't provide a 'Parameter Decorators' feature (vanilla JavaScript)
|
||||
* @param {} ...decorators
|
||||
* @param ...decorators
|
||||
*/
|
||||
export function Bind(...decorators: any[]): MethodDecorator {
|
||||
return <T>(
|
||||
|
||||
@@ -2,17 +2,83 @@ import { PATH_METADATA, SCOPE_OPTIONS_METADATA } from '../../constants';
|
||||
import { isString, isUndefined } from '../../utils/shared.utils';
|
||||
import { ScopeOptions } from './../../interfaces/scope-options.interface';
|
||||
|
||||
/**
|
||||
*
|
||||
* Interface defining options that can be passed to `@Controller()` decorator
|
||||
* @publicApi
|
||||
*/
|
||||
export interface ControllerOptions extends ScopeOptions {
|
||||
/**
|
||||
* Specifies an optional route path prefix. When specified, the route path
|
||||
* for a handler is determined by concatenating the prefix with any path
|
||||
*
|
||||
* @see [Routing](https://docs.nestjs.com/controllers#routing)
|
||||
*/
|
||||
path?: string;
|
||||
}
|
||||
|
||||
export function Controller();
|
||||
export function Controller(prefix: string);
|
||||
export function Controller(options: ControllerOptions);
|
||||
/**
|
||||
* Defines the controller. Controller can inject dependencies through constructor.
|
||||
* Those dependencies have to belong to the same module.
|
||||
* Decorator that marks a class as a Nest controller that can receive inbound
|
||||
* requests and produce responses.
|
||||
*
|
||||
* HTTP Controllers optionally accept configuration
|
||||
* metadata that determines route paths that route handlers in the class
|
||||
* respond to, and lifetime [scope](https://docs.nestjs.com/fundamentals/injection-scopes#usage).
|
||||
*
|
||||
* An HTTP Controller responds to inbound HTTP Requests and produces HTTP Responses.
|
||||
* It defines a class that provides the context for one or more related route
|
||||
* handlers that correspond to HTTP request methods and associated routes
|
||||
* (e.g., `GET /api/profile`, `POST /user/resume`).
|
||||
*
|
||||
* A Microservice Controller responds to Requests and Responses, as well as events,
|
||||
* running over a variety of transports [(read more here)](https://docs.nestjs.com/microservices/basics). It defines
|
||||
* a class that provides a context for one or more message or event handlers.
|
||||
*
|
||||
* @see [Controllers](https://docs.nestjs.com/controllers)
|
||||
* @see [Microservices](https://docs.nestjs.com/microservices/basics#request-response)
|
||||
*
|
||||
* @usageNotes
|
||||
*
|
||||
* ### Setting controller options
|
||||
* The controller decorator takes an optional options object in plain JSON format.
|
||||
* This object can take properties `path` and `scope`.
|
||||
*
|
||||
* ### Setting the default route path prefix
|
||||
* The following example sets `cats` as the default route path prefix for all route
|
||||
* handlers in this controller. When simply passing a route prefix, you can pass
|
||||
* it as a string as shown in the example below.
|
||||
*
|
||||
* ```typescript
|
||||
* @Controller('cats')
|
||||
* export class CatsController {
|
||||
* @Get()
|
||||
* findall(): string {
|
||||
* return 'This action returns all cats';
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
* This route handler will respond to the request
|
||||
* `GET /cats`
|
||||
*
|
||||
* ### Setting the injection scope
|
||||
* The following example sets the scope for all requests in the controller
|
||||
* to request-scoped. Each request will cause Nest to create a new instance of
|
||||
* the controller.
|
||||
* ```typescript
|
||||
* @Controller({
|
||||
* path: 'cats',
|
||||
* scope: Scope.REQUEST,
|
||||
* })
|
||||
* export class CatsController { ... }
|
||||
* ```
|
||||
*
|
||||
* [Read more about scopes here.](https://docs.nestjs.com/fundamentals/injection-scopes)
|
||||
*
|
||||
* @publicApi
|
||||
*/
|
||||
export function Controller(): ClassDecorator;
|
||||
export function Controller(prefix: string): ClassDecorator;
|
||||
export function Controller(options: ControllerOptions): ClassDecorator;
|
||||
export function Controller(
|
||||
prefixOrOptions?: string | ControllerOptions,
|
||||
): ClassDecorator {
|
||||
@@ -20,8 +86,8 @@ export function Controller(
|
||||
const [path, scopeOptions] = isUndefined(prefixOrOptions)
|
||||
? [defaultPath, undefined]
|
||||
: isString(prefixOrOptions)
|
||||
? [prefixOrOptions, undefined]
|
||||
: [prefixOrOptions.path || defaultPath, { scope: prefixOrOptions.scope }];
|
||||
? [prefixOrOptions, undefined]
|
||||
: [prefixOrOptions.path || defaultPath, { scope: prefixOrOptions.scope }];
|
||||
|
||||
return (target: object) => {
|
||||
Reflect.defineMetadata(PATH_METADATA, path, target);
|
||||
|
||||
@@ -5,9 +5,81 @@ import {
|
||||
import { isFunction, isUndefined } from '../../utils/shared.utils';
|
||||
|
||||
/**
|
||||
* Injects provider which has to be available in the current injector (module) scope.
|
||||
* Providers are recognized by either types or tokens.
|
||||
* Decorator that marks a constructor parameter as a target for
|
||||
* [Dependency Injection (DI)](https://docs.nestjs.com/providers#dependency-injection). Takes a single
|
||||
* required parameter which is the
|
||||
* [injection token](https://docs.nestjs.com/fundamentals/custom-providers). The injection token serves
|
||||
* as the lookup key for the [provider](https://docs.nestjs.com/providers) that will be injected
|
||||
* (assigned to the constructor parameter).
|
||||
*
|
||||
* Injection tokens can be types (class names), strings or symbols. This depends
|
||||
* on how the provider with which it is associated was defined. Providers
|
||||
* defined with the `@Injectable()` decorator use the class name. Custom
|
||||
* Providers may use strings or symbols as the injection token.
|
||||
*
|
||||
* Any injected provider must be visible within the module scope (loosely
|
||||
* speaking, the containing module) of the class it is being injected into. This
|
||||
* can be done by:
|
||||
*
|
||||
* - defining the provider in the same module scope
|
||||
* - exporting the provider from one module scope and importing that module into the
|
||||
* module scope of the class being injected into
|
||||
* - exporting the provider from a module that is marked as global using the
|
||||
* `@Global()` decorator
|
||||
*
|
||||
* @see [Providers](https://docs.nestjs.com/providers)
|
||||
* @see [Custom Providers](https://docs.nestjs.com/fundamentals/custom-providers)
|
||||
* @see [Injection Scopes](https://docs.nestjs.com/fundamentals/injection-scopes)
|
||||
*
|
||||
* @usageNotes
|
||||
*
|
||||
* #### Injecting with a type (class name)
|
||||
*
|
||||
* ```typescript
|
||||
* import { Inject } from '@nestjs/common';
|
||||
* import { ConfigService } from './config.service';
|
||||
*
|
||||
* export class CatsService {
|
||||
* constructor(@Inject(ConfigService) private readonly configService) {}
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* The above is equivalent to the conventional constructor injection syntax:
|
||||
* ```typescript
|
||||
* import { ConfigService } from './config.service';
|
||||
*
|
||||
* export class CatsService {
|
||||
* constructor(private readonly configService: ConfigService) {}
|
||||
* }
|
||||
* ```
|
||||
* #### Injecting with a string
|
||||
*
|
||||
* Assume we've registered a provider with the string `'CONNECTION'` as follows:
|
||||
*
|
||||
* ```typescript
|
||||
* import { connection } from './connection';
|
||||
* const connectionProvider = {
|
||||
* provide: 'CONNECTION',
|
||||
* useValue: connection,
|
||||
* };
|
||||
*
|
||||
* @Module({
|
||||
* providers: [connectionProvider],
|
||||
* })
|
||||
* export class ApplicationModule {}
|
||||
* ```
|
||||
* As a result, we now have a provider bound to the DI container using the
|
||||
* injection token `'CONNECTION'`. This provider can be injected as follows:
|
||||
*
|
||||
* ```typescript
|
||||
* @Injectable()
|
||||
* export class CatsRepository {
|
||||
* constructor(@Inject('CONNECTION') connection: Connection) {}
|
||||
* }
|
||||
* ```
|
||||
* @publicApi
|
||||
*/
|
||||
|
||||
export function Inject<T = any>(token?: T) {
|
||||
return (target: Object, key: string | symbol, index?: number) => {
|
||||
token = token || Reflect.getMetadata('design:type', target, key);
|
||||
|
||||
@@ -3,11 +3,110 @@ import { ScopeOptions } from '../../interfaces/scope-options.interface';
|
||||
import { SCOPE_OPTIONS_METADATA } from './../../constants';
|
||||
import { Type } from './../../interfaces/type.interface';
|
||||
|
||||
/**
|
||||
* Defines the injection scope.
|
||||
*
|
||||
* @see [Injection Scopes](https://docs.nestjs.com/fundamentals/injection-scopes)
|
||||
*
|
||||
* @publicApi
|
||||
*/
|
||||
export interface InjectableOptions extends ScopeOptions {}
|
||||
|
||||
/**
|
||||
* Defines the injectable class. This class can inject dependencies through constructor.
|
||||
* Those dependencies have to belong to the same module.
|
||||
* Decorator that marks a class as a [provider](https://docs.nestjs.com/providers). Providers can be
|
||||
* injected into other classes via constructor parameter injection using Nest's
|
||||
* built-in [Dependency Injection (DI)](https://docs.nestjs.com/providers#dependency-injection) system.
|
||||
*
|
||||
* When injecting a provider, it must be visible within the module scope (loosely
|
||||
* speaking, the containing module) of the class it is being injected into. This
|
||||
* can be done by:
|
||||
*
|
||||
* - defining the provider in the same module scope
|
||||
* - exporting the provider from one module scope and importing that module into the
|
||||
* module scope of the class being injected into
|
||||
* - exporting the provider from a module that is marked as global using the
|
||||
* `@Global()` decorator
|
||||
*
|
||||
* Providers can also be defined in a more explicit and imperative form using
|
||||
* various [custom provider](https://docs.nestjs.com/fundamentals/custom-providers) techniques that expose
|
||||
* more capabilities of the DI system.
|
||||
*
|
||||
* @see [Providers](https://docs.nestjs.com/providers)
|
||||
* @see [Custom Providers](https://docs.nestjs.com/fundamentals/custom-providers)
|
||||
* @see [Injection Scopes](https://docs.nestjs.com/fundamentals/injection-scopes)
|
||||
*
|
||||
* @usageNotes
|
||||
*
|
||||
* #### Setting provider scope
|
||||
*
|
||||
* The `@Injector()` decorator takes an optional options object in plain JSON format.
|
||||
* This object has one property: `scope`.
|
||||
*
|
||||
* Following is an example of setting a provider's scope to per-request. See more
|
||||
* about [injection scopes here](https://docs.nestjs.com/fundamentals/injection-scopes).
|
||||
*
|
||||
* ```typescript
|
||||
* import { Injectable, Scope } from '@nestjs/common';
|
||||
*
|
||||
* @Injectable({ scope: Scope.REQUEST })
|
||||
* export class CatsService {}
|
||||
* ```
|
||||
*
|
||||
* #### Declaring providers
|
||||
*
|
||||
* Providers are declared using the `@Injectable()` decorator and a standard
|
||||
* JavaScript class.
|
||||
*
|
||||
* ```typescript
|
||||
* import { Injectable } from '@nestjs/common';
|
||||
* import { Cat } from './interfaces/cat.interface';
|
||||
*
|
||||
* @Injectable()
|
||||
* export class CatsService {
|
||||
* private readonly cats: Cat[] = [];
|
||||
*
|
||||
* create(cat: Cat) {
|
||||
* this.cats.push(cat);
|
||||
* }
|
||||
*
|
||||
* findAll(): Cat[] {
|
||||
* return this.cats;
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* #### Using providers
|
||||
*
|
||||
* Providers created using the `@Injectable()` decorator use an
|
||||
* [injection token](https://docs.nestjs.com/fundamentals/custom-providers) that is the class type.
|
||||
*
|
||||
* For example to inject the provider declared above using constructor injection,
|
||||
* use the following syntax. In this example, `CatsService` is the name of
|
||||
* the provider class declared earlier, and is used as the injection token in
|
||||
* the constructor.
|
||||
*
|
||||
* ```typescript
|
||||
* import { Controller, Get, Post, Body } from '@nestjs/common';
|
||||
* import { CreateCatDto } from './dto/create-cat.dto';
|
||||
* import { CatsService } from './cats.service';
|
||||
* import { Cat } from './interfaces/cat.interface';
|
||||
*
|
||||
* @Controller('cats')
|
||||
* export class CatsController {
|
||||
* constructor(private readonly catsService: CatsService) {}
|
||||
*
|
||||
* @Post()
|
||||
* async create(@Body() createCatDto: CreateCatDto) {
|
||||
* this.catsService.create(createCatDto);
|
||||
* }
|
||||
*
|
||||
* @Get()
|
||||
* async findAll(): Promise<Cat[]> {
|
||||
* return this.catsService.findAll();
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
* @publicApi
|
||||
*/
|
||||
export function Injectable(options?: InjectableOptions): ClassDecorator {
|
||||
return (target: object) => {
|
||||
|
||||
@@ -5,14 +5,38 @@ import { isFunction } from '../../utils/shared.utils';
|
||||
import { validateEach } from '../../utils/validate-each.util';
|
||||
|
||||
/**
|
||||
* Binds guards to the particular context.
|
||||
* When the `@UseGuards()` is used on the controller level:
|
||||
* - Guard will be register to each handler (every method)
|
||||
* Decorator that binds guards to the scope of the controller or method,
|
||||
* depending on its context.
|
||||
*
|
||||
* When the `@UseGuards()` is used on the handler level:
|
||||
* - Guard will be registered only to the specified method
|
||||
* When `@UseGuards` is used at the controller level, the guard will be
|
||||
* applied to every handler (method) in the controller.
|
||||
*
|
||||
* @param {} ...guards
|
||||
* When `@UseGuards` is used at the individual handler level, the guard
|
||||
* will apply only to that specific method.
|
||||
*
|
||||
* @see [Guards](https://docs.nestjs.com/guards)
|
||||
*
|
||||
* @usageNotes
|
||||
*
|
||||
* ### Passing a guard by type
|
||||
* In this example, we pass a guard type, which will delegate instantiating
|
||||
* the guard to the Nest framework, and will allow Dependency Injection.
|
||||
*
|
||||
* ```typescript
|
||||
* @Controller('cats')
|
||||
* @UseGuards(RolesGuard)
|
||||
* export class CatsController {}
|
||||
* ```
|
||||
*
|
||||
* ### Passing a guard instance
|
||||
* It's also possible to pass an instance of a guard directly to the decorator.
|
||||
*
|
||||
* ```typescript
|
||||
* @Controller('cats')
|
||||
* @UseGuards(new RolesGuard())
|
||||
* export class CatsController {}
|
||||
* ```
|
||||
* @publicApi
|
||||
*/
|
||||
export function UseGuards(...guards: (CanActivate | Function)[]) {
|
||||
return (target: any, key?: string, descriptor?: any) => {
|
||||
|
||||
@@ -12,7 +12,7 @@ import { validateEach } from '../../utils/validate-each.util';
|
||||
* When the `@UseInterceptors()` is used on the handle level:
|
||||
* - Interceptor will be registered only to the specified method
|
||||
*
|
||||
* @param {} ...interceptors
|
||||
* @param ...interceptors
|
||||
*/
|
||||
export function UseInterceptors(
|
||||
...interceptors: (NestInterceptor | Function)[]
|
||||
|
||||
@@ -3,6 +3,12 @@ import { extendArrayMetadata } from '../../utils/extend-metadata.util';
|
||||
|
||||
/**
|
||||
* Sets a response header.
|
||||
*
|
||||
* Example: `@Header('Cache-Control', 'none')`
|
||||
*
|
||||
* @see [Headers](https://docs.nestjs.com/controllers#headers)
|
||||
*
|
||||
* @publicApi
|
||||
*/
|
||||
export function Header(name: string, value: string): MethodDecorator {
|
||||
return (target: object, key, descriptor) => {
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
import { HTTP_CODE_METADATA } from '../../constants';
|
||||
|
||||
/**
|
||||
* Defines the HTTP response status code.
|
||||
* It overrides default status code for the given request method.
|
||||
* @publicApi
|
||||
*
|
||||
* @param {number} statusCode
|
||||
* @description
|
||||
* Defines the HTTP response status code. Overrides default status code for
|
||||
* the decorated request method.
|
||||
*
|
||||
* @see [Http Status Codes](https://docs.nestjs.com/controllers#status-code)
|
||||
*/
|
||||
export function HttpCode(statusCode: number): MethodDecorator {
|
||||
return (target: object, key, descriptor) => {
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import { REDIRECT_METADATA } from '../../constants';
|
||||
|
||||
/**
|
||||
* Redirects request.
|
||||
* Redirects request to the specified URL.
|
||||
*
|
||||
* @publicApi
|
||||
*/
|
||||
export function Redirect(url: string): MethodDecorator {
|
||||
return (target: object, key, descriptor) => {
|
||||
|
||||
@@ -2,6 +2,11 @@ import { RENDER_METADATA } from '../../constants';
|
||||
|
||||
/**
|
||||
* Defines a template to be rendered by the controller.
|
||||
*
|
||||
* Example: `@Render('index)`
|
||||
*
|
||||
* @see [Example](https://github.com/nestjs/nest/blob/master/sample/15-mvc/src/app.controller.ts)
|
||||
* @publicApi
|
||||
*/
|
||||
export function Render(template: string): MethodDecorator {
|
||||
return (target: object, key, descriptor) => {
|
||||
|
||||
@@ -31,41 +31,81 @@ const createMappingDecorator = (method: RequestMethod) => (
|
||||
};
|
||||
|
||||
/**
|
||||
* @publicApi
|
||||
*
|
||||
* @description
|
||||
* Routes HTTP POST requests to the specified path.
|
||||
*
|
||||
* @see [Routing](https://docs.nestjs.com/controllers#routing)
|
||||
*/
|
||||
export const Post = createMappingDecorator(RequestMethod.POST);
|
||||
|
||||
/**
|
||||
* @publicApi
|
||||
*
|
||||
* @description
|
||||
* Routes HTTP GET requests to the specified path.
|
||||
*
|
||||
* @see [Routing](https://docs.nestjs.com/controllers#routing)
|
||||
*/
|
||||
export const Get = createMappingDecorator(RequestMethod.GET);
|
||||
|
||||
/**
|
||||
* @publicApi
|
||||
*
|
||||
* @description
|
||||
* Routes HTTP DELETE requests to the specified path.
|
||||
*
|
||||
* @see [Routing](https://docs.nestjs.com/controllers#routing)
|
||||
*/
|
||||
export const Delete = createMappingDecorator(RequestMethod.DELETE);
|
||||
|
||||
/**
|
||||
* @publicApi
|
||||
*
|
||||
* @description
|
||||
* Routes HTTP PUT requests to the specified path.
|
||||
*
|
||||
* @see [Routing](https://docs.nestjs.com/controllers#routing)
|
||||
*/
|
||||
export const Put = createMappingDecorator(RequestMethod.PUT);
|
||||
|
||||
/**
|
||||
* @publicApi
|
||||
*
|
||||
* @description
|
||||
* Routes HTTP PATCH requests to the specified path.
|
||||
*
|
||||
* @see [Routing](https://docs.nestjs.com/controllers#routing)
|
||||
*/
|
||||
export const Patch = createMappingDecorator(RequestMethod.PATCH);
|
||||
|
||||
/**
|
||||
* @publicApi
|
||||
*
|
||||
* @description
|
||||
* Routes HTTP OPTIONS requests to the specified path.
|
||||
*
|
||||
* @see [Routing](https://docs.nestjs.com/controllers#routing)
|
||||
*/
|
||||
export const Options = createMappingDecorator(RequestMethod.OPTIONS);
|
||||
|
||||
/**
|
||||
* @publicApi
|
||||
*
|
||||
* @description
|
||||
* Routes HTTP HEAD requests to the specified path.
|
||||
*
|
||||
* @see [Routing](https://docs.nestjs.com/controllers#routing)
|
||||
*/
|
||||
export const Head = createMappingDecorator(RequestMethod.HEAD);
|
||||
|
||||
/**
|
||||
* @publicApi
|
||||
*
|
||||
* @description
|
||||
* Routes all HTTP requests to the specified path.
|
||||
*
|
||||
* @see [Routing](https://docs.nestjs.com/controllers#routing)
|
||||
*/
|
||||
export const All = createMappingDecorator(RequestMethod.ALL);
|
||||
|
||||
@@ -76,6 +76,19 @@ export const UploadedFile: (
|
||||
export const UploadedFiles: () => ParameterDecorator = createRouteParamDecorator(
|
||||
RouteParamtypes.FILES,
|
||||
);
|
||||
/**
|
||||
* Route handler parameter decorator. Extracts the `headers`
|
||||
* property from the `req` object and populates the decorated
|
||||
* parameter with the value of `headers`.
|
||||
*
|
||||
* `property` - optional name of single header property to extract.
|
||||
*
|
||||
* Example: `async update(@Headers() headers)`
|
||||
*
|
||||
* @see [Request object](https://docs.nestjs.com/controllers#request-object)
|
||||
*
|
||||
* @publicApi
|
||||
*/
|
||||
export const Headers: (
|
||||
property?: string,
|
||||
) => ParameterDecorator = createRouteParamDecorator(RouteParamtypes.HEADERS);
|
||||
@@ -88,6 +101,17 @@ export function Query(
|
||||
property: string,
|
||||
...pipes: (Type<PipeTransform> | PipeTransform)[]
|
||||
): ParameterDecorator;
|
||||
/**
|
||||
* Route handler parameter decorator. Extracts the `query`
|
||||
* property from the `req` object and populates the decorated
|
||||
* parameter with the value of `query`.
|
||||
*
|
||||
* Example: `async find(@Query() query: string)`
|
||||
*
|
||||
* @see [Request object](https://docs.nestjs.com/controllers#request-object)
|
||||
*
|
||||
* @publicApi
|
||||
*/
|
||||
export function Query(
|
||||
property?: string | (Type<PipeTransform> | PipeTransform),
|
||||
...pipes: (Type<PipeTransform> | PipeTransform)[]
|
||||
@@ -106,6 +130,17 @@ export function Body(
|
||||
property: string,
|
||||
...pipes: (Type<PipeTransform> | PipeTransform)[]
|
||||
): ParameterDecorator;
|
||||
/**
|
||||
* Route handler parameter decorator. Extracts the `body`
|
||||
* property from the `req` object and populates the decorated
|
||||
* parameter with the value of `body`.
|
||||
*
|
||||
* Example: `async create(@Body() createCatDto: CreateCatDto)`
|
||||
*
|
||||
* @see [Request object](https://docs.nestjs.com/controllers#request-object)
|
||||
*
|
||||
* @publicApi
|
||||
*/
|
||||
export function Body(
|
||||
property?: string | (Type<PipeTransform> | PipeTransform),
|
||||
...pipes: (Type<PipeTransform> | PipeTransform)[]
|
||||
|
||||
@@ -1,8 +1,38 @@
|
||||
import { GLOBAL_MODULE_METADATA } from '../../constants';
|
||||
|
||||
/**
|
||||
* @publicApi
|
||||
*
|
||||
* @description
|
||||
*
|
||||
* Makes the module global-scoped.
|
||||
* Once imported will be available for all existing modules.
|
||||
* Once imported into any module, the global-scoped module will be visible
|
||||
* in all modules.
|
||||
*
|
||||
* @see [Global modules](https://docs.nestjs.com/modules#global-modules)
|
||||
*
|
||||
* @usageNotes
|
||||
*
|
||||
* `@Global()` makes the `CatsModule` global-scoped. The CatsService provider
|
||||
* will be ubiquitous, and modules that wish to inject the service will not need to import the CatsModule in their imports array.
|
||||
*
|
||||
* Note that the `imports` array is generally the preferred way to make a module's
|
||||
* API available to consumers.
|
||||
*
|
||||
* ```typescript
|
||||
* import { Module, Global } from '@nestjs/common';
|
||||
* import { CatsController } from './cats.controller';
|
||||
* import { CatsService } from './cats.service';
|
||||
*
|
||||
* @Global()
|
||||
* @Module({
|
||||
* controllers: [CatsController],
|
||||
* providers: [CatsService],
|
||||
* exports: [CatsService],
|
||||
* })
|
||||
*
|
||||
* export class CatsModule {}
|
||||
* ```
|
||||
*/
|
||||
export function Global(): ClassDecorator {
|
||||
return (target: any) => {
|
||||
|
||||
@@ -10,11 +10,9 @@ const metadataKeys = [
|
||||
];
|
||||
|
||||
const validateKeys = (keys: string[]) => {
|
||||
const isKeyInvalid = (key: string) =>
|
||||
metadataKeys.findIndex(k => k === key) < 0;
|
||||
|
||||
const validateKey = (key: string) => {
|
||||
if (!isKeyInvalid(key)) {
|
||||
if (metadataKeys.includes(key)) {
|
||||
return;
|
||||
}
|
||||
throw new InvalidModuleConfigException(key);
|
||||
@@ -23,12 +21,37 @@ const validateKeys = (keys: string[]) => {
|
||||
};
|
||||
|
||||
/**
|
||||
* Defines the module
|
||||
* - `imports` - the set of the 'imported' modules
|
||||
* - `controllers` - the list of controllers (e.g. HTTP controllers)
|
||||
* - `providers` - the list of providers that belong to this module. They can be injected between themselves.
|
||||
* - `exports` - the set of components, which should be available for modules, which imports this module
|
||||
* @param options {ModuleMetadata} Module metadata
|
||||
* Decorator that marks a class as a [module](https://docs.nestjs.com/modules). Modules are used by
|
||||
* Nest to organize the application structure into scopes. Controllers and
|
||||
* Providers are scoped by the module they are declared in. Modules and their
|
||||
* classes (Controllers and Providers) form a graph that determines how Nest
|
||||
* performs [Dependency Injection (DI)](https://docs.nestjs.com/providers#dependency-injection).
|
||||
*
|
||||
* @see [Modules](https://docs.nestjs.com/modules)
|
||||
*
|
||||
* @usageNotes
|
||||
* The following example:
|
||||
* - declares `CatsController` as a controller to be instantiated when the
|
||||
* `CatsModule` is bootstrapped
|
||||
* - declares `CatsService` as a provider that can be injected within the
|
||||
* module scope of the `CatsModule`
|
||||
* - exports `CatsService` so that any module that imports `CatsModule`
|
||||
* may inject `CatsService`
|
||||
*
|
||||
* ```typescript
|
||||
* import { Module } from '@nestjs/common';
|
||||
* import { CatsController } from './cats.controller';
|
||||
* import { CatsService } from './cats.service';
|
||||
*
|
||||
* @Module({
|
||||
* controllers: [CatsController],
|
||||
* providers: [CatsService],
|
||||
* exports: [CatsService]
|
||||
* })
|
||||
* export class CatsModule {}
|
||||
* ```
|
||||
*
|
||||
* @publicApi
|
||||
*/
|
||||
export function Module(metadata: ModuleMetadata): ClassDecorator {
|
||||
const propsKeys = Object.keys(metadata);
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { isString } from '../utils/shared.utils';
|
||||
|
||||
export class HttpException extends Error {
|
||||
public readonly message: any;
|
||||
|
||||
@@ -30,4 +32,13 @@ export class HttpException extends Error {
|
||||
public getStatus(): number {
|
||||
return this.status;
|
||||
}
|
||||
|
||||
public toString(): string {
|
||||
const message = this.getErrorString(this.message);
|
||||
return `Error: ${message}`;
|
||||
}
|
||||
|
||||
private getErrorString(target: string | object): string {
|
||||
return isString(target) ? target : JSON.stringify(target);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ export {
|
||||
WebSocketAdapter,
|
||||
WsExceptionFilter,
|
||||
WsMessageHandler,
|
||||
ScopeOptions,
|
||||
} from './interfaces';
|
||||
export * from './pipes';
|
||||
export * from './serializer';
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
import { NestInterceptor } from './features/nest-interceptor.interface';
|
||||
import { CanActivate } from './features/can-activate.interface';
|
||||
|
||||
export interface ConfigurationProvider {
|
||||
getGlobalInterceptors(): NestInterceptor[];
|
||||
getGlobalGuards(): CanActivate[];
|
||||
}
|
||||
@@ -1,4 +1,8 @@
|
||||
/**
|
||||
* Set origin to a function implementing some custom logic. The function takes the
|
||||
* request origin as the first parameter and a callback (which expects the signature
|
||||
* err [object], allow [bool]) as the second.
|
||||
*
|
||||
* @see https://github.com/expressjs/cors
|
||||
*/
|
||||
export type CustomOrigin = (
|
||||
@@ -6,13 +10,42 @@ export type CustomOrigin = (
|
||||
callback: (err: Error | null, allow?: boolean) => void,
|
||||
) => void;
|
||||
|
||||
/**
|
||||
* @publicApi
|
||||
*
|
||||
* @see https://github.com/expressjs/cors
|
||||
*/
|
||||
export interface CorsOptions {
|
||||
/**
|
||||
* Configures the `Access-Control-Allow-Origins` CORS header. See [here for more detail.](https://github.com/expressjs/cors#configuration-options)
|
||||
*/
|
||||
origin?: boolean | string | RegExp | (string | RegExp)[] | CustomOrigin;
|
||||
/**
|
||||
* Configures the Access-Control-Allow-Methods CORS header
|
||||
*/
|
||||
methods?: string | string[];
|
||||
/**
|
||||
* Configures the Access-Control-Allow-Headers CORS header.
|
||||
*/
|
||||
allowedHeaders?: string | string[];
|
||||
/**
|
||||
* Configures the Access-Control-Expose-Headers CORS header.
|
||||
*/
|
||||
exposedHeaders?: string | string[];
|
||||
/**
|
||||
* Configures the Access-Control-Allow-Credentials CORS header.
|
||||
*/
|
||||
credentials?: boolean;
|
||||
/**
|
||||
* Configures the Access-Control-Max-Age CORS header.
|
||||
*/
|
||||
maxAge?: number;
|
||||
/**
|
||||
* Whether to pass the CORS preflight response to the next handler?
|
||||
*/
|
||||
preflightContinue?: boolean;
|
||||
/**
|
||||
* Provides a status code to use for successful OPTIONS requests.
|
||||
*/
|
||||
optionsSuccessStatus?: number;
|
||||
}
|
||||
|
||||
@@ -1,23 +1,74 @@
|
||||
|
||||
/**
|
||||
* Methods to obtain request and response objects.
|
||||
*/
|
||||
export interface HttpArgumentsHost {
|
||||
/**
|
||||
* Returns the in-flight `request` object.
|
||||
*/
|
||||
getRequest<T = any>(): T;
|
||||
/**
|
||||
* Returns the in-flight `response` object.
|
||||
*/
|
||||
getResponse<T = any>(): T;
|
||||
getNext<T = any>(): T;
|
||||
}
|
||||
|
||||
/**
|
||||
* Methods to obtain WebSocket data and client objects.
|
||||
*/
|
||||
export interface WsArgumentsHost {
|
||||
/**
|
||||
* Returns the data object.
|
||||
*/
|
||||
getData<T = any>(): T;
|
||||
/**
|
||||
* Returns the client object.
|
||||
*/
|
||||
getClient<T = any>(): T;
|
||||
}
|
||||
|
||||
/**
|
||||
* Methods to obtain RPC data object.
|
||||
*/
|
||||
export interface RpcArgumentsHost {
|
||||
/**
|
||||
* Returns the data object.
|
||||
*/
|
||||
getData<T = any>(): T;
|
||||
}
|
||||
|
||||
/**
|
||||
* @publicApi
|
||||
*
|
||||
* @description
|
||||
* Provides methods for retrieving the arguments being passed to a handler.
|
||||
* Allows choosing the appropriate execution context (e.g., HTTP, RPC, or
|
||||
* WebSockets) to retrieve the arguments from.
|
||||
*
|
||||
*/
|
||||
export interface ArgumentsHost {
|
||||
/**
|
||||
* Returns the array of arguments being passed to the handler.
|
||||
*/
|
||||
getArgs<T extends Array<any> = any[]>(): T;
|
||||
/**
|
||||
* Returns a particular argument by index.
|
||||
* @param index
|
||||
*/
|
||||
getArgByIndex<T = any>(index: number): T;
|
||||
/**
|
||||
* Switch context to RPC
|
||||
* @returns interface with methods to retrieve RPC arguments
|
||||
*/
|
||||
switchToRpc(): RpcArgumentsHost;
|
||||
/**
|
||||
* Switch context to HTTP
|
||||
* @returns interface with methods to retrieve HTTP arguments
|
||||
*/
|
||||
switchToHttp(): HttpArgumentsHost;
|
||||
/**
|
||||
* Switch context to WebSockets
|
||||
* @returns interface with methods to retrieve WebSockets arguments
|
||||
*/
|
||||
switchToWs(): WsArgumentsHost;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,25 @@
|
||||
import { Observable } from 'rxjs';
|
||||
import { ExecutionContext } from './execution-context.interface';
|
||||
|
||||
/**
|
||||
* @publicApi
|
||||
*
|
||||
* @description
|
||||
* Interface defining the `canActivate()` function that must be implemented
|
||||
* by a guard. Return value indicates whether or not the current request is
|
||||
* allowed to proceed. Return can be either synchronous (`boolean`)
|
||||
* or asynchronous (`Promise` or `Observable`).
|
||||
*
|
||||
* @see [Guards](https://docs.nestjs.com/guards)
|
||||
*/
|
||||
export interface CanActivate {
|
||||
/**
|
||||
* @param context Current execution context. Provides access to details about
|
||||
* the current request pipeline.
|
||||
*
|
||||
* @returns Value indicating whether or not the current request is allowed to
|
||||
* proceed.
|
||||
*/
|
||||
canActivate(
|
||||
context: ExecutionContext,
|
||||
): boolean | Promise<boolean> | Observable<boolean>;
|
||||
|
||||
@@ -1,7 +1,22 @@
|
||||
import { Type } from '../index';
|
||||
import { ArgumentsHost } from './arguments-host.interface';
|
||||
|
||||
/**
|
||||
* @publicApi
|
||||
*
|
||||
* @description
|
||||
* Details about the current request pipeline.
|
||||
*
|
||||
* @see [Execution Context](https://docs.nestjs.com/guards#execution-context)
|
||||
*/
|
||||
export interface ExecutionContext extends ArgumentsHost {
|
||||
/**
|
||||
* Returns the *type* of the controller class which the current handler belongs to.
|
||||
*/
|
||||
getClass<T = any>(): Type<T>;
|
||||
/**
|
||||
* Returns a reference to the handler (method) that will be invoked next in the
|
||||
* request pipeline.
|
||||
*/
|
||||
getHandler(): Function;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,18 @@
|
||||
import { ModuleMetadata } from './module-metadata.interface';
|
||||
import { Type } from '../type.interface';
|
||||
|
||||
/**
|
||||
* @publicApi
|
||||
*
|
||||
* @description
|
||||
*
|
||||
* Interface defining a Dynamic Module.
|
||||
*
|
||||
* @see [Dynamic Modules](https://docs.nestjs.com/modules#dynamic-modules)
|
||||
*/
|
||||
export interface DynamicModule extends ModuleMetadata {
|
||||
/**
|
||||
* A module
|
||||
*/
|
||||
module: Type<any>;
|
||||
}
|
||||
|
||||
@@ -4,12 +4,37 @@ import { DynamicModule } from './dynamic-module.interface';
|
||||
import { ForwardReference } from './forward-reference.interface';
|
||||
import { Provider } from './provider.interface';
|
||||
|
||||
/**
|
||||
* @publicApi
|
||||
*
|
||||
* @description
|
||||
*
|
||||
* Interface defining the property object that describes the module.
|
||||
*
|
||||
* @see [Modules](https://docs.nestjs.com/modules)
|
||||
*/
|
||||
export interface ModuleMetadata {
|
||||
/**
|
||||
* Optional list of imported modules that export the providers which are
|
||||
* required in this module.
|
||||
*/
|
||||
imports?: Array<
|
||||
Type<any> | DynamicModule | Promise<DynamicModule> | ForwardReference
|
||||
>;
|
||||
/**
|
||||
* Optional list of controllers defined in this module which have to be
|
||||
* instantiated.
|
||||
*/
|
||||
controllers?: Type<any>[];
|
||||
/**
|
||||
* Optional list of providers that will be instantiated by the Nest injector
|
||||
* and that may be shared at least across this module.
|
||||
*/
|
||||
providers?: Provider[];
|
||||
/**
|
||||
* Optional list of the subset of providers that are provided by this module
|
||||
* and should be available in other modules which import this module.
|
||||
*/
|
||||
exports?: Array<
|
||||
| DynamicModule
|
||||
| Promise<DynamicModule>
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
/**
|
||||
* @publicApi
|
||||
*
|
||||
* @description
|
||||
* Interface defining method called just before Nest destroys the host module
|
||||
* (`app.close()` method has been evaluated). Use to perform cleanup on
|
||||
* resources (e.g., Database connections).
|
||||
*
|
||||
* @see [Lifecycle Events](https://docs.nestjs.com/fundamentals/lifecycle-events)
|
||||
*/
|
||||
export interface OnModuleDestroy {
|
||||
onModuleDestroy(): any;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/**
|
||||
* @publicApi
|
||||
*
|
||||
* @description
|
||||
* Interface defining method called once the host module has been initialized.
|
||||
*
|
||||
* @see [Lifecycle Events](https://docs.nestjs.com/fundamentals/lifecycle-events)
|
||||
*/
|
||||
export interface OnModuleInit {
|
||||
onModuleInit(): any;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
import { LoggerService } from '../services/logger.service';
|
||||
|
||||
/**
|
||||
* @publicApi
|
||||
*/
|
||||
export class NestApplicationContextOptions {
|
||||
/**
|
||||
* specify the logger to use
|
||||
*/
|
||||
logger?: LoggerService | boolean;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,12 @@ import { LoggerService } from '../services/logger.service';
|
||||
import { Abstract } from './abstract.interface';
|
||||
import { Type } from './type.interface';
|
||||
|
||||
/**
|
||||
* @publicApi
|
||||
*
|
||||
* @description
|
||||
* Interface defining NestApplicationContext.
|
||||
*/
|
||||
export interface INestApplicationContext {
|
||||
/**
|
||||
* Allows navigating through the modules tree, for example, to pull out a specific instance from the selected module.
|
||||
|
||||
@@ -1,9 +1,21 @@
|
||||
import { CorsOptions } from './external/cors-options.interface';
|
||||
import { HttpsOptions } from './external/https-options.interface';
|
||||
import { NestApplicationContextOptions } from './nest-application-context-options.interface';
|
||||
import { CorsOptions } from './external/cors-options.interface';
|
||||
|
||||
/**
|
||||
* @publicApi
|
||||
*/
|
||||
export interface NestApplicationOptions extends NestApplicationContextOptions {
|
||||
/**
|
||||
* CORS options from [CORS package](https://github.com/expressjs/cors#configuration-options)
|
||||
*/
|
||||
cors?: boolean | CorsOptions;
|
||||
/**
|
||||
* Whether to use underlying platform body parser.
|
||||
*/
|
||||
bodyParser?: boolean;
|
||||
/**
|
||||
* Set of configurable HTTPS options
|
||||
*/
|
||||
httpsOptions?: HttpsOptions;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,12 @@ import { MicroserviceOptions } from './microservices/microservice-configuration.
|
||||
import { INestApplicationContext } from './nest-application-context.interface';
|
||||
import { WebSocketAdapter } from './websockets/web-socket-adapter.interface';
|
||||
|
||||
/**
|
||||
* @publicApi
|
||||
*
|
||||
* @description
|
||||
* Interface defining the core NestApplication object.
|
||||
*/
|
||||
export interface INestApplication extends INestApplicationContext {
|
||||
/**
|
||||
* A wrapper function around HTTP adapter method: `adapter.use()`.
|
||||
@@ -29,7 +35,7 @@ export interface INestApplication extends INestApplicationContext {
|
||||
* @param {number} port
|
||||
* @param {string} hostname
|
||||
* @param {Function} callback Optional callback
|
||||
* @returns {Promise}
|
||||
* @returns A Promise that, when resolved, is a reference to the underlying HttpServer.
|
||||
*/
|
||||
listen(port: number | string, callback?: () => void): Promise<any>;
|
||||
listen(
|
||||
@@ -48,16 +54,16 @@ export interface INestApplication extends INestApplicationContext {
|
||||
listenAsync(port: number | string, hostname?: string): Promise<any>;
|
||||
|
||||
/**
|
||||
* Registers the prefix for the every HTTP route path
|
||||
* Registers a prefix for every HTTP route path.
|
||||
*
|
||||
* @param {string} prefix The prefix for the every HTTP route path (for example `/v1/api`)
|
||||
* @param {string} prefix The prefix for every HTTP route path (for example `/v1/api`)
|
||||
* @returns {void}
|
||||
*/
|
||||
setGlobalPrefix(prefix: string): this;
|
||||
|
||||
/**
|
||||
* Setup Ws Adapter which will be used inside Gateways.
|
||||
* Use, when you want to override default `socket.io` library.
|
||||
* Use when you want to override default `socket.io` library.
|
||||
*
|
||||
* @param {WebSocketAdapter} adapter
|
||||
* @returns {void}
|
||||
@@ -65,7 +71,8 @@ export interface INestApplication extends INestApplicationContext {
|
||||
useWebSocketAdapter(adapter: WebSocketAdapter): this;
|
||||
|
||||
/**
|
||||
* Connects microservice to the NestApplication instance. Transforms application to the hybrid instance.
|
||||
* Connects microservice to the NestApplication instance. Transforms application
|
||||
* to a hybrid instance.
|
||||
*
|
||||
* @param {MicroserviceOptions} options Microservice options object
|
||||
* @returns {INestMicroservice}
|
||||
@@ -80,21 +87,21 @@ export interface INestApplication extends INestApplicationContext {
|
||||
getMicroservices(): INestMicroservice[];
|
||||
|
||||
/**
|
||||
* Returns an underlying, native HTTP server.
|
||||
* Returns the underlying native HTTP server.
|
||||
*
|
||||
* @returns {http.Server}
|
||||
*/
|
||||
getHttpServer(): any;
|
||||
|
||||
/**
|
||||
* Returns an underlying HTTP adapter.
|
||||
* Returns the underlying HTTP adapter.
|
||||
*
|
||||
* @returns {HttpServer}
|
||||
*/
|
||||
getHttpAdapter(): HttpServer;
|
||||
|
||||
/**
|
||||
* Starts all connected microservices asynchronously
|
||||
* Starts all connected microservices asynchronously.
|
||||
*
|
||||
* @param {Function} callback Optional callback function
|
||||
* @returns {void}
|
||||
@@ -102,42 +109,45 @@ export interface INestApplication extends INestApplicationContext {
|
||||
startAllMicroservices(callback?: () => void): this;
|
||||
|
||||
/**
|
||||
* Starts all connected microservices and can be awaited
|
||||
* Starts all connected microservices and can be awaited.
|
||||
*
|
||||
* @returns {Promise}
|
||||
*/
|
||||
startAllMicroservicesAsync(): Promise<void>;
|
||||
|
||||
/**
|
||||
* Registers exception filters as a global filters (will be used within every HTTP route handler)
|
||||
* Registers exception filters as global filters (will be used within
|
||||
* every HTTP route handler)
|
||||
*
|
||||
* @param {ExceptionFilter[]} ...filters
|
||||
*/
|
||||
useGlobalFilters(...filters: ExceptionFilter[]): this;
|
||||
|
||||
/**
|
||||
* Registers pipes as a global pipes (will be used within every HTTP route handler)
|
||||
* Registers pipes as global pipes (will be used within every HTTP route handler)
|
||||
*
|
||||
* @param {PipeTransform[]} ...pipes
|
||||
*/
|
||||
useGlobalPipes(...pipes: PipeTransform<any>[]): this;
|
||||
|
||||
/**
|
||||
* Registers interceptors as a global interceptors (will be used within every HTTP route handler)
|
||||
* Registers interceptors as global interceptors (will be used within
|
||||
* every HTTP route handler)
|
||||
*
|
||||
* @param {NestInterceptor[]} ...interceptors
|
||||
*/
|
||||
useGlobalInterceptors(...interceptors: NestInterceptor[]): this;
|
||||
|
||||
/**
|
||||
* Registers guards as a global guards (will be used within every HTTP route handler)
|
||||
* Registers guards as global guards (will be used within every HTTP route handler)
|
||||
*
|
||||
* @param {CanActivate[]} ...guards
|
||||
*/
|
||||
useGlobalGuards(...guards: CanActivate[]): this;
|
||||
|
||||
/**
|
||||
* Terminates the application (including NestApplication, Gateways, and each connected microservice)
|
||||
* Terminates the application (including NestApplication, Gateways, and each connected
|
||||
* microservice)
|
||||
*
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
/**
|
||||
* @publicApi
|
||||
*
|
||||
* @description
|
||||
* Interface defining method called once the application has fully started and
|
||||
* is bootstrapped.
|
||||
*
|
||||
* @see [Lifecycle Events](https://docs.nestjs.com/fundamentals/lifecycle-events)
|
||||
*/
|
||||
export interface OnApplicationBootstrap {
|
||||
onApplicationBootstrap(): any;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
/**
|
||||
* @publicApi
|
||||
*
|
||||
* @description
|
||||
* Interface defining method to respond to system signals (when application gets
|
||||
* shutdown by, e.g., SIGTERM)
|
||||
*
|
||||
* @see [Lifecycle Events](https://docs.nestjs.com/fundamentals/lifecycle-events)
|
||||
*/
|
||||
export interface OnApplicationShutdown {
|
||||
onApplicationShutdown(signal?: string): any;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,31 @@
|
||||
/**
|
||||
* @publicApi
|
||||
*/
|
||||
export enum Scope {
|
||||
/**
|
||||
* The provider can be shared across multiple classes. The provider lifetime
|
||||
* is strictly tied to the application lifecycle. Once the application has
|
||||
* bootstrapped, all providers have been instantiated.
|
||||
*/
|
||||
DEFAULT,
|
||||
/**
|
||||
* A new private instance of the provider is instantiated for every use
|
||||
*/
|
||||
TRANSIENT,
|
||||
/**
|
||||
* A new instance is instantiated for each request processing pipeline
|
||||
*/
|
||||
REQUEST,
|
||||
}
|
||||
|
||||
/**
|
||||
* @publicApi
|
||||
*
|
||||
* @see [Injection Scopes](https://docs.nestjs.com/fundamentals/injection-scopes)
|
||||
*/
|
||||
export interface ScopeOptions {
|
||||
/**
|
||||
* Specifies the lifetime of an injected Provider or Controller.
|
||||
*/
|
||||
scope?: Scope;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nestjs/common",
|
||||
"version": "6.4.0",
|
||||
"version": "6.5.3",
|
||||
"description": "Nest - modern, fast, powerful node.js web framework (@common)",
|
||||
"author": "Kamil Mysliwiec",
|
||||
"repository": {
|
||||
@@ -14,7 +14,7 @@
|
||||
"dependencies": {
|
||||
"axios": "0.19.0",
|
||||
"cli-color": "1.4.0",
|
||||
"uuid": "3.3.2"
|
||||
"uuid": "3.3.3"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"reflect-metadata": "^0.1.12",
|
||||
|
||||
@@ -44,4 +44,29 @@ describe('HttpException', () => {
|
||||
statusCode: 404,
|
||||
});
|
||||
});
|
||||
|
||||
it('should inherit from error', () => {
|
||||
const error = new HttpException('', 400);
|
||||
expect(error instanceof Error).to.be.true;
|
||||
});
|
||||
|
||||
it('should be serializable', () => {
|
||||
const message = 'Some Error';
|
||||
const error = new HttpException(message, 400);
|
||||
expect(`${error}`).to.be.eql(`Error: ${message}`);
|
||||
});
|
||||
|
||||
describe('when "message" is an object', () => {
|
||||
it('should serialize an object', () => {
|
||||
const obj = { foo: 'bar' };
|
||||
const error = new HttpException(obj, 400);
|
||||
expect(`${error}`).to.be.eql(`Error: ${JSON.stringify(obj)}`);
|
||||
expect(`${error}`.includes('[object Object]')).to.not.be.true;
|
||||
});
|
||||
|
||||
it('should serialize sub errors', () => {
|
||||
const error = new NotFoundException();
|
||||
expect(`${error}`.includes('Not Found')).to.be.true;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { expect } from 'chai';
|
||||
import * as sinon from 'sinon';
|
||||
import { ArgumentMetadata } from '../../interfaces';
|
||||
import { ParseUUIDPipe } from '../../pipes/parse-uuid.pipe';
|
||||
|
||||
@@ -56,7 +55,7 @@ describe('ParseUUIDPipe', () => {
|
||||
});
|
||||
|
||||
it('should throw an error - v5 ', async () => {
|
||||
target = new ParseUUIDPipe({ version: '4' });
|
||||
target = new ParseUUIDPipe({ version: '5' });
|
||||
expect(target.transform('123a', {} as ArgumentMetadata)).to.be.rejected;
|
||||
expect(target.transform(v3, {} as ArgumentMetadata)).to.be.rejected;
|
||||
expect(target.transform(v4, {} as ArgumentMetadata)).to.be.rejected;
|
||||
|
||||
1
packages/core/PACKAGE.md
Normal file
1
packages/core/PACKAGE.md
Normal file
@@ -0,0 +1 @@
|
||||
Implements Nest core functionalities, low-level services, and utilities.
|
||||
@@ -15,7 +15,6 @@
|
||||
<a href="https://travis-ci.org/nestjs/nest" target="_blank"><img src="https://api.travis-ci.org/nestjs/nest.svg?branch=master" alt="Travis" /></a>
|
||||
<a href="https://travis-ci.org/nestjs/nest" target="_blank"><img src="https://img.shields.io/travis/nestjs/nest/master.svg?label=linux" alt="Linux" /></a>
|
||||
<a href="https://coveralls.io/github/nestjs/nest?branch=master" target="_blank"><img src="https://coveralls.io/repos/github/nestjs/nest/badge.svg?branch=master#9" alt="Coverage" /></a>
|
||||
<a href="https://gitter.im/nestjs/nestjs?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=body_badge" target="_blank"><img src="https://badges.gitter.im/nestjs/nestjs.svg" alt="Gitter" /></a>
|
||||
<a href="https://discord.gg/G7Qnnhy" target="_blank"><img src="https://img.shields.io/badge/discord-online-brightgreen.svg" alt="Discord"/></a>
|
||||
<a href="https://opencollective.com/nest#backer" target="_blank"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
|
||||
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
|
||||
|
||||
@@ -3,6 +3,13 @@ import { RequestHandler } from '@nestjs/common/interfaces';
|
||||
import { CorsOptions } from '@nestjs/common/interfaces/external/cors-options.interface';
|
||||
import { NestApplicationOptions } from '@nestjs/common/interfaces/nest-application-options.interface';
|
||||
|
||||
/**
|
||||
* @publicApi
|
||||
*
|
||||
* @description
|
||||
*
|
||||
* This is the AbstractHttpAdapter
|
||||
*/
|
||||
export abstract class AbstractHttpAdapter<
|
||||
TServer = any,
|
||||
TRequest = any,
|
||||
|
||||
@@ -5,14 +5,22 @@ import {
|
||||
PipeTransform,
|
||||
WebSocketAdapter,
|
||||
} from '@nestjs/common';
|
||||
import { ConfigurationProvider } from '@nestjs/common/interfaces/configuration-provider.interface';
|
||||
import { InstanceWrapper } from './injector/instance-wrapper';
|
||||
|
||||
export class ApplicationConfig implements ConfigurationProvider {
|
||||
private globalPipes: PipeTransform<any>[] = [];
|
||||
export class ApplicationConfig {
|
||||
private globalPrefix = '';
|
||||
private globalPipes: PipeTransform[] = [];
|
||||
private globalFilters: ExceptionFilter[] = [];
|
||||
private globalInterceptors: NestInterceptor[] = [];
|
||||
private globalGuards: CanActivate[] = [];
|
||||
private globalPrefix = '';
|
||||
private readonly globalRequestPipes: InstanceWrapper<PipeTransform>[] = [];
|
||||
private readonly globalRequestFilters: InstanceWrapper<
|
||||
ExceptionFilter
|
||||
>[] = [];
|
||||
private readonly globalRequestInterceptors: InstanceWrapper<
|
||||
NestInterceptor
|
||||
>[] = [];
|
||||
private readonly globalRequestGuards: InstanceWrapper<CanActivate>[] = [];
|
||||
|
||||
constructor(private ioAdapter: WebSocketAdapter | null = null) {}
|
||||
|
||||
@@ -79,4 +87,38 @@ export class ApplicationConfig implements ConfigurationProvider {
|
||||
public useGlobalGuards(...guards: CanActivate[]) {
|
||||
this.globalGuards = this.globalGuards.concat(guards);
|
||||
}
|
||||
|
||||
public addGlobalRequestInterceptor(
|
||||
wrapper: InstanceWrapper<NestInterceptor>,
|
||||
) {
|
||||
this.globalRequestInterceptors.push(wrapper);
|
||||
}
|
||||
|
||||
public getGlobalRequestInterceptors(): InstanceWrapper<NestInterceptor>[] {
|
||||
return this.globalRequestInterceptors;
|
||||
}
|
||||
|
||||
public addGlobalRequestPipe(wrapper: InstanceWrapper<PipeTransform>) {
|
||||
this.globalRequestPipes.push(wrapper);
|
||||
}
|
||||
|
||||
public getGlobalRequestPipes(): InstanceWrapper<PipeTransform>[] {
|
||||
return this.globalRequestPipes;
|
||||
}
|
||||
|
||||
public addGlobalRequestFilter(wrapper: InstanceWrapper<ExceptionFilter>) {
|
||||
this.globalRequestFilters.push(wrapper);
|
||||
}
|
||||
|
||||
public getGlobalRequestFilters(): InstanceWrapper<ExceptionFilter>[] {
|
||||
return this.globalRequestFilters;
|
||||
}
|
||||
|
||||
public addGlobalRequestGuard(wrapper: InstanceWrapper<CanActivate>) {
|
||||
this.globalRequestGuards.push(wrapper);
|
||||
}
|
||||
|
||||
public getGlobalRequestGuards(): InstanceWrapper<CanActivate>[] {
|
||||
return this.globalRequestGuards;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ import { EXCEPTION_FILTERS_METADATA } from '@nestjs/common/constants';
|
||||
import { Controller } from '@nestjs/common/interfaces';
|
||||
import { isEmpty } from '@nestjs/common/utils/shared.utils';
|
||||
import { STATIC_CONTEXT } from '../injector/constants';
|
||||
import { InstanceWrapper } from '../injector/instance-wrapper';
|
||||
import { RouterProxyCallback } from '../router/router-proxy';
|
||||
import { ApplicationConfig } from './../application-config';
|
||||
import { NestContainer } from './../injector/container';
|
||||
@@ -40,10 +41,23 @@ export class ExternalExceptionFilterContext extends BaseExceptionFilterContext {
|
||||
return exceptionHandler;
|
||||
}
|
||||
|
||||
public getGlobalMetadata<T extends any[]>(): T {
|
||||
public getGlobalMetadata<T extends any[]>(
|
||||
contextId = STATIC_CONTEXT,
|
||||
inquirerId?: string,
|
||||
): T {
|
||||
if (!this.config) {
|
||||
return [] as T;
|
||||
}
|
||||
return this.config.getGlobalFilters() as T;
|
||||
const globalFilters = this.config.getGlobalFilters() as T;
|
||||
if (contextId === STATIC_CONTEXT && !inquirerId) {
|
||||
return globalFilters;
|
||||
}
|
||||
const scopedFilterWrappers = this.config.getGlobalRequestFilters() as InstanceWrapper[];
|
||||
const scopedFilters = scopedFilterWrappers
|
||||
.map(wrapper => wrapper.getInstanceByContextId(contextId, inquirerId))
|
||||
.filter(host => host)
|
||||
.map(host => host.instance);
|
||||
|
||||
return globalFilters.concat(scopedFilters) as T;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { CanActivate } from '@nestjs/common';
|
||||
import { GUARDS_METADATA } from '@nestjs/common/constants';
|
||||
import { Controller } from '@nestjs/common/interfaces';
|
||||
import { ConfigurationProvider } from '@nestjs/common/interfaces/configuration-provider.interface';
|
||||
import { isEmpty, isFunction } from '@nestjs/common/utils/shared.utils';
|
||||
import iterate from 'iterare';
|
||||
import { ApplicationConfig } from '../application-config';
|
||||
import { ContextCreator } from '../helpers/context-creator';
|
||||
import { STATIC_CONTEXT } from '../injector/constants';
|
||||
import { NestContainer } from '../injector/container';
|
||||
@@ -14,7 +14,7 @@ export class GuardsContextCreator extends ContextCreator {
|
||||
|
||||
constructor(
|
||||
private readonly container: NestContainer,
|
||||
private readonly config?: ConfigurationProvider,
|
||||
private readonly config?: ApplicationConfig,
|
||||
) {
|
||||
super();
|
||||
}
|
||||
@@ -86,10 +86,23 @@ export class GuardsContextCreator extends ContextCreator {
|
||||
return injectables.get(guard.name);
|
||||
}
|
||||
|
||||
public getGlobalMetadata<T extends any[]>(): T {
|
||||
public getGlobalMetadata<T extends any[]>(
|
||||
contextId = STATIC_CONTEXT,
|
||||
inquirerId?: string,
|
||||
): T {
|
||||
if (!this.config) {
|
||||
return [] as T;
|
||||
}
|
||||
return this.config.getGlobalGuards() as T;
|
||||
const globalGuards = this.config.getGlobalGuards() as T;
|
||||
if (contextId === STATIC_CONTEXT && !inquirerId) {
|
||||
return globalGuards;
|
||||
}
|
||||
const scopedGuardWrappers = this.config.getGlobalRequestGuards() as InstanceWrapper[];
|
||||
const scopedGuards = scopedGuardWrappers
|
||||
.map(wrapper => wrapper.getInstanceByContextId(contextId, inquirerId))
|
||||
.filter(host => host)
|
||||
.map(host => host.instance);
|
||||
|
||||
return globalGuards.concat(scopedGuards) as T;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,10 @@ export abstract class ContextCreator {
|
||||
contextId?: ContextId,
|
||||
inquirerId?: string,
|
||||
): R;
|
||||
public getGlobalMetadata?<T extends any[]>(): T;
|
||||
public getGlobalMetadata?<T extends any[]>(
|
||||
contextId?: ContextId,
|
||||
inquirerId?: string,
|
||||
): T;
|
||||
|
||||
public createContext<T extends any[], R extends any[]>(
|
||||
instance: Controller,
|
||||
@@ -18,7 +21,8 @@ export abstract class ContextCreator {
|
||||
inquirerId?: string,
|
||||
): R {
|
||||
const globalMetadata =
|
||||
this.getGlobalMetadata && this.getGlobalMetadata<T>();
|
||||
this.getGlobalMetadata &&
|
||||
this.getGlobalMetadata<T>(contextId, inquirerId);
|
||||
const classMetadata = this.reflectClassMetadata<T>(instance, metadataKey);
|
||||
const methodMetadata = this.reflectMethodMetadata<T>(callback, metadataKey);
|
||||
return [
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { ForbiddenException, ParamData } from '@nestjs/common';
|
||||
import { CUSTOM_ROUTE_AGRS_METADATA } from '@nestjs/common/constants';
|
||||
import { Controller, Transform } from '@nestjs/common/interfaces';
|
||||
import { isFunction } from '@nestjs/common/utils/shared.utils';
|
||||
import { Controller, PipeTransform } from '@nestjs/common/interfaces';
|
||||
import { isEmpty, isFunction } from '@nestjs/common/utils/shared.utils';
|
||||
import { FORBIDDEN_MESSAGE } from '../guards/constants';
|
||||
import { GuardsConsumer } from '../guards/guards-consumer';
|
||||
import { GuardsContextCreator } from '../guards/guards-context-creator';
|
||||
@@ -292,7 +292,7 @@ export class ExternalContextCreator {
|
||||
}
|
||||
|
||||
public createPipesFn(
|
||||
pipes: any[],
|
||||
pipes: PipeTransform[],
|
||||
paramsOptions: (ParamProperties & { metatype?: any })[],
|
||||
) {
|
||||
const pipesFn = async (args: any[], ...params: any[]) => {
|
||||
@@ -322,13 +322,11 @@ export class ExternalContextCreator {
|
||||
public async getParamValue<T>(
|
||||
value: T,
|
||||
{ metatype, type, data }: { metatype: any; type: any; data: any },
|
||||
transforms: Transform<any>[],
|
||||
pipes: PipeTransform[],
|
||||
): Promise<any> {
|
||||
return this.pipesConsumer.apply(
|
||||
value,
|
||||
{ metatype, type, data },
|
||||
transforms,
|
||||
);
|
||||
return isEmpty(pipes)
|
||||
? value
|
||||
: this.pipesConsumer.apply(value, { metatype, type, data }, pipes);
|
||||
}
|
||||
|
||||
public async transformToResult(resultOrDeffered: any) {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Controller } from '@nestjs/common/interfaces';
|
||||
import * as hash from 'object-hash';
|
||||
import { ContextId } from './../injector/instance-wrapper';
|
||||
import { ParamProperties } from './context-utils';
|
||||
|
||||
@@ -36,7 +37,7 @@ export class HandlerMetadataStorage<TValue = HandlerMetadata, TKey = any> {
|
||||
|
||||
private getMetadataKey(controller: Controller, methodName: string): string {
|
||||
const ctor = controller.constructor;
|
||||
const controllerKey = ctor && ctor.name;
|
||||
const controllerKey = ctor && hash(ctor);
|
||||
return controllerKey + methodName;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import {
|
||||
*
|
||||
* @param instance The instance which should be checked
|
||||
*/
|
||||
function hasOnAppBootstrapHook(
|
||||
function hasOnAppShutdownHook(
|
||||
instance: unknown,
|
||||
): instance is OnApplicationShutdown {
|
||||
return !isUndefined(
|
||||
@@ -30,7 +30,7 @@ function callOperator(
|
||||
): Promise<any>[] {
|
||||
return iterate(instances)
|
||||
.filter(instance => !isNil(instance))
|
||||
.filter(hasOnAppBootstrapHook)
|
||||
.filter(hasOnAppShutdownHook)
|
||||
.map(async instance =>
|
||||
((instance as any) as OnApplicationShutdown).onApplicationShutdown(
|
||||
signal,
|
||||
@@ -61,7 +61,7 @@ export async function callAppShutdownHook(
|
||||
await Promise.all(callOperator(transientInstances, signal));
|
||||
|
||||
// Call the instance itself
|
||||
if (moduleClassInstance && hasOnAppBootstrapHook(moduleClassInstance)) {
|
||||
if (moduleClassInstance && hasOnAppShutdownHook(moduleClassInstance)) {
|
||||
await (moduleClassInstance as OnApplicationShutdown).onApplicationShutdown(
|
||||
signal,
|
||||
);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { DynamicModule } from '@nestjs/common';
|
||||
import { DynamicModule, Provider } from '@nestjs/common';
|
||||
import { GLOBAL_MODULE_METADATA } from '@nestjs/common/constants';
|
||||
import { Injectable } from '@nestjs/common/interfaces/injectable.interface';
|
||||
import { Type } from '@nestjs/common/interfaces/type.interface';
|
||||
@@ -129,7 +129,7 @@ export class NestContainer {
|
||||
module.addRelatedModule(related);
|
||||
}
|
||||
|
||||
public addProvider(provider: Type<any>, token: string): string {
|
||||
public addProvider(provider: Provider, token: string): string {
|
||||
if (!provider) {
|
||||
throw new CircularDependencyException();
|
||||
}
|
||||
@@ -141,9 +141,9 @@ export class NestContainer {
|
||||
}
|
||||
|
||||
public addInjectable(
|
||||
injectable: Type<any>,
|
||||
injectable: Provider,
|
||||
token: string,
|
||||
host: Type<Injectable>,
|
||||
host?: Type<Injectable>,
|
||||
) {
|
||||
if (!this.modules.has(token)) {
|
||||
throw new UnknownModuleException();
|
||||
|
||||
@@ -106,7 +106,7 @@ export class Injector {
|
||||
contextId,
|
||||
wrapper,
|
||||
);
|
||||
await this.loadEnhancersPerContext(wrapper, module, contextId, wrapper);
|
||||
await this.loadEnhancersPerContext(wrapper, contextId, wrapper);
|
||||
}
|
||||
|
||||
public async loadInjectable(
|
||||
@@ -139,7 +139,7 @@ export class Injector {
|
||||
contextId,
|
||||
inquirer,
|
||||
);
|
||||
await this.loadEnhancersPerContext(wrapper, module, contextId, wrapper);
|
||||
await this.loadEnhancersPerContext(wrapper, contextId, wrapper);
|
||||
}
|
||||
|
||||
public loadPrototype<T>(
|
||||
@@ -630,7 +630,7 @@ export class Injector {
|
||||
instance.constructor && instance.constructor.name,
|
||||
);
|
||||
await this.loadInstance(wrapper, collection, module, ctx, wrapper);
|
||||
await this.loadEnhancersPerContext(wrapper, module, ctx, wrapper);
|
||||
await this.loadEnhancersPerContext(wrapper, ctx, wrapper);
|
||||
|
||||
const host = wrapper.getInstanceByContextId(ctx);
|
||||
return host && (host.instance as T);
|
||||
@@ -638,13 +638,20 @@ export class Injector {
|
||||
|
||||
public async loadEnhancersPerContext(
|
||||
wrapper: InstanceWrapper,
|
||||
module: Module,
|
||||
ctx: ContextId,
|
||||
inquirer?: InstanceWrapper,
|
||||
) {
|
||||
const enhancers = wrapper.getEnhancersMetadata() || [];
|
||||
const loadEnhancer = (item: InstanceWrapper) =>
|
||||
this.loadInstance(item, module.injectables, module, ctx, inquirer);
|
||||
const loadEnhancer = (item: InstanceWrapper) => {
|
||||
const hostModule = item.host;
|
||||
return this.loadInstance(
|
||||
item,
|
||||
hostModule.injectables,
|
||||
hostModule,
|
||||
ctx,
|
||||
inquirer,
|
||||
);
|
||||
};
|
||||
await Promise.all(enhancers.map(loadEnhancer));
|
||||
}
|
||||
|
||||
|
||||
@@ -160,7 +160,7 @@ export class Module {
|
||||
}
|
||||
|
||||
public addInjectable<T extends Injectable>(
|
||||
injectable: Type<T>,
|
||||
injectable: Provider,
|
||||
host?: Type<T>,
|
||||
) {
|
||||
if (this.isCustomProvider(injectable)) {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { INTERCEPTORS_METADATA } from '@nestjs/common/constants';
|
||||
import { Controller, NestInterceptor } from '@nestjs/common/interfaces';
|
||||
import { ConfigurationProvider } from '@nestjs/common/interfaces/configuration-provider.interface';
|
||||
import { isEmpty, isFunction } from '@nestjs/common/utils/shared.utils';
|
||||
import iterate from 'iterare';
|
||||
import { ApplicationConfig } from '../application-config';
|
||||
import { ContextCreator } from '../helpers/context-creator';
|
||||
import { STATIC_CONTEXT } from '../injector/constants';
|
||||
import { NestContainer } from '../injector/container';
|
||||
@@ -13,7 +13,7 @@ export class InterceptorsContextCreator extends ContextCreator {
|
||||
|
||||
constructor(
|
||||
private readonly container: NestContainer,
|
||||
private readonly config?: ConfigurationProvider,
|
||||
private readonly config?: ApplicationConfig,
|
||||
) {
|
||||
super();
|
||||
}
|
||||
@@ -92,10 +92,23 @@ export class InterceptorsContextCreator extends ContextCreator {
|
||||
return module.injectables.get(metatype.name);
|
||||
}
|
||||
|
||||
public getGlobalMetadata<T extends any[]>(): T {
|
||||
public getGlobalMetadata<T extends any[]>(
|
||||
contextId = STATIC_CONTEXT,
|
||||
inquirerId?: string,
|
||||
): T {
|
||||
if (!this.config) {
|
||||
return [] as T;
|
||||
}
|
||||
return this.config.getGlobalInterceptors() as T;
|
||||
const globalInterceptors = this.config.getGlobalInterceptors() as T;
|
||||
if (contextId === STATIC_CONTEXT && !inquirerId) {
|
||||
return globalInterceptors;
|
||||
}
|
||||
const scopedInterceptorWrappers = this.config.getGlobalRequestInterceptors() as InstanceWrapper[];
|
||||
const scopedInterceptors = scopedInterceptorWrappers
|
||||
.map(wrapper => wrapper.getInstanceByContextId(contextId, inquirerId))
|
||||
.filter(host => host)
|
||||
.map(host => host.instance);
|
||||
|
||||
return globalInterceptors.concat(scopedInterceptors) as T;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
import iterate from 'iterare';
|
||||
|
||||
export class MetadataScanner {
|
||||
public scanFromPrototype<T extends Injectable, R>(
|
||||
public scanFromPrototype<T extends Injectable, R = any>(
|
||||
instance: T,
|
||||
prototype: any,
|
||||
callback: (name: string) => R,
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user