mirror of
https://github.com/nestjs/nest.git
synced 2026-02-26 06:35:32 +00:00
Compare commits
223 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2f535c33ae | ||
|
|
20dd9fc8ca | ||
|
|
6110526402 | ||
|
|
0a1f44ac4d | ||
|
|
d048f23ff8 | ||
|
|
f5f8255a37 | ||
|
|
cc4d91fcb3 | ||
|
|
89c76a682e | ||
|
|
63577b9986 | ||
|
|
713e97f6c3 | ||
|
|
c392da09a6 | ||
|
|
02d4841d05 | ||
|
|
cbe9ed4980 | ||
|
|
d654e5e84f | ||
|
|
9d2bd82173 | ||
|
|
02affa5677 | ||
|
|
71a023ebae | ||
|
|
aa75b52255 | ||
|
|
6cf7cdc2a6 | ||
|
|
5b804f5a35 | ||
|
|
b348920d25 | ||
|
|
b6fe9b06cc | ||
|
|
fde2041f17 | ||
|
|
7a4b0e64ad | ||
|
|
afe9c4b5f4 | ||
|
|
5e6694cb8b | ||
|
|
d20f6bb653 | ||
|
|
e8032f37fc | ||
|
|
cae159e77c | ||
|
|
47812f5822 | ||
|
|
afa9903882 | ||
|
|
a7d465bfa1 | ||
|
|
95dfd59e4e | ||
|
|
08e6278a77 | ||
|
|
fbf47a2825 | ||
|
|
643e84c49a | ||
|
|
25c7e8909e | ||
|
|
0d5972c66b | ||
|
|
394d7f23bf | ||
|
|
09d9c6597f | ||
|
|
1d8c8ee264 | ||
|
|
5a9d6d6d14 | ||
|
|
4d13ee8100 | ||
|
|
6b0ae0602c | ||
|
|
d0bd2f7b20 | ||
|
|
5f965cf174 | ||
|
|
504a10ce5e | ||
|
|
a9abd1c2ea | ||
|
|
e7e859adce | ||
|
|
0c98a65e79 | ||
|
|
cd30d7a4a5 | ||
|
|
a6d837e64a | ||
|
|
0904b0ba56 | ||
|
|
150c81e397 | ||
|
|
1717f35717 | ||
|
|
61b6b346da | ||
|
|
b02fb57d8f | ||
|
|
cb302e6719 | ||
|
|
1f9030c504 | ||
|
|
af5a4af675 | ||
|
|
664321465c | ||
|
|
f6d4b5e82a | ||
|
|
09c9f704e5 | ||
|
|
8a8b780273 | ||
|
|
1f0de4923e | ||
|
|
d5833e3e4b | ||
|
|
deffcdcd84 | ||
|
|
ba2eeeeac7 | ||
|
|
36b94b37d0 | ||
|
|
85b93260e2 | ||
|
|
94f74a485b | ||
|
|
b4253525fe | ||
|
|
c38c91217c | ||
|
|
f024af4912 | ||
|
|
6976ffe079 | ||
|
|
2812c3863d | ||
|
|
9ad7927c4c | ||
|
|
afae462b6e | ||
|
|
62e733c018 | ||
|
|
d446a56381 | ||
|
|
2bdf47a572 | ||
|
|
caf99c6cf8 | ||
|
|
5415659fb9 | ||
|
|
e967ba15cf | ||
|
|
0b191fbd17 | ||
|
|
2ea58acc70 | ||
|
|
1f59a81c28 | ||
|
|
fbcb18c978 | ||
|
|
dd7bb313f4 | ||
|
|
946ed2e339 | ||
|
|
96da5bd9c5 | ||
|
|
9f77d5f550 | ||
|
|
9e6cf1f1aa | ||
|
|
d92fa0dee1 | ||
|
|
63109f5717 | ||
|
|
dc33ea57ef | ||
|
|
780bd9c0f9 | ||
|
|
a79041d211 | ||
|
|
eda8e293c3 | ||
|
|
fd797b1a69 | ||
|
|
fd098fc3f7 | ||
|
|
1be2ccdb0b | ||
|
|
cb46174bae | ||
|
|
ac1578793f | ||
|
|
525922ee69 | ||
|
|
5327979745 | ||
|
|
3a0e404832 | ||
|
|
55b1f1e08e | ||
|
|
a05383c635 | ||
|
|
86abc0001c | ||
|
|
c4ff2e736a | ||
|
|
d00d5f2996 | ||
|
|
5f0f6e5b61 | ||
|
|
f39573007c | ||
|
|
f7a367e895 | ||
|
|
dcba92190f | ||
|
|
614d57f130 | ||
|
|
9e170c4ae4 | ||
|
|
85070a5c9c | ||
|
|
f86fc35fa7 | ||
|
|
53184b8df0 | ||
|
|
f385d5c47d | ||
|
|
1527e12013 | ||
|
|
58800f69b1 | ||
|
|
049da42d4a | ||
|
|
21f2e8a9f7 | ||
|
|
432b777f2c | ||
|
|
e39c9d920d | ||
|
|
b84c2b0884 | ||
|
|
e4d0118e9d | ||
|
|
0bf98c46cb | ||
|
|
442b08fdb9 | ||
|
|
9c2a9d76d2 | ||
|
|
a354741c31 | ||
|
|
8d62307987 | ||
|
|
e2de979081 | ||
|
|
0f62bcd41f | ||
|
|
d4c9644368 | ||
|
|
0c4fe26c21 | ||
|
|
3cf8607b20 | ||
|
|
3d2d838bd1 | ||
|
|
a9204cb399 | ||
|
|
bd3b102c2f | ||
|
|
9cf27a35dd | ||
|
|
c1c5b15859 | ||
|
|
3e55de545f | ||
|
|
ced6729157 | ||
|
|
a57eb17640 | ||
|
|
6c2863d709 | ||
|
|
fc05b244a8 | ||
|
|
c80fd77416 | ||
|
|
e2d15db3f4 | ||
|
|
8057a5cf19 | ||
|
|
a6ab849df2 | ||
|
|
7143d3b8ac | ||
|
|
be6d90ace2 | ||
|
|
7023905b53 | ||
|
|
f4817ee4eb | ||
|
|
a87eee0849 | ||
|
|
a8803fd166 | ||
|
|
18f68d96b7 | ||
|
|
ecd61e3777 | ||
|
|
10eeac9ae7 | ||
|
|
59e6a3d262 | ||
|
|
292fe2136c | ||
|
|
f80cd9edd1 | ||
|
|
adbfae2b71 | ||
|
|
4cfda07b2a | ||
|
|
3ac7802315 | ||
|
|
1813e5a09c | ||
|
|
c9184acee1 | ||
|
|
1c98d6b18c | ||
|
|
7172671dcc | ||
|
|
294e269ede | ||
|
|
00c98501ff | ||
|
|
51d5be4e9d | ||
|
|
f86c0e33c4 | ||
|
|
3888d8ee8b | ||
|
|
8029796193 | ||
|
|
f3c28f57ac | ||
|
|
03db0d357a | ||
|
|
7ad6095e16 | ||
|
|
617bc70944 | ||
|
|
f2d2d56111 | ||
|
|
84d31f9449 | ||
|
|
da3745f386 | ||
|
|
7e47100d3e | ||
|
|
0c8e8fb4f7 | ||
|
|
f337206785 | ||
|
|
3984bc92f2 | ||
|
|
89fe60a213 | ||
|
|
3ebec419fe | ||
|
|
fed2459677 | ||
|
|
33c7049d71 | ||
|
|
e44f51d647 | ||
|
|
31aa2f09c5 | ||
|
|
3fffc01890 | ||
|
|
e1abf80569 | ||
|
|
a7fde9b6cc | ||
|
|
92d3ed48db | ||
|
|
c5455de9d1 | ||
|
|
7b5b054818 | ||
|
|
17a609cd9c | ||
|
|
ae128f6e91 | ||
|
|
cb24ca9ee5 | ||
|
|
e37b9f7d81 | ||
|
|
55600edb2d | ||
|
|
033068b5d7 | ||
|
|
9ea7db9160 | ||
|
|
1801bf86b6 | ||
|
|
ba5c59bc34 | ||
|
|
bf30a304d8 | ||
|
|
310d530308 | ||
|
|
75775d6ea1 | ||
|
|
f9e02b60fa | ||
|
|
c5a3385156 | ||
|
|
403a137847 | ||
|
|
c7bd1afc39 | ||
|
|
fcf24d32c9 | ||
|
|
aba394f742 | ||
|
|
6a49b833ca | ||
|
|
7e022be24a | ||
|
|
fb860c70e3 |
41
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
41
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
## PR Checklist
|
||||
Please check if your PR fulfills the following requirements:
|
||||
|
||||
- [ ] The commit message follows our guidelines: https://github.com/nestjs/nest/blob/master/CONTRIBUTING.md
|
||||
- [ ] Tests for the changes have been added (for bug fixes / features)
|
||||
- [ ] Docs have been added / updated (for bug fixes / features)
|
||||
|
||||
|
||||
## PR Type
|
||||
What kind of change does this PR introduce?
|
||||
|
||||
<!-- Please check the one that applies to this PR using "x". -->
|
||||
```
|
||||
[ ] Bugfix
|
||||
[ ] Feature
|
||||
[ ] Code style update (formatting, local variables)
|
||||
[ ] Refactoring (no functional changes, no api changes)
|
||||
[ ] Build related changes
|
||||
[ ] CI related changes
|
||||
[ ] Other... Please describe:
|
||||
```
|
||||
|
||||
## What is the current behavior?
|
||||
<!-- Please describe the current behavior that you are modifying, or link to a relevant issue. -->
|
||||
|
||||
Issue Number: N/A
|
||||
|
||||
|
||||
## What is the new behavior?
|
||||
|
||||
|
||||
## Does this PR introduce a breaking change?
|
||||
```
|
||||
[ ] Yes
|
||||
[ ] No
|
||||
```
|
||||
|
||||
<!-- If this PR contains a breaking change, please describe the impact and migration path for existing applications below. -->
|
||||
|
||||
|
||||
## Other information
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,6 +1,5 @@
|
||||
# dependencies
|
||||
node_modules/
|
||||
package-lock.json
|
||||
|
||||
# IDE
|
||||
/.idea
|
||||
|
||||
@@ -2,6 +2,10 @@ language: node_js
|
||||
node_js:
|
||||
- "8"
|
||||
- "9"
|
||||
- "10"
|
||||
cache:
|
||||
directories:
|
||||
- "node_modules"
|
||||
git:
|
||||
depth: 5
|
||||
addons:
|
||||
|
||||
@@ -183,10 +183,10 @@ Footer should contain a [closing reference to an issue](https://help.github.com/
|
||||
Samples: (even more [samples](https://github.com/nestjs/nest/commits/master))
|
||||
|
||||
```
|
||||
docs(changelog): update change log to beta.5
|
||||
docs(changelog) update change log to beta.5
|
||||
```
|
||||
```
|
||||
fix(release): need to depend on latest rxjs and zone.js
|
||||
bugfix(core) need to depend on latest rxjs and zone.js
|
||||
|
||||
The version in our package.json gets copied to the one we publish, and users need the latest of these.
|
||||
```
|
||||
@@ -200,8 +200,8 @@ Must be one of the following:
|
||||
* **build**: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
|
||||
* **ci**: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
|
||||
* **docs**: Documentation only changes
|
||||
* **feat**: A new feature
|
||||
* **fix**: A bug fix
|
||||
* **feature**: A new feature
|
||||
* **bugfix**: A bug fix
|
||||
* **perf**: A code change that improves performance
|
||||
* **refactor**: A code change that neither fixes a bug nor adds a feature
|
||||
* **style**: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
|
||||
@@ -214,7 +214,7 @@ The following is the list of supported scopes:
|
||||
|
||||
* **common**
|
||||
* **core**
|
||||
* **examples**
|
||||
* **sample**
|
||||
* **microservices**
|
||||
* **testing**
|
||||
* **websockets**
|
||||
@@ -223,7 +223,7 @@ There are currently a few exceptions to the "use package name" rule:
|
||||
|
||||
* **packaging**: used for changes that change the npm package layout in all of our packages, e.g. public path changes, package.json changes done to all packages, d.ts file/format changes, changes to bundles, etc.
|
||||
* **changelog**: used for updating the release notes in CHANGELOG.md
|
||||
* **examples/#**: for the example apps directory, replacing # with the example app number
|
||||
* **sample/#**: for the example apps directory, replacing # with the example app number
|
||||
<!-- * **aio**: used for docs-app (angular.io) related changes within the /aio directory of the repo -->
|
||||
* none/empty string: useful for `style`, `test` and `refactor` changes that are done across all packages (e.g. `style: add missing semicolons`)
|
||||
|
||||
|
||||
19
Readme.md
19
Readme.md
@@ -14,7 +14,7 @@
|
||||
<a href="https://www.npmjs.com/~nestjscore"><img src="https://img.shields.io/npm/dm/@nestjs/core.svg" alt="NPM Downloads" /></a>
|
||||
<a href="https://travis-ci.org/nestjs/nest"><img src="https://api.travis-ci.org/nestjs/nest.svg?branch=master" alt="Travis" /></a>
|
||||
<a href="https://travis-ci.org/nestjs/nest"><img src="https://img.shields.io/travis/nestjs/nest/master.svg?label=linux" alt="Linux" /></a>
|
||||
<a href="https://coveralls.io/github/nestjs/nest?branch=master"><img src="https://coveralls.io/repos/github/nestjs/nest/badge.svg?branch=master#6" alt="Coverage" /></a>
|
||||
<a href="https://coveralls.io/github/nestjs/nest?branch=master"><img src="https://coveralls.io/repos/github/nestjs/nest/badge.svg?branch=master#7" alt="Coverage" /></a>
|
||||
<a href="https://gitter.im/nestjs/nestjs?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=body_badge"><img src="https://badges.gitter.im/nestjs/nestjs.svg" alt="Gitter" /></a>
|
||||
<a href="https://opencollective.com/nest#backer"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
|
||||
<a href="https://opencollective.com/nest#sponsor"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
|
||||
@@ -37,7 +37,8 @@
|
||||
|
||||
## Getting started
|
||||
|
||||
To check out the [guide](https://docs.nestjs.com), visit [docs.nestjs.com](https://docs.nestjs.com). :books:
|
||||
* To check out the [guide](https://docs.nestjs.com), visit [docs.nestjs.com](https://docs.nestjs.com). :books:
|
||||
* 要查看中文 [指南](readme_zh.md), 请访问 [docs.nestjs.cn](https://docs.nestjs.cn). :books:
|
||||
|
||||
## Support
|
||||
|
||||
@@ -45,11 +46,19 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
|
||||
|
||||
#### Principal Sponsor
|
||||
|
||||
<a href="https://valor-software.com/"><img src="https://docs.nestjs.com/assets/sponsors/valor-software.png" width="300" /></a>
|
||||
<a href="https://valor-software.com/"><img src="https://docs.nestjs.com/assets/sponsors/valor-software.png" width="320" /></a>
|
||||
|
||||
#### Gold Sponsors
|
||||
|
||||
<a href="http://xtremis.com/"><img src="https://nestjs.com/img/logo-xtremis.svg" width="220" /></a>
|
||||
|
||||
#### Silver Sponsors
|
||||
|
||||
<a href="https://neoteric.eu/"><img src="https://nestjs.com/img/neoteric-cut.png" width="120" /></a> <a href="https://www.swingdev.io"><img src="https://nestjs.com/img/swingdev-logo.svg#1" width="150" /></a>
|
||||
|
||||
#### Sponsors
|
||||
|
||||
<a href="https://scal.io"><img src="https://nestjs.com/img/scalio-logo.svg" width="120" /></a> <a href="https://www.swingdev.io"><img src="https://nestjs.com/img/swingdev-logo.svg#1" width="120" /></a> <a href="http://angularity.io"><img src="http://angularity.io/media/logo.svg" height="32" /></a> <a href="http://gojob.com"><img src="https://gojob.com/w/wp-content/uploads/2017/02/cropped-Logo-web-home.png" height="44" /></a>
|
||||
<a href="https://scal.io"><img src="https://nestjs.com/img/scalio-logo.svg" width="110" /></a> <a href="http://angularity.io"><img src="http://angularity.io/media/logo.svg" height="30" /></a> <a href="http://gojob.com"><img src="https://gojob.com/w/wp-content/uploads/2017/02/cropped-Logo-web-home.png" height="40" /> <!--<a href="https://keycdn.com"><img src="https://nestjs.com/img/keycdn.svg" height="30" /></a> --> <a href="https://hostpresto.com"><img src="https://nestjs.com/img/hostpresto.png" height="30" /></a>
|
||||
|
||||
## Backers
|
||||
|
||||
@@ -64,5 +73,3 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
|
||||
## License
|
||||
|
||||
Nest is [MIT licensed](LICENSE).
|
||||
|
||||
<h4 align="center"> <a href="readme_zh.md">中文说明</a></h4>
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
<a href="https://www.npmjs.com/~nestjscore"><img src="https://img.shields.io/npm/dm/@nestjs/core.svg" alt="NPM Downloads" /></a>
|
||||
<a href="https://travis-ci.org/nestjs/nest"><img src="https://api.travis-ci.org/nestjs/nest.svg?branch=master" alt="Travis" /></a>
|
||||
<a href="https://travis-ci.org/nestjs/nest"><img src="https://img.shields.io/travis/nestjs/nest/master.svg?label=linux" alt="Linux" /></a>
|
||||
<a href="https://coveralls.io/github/nestjs/nest?branch=master"><img src="https://coveralls.io/repos/github/nestjs/nest/badge.svg?branch=master#5" alt="Coverage" /></a>
|
||||
<a href="https://coveralls.io/github/nestjs/nest?branch=master"><img src="https://coveralls.io/repos/github/nestjs/nest/badge.svg?branch=master#7" alt="Coverage" /></a>
|
||||
<a href="https://gitter.im/nestjs/nestjs?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=body_badge"><img src="https://badges.gitter.im/nestjs/nestjs.svg" alt="Gitter" /></a>
|
||||
<a href="https://opencollective.com/nest#backer"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
|
||||
<a href="https://opencollective.com/nest#sponsor"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
|
||||
@@ -37,7 +37,8 @@
|
||||
|
||||
## Getting started
|
||||
|
||||
To check out the [guide](https://docs.nestjs.com), visit [docs.nestjs.com](https://docs.nestjs.com). :books:
|
||||
* To check out the [guide](https://docs.nestjs.com), visit [docs.nestjs.com](https://docs.nestjs.com). :books:
|
||||
* 要查看中文 [指南](readme_zh.md), 请访问 [docs.nestjs.cn](https://docs.nestjs.cn). :books:
|
||||
|
||||
## Support
|
||||
|
||||
@@ -45,58 +46,23 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
|
||||
|
||||
#### Principal Sponsor
|
||||
|
||||
<a href="https://valor-software.com/"><img src="https://docs.nestjs.com/assets/sponsors/valor-software.png" width="300" /></a>
|
||||
<a href="https://valor-software.com/"><img src="https://docs.nestjs.com/assets/sponsors/valor-software.png" width="320" /></a>
|
||||
|
||||
#### Gold Sponsors
|
||||
|
||||
<a href="http://xtremis.com/"><img src="https://nestjs.com/img/logo-xtremis.svg" width="220" /></a>
|
||||
|
||||
#### Silver Sponsors
|
||||
|
||||
<a href="https://neoteric.eu/"><img src="https://nestjs.com/img/neoteric-cut.png" width="120" /></a> <a href="https://www.swingdev.io"><img src="https://nestjs.com/img/swingdev-logo.svg#1" width="150" /></a>
|
||||
|
||||
#### Sponsors
|
||||
|
||||
<a href="https://scal.io"><img src="https://nestjs.com/img/scalio-logo.svg" width="150" /></a> <a href="https://www.swingdev.io"><img src="https://nestjs.com/img/swingdev-logo.svg#1" width="150" /></a>
|
||||
<a href="https://scal.io"><img src="https://nestjs.com/img/scalio-logo.svg" width="110" /></a> <a href="http://angularity.io"><img src="http://angularity.io/media/logo.svg" height="30" /></a> <a href="http://gojob.com"><img src="https://gojob.com/w/wp-content/uploads/2017/02/cropped-Logo-web-home.png" height="40" /> <!--<a href="https://keycdn.com"><img src="https://nestjs.com/img/keycdn.svg" height="30" /></a> --> <a href="https://hostpresto.com"><img src="https://nestjs.com/img/hostpresto.png" height="30" /></a>
|
||||
|
||||
## Backers
|
||||
|
||||
<a href="https://opencollective.com/nest/backer/0/website" target="_blank"><img src="https://opencollective.com/nest/backer/0/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/nest/backer/1/website" target="_blank"><img src="https://opencollective.com/nest/backer/1/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/nest/backer/2/website" target="_blank"><img src="https://opencollective.com/nest/backer/2/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/nest/backer/3/website" target="_blank"><img src="https://opencollective.com/nest/backer/3/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/nest/backer/4/website" target="_blank"><img src="https://opencollective.com/nest/backer/4/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/nest/backer/5/website" target="_blank"><img src="https://opencollective.com/nest/backer/5/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/nest/backer/6/website" target="_blank"><img src="https://opencollective.com/nest/backer/6/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/nest/backer/7/website" target="_blank"><img src="https://opencollective.com/nest/backer/7/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/nest/backer/8/website" target="_blank"><img src="https://opencollective.com/nest/backer/8/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/nest/backer/9/website" target="_blank"><img src="https://opencollective.com/nest/backer/9/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/nest/backer/10/website" target="_blank"><img src="https://opencollective.com/nest/backer/10/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/nest/backer/11/website" target="_blank"><img src="https://opencollective.com/nest/backer/11/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/nest/backer/12/website" target="_blank"><img src="https://opencollective.com/nest/backer/12/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/nest/backer/13/website" target="_blank"><img src="https://opencollective.com/nest/backer/13/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/nest/backer/14/website" target="_blank"><img src="https://opencollective.com/nest/backer/14/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/nest/backer/15/website" target="_blank"><img src="https://opencollective.com/nest/backer/15/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/nest/backer/16/website" target="_blank"><img src="https://opencollective.com/nest/backer/16/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/nest/backer/17/website" target="_blank"><img src="https://opencollective.com/nest/backer/17/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/nest/backer/18/website" target="_blank"><img src="https://opencollective.com/nest/backer/18/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/nest/backer/19/website" target="_blank"><img src="https://opencollective.com/nest/backer/19/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/nest/backer/20/website" target="_blank"><img src="https://opencollective.com/nest/backer/20/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/nest/backer/21/website" target="_blank"><img src="https://opencollective.com/nest/backer/21/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/nest/backer/22/website" target="_blank"><img src="https://opencollective.com/nest/backer/22/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/nest/backer/23/website" target="_blank"><img src="https://opencollective.com/nest/backer/23/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/nest/backer/24/website" target="_blank"><img src="https://opencollective.com/nest/backer/24/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/nest/backer/25/website" target="_blank"><img src="https://opencollective.com/nest/backer/25/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/nest/backer/26/website" target="_blank"><img src="https://opencollective.com/nest/backer/26/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/nest/backer/27/website" target="_blank"><img src="https://opencollective.com/nest/backer/27/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/nest/backer/28/website" target="_blank"><img src="https://opencollective.com/nest/backer/28/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/nest/backer/29/website" target="_blank"><img src="https://opencollective.com/nest/backer/29/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/nest/backer/30/website" target="_blank"><img src="https://opencollective.com/nest/backer/30/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/nest/backer/31/website" target="_blank"><img src="https://opencollective.com/nest/backer/31/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/nest/backer/32/website" target="_blank"><img src="https://opencollective.com/nest/backer/32/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/nest/backer/33/website" target="_blank"><img src="https://opencollective.com/nest/backer/33/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/nest/backer/34/website" target="_blank"><img src="https://opencollective.com/nest/backer/34/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/nest/backer/35/website" target="_blank"><img src="https://opencollective.com/nest/backer/35/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/nest/backer/36/website" target="_blank"><img src="https://opencollective.com/nest/backer/36/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/nest/backer/37/website" target="_blank"><img src="https://opencollective.com/nest/backer/37/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/nest/backer/38/website" target="_blank"><img src="https://opencollective.com/nest/backer/38/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/nest/backer/39/website" target="_blank"><img src="https://opencollective.com/nest/backer/39/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/nest/backer/40/website" target="_blank"><img src="https://opencollective.com/nest/backer/40/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/nest/backer/41/website" target="_blank"><img src="https://opencollective.com/nest/backer/41/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/nest/backer/42/website" target="_blank"><img src="https://opencollective.com/nest/backer/42/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/nest/backer/43/website" target="_blank"><img src="https://opencollective.com/nest/backer/43/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/nest"><img src="https://opencollective.com/nest/backers.svg?width=890"></a>
|
||||
|
||||
## Stay in touch
|
||||
|
||||
@@ -107,5 +73,3 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
|
||||
## License
|
||||
|
||||
Nest is [MIT licensed](LICENSE).
|
||||
|
||||
<h4 align="center"> <a href="readme_zh.md">中文说明</a></h4>
|
||||
|
||||
3
bundle/common/cache/cache.constants.d.ts
vendored
Normal file
3
bundle/common/cache/cache.constants.d.ts
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export declare const CACHE_MANAGER = "CACHE_MANAGER";
|
||||
export declare const CACHE_MODULE_OPTIONS = "CACHE_MODULE_OPTIONS";
|
||||
export declare const CACHE_KEY_METADATA = "cache_module:cache_key";
|
||||
5
bundle/common/cache/cache.constants.js
vendored
Normal file
5
bundle/common/cache/cache.constants.js
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CACHE_MANAGER = 'CACHE_MANAGER';
|
||||
exports.CACHE_MODULE_OPTIONS = 'CACHE_MODULE_OPTIONS';
|
||||
exports.CACHE_KEY_METADATA = 'cache_module:cache_key';
|
||||
8
bundle/common/cache/cache.module.d.ts
vendored
Normal file
8
bundle/common/cache/cache.module.d.ts
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import { DynamicModule } from '../interfaces';
|
||||
import { CacheModuleAsyncOptions, CacheModuleOptions } from './interfaces/cache-module.interface';
|
||||
export declare class CacheModule {
|
||||
static register(options?: CacheModuleOptions): DynamicModule;
|
||||
static registerAsync(options: CacheModuleAsyncOptions): DynamicModule;
|
||||
private static createAsyncProviders(options);
|
||||
private static createAsyncOptionsProvider(options);
|
||||
}
|
||||
60
bundle/common/cache/cache.module.js
vendored
Normal file
60
bundle/common/cache/cache.module.js
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const decorators_1 = require("../decorators");
|
||||
const cache_constants_1 = require("./cache.constants");
|
||||
const cache_providers_1 = require("./cache.providers");
|
||||
let CacheModule = CacheModule_1 = class CacheModule {
|
||||
static register(options = {}) {
|
||||
return {
|
||||
module: CacheModule_1,
|
||||
providers: [{ provide: cache_constants_1.CACHE_MODULE_OPTIONS, useValue: options }],
|
||||
};
|
||||
}
|
||||
static registerAsync(options) {
|
||||
return {
|
||||
module: CacheModule_1,
|
||||
imports: options.imports,
|
||||
providers: this.createAsyncProviders(options),
|
||||
};
|
||||
}
|
||||
static createAsyncProviders(options) {
|
||||
if (options.useExisting || options.useFactory) {
|
||||
return [this.createAsyncOptionsProvider(options)];
|
||||
}
|
||||
return [
|
||||
this.createAsyncOptionsProvider(options),
|
||||
{
|
||||
provide: options.useClass,
|
||||
useClass: options.useClass,
|
||||
},
|
||||
];
|
||||
}
|
||||
static createAsyncOptionsProvider(options) {
|
||||
if (options.useFactory) {
|
||||
return {
|
||||
provide: cache_constants_1.CACHE_MODULE_OPTIONS,
|
||||
useFactory: options.useFactory,
|
||||
inject: options.inject || [],
|
||||
};
|
||||
}
|
||||
return {
|
||||
provide: cache_constants_1.CACHE_MODULE_OPTIONS,
|
||||
useFactory: async (optionsFactory) => await optionsFactory.createCacheOptions(),
|
||||
inject: [options.useExisting || options.useClass],
|
||||
};
|
||||
}
|
||||
};
|
||||
CacheModule = CacheModule_1 = __decorate([
|
||||
decorators_1.Module({
|
||||
providers: [cache_providers_1.createCacheManager()],
|
||||
exports: [cache_constants_1.CACHE_MANAGER],
|
||||
})
|
||||
], CacheModule);
|
||||
exports.CacheModule = CacheModule;
|
||||
var CacheModule_1;
|
||||
2
bundle/common/cache/cache.providers.d.ts
vendored
Normal file
2
bundle/common/cache/cache.providers.d.ts
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import { Provider } from '../interfaces';
|
||||
export declare function createCacheManager(): Provider;
|
||||
17
bundle/common/cache/cache.providers.js
vendored
Normal file
17
bundle/common/cache/cache.providers.js
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const load_package_util_1 = require("../utils/load-package.util");
|
||||
const cache_constants_1 = require("./cache.constants");
|
||||
const default_options_1 = require("./default-options");
|
||||
function createCacheManager() {
|
||||
return {
|
||||
provide: cache_constants_1.CACHE_MANAGER,
|
||||
useFactory: (options) => {
|
||||
const cacheManager = load_package_util_1.loadPackage('cache-manager', 'CacheModule');
|
||||
const memoryCache = cacheManager.caching(Object.assign({}, default_options_1.defaultCacheOptions, (options || {})));
|
||||
return memoryCache;
|
||||
},
|
||||
inject: [cache_constants_1.CACHE_MODULE_OPTIONS],
|
||||
};
|
||||
}
|
||||
exports.createCacheManager = createCacheManager;
|
||||
1
bundle/common/cache/decorators/cache-key.decorator.d.ts
vendored
Normal file
1
bundle/common/cache/decorators/cache-key.decorator.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export declare const CacheKey: (key: string) => (target: object, key?: any, descriptor?: any) => any;
|
||||
5
bundle/common/cache/decorators/cache-key.decorator.js
vendored
Normal file
5
bundle/common/cache/decorators/cache-key.decorator.js
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const decorators_1 = require("../../decorators");
|
||||
const cache_constants_1 = require("../cache.constants");
|
||||
exports.CacheKey = (key) => decorators_1.ReflectMetadata(cache_constants_1.CACHE_KEY_METADATA, key);
|
||||
1
bundle/common/cache/decorators/index.d.ts
vendored
Normal file
1
bundle/common/cache/decorators/index.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export * from './cache-key.decorator';
|
||||
6
bundle/common/cache/decorators/index.js
vendored
Normal file
6
bundle/common/cache/decorators/index.js
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
"use strict";
|
||||
function __export(m) {
|
||||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
||||
}
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
__export(require("./cache-key.decorator"));
|
||||
5
bundle/common/cache/default-options.d.ts
vendored
Normal file
5
bundle/common/cache/default-options.d.ts
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
export declare const defaultCacheOptions: {
|
||||
ttl: number;
|
||||
max: number;
|
||||
store: string;
|
||||
};
|
||||
7
bundle/common/cache/default-options.js
vendored
Normal file
7
bundle/common/cache/default-options.js
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.defaultCacheOptions = {
|
||||
ttl: 5,
|
||||
max: 100,
|
||||
store: 'memory',
|
||||
};
|
||||
5
bundle/common/cache/index.d.ts
vendored
Normal file
5
bundle/common/cache/index.d.ts
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
export { CACHE_MANAGER } from './cache.constants';
|
||||
export * from './cache.module';
|
||||
export * from './decorators';
|
||||
export * from './interceptors';
|
||||
export * from './interfaces';
|
||||
10
bundle/common/cache/index.js
vendored
Normal file
10
bundle/common/cache/index.js
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
"use strict";
|
||||
function __export(m) {
|
||||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
||||
}
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var cache_constants_1 = require("./cache.constants");
|
||||
exports.CACHE_MANAGER = cache_constants_1.CACHE_MANAGER;
|
||||
__export(require("./cache.module"));
|
||||
__export(require("./decorators"));
|
||||
__export(require("./interceptors"));
|
||||
11
bundle/common/cache/interceptors/cache.interceptor.d.ts
vendored
Normal file
11
bundle/common/cache/interceptors/cache.interceptor.d.ts
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
import { Observable } from 'rxjs';
|
||||
import { ExecutionContext, HttpServer, NestInterceptor } from '../../interfaces';
|
||||
export declare class CacheInterceptor implements NestInterceptor {
|
||||
protected readonly httpServer: HttpServer;
|
||||
protected readonly cacheManager: any;
|
||||
protected readonly reflector: any;
|
||||
protected readonly isHttpApp: boolean;
|
||||
constructor(httpServer: HttpServer, cacheManager: any, reflector: any);
|
||||
intercept(context: ExecutionContext, call$: Observable<any>): Promise<Observable<any>>;
|
||||
trackBy(context: ExecutionContext): string | undefined;
|
||||
}
|
||||
68
bundle/common/cache/interceptors/cache.interceptor.js
vendored
Normal file
68
bundle/common/cache/interceptors/cache.interceptor.js
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
return function (target, key) { decorator(target, key, paramIndex); }
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const rxjs_1 = require("rxjs");
|
||||
const operators_1 = require("rxjs/operators");
|
||||
const decorators_1 = require("../../decorators");
|
||||
const cache_constants_1 = require("../cache.constants");
|
||||
// NOTE (external)
|
||||
// We need to deduplicate them here due to the circular dependency
|
||||
// between core and common packages
|
||||
const HTTP_SERVER_REF = 'HTTP_SERVER_REF';
|
||||
const REFLECTOR = 'Reflector';
|
||||
let CacheInterceptor = class CacheInterceptor {
|
||||
constructor(httpServer, cacheManager, reflector) {
|
||||
this.httpServer = httpServer;
|
||||
this.cacheManager = cacheManager;
|
||||
this.reflector = reflector;
|
||||
this.isHttpApp = httpServer && !!httpServer.getRequestMethod;
|
||||
}
|
||||
async intercept(context, call$) {
|
||||
const key = this.trackBy(context);
|
||||
if (!key) {
|
||||
return call$;
|
||||
}
|
||||
try {
|
||||
const value = await this.cacheManager.get(key);
|
||||
if (value) {
|
||||
return rxjs_1.of(value);
|
||||
}
|
||||
return call$.pipe(operators_1.tap(response => this.cacheManager.set(key, response)));
|
||||
}
|
||||
catch (_a) {
|
||||
return call$;
|
||||
}
|
||||
}
|
||||
trackBy(context) {
|
||||
if (!this.isHttpApp) {
|
||||
return this.reflector.get(cache_constants_1.CACHE_KEY_METADATA, context.getHandler());
|
||||
}
|
||||
const request = context.getArgByIndex(0);
|
||||
const excludePaths = [];
|
||||
if (this.httpServer.getRequestMethod(request) !== 'GET' ||
|
||||
excludePaths.includes(this.httpServer.getRequestUrl)) {
|
||||
return undefined;
|
||||
}
|
||||
return this.httpServer.getRequestUrl(context.getArgByIndex(0));
|
||||
}
|
||||
};
|
||||
CacheInterceptor = __decorate([
|
||||
decorators_1.Injectable(),
|
||||
__param(0, decorators_1.Optional()),
|
||||
__param(0, decorators_1.Inject(HTTP_SERVER_REF)),
|
||||
__param(1, decorators_1.Inject(cache_constants_1.CACHE_MANAGER)),
|
||||
__param(2, decorators_1.Inject(REFLECTOR)),
|
||||
__metadata("design:paramtypes", [Object, Object, Object])
|
||||
], CacheInterceptor);
|
||||
exports.CacheInterceptor = CacheInterceptor;
|
||||
1
bundle/common/cache/interceptors/index.d.ts
vendored
Normal file
1
bundle/common/cache/interceptors/index.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export * from './cache.interceptor';
|
||||
6
bundle/common/cache/interceptors/index.js
vendored
Normal file
6
bundle/common/cache/interceptors/index.js
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
"use strict";
|
||||
function __export(m) {
|
||||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
||||
}
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
__export(require("./cache.interceptor"));
|
||||
17
bundle/common/cache/interfaces/cache-manager.interface.d.ts
vendored
Normal file
17
bundle/common/cache/interfaces/cache-manager.interface.d.ts
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
export interface LiteralObject {
|
||||
[key: string]: any;
|
||||
}
|
||||
export interface CacheStore {
|
||||
set<T>(key: string, value: T): Promise<void> | void;
|
||||
get<T>(key: string): Promise<void> | void;
|
||||
del(key: string): void | Promise<void>;
|
||||
}
|
||||
export interface CacheStoreFactory {
|
||||
create(args: LiteralObject): CacheStore;
|
||||
}
|
||||
export interface CacheManagerOptions {
|
||||
store?: string | CacheStoreFactory;
|
||||
ttl?: number;
|
||||
max?: number;
|
||||
isCacheableValue?: (value: any) => boolean;
|
||||
}
|
||||
2
bundle/common/cache/interfaces/cache-manager.interface.js
vendored
Normal file
2
bundle/common/cache/interfaces/cache-manager.interface.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
14
bundle/common/cache/interfaces/cache-module.interface.d.ts
vendored
Normal file
14
bundle/common/cache/interfaces/cache-module.interface.d.ts
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
import { ModuleMetadata, Type } from './../../interfaces';
|
||||
import { CacheManagerOptions } from './cache-manager.interface';
|
||||
export interface CacheModuleOptions extends CacheManagerOptions {
|
||||
[key: string]: any;
|
||||
}
|
||||
export interface CacheOptionsFactory {
|
||||
createCacheOptions(): Promise<CacheModuleOptions> | CacheModuleOptions;
|
||||
}
|
||||
export interface CacheModuleAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
|
||||
useExisting?: Type<CacheOptionsFactory>;
|
||||
useClass?: Type<CacheOptionsFactory>;
|
||||
useFactory?: (...args: any[]) => Promise<CacheModuleOptions> | CacheModuleOptions;
|
||||
inject?: any[];
|
||||
}
|
||||
2
bundle/common/cache/interfaces/cache-module.interface.js
vendored
Normal file
2
bundle/common/cache/interfaces/cache-module.interface.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
2
bundle/common/cache/interfaces/index.d.ts
vendored
Normal file
2
bundle/common/cache/interfaces/index.d.ts
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from './cache-manager.interface';
|
||||
export * from './cache-module.interface';
|
||||
2
bundle/common/cache/interfaces/index.js
vendored
Normal file
2
bundle/common/cache/interfaces/index.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
1
bundle/common/constants.d.ts
vendored
1
bundle/common/constants.d.ts
vendored
@@ -11,6 +11,7 @@ export declare const GLOBAL_MODULE_METADATA = "__globalModule__";
|
||||
export declare const PATH_METADATA = "path";
|
||||
export declare const PARAMTYPES_METADATA = "design:paramtypes";
|
||||
export declare const SELF_DECLARED_DEPS_METADATA = "self:paramtypes";
|
||||
export declare const OPTIONAL_DEPS_METADATA = "optional:paramtypes";
|
||||
export declare const METHOD_METADATA = "method";
|
||||
export declare const ROUTE_ARGS_METADATA = "__routeArguments__";
|
||||
export declare const CUSTOM_ROUTE_AGRS_METADATA = "__customRouteArgs__";
|
||||
|
||||
@@ -13,6 +13,7 @@ exports.GLOBAL_MODULE_METADATA = '__globalModule__';
|
||||
exports.PATH_METADATA = 'path';
|
||||
exports.PARAMTYPES_METADATA = 'design:paramtypes';
|
||||
exports.SELF_DECLARED_DEPS_METADATA = 'self:paramtypes';
|
||||
exports.OPTIONAL_DEPS_METADATA = 'optional:paramtypes';
|
||||
exports.METHOD_METADATA = 'method';
|
||||
exports.ROUTE_ARGS_METADATA = '__routeArguments__';
|
||||
exports.CUSTOM_ROUTE_AGRS_METADATA = '__customRouteArgs__';
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'reflect-metadata';
|
||||
import { Type } from '../../interfaces';
|
||||
/**
|
||||
* Defines the Exceptions Filter. Takes set of exception types as an argument which has to be caught by this Filter.
|
||||
* The class should implement the `ExceptionFilter` interface.
|
||||
*/
|
||||
export declare function Catch(...exceptions: any[]): ClassDecorator;
|
||||
export declare function Catch(...exceptions: Type<any>[]): ClassDecorator;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const deprecate = require("deprecate");
|
||||
const uuid = require("uuid/v4");
|
||||
/**
|
||||
* Defines the injectable class. This class can inject dependencies through constructor.
|
||||
* Those dependencies have to belong to the same module.
|
||||
@@ -56,9 +57,8 @@ function Interceptor() {
|
||||
}
|
||||
exports.Interceptor = Interceptor;
|
||||
function mixin(mixinClass) {
|
||||
this.offset = this.offset ? ++this.offset : Math.random() * 100;
|
||||
Object.defineProperty(mixinClass, 'name', {
|
||||
value: JSON.stringify(this.offset),
|
||||
value: uuid(),
|
||||
});
|
||||
Injectable()(mixinClass);
|
||||
return mixinClass;
|
||||
|
||||
21
bundle/common/decorators/core/index.d.ts
vendored
21
bundle/common/decorators/core/index.d.ts
vendored
@@ -1,11 +1,12 @@
|
||||
export * from './controller.decorator';
|
||||
export * from './component.decorator';
|
||||
export * from './dependencies.decorator';
|
||||
export * from './inject.decorator';
|
||||
export * from './catch.decorator';
|
||||
export * from './exception-filters.decorator';
|
||||
export * from './use-pipes.decorator';
|
||||
export * from './use-guards.decorator';
|
||||
export * from './reflect-metadata.decorator';
|
||||
export * from './use-interceptors.decorator';
|
||||
export * from './bind.decorator';
|
||||
export * from './catch.decorator';
|
||||
export * from './component.decorator';
|
||||
export * from './controller.decorator';
|
||||
export * from './dependencies.decorator';
|
||||
export * from './exception-filters.decorator';
|
||||
export * from './inject.decorator';
|
||||
export * from './optional.decorator';
|
||||
export * from './reflect-metadata.decorator';
|
||||
export * from './use-guards.decorator';
|
||||
export * from './use-interceptors.decorator';
|
||||
export * from './use-pipes.decorator';
|
||||
|
||||
@@ -3,14 +3,15 @@ function __export(m) {
|
||||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
||||
}
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
__export(require("./controller.decorator"));
|
||||
__export(require("./component.decorator"));
|
||||
__export(require("./dependencies.decorator"));
|
||||
__export(require("./inject.decorator"));
|
||||
__export(require("./catch.decorator"));
|
||||
__export(require("./exception-filters.decorator"));
|
||||
__export(require("./use-pipes.decorator"));
|
||||
__export(require("./use-guards.decorator"));
|
||||
__export(require("./reflect-metadata.decorator"));
|
||||
__export(require("./use-interceptors.decorator"));
|
||||
__export(require("./bind.decorator"));
|
||||
__export(require("./catch.decorator"));
|
||||
__export(require("./component.decorator"));
|
||||
__export(require("./controller.decorator"));
|
||||
__export(require("./dependencies.decorator"));
|
||||
__export(require("./exception-filters.decorator"));
|
||||
__export(require("./inject.decorator"));
|
||||
__export(require("./optional.decorator"));
|
||||
__export(require("./reflect-metadata.decorator"));
|
||||
__export(require("./use-guards.decorator"));
|
||||
__export(require("./use-interceptors.decorator"));
|
||||
__export(require("./use-pipes.decorator"));
|
||||
|
||||
@@ -3,4 +3,4 @@ import 'reflect-metadata';
|
||||
* Injects provider which has to be available in the current injector (module) scope.
|
||||
* Providers are recognized by types or tokens.
|
||||
*/
|
||||
export declare function Inject(token: any): ParameterDecorator;
|
||||
export declare function Inject<T = any>(token: T): ParameterDecorator;
|
||||
|
||||
5
bundle/common/decorators/core/optional.decorator.d.ts
vendored
Normal file
5
bundle/common/decorators/core/optional.decorator.d.ts
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
import 'reflect-metadata';
|
||||
/**
|
||||
* Sets dependency as an optional one.
|
||||
*/
|
||||
export declare function Optional(): ParameterDecorator;
|
||||
14
bundle/common/decorators/core/optional.decorator.js
Normal file
14
bundle/common/decorators/core/optional.decorator.js
Normal file
@@ -0,0 +1,14 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
require("reflect-metadata");
|
||||
const constants_1 = require("../../constants");
|
||||
/**
|
||||
* Sets dependency as an optional one.
|
||||
*/
|
||||
function Optional() {
|
||||
return (target, key, index) => {
|
||||
const args = Reflect.getMetadata(constants_1.OPTIONAL_DEPS_METADATA, target) || [];
|
||||
Reflect.defineMetadata(constants_1.OPTIONAL_DEPS_METADATA, [...args, index], target);
|
||||
};
|
||||
}
|
||||
exports.Optional = Optional;
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Assigns the metadata to the class / function under specified `key`.
|
||||
* Assigns the metadata to the class/function under specified `key`.
|
||||
* This metadata can be reflected using `Reflector` class.
|
||||
*/
|
||||
export declare const ReflectMetadata: (metadataKey: any, metadataValue: any) => (target: object, key?: any, descriptor?: any) => any;
|
||||
export declare const ReflectMetadata: <K = any, V = any>(metadataKey: K, metadataValue: V) => (target: object, key?: any, descriptor?: any) => any;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
/**
|
||||
* Assigns the metadata to the class / function under specified `key`.
|
||||
* Assigns the metadata to the class/function under specified `key`.
|
||||
* This metadata can be reflected using `Reflector` class.
|
||||
*/
|
||||
exports.ReflectMetadata = (metadataKey, metadataValue) => (target, key, descriptor) => {
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
import { CustomParamFactory } from '../../interfaces/features/custom-route-param-factory.interface';
|
||||
import { PipeTransform } from '../../index';
|
||||
import { Type } from '../../interfaces';
|
||||
import { CustomParamFactory } from '../../interfaces/features/custom-route-param-factory.interface';
|
||||
export declare type ParamDecoratorEnhancer = ParameterDecorator;
|
||||
/**
|
||||
* Creates HTTP route param decorator
|
||||
* Defines HTTP route param decorator
|
||||
* @param factory
|
||||
*/
|
||||
export declare function createParamDecorator(factory: CustomParamFactory): (data?: any, ...pipes: PipeTransform<any>[]) => ParameterDecorator;
|
||||
export declare function createParamDecorator(factory: CustomParamFactory, enhancers?: ParamDecoratorEnhancer[]): (...dataOrPipes: (Type<PipeTransform> | PipeTransform | any)[]) => ParameterDecorator;
|
||||
/**
|
||||
* Creates HTTP route param decorator
|
||||
* Defines HTTP route param decorator
|
||||
* @deprecated
|
||||
* @param factory
|
||||
*/
|
||||
export declare function createRouteParamDecorator(factory: CustomParamFactory): (data?: any, ...pipes: PipeTransform<any>[]) => ParameterDecorator;
|
||||
export declare function createRouteParamDecorator(factory: CustomParamFactory): (data?: any, ...pipes: (Type<PipeTransform> | PipeTransform)[]) => ParameterDecorator;
|
||||
|
||||
@@ -1,30 +1,35 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const deprecate = require("deprecate");
|
||||
const uuid = require("uuid/v4");
|
||||
const constants_1 = require("../../constants");
|
||||
const shared_utils_1 = require("../../utils/shared.utils");
|
||||
const assignCustomMetadata = (args, paramtype, index, factory, data, ...pipes) => (Object.assign({}, args, { [`${paramtype}${constants_1.CUSTOM_ROUTE_AGRS_METADATA}:${index}`]: {
|
||||
index,
|
||||
factory,
|
||||
data,
|
||||
pipes,
|
||||
} }));
|
||||
const randomString = () => Math.random()
|
||||
.toString(36)
|
||||
.substring(2, 15);
|
||||
/**
|
||||
* Creates HTTP route param decorator
|
||||
* Defines HTTP route param decorator
|
||||
* @param factory
|
||||
*/
|
||||
function createParamDecorator(factory) {
|
||||
const paramtype = randomString() + randomString();
|
||||
function createParamDecorator(factory, enhancers = []) {
|
||||
const paramtype = uuid();
|
||||
return (data, ...pipes) => (target, key, index) => {
|
||||
const args = Reflect.getMetadata(constants_1.ROUTE_ARGS_METADATA, target.constructor, key) || {};
|
||||
Reflect.defineMetadata(constants_1.ROUTE_ARGS_METADATA, assignCustomMetadata(args, paramtype, index, factory, data, ...pipes), target.constructor, key);
|
||||
const isPipe = pipe => pipe &&
|
||||
((shared_utils_1.isFunction(pipe) && pipe.prototype) || shared_utils_1.isFunction(pipe.transform));
|
||||
const hasParamData = shared_utils_1.isNil(data) || !isPipe(data);
|
||||
const paramData = hasParamData ? data : undefined;
|
||||
const paramPipes = hasParamData ? pipes : [data, ...pipes];
|
||||
Reflect.defineMetadata(constants_1.ROUTE_ARGS_METADATA, assignCustomMetadata(args, paramtype, index, factory, paramData, ...paramPipes), target.constructor, key);
|
||||
enhancers.forEach(fn => fn(target, key, index));
|
||||
};
|
||||
}
|
||||
exports.createParamDecorator = createParamDecorator;
|
||||
/**
|
||||
* Creates HTTP route param decorator
|
||||
* Defines HTTP route param decorator
|
||||
* @deprecated
|
||||
* @param factory
|
||||
*/
|
||||
|
||||
@@ -12,7 +12,7 @@ export declare const Request: () => ParameterDecorator;
|
||||
export declare const Response: () => ParameterDecorator;
|
||||
export declare const Next: () => ParameterDecorator;
|
||||
export declare const Session: () => ParameterDecorator;
|
||||
export declare const UploadedFile: () => ParameterDecorator;
|
||||
export declare const UploadedFile: (fileKey?: string) => ParameterDecorator;
|
||||
export declare const UploadedFiles: () => ParameterDecorator;
|
||||
export declare const Headers: (property?: string) => ParameterDecorator;
|
||||
export declare function Query(): any;
|
||||
|
||||
10
bundle/common/exceptions/im-a-teapot.exception.d.ts
vendored
Normal file
10
bundle/common/exceptions/im-a-teapot.exception.d.ts
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
import { HttpException } from './http.exception';
|
||||
/**
|
||||
* Any attempt to brew coffee with a teapot should result in the error code "418 I'm a teapot".
|
||||
* The resulting entity body MAY be short and stout.
|
||||
*
|
||||
* http://save418.com/
|
||||
*/
|
||||
export declare class ImATeapotException extends HttpException {
|
||||
constructor(message?: string | object | any, error?: string);
|
||||
}
|
||||
17
bundle/common/exceptions/im-a-teapot.exception.js
Normal file
17
bundle/common/exceptions/im-a-teapot.exception.js
Normal file
@@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const http_exception_1 = require("./http.exception");
|
||||
const http_status_enum_1 = require("../enums/http-status.enum");
|
||||
const http_exception_body_util_1 = require("../utils/http-exception-body.util");
|
||||
/**
|
||||
* Any attempt to brew coffee with a teapot should result in the error code "418 I'm a teapot".
|
||||
* The resulting entity body MAY be short and stout.
|
||||
*
|
||||
* http://save418.com/
|
||||
*/
|
||||
class ImATeapotException extends http_exception_1.HttpException {
|
||||
constructor(message, error = 'I\'m a teapot') {
|
||||
super(http_exception_body_util_1.createHttpExceptionBody(message, error, http_status_enum_1.HttpStatus.I_AM_A_TEAPOT), http_status_enum_1.HttpStatus.I_AM_A_TEAPOT);
|
||||
}
|
||||
}
|
||||
exports.ImATeapotException = ImATeapotException;
|
||||
1
bundle/common/exceptions/index.d.ts
vendored
1
bundle/common/exceptions/index.d.ts
vendored
@@ -16,3 +16,4 @@ export * from './not-implemented.exception';
|
||||
export * from './bad-gateway.exception';
|
||||
export * from './service-unavailable.exception';
|
||||
export * from './gateway-timeout.exception';
|
||||
export * from './im-a-teapot.exception';
|
||||
|
||||
@@ -21,3 +21,4 @@ __export(require("./not-implemented.exception"));
|
||||
__export(require("./bad-gateway.exception"));
|
||||
__export(require("./service-unavailable.exception"));
|
||||
__export(require("./gateway-timeout.exception"));
|
||||
__export(require("./im-a-teapot.exception"));
|
||||
|
||||
1
bundle/common/files/files.constants.d.ts
vendored
Normal file
1
bundle/common/files/files.constants.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export declare const MULTER_MODULE_OPTIONS = "MULTER_MODULE_OPTIONS";
|
||||
3
bundle/common/files/files.constants.js
Normal file
3
bundle/common/files/files.constants.js
Normal file
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.MULTER_MODULE_OPTIONS = 'MULTER_MODULE_OPTIONS';
|
||||
3
bundle/common/files/index.d.ts
vendored
Normal file
3
bundle/common/files/index.d.ts
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export * from './interceptors';
|
||||
export * from './interfaces';
|
||||
export * from './multer.module';
|
||||
7
bundle/common/files/index.js
Normal file
7
bundle/common/files/index.js
Normal file
@@ -0,0 +1,7 @@
|
||||
"use strict";
|
||||
function __export(m) {
|
||||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
||||
}
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
__export(require("./interceptors"));
|
||||
__export(require("./multer.module"));
|
||||
2
bundle/common/files/interceptors/file-fields.interceptor.d.ts
vendored
Normal file
2
bundle/common/files/interceptors/file-fields.interceptor.d.ts
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import { MulterField, MulterOptions } from '../../interfaces/external/multer-options.interface';
|
||||
export declare function FileFieldsInterceptor(uploadFields: MulterField[], localOptions?: MulterOptions): any;
|
||||
45
bundle/common/files/interceptors/file-fields.interceptor.js
Normal file
45
bundle/common/files/interceptors/file-fields.interceptor.js
Normal file
@@ -0,0 +1,45 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
return function (target, key) { decorator(target, key, paramIndex); }
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const multer = require("multer");
|
||||
const decorators_1 = require("../../decorators");
|
||||
const component_decorator_1 = require("../../decorators/core/component.decorator");
|
||||
const files_constants_1 = require("./../files.constants");
|
||||
const multer_utils_1 = require("./../multer/multer.utils");
|
||||
function FileFieldsInterceptor(uploadFields, localOptions) {
|
||||
let MixinInterceptor = class MixinInterceptor {
|
||||
constructor(options = {}) {
|
||||
this.upload = multer(Object.assign({}, options, localOptions));
|
||||
}
|
||||
async intercept(context, call$) {
|
||||
const ctx = context.switchToHttp();
|
||||
await new Promise((resolve, reject) => this.upload.fields(uploadFields)(ctx.getRequest(), ctx.getResponse(), err => {
|
||||
if (err) {
|
||||
const error = multer_utils_1.transformException(err);
|
||||
return reject(error);
|
||||
}
|
||||
resolve();
|
||||
}));
|
||||
return call$;
|
||||
}
|
||||
};
|
||||
MixinInterceptor = __decorate([
|
||||
__param(0, decorators_1.Optional()),
|
||||
__param(0, decorators_1.Inject(files_constants_1.MULTER_MODULE_OPTIONS)),
|
||||
__metadata("design:paramtypes", [Object])
|
||||
], MixinInterceptor);
|
||||
const Interceptor = component_decorator_1.mixin(MixinInterceptor);
|
||||
return Interceptor;
|
||||
}
|
||||
exports.FileFieldsInterceptor = FileFieldsInterceptor;
|
||||
2
bundle/common/files/interceptors/file.interceptor.d.ts
vendored
Normal file
2
bundle/common/files/interceptors/file.interceptor.d.ts
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import { MulterOptions } from '../../interfaces/external/multer-options.interface';
|
||||
export declare function FileInterceptor(fieldName: string, localOptions?: MulterOptions): any;
|
||||
45
bundle/common/files/interceptors/file.interceptor.js
Normal file
45
bundle/common/files/interceptors/file.interceptor.js
Normal file
@@ -0,0 +1,45 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
return function (target, key) { decorator(target, key, paramIndex); }
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const multer = require("multer");
|
||||
const decorators_1 = require("../../decorators");
|
||||
const component_decorator_1 = require("../../decorators/core/component.decorator");
|
||||
const files_constants_1 = require("./../files.constants");
|
||||
const multer_utils_1 = require("./../multer/multer.utils");
|
||||
function FileInterceptor(fieldName, localOptions) {
|
||||
let MixinInterceptor = class MixinInterceptor {
|
||||
constructor(options = {}) {
|
||||
this.upload = multer(Object.assign({}, options, localOptions));
|
||||
}
|
||||
async intercept(context, call$) {
|
||||
const ctx = context.switchToHttp();
|
||||
await new Promise((resolve, reject) => this.upload.single(fieldName)(ctx.getRequest(), ctx.getResponse(), err => {
|
||||
if (err) {
|
||||
const error = multer_utils_1.transformException(err);
|
||||
return reject(error);
|
||||
}
|
||||
resolve();
|
||||
}));
|
||||
return call$;
|
||||
}
|
||||
};
|
||||
MixinInterceptor = __decorate([
|
||||
__param(0, decorators_1.Optional()),
|
||||
__param(0, decorators_1.Inject(files_constants_1.MULTER_MODULE_OPTIONS)),
|
||||
__metadata("design:paramtypes", [Object])
|
||||
], MixinInterceptor);
|
||||
const Interceptor = component_decorator_1.mixin(MixinInterceptor);
|
||||
return Interceptor;
|
||||
}
|
||||
exports.FileInterceptor = FileInterceptor;
|
||||
2
bundle/common/files/interceptors/files.interceptor.d.ts
vendored
Normal file
2
bundle/common/files/interceptors/files.interceptor.d.ts
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import { MulterOptions } from '../../interfaces/external/multer-options.interface';
|
||||
export declare function FilesInterceptor(fieldName: string, maxCount?: number, localOptions?: MulterOptions): any;
|
||||
45
bundle/common/files/interceptors/files.interceptor.js
Normal file
45
bundle/common/files/interceptors/files.interceptor.js
Normal file
@@ -0,0 +1,45 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
return function (target, key) { decorator(target, key, paramIndex); }
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const multer = require("multer");
|
||||
const decorators_1 = require("../../decorators");
|
||||
const component_decorator_1 = require("../../decorators/core/component.decorator");
|
||||
const files_constants_1 = require("./../files.constants");
|
||||
const multer_utils_1 = require("./../multer/multer.utils");
|
||||
function FilesInterceptor(fieldName, maxCount, localOptions) {
|
||||
let MixinInterceptor = class MixinInterceptor {
|
||||
constructor(options = {}) {
|
||||
this.upload = multer(Object.assign({}, options, localOptions));
|
||||
}
|
||||
async intercept(context, call$) {
|
||||
const ctx = context.switchToHttp();
|
||||
await new Promise((resolve, reject) => this.upload.array(fieldName, maxCount)(ctx.getRequest(), ctx.getResponse(), err => {
|
||||
if (err) {
|
||||
const error = multer_utils_1.transformException(err);
|
||||
return reject(error);
|
||||
}
|
||||
resolve();
|
||||
}));
|
||||
return call$;
|
||||
}
|
||||
};
|
||||
MixinInterceptor = __decorate([
|
||||
__param(0, decorators_1.Optional()),
|
||||
__param(0, decorators_1.Inject(files_constants_1.MULTER_MODULE_OPTIONS)),
|
||||
__metadata("design:paramtypes", [Object])
|
||||
], MixinInterceptor);
|
||||
const Interceptor = component_decorator_1.mixin(MixinInterceptor);
|
||||
return Interceptor;
|
||||
}
|
||||
exports.FilesInterceptor = FilesInterceptor;
|
||||
3
bundle/common/files/interceptors/index.d.ts
vendored
Normal file
3
bundle/common/files/interceptors/index.d.ts
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export * from './file-fields.interceptor';
|
||||
export * from './file.interceptor';
|
||||
export * from './files.interceptor';
|
||||
8
bundle/common/files/interceptors/index.js
Normal file
8
bundle/common/files/interceptors/index.js
Normal file
@@ -0,0 +1,8 @@
|
||||
"use strict";
|
||||
function __export(m) {
|
||||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
||||
}
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
__export(require("./file-fields.interceptor"));
|
||||
__export(require("./file.interceptor"));
|
||||
__export(require("./files.interceptor"));
|
||||
13
bundle/common/files/interfaces/files-upload-module.interface.d.ts
vendored
Normal file
13
bundle/common/files/interfaces/files-upload-module.interface.d.ts
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
import { ModuleMetadata, Type } from '@nestjs/common/interfaces';
|
||||
import { MulterOptions } from './../../interfaces/external/multer-options.interface';
|
||||
export interface MulterModuleOptions extends MulterOptions {
|
||||
}
|
||||
export interface MulterOptionsFactory {
|
||||
createMulterOptions(): Promise<MulterModuleOptions> | MulterModuleOptions;
|
||||
}
|
||||
export interface MulterModuleAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
|
||||
useExisting?: Type<MulterOptionsFactory>;
|
||||
useClass?: Type<MulterOptionsFactory>;
|
||||
useFactory?: (...args: any[]) => Promise<MulterModuleOptions> | MulterModuleOptions;
|
||||
inject?: any[];
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
1
bundle/common/files/interfaces/index.d.ts
vendored
Normal file
1
bundle/common/files/interfaces/index.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export * from './files-upload-module.interface';
|
||||
2
bundle/common/files/interfaces/index.js
Normal file
2
bundle/common/files/interfaces/index.js
Normal file
@@ -0,0 +1,2 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
8
bundle/common/files/multer.module.d.ts
vendored
Normal file
8
bundle/common/files/multer.module.d.ts
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import { DynamicModule } from '@nestjs/common';
|
||||
import { MulterModuleAsyncOptions, MulterModuleOptions } from './interfaces/files-upload-module.interface';
|
||||
export declare class MulterModule {
|
||||
static register(options?: MulterModuleOptions): DynamicModule;
|
||||
static registerAsync(options: MulterModuleAsyncOptions): DynamicModule;
|
||||
private static createAsyncProviders(options);
|
||||
private static createAsyncOptionsProvider(options);
|
||||
}
|
||||
58
bundle/common/files/multer.module.js
Normal file
58
bundle/common/files/multer.module.js
Normal file
@@ -0,0 +1,58 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const common_1 = require("@nestjs/common");
|
||||
const files_constants_1 = require("./files.constants");
|
||||
let MulterModule = MulterModule_1 = class MulterModule {
|
||||
static register(options = {}) {
|
||||
return {
|
||||
module: MulterModule_1,
|
||||
providers: [{ provide: files_constants_1.MULTER_MODULE_OPTIONS, useValue: options }],
|
||||
exports: [files_constants_1.MULTER_MODULE_OPTIONS],
|
||||
};
|
||||
}
|
||||
static registerAsync(options) {
|
||||
return {
|
||||
module: MulterModule_1,
|
||||
imports: options.imports,
|
||||
providers: this.createAsyncProviders(options),
|
||||
exports: [files_constants_1.MULTER_MODULE_OPTIONS],
|
||||
};
|
||||
}
|
||||
static createAsyncProviders(options) {
|
||||
if (options.useExisting || options.useFactory) {
|
||||
return [this.createAsyncOptionsProvider(options)];
|
||||
}
|
||||
return [
|
||||
this.createAsyncOptionsProvider(options),
|
||||
{
|
||||
provide: options.useClass,
|
||||
useClass: options.useClass,
|
||||
},
|
||||
];
|
||||
}
|
||||
static createAsyncOptionsProvider(options) {
|
||||
if (options.useFactory) {
|
||||
return {
|
||||
provide: files_constants_1.MULTER_MODULE_OPTIONS,
|
||||
useFactory: options.useFactory,
|
||||
inject: options.inject || [],
|
||||
};
|
||||
}
|
||||
return {
|
||||
provide: files_constants_1.MULTER_MODULE_OPTIONS,
|
||||
useFactory: async (optionsFactory) => await optionsFactory.createMulterOptions(),
|
||||
inject: [options.useExisting || options.useClass],
|
||||
};
|
||||
}
|
||||
};
|
||||
MulterModule = MulterModule_1 = __decorate([
|
||||
common_1.Module({})
|
||||
], MulterModule);
|
||||
exports.MulterModule = MulterModule;
|
||||
var MulterModule_1;
|
||||
9
bundle/common/files/multer/multer.constants.d.ts
vendored
Normal file
9
bundle/common/files/multer/multer.constants.d.ts
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
export declare const multerExceptions: {
|
||||
LIMIT_PART_COUNT: string;
|
||||
LIMIT_FILE_SIZE: string;
|
||||
LIMIT_FILE_COUNT: string;
|
||||
LIMIT_FIELD_KEY: string;
|
||||
LIMIT_FIELD_VALUE: string;
|
||||
LIMIT_FIELD_COUNT: string;
|
||||
LIMIT_UNEXPECTED_FILE: string;
|
||||
};
|
||||
11
bundle/common/files/multer/multer.constants.js
Normal file
11
bundle/common/files/multer/multer.constants.js
Normal file
@@ -0,0 +1,11 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.multerExceptions = {
|
||||
LIMIT_PART_COUNT: 'Too many parts',
|
||||
LIMIT_FILE_SIZE: 'File too large',
|
||||
LIMIT_FILE_COUNT: 'Too many files',
|
||||
LIMIT_FIELD_KEY: 'Field name too long',
|
||||
LIMIT_FIELD_VALUE: 'Field value too long',
|
||||
LIMIT_FIELD_COUNT: 'Too many fields',
|
||||
LIMIT_UNEXPECTED_FILE: 'Unexpected field',
|
||||
};
|
||||
2
bundle/common/files/multer/multer.utils.d.ts
vendored
Normal file
2
bundle/common/files/multer/multer.utils.d.ts
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import { BadRequestException, PayloadTooLargeException } from './../../exceptions';
|
||||
export declare function transformException(error: Error | undefined): Error | BadRequestException | PayloadTooLargeException;
|
||||
22
bundle/common/files/multer/multer.utils.js
Normal file
22
bundle/common/files/multer/multer.utils.js
Normal file
@@ -0,0 +1,22 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const exceptions_1 = require("./../../exceptions");
|
||||
const multer_constants_1 = require("./multer.constants");
|
||||
function transformException(error) {
|
||||
if (!error || error instanceof exceptions_1.HttpException) {
|
||||
return error;
|
||||
}
|
||||
switch (error.message) {
|
||||
case multer_constants_1.multerExceptions.LIMIT_FILE_SIZE:
|
||||
return new exceptions_1.PayloadTooLargeException(error.message);
|
||||
case multer_constants_1.multerExceptions.LIMIT_FILE_COUNT:
|
||||
case multer_constants_1.multerExceptions.LIMIT_FIELD_KEY:
|
||||
case multer_constants_1.multerExceptions.LIMIT_FIELD_VALUE:
|
||||
case multer_constants_1.multerExceptions.LIMIT_FIELD_COUNT:
|
||||
case multer_constants_1.multerExceptions.LIMIT_UNEXPECTED_FILE:
|
||||
case multer_constants_1.multerExceptions.LIMIT_PART_COUNT:
|
||||
return new exceptions_1.BadRequestException(error.message);
|
||||
}
|
||||
return error;
|
||||
}
|
||||
exports.transformException = transformException;
|
||||
1
bundle/common/http/http.constants.d.ts
vendored
Normal file
1
bundle/common/http/http.constants.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export declare const AXIOS_INSTANCE_TOKEN = "AXIOS_INSTANCE_TOKEN";
|
||||
3
bundle/common/http/http.constants.js
Normal file
3
bundle/common/http/http.constants.js
Normal file
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.AXIOS_INSTANCE_TOKEN = 'AXIOS_INSTANCE_TOKEN';
|
||||
3
bundle/common/http/http.module.d.ts
vendored
3
bundle/common/http/http.module.d.ts
vendored
@@ -1,2 +1,5 @@
|
||||
import { AxiosRequestConfig } from 'axios';
|
||||
import { DynamicModule } from '../interfaces';
|
||||
export declare class HttpModule {
|
||||
static register(config: AxiosRequestConfig): DynamicModule;
|
||||
}
|
||||
|
||||
@@ -6,14 +6,29 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const axios_1 = require("axios");
|
||||
const module_decorator_1 = require("../decorators/modules/module.decorator");
|
||||
const http_constants_1 = require("./http.constants");
|
||||
const http_service_1 = require("./http.service");
|
||||
let HttpModule = class HttpModule {
|
||||
let HttpModule = HttpModule_1 = class HttpModule {
|
||||
static register(config) {
|
||||
return {
|
||||
module: HttpModule_1,
|
||||
providers: [{
|
||||
provide: http_constants_1.AXIOS_INSTANCE_TOKEN,
|
||||
useValue: axios_1.default.create(config),
|
||||
}],
|
||||
};
|
||||
}
|
||||
};
|
||||
HttpModule = __decorate([
|
||||
HttpModule = HttpModule_1 = __decorate([
|
||||
module_decorator_1.Module({
|
||||
providers: [http_service_1.HttpService],
|
||||
providers: [http_service_1.HttpService, {
|
||||
provide: http_constants_1.AXIOS_INSTANCE_TOKEN,
|
||||
useValue: axios_1.default,
|
||||
}],
|
||||
exports: [http_service_1.HttpService],
|
||||
})
|
||||
], HttpModule);
|
||||
exports.HttpModule = HttpModule;
|
||||
var HttpModule_1;
|
||||
|
||||
5
bundle/common/http/http.service.d.ts
vendored
5
bundle/common/http/http.service.d.ts
vendored
@@ -1,6 +1,8 @@
|
||||
import { AxiosRequestConfig, AxiosResponse } from 'axios';
|
||||
import { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';
|
||||
import { Observable } from 'rxjs';
|
||||
export declare class HttpService {
|
||||
private readonly instance;
|
||||
constructor(instance?: AxiosInstance);
|
||||
request<T = any>(config: AxiosRequestConfig): Observable<AxiosResponse<T>>;
|
||||
get<T = any>(url: string, config?: AxiosRequestConfig): Observable<AxiosResponse<T>>;
|
||||
delete<T = any>(url: string, config?: AxiosRequestConfig): Observable<AxiosResponse<T>>;
|
||||
@@ -8,4 +10,5 @@ export declare class HttpService {
|
||||
post<T = any>(url: string, data?: any, config?: AxiosRequestConfig): Observable<AxiosResponse<T>>;
|
||||
put<T = any>(url: string, data?: any, config?: AxiosRequestConfig): Observable<AxiosResponse<T>>;
|
||||
patch<T = any>(url: string, data?: any, config?: AxiosRequestConfig): Observable<AxiosResponse<T>>;
|
||||
readonly axiosRef: AxiosInstance;
|
||||
}
|
||||
|
||||
@@ -1,28 +1,52 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
return function (target, key) { decorator(target, key, paramIndex); }
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const axios_1 = require("axios");
|
||||
const rxjs_1 = require("rxjs");
|
||||
class HttpService {
|
||||
const decorators_1 = require("../decorators");
|
||||
const http_constants_1 = require("./http.constants");
|
||||
let HttpService = class HttpService {
|
||||
constructor(instance = axios_1.default) {
|
||||
this.instance = instance;
|
||||
}
|
||||
request(config) {
|
||||
return rxjs_1.from(axios_1.default.request(config));
|
||||
return rxjs_1.defer(() => this.instance.request(config));
|
||||
}
|
||||
get(url, config) {
|
||||
return rxjs_1.from(axios_1.default.get(url, config));
|
||||
return rxjs_1.defer(() => this.instance.get(url, config));
|
||||
}
|
||||
delete(url, config) {
|
||||
return rxjs_1.from(axios_1.default.delete(url, config));
|
||||
return rxjs_1.defer(() => this.instance.delete(url, config));
|
||||
}
|
||||
head(url, config) {
|
||||
return rxjs_1.from(axios_1.default.head(url, config));
|
||||
return rxjs_1.defer(() => this.instance.head(url, config));
|
||||
}
|
||||
post(url, data, config) {
|
||||
return rxjs_1.from(axios_1.default.post(url, data, config));
|
||||
return rxjs_1.defer(() => this.instance.post(url, data, config));
|
||||
}
|
||||
put(url, data, config) {
|
||||
return rxjs_1.from(axios_1.default.post(url, data, config));
|
||||
return rxjs_1.defer(() => this.instance.put(url, data, config));
|
||||
}
|
||||
patch(url, data, config) {
|
||||
return rxjs_1.from(axios_1.default.post(url, data, config));
|
||||
return rxjs_1.defer(() => this.instance.patch(url, data, config));
|
||||
}
|
||||
}
|
||||
get axiosRef() {
|
||||
return this.instance;
|
||||
}
|
||||
};
|
||||
HttpService = __decorate([
|
||||
__param(0, decorators_1.Inject(http_constants_1.AXIOS_INSTANCE_TOKEN)),
|
||||
__metadata("design:paramtypes", [Object])
|
||||
], HttpService);
|
||||
exports.HttpService = HttpService;
|
||||
|
||||
12
bundle/common/index.d.ts
vendored
12
bundle/common/index.d.ts
vendored
@@ -1,9 +1,11 @@
|
||||
export * from './cache';
|
||||
export * from './decorators';
|
||||
export * from './enums';
|
||||
export { NestModule, INestApplication, INestMicroservice, NestMiddleware, MiddlewareFunction, MiddlewareConsumer, OnModuleInit, ExceptionFilter, WebSocketAdapter, PipeTransform, Paramtype, ArgumentMetadata, OnModuleDestroy, ExecutionContext, CanActivate, RpcExceptionFilter, WsExceptionFilter, NestInterceptor, DynamicModule, INestApplicationContext, HttpServer, Provider, Type, HttpServerFactory, ArgumentsHost, INestExpressApplication, INestFastifyApplication, ForwardReference } from './interfaces';
|
||||
export * from './interceptors';
|
||||
export * from './services/logger.service';
|
||||
export * from './pipes';
|
||||
export * from './utils';
|
||||
export * from './exceptions';
|
||||
export * from './files';
|
||||
export * from './http';
|
||||
export { ArgumentMetadata, ArgumentsHost, CanActivate, DynamicModule, ExceptionFilter, ExecutionContext, ForwardReference, HttpServer, HttpServerFactory, INestApplication, INestApplicationContext, INestExpressApplication, INestFastifyApplication, INestMicroservice, MiddlewareConsumer, MiddlewareFunction, NestInterceptor, NestMiddleware, NestModule, OnApplicationBootstrap, OnModuleDestroy, OnModuleInit, Paramtype, PipeTransform, Provider, RpcExceptionFilter, Type, WebSocketAdapter, WsExceptionFilter } from './interfaces';
|
||||
export * from './pipes';
|
||||
export * from './serializer';
|
||||
export * from './services/logger.service';
|
||||
export * from './utils';
|
||||
|
||||
@@ -9,11 +9,13 @@ function __export(m) {
|
||||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
||||
}
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
__export(require("./cache"));
|
||||
__export(require("./decorators"));
|
||||
__export(require("./enums"));
|
||||
__export(require("./interceptors"));
|
||||
__export(require("./services/logger.service"));
|
||||
__export(require("./pipes"));
|
||||
__export(require("./utils"));
|
||||
__export(require("./exceptions"));
|
||||
__export(require("./files"));
|
||||
__export(require("./http"));
|
||||
__export(require("./pipes"));
|
||||
__export(require("./serializer"));
|
||||
__export(require("./services/logger.service"));
|
||||
__export(require("./utils"));
|
||||
|
||||
2
bundle/common/interceptors/file-fields.interceptor.d.ts
vendored
Normal file
2
bundle/common/interceptors/file-fields.interceptor.d.ts
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import { MulterField, MulterOptions } from '../interfaces/external/multer-options.interface';
|
||||
export declare function FileFieldsInterceptor(uploadFields: MulterField[], options?: MulterOptions): any;
|
||||
25
bundle/common/interceptors/file-fields.interceptor.js
Normal file
25
bundle/common/interceptors/file-fields.interceptor.js
Normal file
@@ -0,0 +1,25 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const multer = require("multer");
|
||||
const component_decorator_1 = require("../decorators/core/component.decorator");
|
||||
const multer_utils_1 = require("./multer/multer.utils");
|
||||
function FileFieldsInterceptor(uploadFields, options) {
|
||||
const Interceptor = component_decorator_1.mixin(class {
|
||||
constructor() {
|
||||
this.upload = multer(options);
|
||||
}
|
||||
async intercept(context, call$) {
|
||||
const ctx = context.switchToHttp();
|
||||
await new Promise((resolve, reject) => this.upload.fields(uploadFields)(ctx.getRequest(), ctx.getResponse(), err => {
|
||||
if (err) {
|
||||
const error = multer_utils_1.transformException(err);
|
||||
return reject(error);
|
||||
}
|
||||
resolve();
|
||||
}));
|
||||
return call$;
|
||||
}
|
||||
});
|
||||
return Interceptor;
|
||||
}
|
||||
exports.FileFieldsInterceptor = FileFieldsInterceptor;
|
||||
@@ -1,9 +1,2 @@
|
||||
import { Observable } from 'rxjs';
|
||||
import { MulterOptions } from '../interfaces/external/multer-options.interface';
|
||||
import { ExecutionContext } from '../interfaces';
|
||||
export declare function FilesInterceptor(fieldName: string, maxCount?: number, options?: MulterOptions): {
|
||||
new (): {
|
||||
readonly upload: any;
|
||||
intercept(context: ExecutionContext, call$: Observable<any>): Promise<Observable<any>>;
|
||||
};
|
||||
};
|
||||
export declare function FilesInterceptor(fieldName: string, maxCount?: number, options?: MulterOptions): any;
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const multer = require("multer");
|
||||
const component_decorator_1 = require("../decorators/core/component.decorator");
|
||||
const multer_utils_1 = require("./multer/multer.utils");
|
||||
function FilesInterceptor(fieldName, maxCount, options) {
|
||||
const Interceptor = class {
|
||||
const Interceptor = component_decorator_1.mixin(class {
|
||||
constructor() {
|
||||
this.upload = multer(options);
|
||||
}
|
||||
@@ -18,7 +19,7 @@ function FilesInterceptor(fieldName, maxCount, options) {
|
||||
}));
|
||||
return call$;
|
||||
}
|
||||
};
|
||||
});
|
||||
return Interceptor;
|
||||
}
|
||||
exports.FilesInterceptor = FilesInterceptor;
|
||||
|
||||
1
bundle/common/interceptors/index.d.ts
vendored
1
bundle/common/interceptors/index.d.ts
vendored
@@ -1,2 +1,3 @@
|
||||
export * from './file-fields.interceptor';
|
||||
export * from './file.interceptor';
|
||||
export * from './files.interceptor';
|
||||
|
||||
@@ -3,5 +3,6 @@ function __export(m) {
|
||||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
||||
}
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
__export(require("./file-fields.interceptor"));
|
||||
__export(require("./file.interceptor"));
|
||||
__export(require("./files.interceptor"));
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
import { PayloadTooLargeException, BadRequestException } from './../../exceptions';
|
||||
import { BadRequestException, PayloadTooLargeException } from './../../exceptions';
|
||||
export declare function transformException(error: Error | undefined): Error | BadRequestException | PayloadTooLargeException;
|
||||
|
||||
41
bundle/common/interfaces/external/class-transform-options.interface.d.ts
vendored
Normal file
41
bundle/common/interfaces/external/class-transform-options.interface.d.ts
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* Options to be passed during transformation.
|
||||
* @see https://github.com/typestack/class-transformer
|
||||
*/
|
||||
export interface ClassTransformOptions {
|
||||
/**
|
||||
* Exclusion strategy. By default exposeAll is used, which means that it will expose all properties are transformed
|
||||
* by default.
|
||||
*/
|
||||
strategy?: 'excludeAll' | 'exposeAll';
|
||||
/**
|
||||
* Only properties with given groups gonna be transformed.
|
||||
*/
|
||||
groups?: string[];
|
||||
/**
|
||||
* Only properties with "since" > version < "until" gonna be transformed.
|
||||
*/
|
||||
version?: number;
|
||||
/**
|
||||
* Excludes properties with the given prefixes. For example, if you mark your private properties with "_" and "__"
|
||||
* you can set this option's value to ["_", "__"] and all private properties will be skipped.
|
||||
* This works only for "exposeAll" strategy.
|
||||
*/
|
||||
excludePrefixes?: string[];
|
||||
/**
|
||||
* If set to true then class transformer will ignore all @Expose and @Exclude decorators and what inside them.
|
||||
* This option is useful if you want to kinda clone your object but do not apply decorators affects.
|
||||
*/
|
||||
ignoreDecorators?: boolean;
|
||||
/**
|
||||
* Target maps allows to set a Types of the transforming object without using @Type decorator.
|
||||
* This is useful when you are transforming external classes, or if you already have type metadata for
|
||||
* objects and you don't want to set it up again.
|
||||
*/
|
||||
targetMaps?: any[];
|
||||
/**
|
||||
* If set to true then class transformer will perform a circular check. (circular check is turned off by default)
|
||||
* This option is useful when you know for sure that your types might have a circular dependency.
|
||||
*/
|
||||
enableCircularCheck?: boolean;
|
||||
}
|
||||
2
bundle/common/interfaces/external/class-transform-options.interface.js
vendored
Normal file
2
bundle/common/interfaces/external/class-transform-options.interface.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
@@ -49,3 +49,9 @@ export interface MulterOptions {
|
||||
buffer: Buffer;
|
||||
}, callback: (error: Error | null, acceptFile: boolean) => void): void;
|
||||
}
|
||||
export interface MulterField {
|
||||
/** The field name. */
|
||||
name: string;
|
||||
/** Optional maximum number of files per field to accept. */
|
||||
maxCount?: number;
|
||||
}
|
||||
|
||||
@@ -57,4 +57,8 @@ export interface ServeStaticOptions {
|
||||
* stat the stat object of the file that is being sent
|
||||
*/
|
||||
setHeaders?: (res, path: string, stat: any) => any;
|
||||
/**
|
||||
* Creates a virtual path prefix
|
||||
*/
|
||||
prefix?: string;
|
||||
}
|
||||
|
||||
@@ -39,4 +39,8 @@ export interface ValidatorOptions {
|
||||
*/
|
||||
value?: boolean;
|
||||
};
|
||||
/**
|
||||
* Setting true will cause fail validation of unknown objects.
|
||||
*/
|
||||
forbidUnknownValues?: boolean;
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
export declare type CustomParamFactory = (data, req) => any;
|
||||
export declare type CustomParamFactory<TData = any, TRequest = any, TResult = any> = (data: TData, req: TRequest) => TResult;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/// <reference types="node" />
|
||||
import { IncomingMessage, ServerResponse } from 'http';
|
||||
import { RequestMethod } from '../../enums';
|
||||
export declare type ErrorHandler = (error: any, req: Partial<IncomingMessage>, res: ServerResponse | any, next?: Function) => any;
|
||||
export declare type RequestHandler = (req: Partial<IncomingMessage>, res: ServerResponse | any, next?: Function) => any;
|
||||
export interface HttpServer {
|
||||
@@ -29,8 +30,10 @@ export interface HttpServer {
|
||||
useStaticAssets?(...args: any[]): this;
|
||||
setBaseViewsDir?(path: string): this;
|
||||
setViewEngine?(engineOrOptions: any): this;
|
||||
createMiddlewareFactory(method: RequestMethod): (path: string, callback: Function) => any;
|
||||
getRequestMethod?(request: any): string;
|
||||
getRequestUrl?(request: any): string;
|
||||
getInstance(): any;
|
||||
getHttpServer(): any;
|
||||
close(): any;
|
||||
}
|
||||
|
||||
45
bundle/common/interfaces/index.d.ts
vendored
45
bundle/common/interfaces/index.d.ts
vendored
@@ -1,33 +1,32 @@
|
||||
export * from './request-mapping-metadata.interface';
|
||||
export * from './modules/nest-module.interface';
|
||||
export * from './modules/module-metadata.interface';
|
||||
export * from './controllers/controller.interface';
|
||||
export * from './injectable.interface';
|
||||
export * from './controllers/controller-metadata.interface';
|
||||
export * from './modules/module-metadata.interface';
|
||||
export * from './type.interface';
|
||||
export * from './nest-application.interface';
|
||||
export * from './nest-microservice.interface';
|
||||
export * from './nest-application-context.interface';
|
||||
export * from './modules/on-init.interface';
|
||||
export * from './modules/on-destroy.interface';
|
||||
export * from './controllers/controller.interface';
|
||||
export * from './exceptions/exception-filter.interface';
|
||||
export * from './middleware';
|
||||
export * from './websockets/web-socket-adapter.interface';
|
||||
export * from './features/pipe-transform.interface';
|
||||
export * from './features/paramtype.interface';
|
||||
export * from './features/can-activate.interface';
|
||||
export * from './exceptions/rpc-exception-filter.interface';
|
||||
export * from './exceptions/ws-exception-filter.interface';
|
||||
export * from './features/arguments-host.interface';
|
||||
export * from './features/can-activate.interface';
|
||||
export * from './features/custom-route-param-factory.interface';
|
||||
export * from './features/execution-context.interface';
|
||||
export * from './features/nest-interceptor.interface';
|
||||
export * from './features/custom-route-param-factory.interface';
|
||||
export * from './modules/dynamic-module.interface';
|
||||
export * from './http/http-server.interface';
|
||||
export * from './features/paramtype.interface';
|
||||
export * from './features/pipe-transform.interface';
|
||||
export * from './http/http-server-factory.interface';
|
||||
export * from './features/arguments-host.interface';
|
||||
export * from './http/http-server.interface';
|
||||
export * from './injectable.interface';
|
||||
export * from './middleware';
|
||||
export * from './modules/dynamic-module.interface';
|
||||
export * from './modules/forward-reference.interface';
|
||||
export * from './modules/module-metadata.interface';
|
||||
export * from './modules/nest-module.interface';
|
||||
export * from './modules/on-destroy.interface';
|
||||
export * from './modules/on-init.interface';
|
||||
export * from './modules/provider.interface';
|
||||
export * from './nest-application-context.interface';
|
||||
export * from './nest-application.interface';
|
||||
export * from './nest-express-application.interface';
|
||||
export * from './nest-fastify-application.interface';
|
||||
export * from './modules/provider.interface';
|
||||
export * from './nest-microservice.interface';
|
||||
export * from './on-application-bootstrap.interface';
|
||||
export * from './request-mapping-metadata.interface';
|
||||
export * from './type.interface';
|
||||
export * from './modules/forward-reference.interface';
|
||||
export * from './websockets/web-socket-adapter.interface';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Transport } from '../../enums/transport.enum';
|
||||
import { CustomTransportStrategy } from './custom-transport-strategy.interface';
|
||||
import { MqttClientOptions } from '../external/mqtt-options.interface';
|
||||
import { CustomTransportStrategy } from './custom-transport-strategy.interface';
|
||||
export declare type MicroserviceOptions = GrpcOptions | TcpOptions | RedisOptions | NatsOptions | MqttOptions | CustomStrategy;
|
||||
export interface CustomStrategy {
|
||||
strategy?: CustomTransportStrategy;
|
||||
@@ -13,6 +13,21 @@ export interface GrpcOptions {
|
||||
credentials?: any;
|
||||
protoPath: string;
|
||||
package: string;
|
||||
/** @deprecated */
|
||||
root?: string;
|
||||
loader?: {
|
||||
keepCase?: boolean;
|
||||
alternateCommentMode?: boolean;
|
||||
longs?: Function;
|
||||
enums?: Function;
|
||||
bytes?: Function;
|
||||
defaults?: boolean;
|
||||
arrays?: boolean;
|
||||
objects?: boolean;
|
||||
oneofs?: boolean;
|
||||
json?: boolean;
|
||||
includeDirs?: string[];
|
||||
};
|
||||
};
|
||||
}
|
||||
export interface TcpOptions {
|
||||
|
||||
@@ -1,19 +1,28 @@
|
||||
import { MiddlewareConsumer } from './middleware-consumer.interface';
|
||||
import { Type } from '../type.interface';
|
||||
import { RouteInfo } from './middleware-configuration.interface';
|
||||
import { MiddlewareConsumer } from './middleware-consumer.interface';
|
||||
export interface MiddlewareConfigProxy {
|
||||
/**
|
||||
* Passes custom arguments to `resolve()` method of the middleware.
|
||||
* Delegates custom arguments to the `resolve()` method of the middleware.
|
||||
*
|
||||
* @param {} ...data
|
||||
* @returns {MiddlewareConfigProxy}
|
||||
*/
|
||||
with(...data: any[]): MiddlewareConfigProxy;
|
||||
/**
|
||||
* Attaches passed either routes (strings) or controllers to the processed middleware(s).
|
||||
* When you pass Controller class Nest will attach middleware to every path defined within this controller.
|
||||
* Excludes routes from the currently processed middleware.
|
||||
* This excluded route has to use an exact same route path.
|
||||
*
|
||||
* @param {} ...routes
|
||||
* @returns {MiddlewareConfigProxy}
|
||||
*/
|
||||
exclude(...routes: (string | RouteInfo)[]): MiddlewareConfigProxy;
|
||||
/**
|
||||
* Attaches passed either routes or controllers to the currently configured middleware.
|
||||
* If you pass a class, Nest would attach middleware to every path defined within this controller.
|
||||
*
|
||||
* @param {} ...routes
|
||||
* @returns {MiddlewareConsumer}
|
||||
*/
|
||||
forRoutes(...routes: (string | Type<any>)[]): MiddlewareConsumer;
|
||||
forRoutes(...routes: (string | Type<any> | RouteInfo)[]): MiddlewareConsumer;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
import { RequestMethod } from '../../enums';
|
||||
import { Type } from '../type.interface';
|
||||
export interface MiddlewareConfiguration {
|
||||
middleware: any;
|
||||
forRoutes: (Type<any> | string)[];
|
||||
export interface RouteInfo {
|
||||
path: string;
|
||||
method: RequestMethod;
|
||||
}
|
||||
export interface MiddlewareConfiguration<T = any> {
|
||||
middleware: T;
|
||||
forRoutes: (Type<any> | string | RouteInfo)[];
|
||||
}
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import { Type } from '../type.interface';
|
||||
import { MiddlewareConfigProxy } from './middleware-config-proxy.interface';
|
||||
export interface MiddlewareConsumer {
|
||||
/**
|
||||
* Takes single middleware class or array of classes
|
||||
* that subsequently could be attached to the passed either routes or controllers.
|
||||
* Takes either middleware class/function or array of classes/functions
|
||||
* that subsequently shall be attached to the passed routes.
|
||||
*
|
||||
* @param {any|any[]} middleware
|
||||
* @returns {MiddlewareConfigProxy}
|
||||
*/
|
||||
apply(middleware: any | any[]): MiddlewareConfigProxy;
|
||||
apply(...middleware: (Type<any> | Function)[]): MiddlewareConfigProxy;
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
export declare type MiddlewareFunction = (req?, res?, next?) => any;
|
||||
export declare type MiddlewareFunction<TRequest = any, TResponse = any, TResult = any> = (req?: TRequest, res?: TResponse, next?: Function) => TResult;
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import { DynamicModule } from './dynamic-module.interface';
|
||||
import { Type } from '../type.interface';
|
||||
import { Provider } from './provider.interface';
|
||||
import { DynamicModule } from './dynamic-module.interface';
|
||||
import { ForwardReference } from './forward-reference.interface';
|
||||
import { Provider } from './provider.interface';
|
||||
export interface ModuleMetadata {
|
||||
imports?: Array<Type<any> | DynamicModule | ForwardReference>;
|
||||
imports?: Array<Type<any> | DynamicModule | Promise<DynamicModule> | ForwardReference>;
|
||||
controllers?: Type<any>[];
|
||||
providers?: Provider[];
|
||||
exports?: Array<DynamicModule | string | Provider | ForwardReference>;
|
||||
exports?: Array<DynamicModule | Promise<DynamicModule> | string | Provider | ForwardReference>;
|
||||
/** @deprecated */
|
||||
modules?: Array<Type<any> | DynamicModule | ForwardReference>;
|
||||
modules?: Array<Type<any> | DynamicModule | Promise<DynamicModule> | ForwardReference>;
|
||||
/** @deprecated */
|
||||
components?: Provider[];
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { LoggerService } from './../services/logger.service';
|
||||
import { Type } from './type.interface';
|
||||
export interface INestApplicationContext {
|
||||
/**
|
||||
@@ -7,9 +8,19 @@ export interface INestApplicationContext {
|
||||
select<T>(module: Type<T>): INestApplicationContext;
|
||||
/**
|
||||
* Retrieves an instance of either injectable or controller available anywhere, otherwise, throws exception.
|
||||
* @returns {T}
|
||||
* @returns {TResult}
|
||||
*/
|
||||
get<T>(typeOrToken: Type<T> | string | symbol, options?: {
|
||||
get<TInput = any, TResult = TInput>(typeOrToken: Type<TInput> | string | symbol, options?: {
|
||||
strict: boolean;
|
||||
}): T;
|
||||
}): TResult;
|
||||
/**
|
||||
* Terminates the application
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
close(): Promise<void>;
|
||||
/**
|
||||
* Sets custom logger service
|
||||
* @returns {void}
|
||||
*/
|
||||
useLogger(logger: LoggerService): any;
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user