Compare commits

...

110 Commits

Author SHA1 Message Date
Kamil Myśliwiec
195ae2726d chore(release) publish v5.0.0-beta.7 2018-04-29 16:13:44 +02:00
Kamil Myśliwiec
484a2eb4ec sample(@nestjs) update authentication example (passport) 2018-04-29 16:03:25 +02:00
Kamil Myśliwiec
6630313ece improvement(@nestjs/common) move class-validator and class-transformer 2018-04-29 15:58:44 +02:00
Kamil Myśliwiec
c7a8caacef Merge remote-tracking branch 'origin/master' 2018-04-28 18:10:33 +02:00
Kamil Myśliwiec
021b96eaa0 chore(release) publish v5.0.0-beta.6 2018-04-28 18:05:23 +02:00
Kamil Myśliwiec
fb53ba2b1a chore(release) publish v5.0.0-beta.6 2018-04-28 18:03:49 +02:00
Kamil Myśliwiec
bf2fcb7aa1 Update CHANGELOG.md 2018-04-28 15:27:00 +02:00
Kamil Myśliwiec
518ea8d33f chore(release) publish v5.0.0-beta.4 2018-04-28 15:24:39 +02:00
Kamil Myśliwiec
3ad570e62e bugfix(@nestjs/microservices) extract external typings #594 2018-04-28 15:23:03 +02:00
Kamil Myśliwiec
5cfb0bfc85 refactor(@nestjs) fix typos, extract module compiler, fix broken guards 2018-04-28 12:42:35 +02:00
Kamil Myśliwiec
59fb9c71e2 Merge branch 'master' of https://github.com/nestjs/nest 2018-04-27 13:52:24 +02:00
Kamil Myśliwiec
8e2c957833 sample(@nestjs) bump packages versions 2018-04-27 13:42:09 +02:00
Kamil Myśliwiec
944921f2e9 external(@nestjs) update to rxjs@6.0.0 2018-04-27 13:13:02 +02:00
Kamil Myśliwiec
59f5d68df5 feature(@nestjs/common) add @Header() decorator 2018-04-23 22:44:57 +02:00
Kamil Myśliwiec
91c879d922 Update CHANGELOG.md 2018-04-22 12:12:20 +02:00
Kamil Myśliwiec
f918e2b774 Update CHANGELOG.md 2018-04-22 12:08:13 +02:00
Kamil Myśliwiec
6cac4b7e1e chore(release) publish v5.0.0-beta.3 2018-04-22 11:45:33 +02:00
Kamil Myśliwiec
8117cfb10b chore(release) publish v5.0.0-beta.3 2018-04-22 11:42:26 +02:00
Kamil Myśliwiec
4b926da0d6 format(@nestjs) revert lint precommit hook 2018-04-21 16:03:16 +02:00
Kamil Myśliwiec
77d4ea7513 ci(@nestjs) fix unit tests, falling linux build 2018-04-21 16:01:59 +02:00
Kamil Myśliwiec
3160245145 refactor(@nestjs) fix tslint issues, format code 2018-04-21 14:22:24 +02:00
Kamil Myśliwiec
6e19f3554a Merge branch 'update/version-5' 2018-04-21 13:57:28 +02:00
Kamil Myśliwiec
ae6eb8fa7d format(@nestjs) add tslint precommit hook 2018-04-21 13:56:55 +02:00
Kamil Myśliwiec
5d28b98a8c feature(@nestjs/core) add async lifecycle hooks support 2018-04-21 13:55:58 +02:00
Kamil Myśliwiec
52acfe4ea2 tests(@nestjs) add dynamic modules & express instance integration tests 2018-04-21 00:04:18 +02:00
Kamil Myśliwiec
01a4f64a2e Merge pull request #577 from afurculita/patch-1
Update http.exception.ts
2018-04-20 15:54:17 +02:00
Alexandru Furculita ♻
b47a384621 Update http.exception.ts 2018-04-19 14:21:02 +03:00
Alexandru Furculita ♻
e842768bb1 Update http.exception.ts
Some remains from a git merge/rebase conflict
2018-04-19 14:20:22 +03:00
Kamil Myśliwiec
998a24d62f Update Readme.md 2018-04-18 23:25:03 +02:00
Kamil Myśliwiec
64d072d8bb Merge pull request #489 from nestjs/update/version-5
Update: release v5.0.0-beta
2018-04-18 12:50:06 +02:00
Kamil Myśliwiec
6835dd9819 chore(release) publish v5.0.0-beta.2 2018-04-18 12:31:45 +02:00
Kamil Myśliwiec
5f735b11c9 bugfix: deprecate missing @Pipe() decorator, fix HttpModule 2018-04-18 12:29:39 +02:00
Kamil Myśliwiec
4fad0ae2bc Merge branch 'master' into update/version-5 2018-04-17 18:55:09 +02:00
Kamil Myśliwiec
45da5db11b refactor(@nestjs) remove redundant lib directory 2018-04-17 18:51:56 +02:00
Kamil Myśliwiec
0b9baf8588 refactor(@nestjs) move reflect-metadata to internal dependencies 2018-04-17 18:49:03 +02:00
Kamil Myśliwiec
cef628f314 Update README.md 2018-04-17 18:44:46 +02:00
Kamil Myśliwiec
421c2f69f7 Update README.md 2018-04-17 18:39:29 +02:00
Kamil Myśliwiec
69cd3ab5f9 chore(release) publish v5.0.0-beta.1 2018-04-17 18:33:30 +02:00
Kamil Myśliwiec
b144dbef8c chore(release) publish v5.0.0-beta.0 2018-04-17 18:22:27 +02:00
Kamil Myśliwiec
eff9942466 v5.0.0-beta.0 2018-04-17 18:13:20 +02:00
Kamil Myśliwiec
525a5969bc Update Readme.md 2018-04-03 12:47:07 +02:00
Kamil Myśliwiec
b49366fd31 feature(@nestjs/core) context creator improvements (injection support) 2018-03-31 16:43:07 +02:00
Kamil Myśliwiec
354277ba6e feature(@nestjs/core) reduce injector complexity (remove scopes) 2018-03-29 11:40:12 +02:00
Kamil Myśliwiec
658391fe85 sample(@nestjs) update graphql and mongoose example 2018-03-29 11:39:36 +02:00
Kamil Myśliwiec
b574bb3f4c lib(@nestjs) update packages README 2018-03-28 19:18:33 +02:00
Kamil Myśliwiec
7b760c645f Merge remote-tracking branch 'origin' into update/version-5 2018-03-28 19:15:41 +02:00
Kamil Myśliwiec
32445dcf55 lib(@nestjs) fix incorrect dependencies (multer) 2018-03-28 19:09:19 +02:00
Kamil Myśliwiec
e45fd1aa12 lib(@nestjs) update packages README 2018-03-28 19:08:05 +02:00
Kamil Myśliwiec
3855b3a710 lib(@nestjs) update package.json files 2018-03-28 19:03:47 +02:00
Kamil Myśliwiec
1ca812abbf Update Readme.md 2018-03-28 13:00:52 +02:00
Kamil Myśliwiec
7470911bd7 Update Readme.md 2018-03-28 12:43:30 +02:00
Kamil Myśliwiec
adf72acf63 Update Readme.md 2018-03-28 12:42:53 +02:00
Kamil Myśliwiec
0e9f8f5e7e Update Readme.md 2018-03-28 12:38:47 +02:00
Kamil Myśliwiec
eb05d237af sample(@nestjs) add execution context app example 2018-03-27 13:26:50 +02:00
Kamil Myśliwiec
fa8b4ecef4 Update Readme.md 2018-03-27 12:20:30 +02:00
Kamil Myśliwiec
707b3efea4 tests(@nestjs/core) fix router execution context unit test (render) 2018-03-26 19:15:28 +02:00
Kamil Myśliwiec
5f37fadd24 Auto stash before merge of "master" and "origin/master" 2018-03-26 17:10:32 +02:00
Kamil Myśliwiec
eefbece0e1 Merge branch 'master' into update/version-5 2018-03-26 17:07:19 +02:00
Kamil Myśliwiec
a54102a660 Merge pull request #517 from pumano/master
chore(@nestjs/core) update debug dependency due to security flaw
2018-03-26 17:05:51 +02:00
Kamil Myśliwiec
b5de592eee format(@nestjs) run prettier 2018-03-26 17:04:55 +02:00
Kamil Myśliwiec
20493377af Update Readme.md 2018-03-26 16:49:11 +02:00
Kamil Myśliwiec
f91a16268f Update Readme.md 2018-03-26 15:38:32 +02:00
Kamil Myśliwiec
34b3e77d47 Update Readme.md 2018-03-26 15:32:53 +02:00
Kamil Myśliwiec
557009c11e Update Readme.md 2018-03-26 15:31:12 +02:00
Kamil Myśliwiec
32bf174b5c samples(@nestjs) update sample applications 2018-03-25 23:28:44 +02:00
Kamil Myśliwiec
6a6d3d4805 sample(@nestjs) partial webpack integration 2018-03-25 21:43:37 +02:00
Kamil Myśliwiec
91b4974d2c samples(@nestjs) update sample applications 2018-03-25 21:38:52 +02:00
Kamil Myśliwiec
e50ddf9cb9 tests(@nestjs) fix broken unit tests 2018-03-24 20:55:06 +01:00
Kamil Myśliwiec
fdbf364087 feature(@nestjs) enhance execution context, create host 2018-03-24 17:19:47 +01:00
Kamil Myśliwiec
0eb3354344 /version-5: Auto stash before merge of "update/version-5" and "origin/update/version-5" 2018-03-24 15:28:40 +01:00
Kamil Myśliwiec
a798714f21 Merge remote-tracking branch 'origin/update/version-5' into update/version-5 2018-03-24 15:28:26 +01:00
Kamil Myśliwiec
574830796f build(@nestjs) fix gulpfile configuration 2018-03-24 15:28:13 +01:00
Kamil Myśliwiec
fb26c4ab60 Delete .DS_Store 2018-03-24 15:22:23 +01:00
Kamil Myśliwiec
614de27310 refactor(@nestjs) rename directories, add script, fix tests 2018-03-24 15:11:48 +01:00
Kamil Myśliwiec
3b6981918a format(@nestjs) run prettier, format existing codebase 2018-03-22 19:05:38 +01:00
Kamil Myśliwiec
84f531ca34 feature: generalise interfaces, improve decorators 2018-03-22 18:48:43 +01:00
Kamil Myśliwiec
11b397a348 test(@nestjs) update unit tests 2018-03-22 10:32:43 +01:00
pumano
9fe8c98a42 chore(@nestjs/core) update debug dependency due to security flaw
According to node security project
534 - Regular Expression Denial of Service
Vulnerable: <= 2.6.8 || >= 3.0.0 <= 3.0.1 - Patched: >= 2.6.9 < 3.0.0 || >= 3.1.0 - Path: @nestjs/core@4.6.4 > body-parser@1.17.2 > debug@2.6.7

How to fix
Upgrade to version 2.6.9 or greater if you are on the 2.6.x series or 3.1.0 or greater.
2018-03-19 14:46:14 +03:00
Kamil Myśliwiec
852ce08bf3 feature(@nestjs/microservices) add grpc, mqtt, microservices refactor 2018-03-18 15:49:26 +01:00
Kamil Myśliwiec
a18e4c69ee tests(@nestjs) push basic integration tests 2018-03-17 15:01:17 +01:00
Kamil Myśliwiec
43da706a61 feature(@nestjs/microservices) add stan transport strategy 2018-03-17 14:56:55 +01:00
Kamil Myśliwiec
81691afb46 Merge remote-tracking branch 'origin/update/version-5' into update/version-5 2018-03-15 23:21:44 +01:00
Kamil Myśliwiec
9258229fdb feature(@netsjs/microservices) add nats transport strategy 2018-03-15 23:20:51 +01:00
Kamil Myśliwiec
e481a71b5c feature(@nestjs/core) better type checking for fastify adapter 2018-03-14 14:27:12 +01:00
Kamil Myśliwiec
fc092ae0b3 Merge branch 'update/version-5' of https://github.com/nestjs/nest into update/version-5 2018-03-14 12:08:19 +01:00
Kamil Myśliwiec
6c70f9c777 test(@nestjs/common) cover multer, FileInterceptor unit tests 2018-03-14 12:07:43 +01:00
Kamil Myśliwiec
15a8225ec1 bugfix(@nestjs/core) fix express adapter incompatibility 2018-03-13 18:53:18 +01:00
Kamil Myśliwiec
7bb35c0b38 Update Readme.md 2018-03-12 20:27:33 +01:00
Kamil Myśliwiec
cc8c3ddc95 Update Readme.md 2018-03-12 20:26:34 +01:00
Kamil Myśliwiec
10781a7a8e merge(@nestjs) resolve conflicts with master branch 2018-03-11 14:11:51 +01:00
Kamil Myśliwiec
2f26e3a1dc chore(release) publish v4.6.6 2018-03-11 13:50:47 +01:00
Kamil Myśliwiec
531b2fe018 update(@nestjs) upgrade reflect-metadata package 2018-03-09 15:59:26 +01:00
Kamil Myśliwiec
2ebfca2f07 fix(@nestjs) fix merge conflicts 2018-03-08 21:45:24 +01:00
Kamil Myśliwiec
1746fb452a test(@nestjs) build & fix unit tests 2018-03-08 18:14:30 +01:00
Kamil Myśliwiec
9d85f8a29a feature(@nestjs) extract http server, increase flexibility 2018-03-08 16:40:51 +01:00
Kamil Myśliwiec
a66537a2ff bugfix(@nestjs/common) fix NestMiddleware interface 2018-03-07 16:50:06 +01:00
Kamil Myśliwiec
df9fe07d26 feature(@nestjs/core) add find() method to NestApplicationContext 2018-03-02 00:01:03 +01:00
Kamil Myśliwiec
5b7b4c73f4 feature(@nestjs/microservices) allow applying multiple params in ctx creator 2018-02-28 12:20:39 +01:00
Kamil Myśliwiec
c262b7caf6 feature(@nestjs/microservices) sendMessage breaking change 2018-02-24 13:30:06 +01:00
Kamil Myśliwiec
559e919636 feature(@nestjs/microservices) add TCP/Redis retrying strategy 2018-02-18 22:36:51 +01:00
Kamil Myśliwiec
5c7f9fa5a7 Merge branch 'master' into update/version-5 2018-02-18 13:38:57 +01:00
Kamil Myśliwiec
9b834871ea feature(@nestjs) improve typings, better type checking 2018-02-17 23:33:09 +01:00
Kamil Myśliwiec
23c46abd53 examples(@nestjs) update packages in examples 2018-02-16 13:39:42 +01:00
Kamil Myśliwiec
3029e3c65a update(@nestjs) update to latest version of rxjs lib (v5.5.6) 2018-02-16 11:38:01 +01:00
Kamil Myśliwiec
7e5d6a1f07 deprecate(@nestjs/common) deprecate modules and components property 2018-02-16 09:06:31 +01:00
Kamil Myśliwiec
d84f5adcad Merge pull request #328 from wbhob/deprecate-modules
[SEMVER-MAJOR] chore(): deprecate modules property
2018-02-16 01:13:12 +01:00
Kamil Myśliwiec
294bc5d053 Merge branch 'update/version-5' into deprecate-modules 2018-02-16 01:12:24 +01:00
Kamil Myśliwiec
f67c876c0d feature(@nestjs/common) add @Injectable() class, providers property integration 2018-02-16 01:10:15 +01:00
Wilson Hobbs
05c44f66b8 Merge branch 'master' into deprecate-modules 2018-01-29 22:53:00 -05:00
Wilson Hobbs
ad3f679c5a chore(): deprecate modules property 2017-12-23 14:40:16 -05:00
1730 changed files with 50366 additions and 10448 deletions

3
.gitignore vendored
View File

@@ -8,6 +8,7 @@ package-lock.json
/.vscode
# misc
.DS_Store
lerna-debug.log
npm-debug.log
yarn-error.log
@@ -24,6 +25,6 @@ yarn-error.log
# tests
/test
/integration
/coverage
/.nyc_output
build/config\.gypi

1
.prettierignore Normal file
View File

@@ -0,0 +1 @@
/bundle

View File

@@ -1,3 +1,55 @@
## 5.0.0-beta.4
### Bug Fixes
- **core**: param pipes aren't working correctly [#592](https://github.com/nestjs/nest/issues/592)
- **microservices**: unnecessary modules required [#594](https://github.com/nestjs/nest/issues/594)
### Improvements
- **all**: upgrade RxJS version (`v6.0.0`)
## 5.0.0-beta.3
### Bug Fixes
- **core**: incorrect `ExpressAdapter` method wrappers [#585](https://github.com/nestjs/nest/issues/585)
- **core**: the `fastify-formbody` is no longer a required dependency [#575](https://github.com/nestjs/nest/issues/575)
- **core**: incorrect `createApplication()` typings (unable to pass express instance directly) [#575](https://github.com/nestjs/nest/issues/575)
## 5.0.0-beta.0
### Features
- **core**: support async lifecycle hooks (`OnModuleInit` and `OnModuleDestroy`) [#569](https://github.com/nestjs/nest/issues/569)
- **core**: HTTP server independence, [fastify](https://github.com/fastify/fastify) integration (`FastifyAdapter`)
- **core**: allow binding global interceptors, filters, pipes, and guards from any module. Example:
```typescript
{
provide: APP_INTERCEPTOR,
useClass: LoggerInterceptor,
}
```
- **core**: `@UseGuards()`, `@UsePipes()`, `@UseFilters()`, and `@UseInterceptors()` extend metadata, instead of overriding existing one
- **core**: dependency injection everywhere (pipes, filters, interceptors, and guards)
- **core**: pass `ArgumentsHost` to exception filters (ability to access each argument)
- **core**: pass enhanced `ExecutionContext` to both interceptors and guards (ability to access each argument and execution context)
- **microservices**: improve existing transporters (TCP, Redis), provide new strategies: Nats, MQTT, gRPC
### Bug Fixes
- **common**: incorrent `multer` dependency [#532](https://github.com/nestjs/nest/issues/532)
- **core**: hanging `NestApplicationContext` process [#503](https://github.com/nestjs/nest/issues/503)
- **microservices**: concurrency issues (both TCP and Redis transporters) [#505](https://github.com/nestjs/nest/issues/505)
### Improvements
- **all**: remove `reflect-metadata` peer dependency [#563](https://github.com/nestjs/nest/issues/563)
- **all**: upgrade RxJS (make use of pipeable operators)
- **core**: more descriptive exceptions (circular dependency) [#493](https://github.com/nestjs/nest/issues/493)
- **core**: Nest container compatible with `useContainer()` (`class-validator` and `typeorm` packages) [#528](https://github.com/nestjs/nest/issues/528)
- **core**: remove static dependencies (webpack compatibility)
- **websockets**: `@WebSocketGateway()` takes options argument that is passed to socket.io instance [#508](https://github.com/nestjs/nest/issues/508)
### Deprecations
- **common**: deprecate `@Component()`, `@Middleware()`, `@Interceptor()`, `@Pipe()`, and `@Guard()` decorators (use `@Injectable()` instead)
- **core**: deprecate `modules: []` property (use `imports: []` instead)
- **core**: deprecate `components: []` property (use `providers: []` instead)
### Notes
- move from traditional express middleware model: each middleware is solely bounded to a particular path, regardless of the request method
## 4.6.6
### Bug Fixes:
- **common**: `File(s)Interceptor` throws http status code 500 [#465](https://github.com/nestjs/nest/issues/437)
@@ -130,10 +182,10 @@
## 4.3.0
- **common**: `ValidationPipe` is now available out-of-the-box (`@nestjs/common`)
- **core**: `json` and `urlencoded` (`body-parser`) middlewares are applied by default now, bugfix #252
- **core**: `json` and `urlencoded` (`body-parser`) middleware are applied by default now, bugfix #252
- **core** more informative error message (injector) #223
example: `[ExceptionHandler] Nest can't resolve dependencies of the UsersService (+, +, ?, +, +, +). Please verify whether [2] argument is available in the current context.`
- **core**: bugfix #240 - middlewares container state
- **core**: bugfix #240 - middleware container state
- **core**: bugifx #257 - `@Next()` issue
- **testing**: testing module is now independent from `@nestjs/microservices`
@@ -183,7 +235,7 @@ example: `[ExceptionHandler] Nest can't resolve dependencies of the UsersService
- `@Shared()` deprecated (modules are singletons by default) [read more](http://www.docs.nestjs.com/modules)
- `@SingleScope()` decorator [read more](http://www.docs.nestjs.com/modules)
- Modules re-exporting [read more](http://www.docs.nestjs.com/modules)
- Deffered & functional middlewares [read more](http://www.docs.nestjs.com/middlewares)
- Deffered & functional middleware [read more](http://www.docs.nestjs.com/middleware)
- Guards feature [read more](http://www.docs.nestjs.com/guards)
- Async components [read more](http://www.docs.nestjs.com/advanced/async-components)
- Hierarchical injector improvements [read more](http://www.docs.nestjs.com/advanced/hierarchical-injector)
@@ -206,7 +258,7 @@ example: `[ExceptionHandler] Nest can't resolve dependencies of the UsersService
## 3.0.1 (24.06.2017)
**@nestjs/core**
- Hierarchical injector bugfix,
- Middlewares `@UseFilters()` bugfix (#95).
- Middleware `@UseFilters()` bugfix (#95).
**@nestjs/microservices**
- TCP server / client bugfix (#91)
@@ -271,12 +323,12 @@ example: `[ExceptionHandler] Nest can't resolve dependencies of the UsersService
## 1.0.0 (Final - 01.05.2017)
- Added **Gateway Middlewares** support:
- Added **Gateway Middleware** support:
```
@WebSocketGateway({
port: 2000,
middlewares: [ChatMiddleware],
middleware: [ChatMiddleware],
})
```
Gateway Middleware example:
@@ -319,7 +371,7 @@ Session: () => ParameterDecorator
Headers: (property?: string) => ParameterDecorator
```
- `MiddlewaresBuilder` -> `MiddlewaresConsumer`
- `MiddlewareBuilder` -> `MiddlewareConsumer`
- **Exception Filters** support
```

View File

@@ -1,12 +1,12 @@
<p align="center">
<a href="http://nestjs.com/" target="blank"><img src="http://kamilmysliwiec.com/public/nest-logo.png#1" alt="Nest Logo" /></a>
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo_text.svg" width="320" alt="Nest Logo" /></a>
</p>
[travis-image]: https://api.travis-ci.org/nestjs/nest.svg?branch=master
[travis-url]: https://travis-ci.org/nestjs/nest
[linux-image]: https://img.shields.io/travis/nestjs/nest/master.svg?label=linux
[linux-url]: https://travis-ci.org/nestjs/nest
<p align="center">A progressive <a href="http://nodejs.org" target="blank">Node.js</a> framework for building efficient and scalable server-side applications, heavily inspired by <a href="https://angular.io" target="blank">Angular</a>.</p>
<p align="center">
<a href="https://www.npmjs.com/~nestjscore"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
@@ -14,10 +14,12 @@
<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#6" 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>
<a href="https://paypal.me/kamilmysliwiec"><img src="https://img.shields.io/badge/Donate-PayPal-ff3f59.svg"/></a>
<a href="https://twitter.com/nestframework"><img src="https://img.shields.io/twitter/follow/nestframework.svg?style=social&label=Follow"></a>
</p>
<!--[![Backers on Open Collective](https://opencollective.com/nest/backers/badge.svg)](https://opencollective.com/nest#backer)
[![Sponsors on Open Collective](https://opencollective.com/nest/sponsors/badge.svg)](https://opencollective.com/nest#sponsor)-->
@@ -25,7 +27,8 @@
## Description
<p>Nest is a framework for building efficient, scalable <a href="http://nodejs.org" target="_blank">Node.js</a> server-side applications. It uses modern JavaScript, is built with <a href="http://www.typescriptlang.org" target="_blank">TypeScript</a> (preserves compatibility with pure JavaScript) and combines elements of OOP (Object Oriented Programming), FP (Functional Programming), and FRP (Functional Reactive Programming).</p>
<p>Under the hood, Nest makes use of <a href="https://expressjs.com/" target="_blank">Express</a>, allowing for easy use of the myriad third-party plugins which are available.</p>
<p>Under the hood, Nest makes use of <a href="https://expressjs.com/" target="_blank">Express</a>, but also, provides compatibility with a wide range of other libraries, like e.g. <a href="https://github.com/fastify/fastify" target="blank">Fastify</a>, allowing for easy use of the myriad third-party plugins which are available.</p>
## Philosophy
@@ -38,16 +41,17 @@ To check out the [guide](https://docs.nestjs.com), visit [docs.nestjs.com](https
## Support
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://opencollective.com/nest).
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support).
#### Principal Sponsor
<a href="https://valor-software.com/"><img src="https://docs.nestjs.com/assets/sponsors/valor-software.png" width="210" /></a>
<a href="https://valor-software.com/"><img src="https://docs.nestjs.com/assets/sponsors/valor-software.png" width="300" /></a>
#### Sponsors
<a href="https://scal.io"><img src="https://nestjs.com/img/scalio-logo.svg" width="160" /></a> &nbsp; <a href="https://www.swingdev.io"><img src="https://nestjs.com/img/swingdev-logo.svg#1" width="160" /></a>
## Backers
<a href="https://scal.io"><img src="https://nestjs.com/img/scalio-logo.svg" width="150" /></a> &nbsp; <a href="https://www.swingdev.io"><img src="https://nestjs.com/img/swingdev-logo.svg#1" width="150" /></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>
@@ -96,12 +100,12 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
## Stay in touch
- Author - [Kamil Myśliwiec](https://kamilmysliwiec.com)
- Website - [https://nestjs.com](https://nestjs.com/)
- Twitter - [@nestframework](https://twitter.com/nestframework)
* Author - [Kamil Myśliwiec](https://kamilmysliwiec.com)
* Website - [https://nestjs.com](https://nestjs.com/)
* Twitter - [@nestframework](https://twitter.com/nestframework)
## License
Nest is [MIT licensed](LICENSE).
Nest is [MIT licensed](LICENSE).
<h4 align="center"> <a href="readme_zh.md">中文说明</a></h4>

View File

@@ -1,12 +1,12 @@
<p align="center">
<a href="http://nestjs.com/" target="blank"><img src="http://kamilmysliwiec.com/public/nest-logo.png#1" alt="Nest Logo" /></a>
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo_text.svg" width="320" alt="Nest Logo" /></a>
</p>
[travis-image]: https://api.travis-ci.org/nestjs/nest.svg?branch=master
[travis-url]: https://travis-ci.org/nestjs/nest
[linux-image]: https://img.shields.io/travis/nestjs/nest/master.svg?label=linux
[linux-url]: https://travis-ci.org/nestjs/nest
<p align="center">A progressive <a href="http://nodejs.org" target="blank">Node.js</a> framework for building efficient and scalable server-side applications, heavily inspired by <a href="https://angular.io" target="blank">Angular</a>.</p>
<p align="center">
<a href="https://www.npmjs.com/~nestjscore"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
@@ -18,6 +18,8 @@
<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>
<a href="https://paypal.me/kamilmysliwiec"><img src="https://img.shields.io/badge/Donate-PayPal-ff3f59.svg"/></a>
<a href="https://twitter.com/nestframework"><img src="https://img.shields.io/twitter/follow/nestframework.svg?style=social&label=Follow"></a>
</p>
<!--[![Backers on Open Collective](https://opencollective.com/nest/backers/badge.svg)](https://opencollective.com/nest#backer)
[![Sponsors on Open Collective](https://opencollective.com/nest/sponsors/badge.svg)](https://opencollective.com/nest#sponsor)-->
@@ -25,7 +27,8 @@
## Description
<p>Nest is a framework for building efficient, scalable <a href="http://nodejs.org" target="_blank">Node.js</a> server-side applications. It uses modern JavaScript, is built with <a href="http://www.typescriptlang.org" target="_blank">TypeScript</a> (preserves compatibility with pure JavaScript) and combines elements of OOP (Object Oriented Programming), FP (Functional Programming), and FRP (Functional Reactive Programming).</p>
<p>Under the hood, Nest makes use of <a href="https://expressjs.com/" target="_blank">Express</a>, allowing for easy use of the myriad third-party plugins which are available.</p>
<p>Under the hood, Nest makes use of <a href="https://expressjs.com/" target="_blank">Express</a>, but also, provides compatibility with a wide range of other libraries, like e.g. <a href="https://github.com/fastify/fastify" target="blank">Fastify</a>, allowing for easy use of the myriad third-party plugins which are available.</p>
## Philosophy
@@ -38,16 +41,17 @@ To check out the [guide](https://docs.nestjs.com), visit [docs.nestjs.com](https
## Support
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://opencollective.com/nest).
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support).
#### Principal Sponsor
<a href="https://valor-software.com/"><img src="https://docs.nestjs.com/assets/sponsors/valor-software.png" width="210" /></a>
<a href="https://valor-software.com/"><img src="https://docs.nestjs.com/assets/sponsors/valor-software.png" width="300" /></a>
#### Sponsors
<a href="https://scal.io"><img src="https://nestjs.com/img/scalio-logo.svg" width="160" /></a> &nbsp; <a href="https://www.swingdev.io"><img src="https://nestjs.com/img/swingdev-logo.svg#1" width="160" /></a>
## Backers
<a href="https://scal.io"><img src="https://nestjs.com/img/scalio-logo.svg" width="150" /></a> &nbsp; <a href="https://www.swingdev.io"><img src="https://nestjs.com/img/swingdev-logo.svg#1" width="150" /></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>
@@ -96,12 +100,12 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
## Stay in touch
- Author - [Kamil Myśliwiec](https://kamilmysliwiec.com)
- Website - [https://nestjs.com](https://nestjs.com/)
- Twitter - [@nestframework](https://twitter.com/nestframework)
* Author - [Kamil Myśliwiec](https://kamilmysliwiec.com)
* Website - [https://nestjs.com](https://nestjs.com/)
* Twitter - [@nestframework](https://twitter.com/nestframework)
## License
Nest is [MIT licensed](LICENSE).
Nest is [MIT licensed](LICENSE).
<h4 align="center"> <a href="readme_zh.md">中文说明</a></h4>

27
bundle/common/constants.d.ts vendored Normal file
View File

@@ -0,0 +1,27 @@
export declare const metadata: {
MODULES: string;
IMPORTS: string;
COMPONENTS: string;
PROVIDERS: string;
CONTROLLERS: string;
EXPORTS: string;
};
export declare const SHARED_MODULE_METADATA = "__sharedModule__";
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 METHOD_METADATA = "method";
export declare const ROUTE_ARGS_METADATA = "__routeArguments__";
export declare const CUSTOM_ROUTE_AGRS_METADATA = "__customRouteArgs__";
export declare const EXCEPTION_FILTERS_METADATA = "__exceptionFilters__";
export declare const FILTER_CATCH_EXCEPTIONS = "__filterCatchExceptions__";
export declare const PIPES_METADATA = "__pipes__";
export declare const GUARDS_METADATA = "__guards__";
export declare const RENDER_METADATA = "__renderTemplate__";
export declare const INTERCEPTORS_METADATA = "__interceptors__";
export declare const HTTP_CODE_METADATA = "__httpCode__";
export declare const GATEWAY_MIDDLEWARES = "__gatewayMiddleware";
export declare const MODULE_PATH = "__module_path__";
export declare const HEADERS_METADATA = "__headers__";
export declare const REDIRECT_METADATA = "__redirect__";

View File

@@ -4,6 +4,7 @@ exports.metadata = {
MODULES: 'modules',
IMPORTS: 'imports',
COMPONENTS: 'components',
PROVIDERS: 'providers',
CONTROLLERS: 'controllers',
EXPORTS: 'exports',
};
@@ -22,5 +23,7 @@ exports.GUARDS_METADATA = '__guards__';
exports.RENDER_METADATA = '__renderTemplate__';
exports.INTERCEPTORS_METADATA = '__interceptors__';
exports.HTTP_CODE_METADATA = '__httpCode__';
exports.GATEWAY_MIDDLEWARES = '__gatewayMiddlewares';
exports.GATEWAY_MIDDLEWARES = '__gatewayMiddleware';
exports.MODULE_PATH = '__module_path__';
exports.HEADERS_METADATA = '__headers__';
exports.REDIRECT_METADATA = '__redirect__';

View File

@@ -0,0 +1,6 @@
/**
* Binds parameters decorators to the particular method
* Useful when the language doesn't provide a 'Parameter Decorators' feature (vanilla JavaScript)
* @param {} ...decorators
*/
export declare function Bind(...decorators: any[]): (target: object, key: any, descriptor: any) => any;

View File

@@ -1,8 +1,8 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
* Binds parameters decorators to the method
* Useful when the language doesn't provide a 'Parameter Decorators' feature
* Binds parameters decorators to the particular method
* Useful when the language doesn't provide a 'Parameter Decorators' feature (vanilla JavaScript)
* @param {} ...decorators
*/
function Bind(...decorators) {

View File

@@ -1,6 +1,6 @@
import 'reflect-metadata';
/**
* Defines the Exceptions Filter. Takes set of exception types as an argument, which has to be catched by this Filter.
* The class should implements the `ExceptionFilter` interface.
* 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;

View File

@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
require("reflect-metadata");
const constants_1 = require("../../constants");
/**
* Defines the Exceptions Filter. Takes set of exception types as an argument, which has to be catched by this Filter.
* The class should implements the `ExceptionFilter` interface.
* 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.
*/
function Catch(...exceptions) {
return (target) => {

View File

@@ -1,21 +1,31 @@
/**
* Defines the injectable class. This class can inject dependencies through constructor.
* Those dependencies have to belong to the same module.
*/
export declare function Injectable(): ClassDecorator;
/**
* @deprecated
* Defines the Component. The component can inject dependencies through constructor.
* Those dependencies should belongs to the same module.
* Those dependencies have to belong to the same module.
*/
export declare function Component(): ClassDecorator;
/**
* Defines the Pipe. The Pipe should implements the `PipeTransform` interface.
* @deprecated
* Defines the Pipe. The Pipe should implement the `PipeTransform` interface.
*/
export declare function Pipe(): ClassDecorator;
/**
* @deprecated
* Defines the Guard. The Guard should implement the `CanActivate` interface.
*/
export declare function Guard(): ClassDecorator;
/**
* @deprecated
* Defines the Middleware. The Middleware should implement the `NestMiddleware` interface.
*/
export declare function Middleware(): ClassDecorator;
/**
* @deprecated
* Defines the Interceptor. The Interceptor should implement `HttpInterceptor`, `RpcInterceptor` or `WsInterceptor` interface.
*/
export declare function Interceptor(): ClassDecorator;

View File

@@ -0,0 +1,66 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const deprecate = require("deprecate");
/**
* Defines the injectable class. This class can inject dependencies through constructor.
* Those dependencies have to belong to the same module.
*/
function Injectable() {
return (target) => { };
}
exports.Injectable = Injectable;
/**
* @deprecated
* Defines the Component. The component can inject dependencies through constructor.
* Those dependencies have to belong to the same module.
*/
function Component() {
deprecate('The @Component() decorator is deprecated and will be removed within next major release. Use @Injectable() instead.');
return (target) => { };
}
exports.Component = Component;
/**
* @deprecated
* Defines the Pipe. The Pipe should implement the `PipeTransform` interface.
*/
function Pipe() {
deprecate('The @Pipe() decorator is deprecated and will be removed within next major release. Use @Injectable() instead.');
return (target) => { };
}
exports.Pipe = Pipe;
/**
* @deprecated
* Defines the Guard. The Guard should implement the `CanActivate` interface.
*/
function Guard() {
deprecate('The @Guard() decorator is deprecated and will be removed within next major release. Use @Injectable() instead.');
return (target) => { };
}
exports.Guard = Guard;
/**
* @deprecated
* Defines the Middleware. The Middleware should implement the `NestMiddleware` interface.
*/
function Middleware() {
deprecate('The @Middleware() decorator is deprecated and will be removed within next major release. Use @Injectable() instead.');
return (target) => { };
}
exports.Middleware = Middleware;
/**
* @deprecated
* Defines the Interceptor. The Interceptor should implement `HttpInterceptor`, `RpcInterceptor` or `WsInterceptor` interface.
*/
function Interceptor() {
deprecate('The @Interceptor() decorator is deprecated and will be removed within next major release. Use @Injectable() instead.');
return (target) => { };
}
exports.Interceptor = Interceptor;
function mixin(mixinClass) {
this.offset = this.offset ? ++this.offset : Math.random() * 100;
Object.defineProperty(mixinClass, 'name', {
value: JSON.stringify(this.offset),
});
Injectable()(mixinClass);
return mixinClass;
}
exports.mixin = mixin;

View File

@@ -1,6 +1,6 @@
import 'reflect-metadata';
/**
* Defines the Controller. The controller can inject dependencies through constructor.
* Those dependencies should belongs to the same module.
* Those dependencies have to belong to the same module.
*/
export declare function Controller(prefix?: string): ClassDecorator;

View File

@@ -5,7 +5,7 @@ const shared_utils_1 = require("../../utils/shared.utils");
const constants_1 = require("../../constants");
/**
* Defines the Controller. The controller can inject dependencies through constructor.
* Those dependencies should belongs to the same module.
* Those dependencies have to belong to the same module.
*/
function Controller(prefix) {
const path = shared_utils_1.isUndefined(prefix) ? '/' : prefix;

View File

@@ -1,2 +1,3 @@
import 'reflect-metadata';
export declare function flatten(arr: any[]): any;
export declare const Dependencies: (...dependencies: any[]) => ClassDecorator;

View File

@@ -2,10 +2,11 @@
Object.defineProperty(exports, "__esModule", { value: true });
require("reflect-metadata");
const constants_1 = require("../../constants");
const flatten = arr => {
function flatten(arr) {
const flat = [].concat(...arr);
return flat.some(Array.isArray) ? flatten(flat) : flat;
};
}
exports.flatten = flatten;
exports.Dependencies = (...dependencies) => {
const flattenDeps = flatten(dependencies);
return (target) => {

View File

@@ -8,8 +8,6 @@ import { ExceptionFilter } from '../../index';
* When the `@UseFilters()` is used on the handle level:
* - Exception Filter will be set up only to specified method
*
* @param {ExceptionFilter[]} ...filters (instances)
* @param {ExceptionFilter[]} ...filters
*/
export declare const UseFilters: (
...filters: ExceptionFilter[]
) => (target: object, key?: any, descriptor?: any) => any;
export declare const UseFilters: (...filters: (Function | ExceptionFilter<any>)[]) => (target: any, key?: any, descriptor?: any) => any;

View File

@@ -0,0 +1,31 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
require("reflect-metadata");
const constants_1 = require("../../constants");
const extend_metadata_util_1 = require("../../utils/extend-metadata.util");
const shared_utils_1 = require("../../utils/shared.utils");
const validate_each_util_1 = require("../../utils/validate-each.util");
const defineFiltersMetadata = (...filters) => {
return (target, key, descriptor) => {
const isFilterValid = filter => filter && (shared_utils_1.isFunction(filter) || shared_utils_1.isFunction(filter.catch));
if (descriptor) {
validate_each_util_1.validateEach(target.constructor, filters, isFilterValid, '@UseFilters', 'filter');
extend_metadata_util_1.extendArrayMetadata(constants_1.EXCEPTION_FILTERS_METADATA, filters, descriptor.value);
return descriptor;
}
validate_each_util_1.validateEach(target, filters, isFilterValid, '@UseFilters', 'filter');
extend_metadata_util_1.extendArrayMetadata(constants_1.EXCEPTION_FILTERS_METADATA, filters, target);
return target;
};
};
/**
* Setups exception filters to the chosen context.
* When the `@UseFilters()` is used on the controller level:
* - Exception Filter will be set up to every handler (every method)
*
* When the `@UseFilters()` is used on the handle level:
* - Exception Filter will be set up only to specified method
*
* @param {ExceptionFilter[]} ...filters
*/
exports.UseFilters = (...filters) => defineFiltersMetadata(...filters);

View File

@@ -0,0 +1,6 @@
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;

View File

@@ -4,8 +4,8 @@ require("reflect-metadata");
const constants_1 = require("../../constants");
const shared_utils_1 = require("../../utils/shared.utils");
/**
* Injects component, which has to be available in the current injector (module) scope.
* Components are recognized by types / or tokens.
* Injects provider which has to be available in the current injector (module) scope.
* Providers are recognized by types or tokens.
*/
function Inject(token) {
return (target, key, index) => {

View File

@@ -0,0 +1,5 @@
/**
* 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;

View File

@@ -0,0 +1,12 @@
import { CanActivate } from '../../interfaces';
/**
* Binds guards to the particular context.
* When the `@UseGuards()` is used on the controller level:
* - Guard will be register to each handler (every method)
*
* When the `@UseGuards()` is used on the handler level:
* - Guard will be registered only to specified method
*
* @param {} ...guards
*/
export declare function UseGuards(...guards: (CanActivate | Function)[]): (target: any, key?: any, descriptor?: any) => any;

View File

@@ -0,0 +1,30 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const constants_1 = require("../../constants");
const extend_metadata_util_1 = require("../../utils/extend-metadata.util");
const validate_each_util_1 = require("../../utils/validate-each.util");
const shared_utils_1 = require("../../utils/shared.utils");
/**
* Binds guards to the particular context.
* When the `@UseGuards()` is used on the controller level:
* - Guard will be register to each handler (every method)
*
* When the `@UseGuards()` is used on the handler level:
* - Guard will be registered only to specified method
*
* @param {} ...guards
*/
function UseGuards(...guards) {
return (target, key, descriptor) => {
const isValidGuard = guard => guard && (shared_utils_1.isFunction(guard) || shared_utils_1.isFunction(guard.canActivate));
if (descriptor) {
validate_each_util_1.validateEach(target.constructor, guards, isValidGuard, '@UseGuards', 'guard');
extend_metadata_util_1.extendArrayMetadata(constants_1.GUARDS_METADATA, guards, descriptor.value);
return descriptor;
}
validate_each_util_1.validateEach(target, guards, isValidGuard, '@UseGuards', 'guard');
extend_metadata_util_1.extendArrayMetadata(constants_1.GUARDS_METADATA, guards, target);
return target;
};
}
exports.UseGuards = UseGuards;

View File

@@ -0,0 +1,12 @@
import { NestInterceptor } from '../../interfaces';
/**
* Binds interceptors to the particular context.
* When the `@UseInterceptors()` is used on the controller level:
* - Interceptor will be register to each handler (every method)
*
* When the `@UseInterceptors()` is used on the handle level:
* - Interceptor will be registered only to specified method
*
* @param {} ...interceptors
*/
export declare function UseInterceptors(...interceptors: (NestInterceptor | Function)[]): (target: any, key?: any, descriptor?: any) => any;

View File

@@ -0,0 +1,31 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const constants_1 = require("../../constants");
const extend_metadata_util_1 = require("../../utils/extend-metadata.util");
const shared_utils_1 = require("../../utils/shared.utils");
const validate_each_util_1 = require("../../utils/validate-each.util");
/**
* Binds interceptors to the particular context.
* When the `@UseInterceptors()` is used on the controller level:
* - Interceptor will be register to each handler (every method)
*
* When the `@UseInterceptors()` is used on the handle level:
* - Interceptor will be registered only to specified method
*
* @param {} ...interceptors
*/
function UseInterceptors(...interceptors) {
return (target, key, descriptor) => {
const isValidInterceptor = interceptor => interceptor &&
(shared_utils_1.isFunction(interceptor) || shared_utils_1.isFunction(interceptor.intercept));
if (descriptor) {
validate_each_util_1.validateEach(target.constructor, interceptors, isValidInterceptor, '@UseInterceptors', 'interceptor');
extend_metadata_util_1.extendArrayMetadata(constants_1.INTERCEPTORS_METADATA, interceptors, descriptor.value);
return descriptor;
}
validate_each_util_1.validateEach(target, interceptors, isValidInterceptor, '@UseInterceptors', 'interceptor');
extend_metadata_util_1.extendArrayMetadata(constants_1.INTERCEPTORS_METADATA, interceptors, target);
return target;
};
}
exports.UseInterceptors = UseInterceptors;

View File

@@ -0,0 +1,12 @@
import { PipeTransform } from '../../interfaces/index';
/**
* Binds pipes to the particular context.
* When the `@UsePipes()` is used on the controller level:
* - Pipe will be register to each handler (every method)
*
* When the `@UsePipes()` is used on the handle level:
* - Pipe will be registered only to specified method
*
* @param {PipeTransform[]} ...pipes
*/
export declare function UsePipes(...pipes: (PipeTransform | Function)[]): (target: any, key?: any, descriptor?: any) => any;

View File

@@ -0,0 +1,29 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const constants_1 = require("../../constants");
const extend_metadata_util_1 = require("../../utils/extend-metadata.util");
const validate_each_util_1 = require("../../utils/validate-each.util");
const shared_utils_1 = require("../../utils/shared.utils");
/**
* Binds pipes to the particular context.
* When the `@UsePipes()` is used on the controller level:
* - Pipe will be register to each handler (every method)
*
* When the `@UsePipes()` is used on the handle level:
* - Pipe will be registered only to specified method
*
* @param {PipeTransform[]} ...pipes
*/
function UsePipes(...pipes) {
return (target, key, descriptor) => {
const isPipeValid = pipe => pipe && (shared_utils_1.isFunction(pipe) || shared_utils_1.isFunction(pipe.transform));
if (descriptor) {
extend_metadata_util_1.extendArrayMetadata(constants_1.PIPES_METADATA, pipes, descriptor.value);
return descriptor;
}
validate_each_util_1.validateEach(target, pipes, isPipeValid, '@UsePipes', 'pipe');
extend_metadata_util_1.extendArrayMetadata(constants_1.PIPES_METADATA, pipes, target);
return target;
};
}
exports.UsePipes = UsePipes;

View File

@@ -0,0 +1,13 @@
import { CustomParamFactory } from '../../interfaces/features/custom-route-param-factory.interface';
import { PipeTransform } from '../../index';
/**
* Creates HTTP route param decorator
* @param factory
*/
export declare function createParamDecorator(factory: CustomParamFactory): (data?: any, ...pipes: PipeTransform<any>[]) => ParameterDecorator;
/**
* Creates HTTP route param decorator
* @deprecated
* @param factory
*/
export declare function createRouteParamDecorator(factory: CustomParamFactory): (data?: any, ...pipes: PipeTransform<any>[]) => ParameterDecorator;

View File

@@ -1,5 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const deprecate = require("deprecate");
const constants_1 = require("../../constants");
const assignCustomMetadata = (args, paramtype, index, factory, data, ...pipes) => (Object.assign({}, args, { [`${paramtype}${constants_1.CUSTOM_ROUTE_AGRS_METADATA}:${index}`]: {
index,
@@ -11,14 +12,24 @@ const randomString = () => Math.random()
.toString(36)
.substring(2, 15);
/**
* Create route params custom decorator
* Creates HTTP route param decorator
* @param factory
*/
function createParamDecorator(factory) {
const paramtype = randomString() + randomString();
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);
};
}
exports.createParamDecorator = createParamDecorator;
/**
* Creates HTTP route param decorator
* @deprecated
* @param factory
*/
function createRouteParamDecorator(factory) {
const paramtype = randomString() + randomString();
return (data, ...pipes) => (target, key, index) => {
const args = Reflect.getMetadata(constants_1.ROUTE_ARGS_METADATA, target, key) || {};
Reflect.defineMetadata(constants_1.ROUTE_ARGS_METADATA, assignCustomMetadata(args, paramtype, index, factory, data, ...pipes), target, key);
};
deprecate('The "createRouteParamDecorator" function is deprecated and will be removed within next major release. Use "createParamDecorator" instead.');
return createParamDecorator(factory);
}
exports.createRouteParamDecorator = createRouteParamDecorator;

View File

@@ -0,0 +1,5 @@
import 'reflect-metadata';
/**
* Sets a response header.
*/
export declare function Header(name: string, value: string): MethodDecorator;

View File

@@ -0,0 +1,15 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
require("reflect-metadata");
const constants_1 = require("../../constants");
const extend_metadata_util_1 = require("../../utils/extend-metadata.util");
/**
* Sets a response header.
*/
function Header(name, value) {
return (target, key, descriptor) => {
extend_metadata_util_1.extendArrayMetadata(constants_1.HEADERS_METADATA, [{ name, value }], descriptor.value);
return descriptor;
};
}
exports.Header = Header;

View File

@@ -1,5 +1,5 @@
/**
* Defines the HTTP status code, which should be sent with response.
* Defines the HTTP response status code.
* It overrides default status code for the given request method.
*
* @param {number} statusCode

View File

@@ -2,7 +2,7 @@
Object.defineProperty(exports, "__esModule", { value: true });
const constants_1 = require("../../constants");
/**
* Defines the HTTP status code, which should be sent with response.
* Defines the HTTP response status code.
* It overrides default status code for the given request method.
*
* @param {number} statusCode

View File

@@ -3,3 +3,4 @@ export * from './route-params.decorator';
export * from './http-code.decorator';
export * from './create-route-param-metadata.decorator';
export * from './render.decorator';
export * from './header.decorator';

View File

@@ -8,3 +8,4 @@ __export(require("./route-params.decorator"));
__export(require("./http-code.decorator"));
__export(require("./create-route-param-metadata.decorator"));
__export(require("./render.decorator"));
__export(require("./header.decorator"));

View File

@@ -0,0 +1,6 @@
import 'reflect-metadata';
/**
* Redirects request.
*/
export declare function Redirect(url: string): MethodDecorator;

View File

@@ -0,0 +1,14 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
require("reflect-metadata");
const constants_1 = require("../../constants");
/**
* Redirects request.
*/
function Redirect(url) {
return (target, key, descriptor) => {
Reflect.defineMetadata(constants_1.REDIRECT_METADATA, url, descriptor.value);
return descriptor;
};
}
exports.Redirect = Redirect;

View File

@@ -1,5 +1,5 @@
import 'reflect-metadata';
/**
* Defines a template that should be rendered by a controller.
* Defines a template to be rendered by the controller.
*/
export declare function Render(template: string): MethodDecorator;

View File

@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
require("reflect-metadata");
const constants_1 = require("../../constants");
/**
* Defines a template that should be rendered by a controller.
* Defines a template to be rendered by the controller.
*/
function Render(template) {
return (target, key, descriptor) => {

View File

@@ -1,8 +1,6 @@
import 'reflect-metadata';
import { RequestMappingMetadata } from '../../interfaces/request-mapping-metadata.interface';
export declare const RequestMapping: (
metadata?: RequestMappingMetadata,
) => MethodDecorator;
export declare const RequestMapping: (metadata?: RequestMappingMetadata) => MethodDecorator;
/**
* Routes HTTP POST requests to the specified path.
*/

View File

@@ -1,11 +1,12 @@
import 'reflect-metadata';
import { PipeTransform } from '../../index';
import { Type } from '../../interfaces';
export declare type ParamData = object | string | number;
export interface RouteParamsMetadata {
[prop: number]: {
index: number;
data?: ParamData;
};
[prop: number]: {
index: number;
data?: ParamData;
};
}
export declare const Request: () => ParameterDecorator;
export declare const Response: () => ParameterDecorator;
@@ -15,22 +16,13 @@ export declare const UploadedFile: () => ParameterDecorator;
export declare const UploadedFiles: () => ParameterDecorator;
export declare const Headers: (property?: string) => ParameterDecorator;
export declare function Query(): any;
export declare function Query(...pipes: PipeTransform<any>[]): any;
export declare function Query(
property: string,
...pipes: PipeTransform<any>[]
): any;
export declare function Query(...pipes: (Type<PipeTransform> | PipeTransform)[]): any;
export declare function Query(property: string, ...pipes: (Type<PipeTransform> | PipeTransform)[]): any;
export declare function Body(): any;
export declare function Body(...pipes: PipeTransform<any>[]): any;
export declare function Body(
property: string,
...pipes: PipeTransform<any>[]
): any;
export declare function Body(...pipes: (Type<PipeTransform> | PipeTransform)[]): any;
export declare function Body(property: string, ...pipes: (Type<PipeTransform> | PipeTransform)[]): any;
export declare function Param(): any;
export declare function Param(...pipes: PipeTransform<any>[]): any;
export declare function Param(
property: string,
...pipes: PipeTransform<any>[]
): any;
export declare function Param(...pipes: (Type<PipeTransform> | PipeTransform)[]): any;
export declare function Param(property: string, ...pipes: (Type<PipeTransform> | PipeTransform)[]): any;
export declare const Req: () => ParameterDecorator;
export declare const Res: () => ParameterDecorator;

View File

@@ -11,16 +11,16 @@ const assignMetadata = (args, paramtype, index, data, ...pipes) => (Object.assig
} }));
const createRouteParamDecorator = (paramtype) => {
return (data) => (target, key, index) => {
const args = Reflect.getMetadata(constants_1.ROUTE_ARGS_METADATA, target, key) || {};
Reflect.defineMetadata(constants_1.ROUTE_ARGS_METADATA, assignMetadata(args, paramtype, index, data), target, key);
const args = Reflect.getMetadata(constants_1.ROUTE_ARGS_METADATA, target.constructor, key) || {};
Reflect.defineMetadata(constants_1.ROUTE_ARGS_METADATA, assignMetadata(args, paramtype, index, data), target.constructor, key);
};
};
const createPipesRouteParamDecorator = (paramtype) => (data, ...pipes) => (target, key, index) => {
const args = Reflect.getMetadata(constants_1.ROUTE_ARGS_METADATA, target, key) || {};
const args = Reflect.getMetadata(constants_1.ROUTE_ARGS_METADATA, target.constructor, key) || {};
const hasParamData = shared_utils_1.isNil(data) || shared_utils_1.isString(data);
const paramData = hasParamData ? data : undefined;
const paramPipes = hasParamData ? pipes : [data, ...pipes];
Reflect.defineMetadata(constants_1.ROUTE_ARGS_METADATA, assignMetadata(args, paramtype, index, paramData, ...paramPipes), target, key);
Reflect.defineMetadata(constants_1.ROUTE_ARGS_METADATA, assignMetadata(args, paramtype, index, paramData, ...paramPipes), target.constructor, key);
};
exports.Request = createRouteParamDecorator(route_paramtypes_enum_1.RouteParamtypes.REQUEST);
exports.Response = createRouteParamDecorator(route_paramtypes_enum_1.RouteParamtypes.RESPONSE);

View File

@@ -1,3 +1,3 @@
export declare class InvalidModuleConfigException extends Error {
constructor(property: string);
constructor(property: string);
}

View File

@@ -1,6 +1,6 @@
import 'reflect-metadata';
/**
* Makes the module global-scoped.
* Once imported will be available for all of the existing modules.
* Once imported will be available for all existing modules.
*/
export declare function Global(): ClassDecorator;

View File

@@ -4,7 +4,7 @@ require("reflect-metadata");
const constants_1 = require("../../constants");
/**
* Makes the module global-scoped.
* Once imported will be available for all of the existing modules.
* Once imported will be available for all existing modules.
*/
function Global() {
return (target) => {

View File

@@ -1,4 +1,3 @@
export * from './module.decorator';
export * from './shared.decorator';
export * from './single-scope.decorator';
export * from './global.decorator';

View File

@@ -4,6 +4,5 @@ function __export(m) {
}
Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./module.decorator"));
__export(require("./shared.decorator"));
__export(require("./single-scope.decorator"));
__export(require("./global.decorator"));

View File

@@ -4,9 +4,9 @@ import { ModuleMetadata } from '../../interfaces/modules/module-metadata.interfa
* Defines the module
* - `imports` - the set of the 'imported' modules
* - `controllers` - the list of controllers (e.g. HTTP controllers)
* - `components` - the list of components that belong to this module. They can be injected between themselves.
* - `providers` - the list of providers that belong to this module. They can be injected between themselves.
* - `exports` - the set of components, which should be available for modules, which imports this module
* - `modules` - @deprecated the set of the 'imported' modules
* @param obj {ModuleMetadata} Module metadata
* - `components` - @deprecated the list of components that belong to this module. They can be injected between themselves.
* @param options {ModuleMetadata} Module metadata
*/
export declare function Module(obj: ModuleMetadata): ClassDecorator;
export declare function Module(metadata: ModuleMetadata): ClassDecorator;

View File

@@ -0,0 +1,61 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
require("reflect-metadata");
const deprecate = require("deprecate");
const constants_1 = require("../../constants");
const invalid_module_config_exception_1 = require("./exceptions/invalid-module-config.exception");
const metadataKeys = [
constants_1.metadata.MODULES,
constants_1.metadata.IMPORTS,
constants_1.metadata.EXPORTS,
constants_1.metadata.COMPONENTS,
constants_1.metadata.CONTROLLERS,
constants_1.metadata.PROVIDERS,
];
const validateKeys = (keys) => {
const isKeyInvalid = key => metadataKeys.findIndex(k => k === key) < 0;
const validateKey = key => {
if (!isKeyInvalid(key)) {
return;
}
throw new invalid_module_config_exception_1.InvalidModuleConfigException(key);
};
keys.forEach(validateKey);
};
/**
* Defines the module
* - `imports` - the set of the 'imported' modules
* - `controllers` - the list of controllers (e.g. HTTP controllers)
* - `providers` - the list of providers that belong to this module. They can be injected between themselves.
* - `exports` - the set of components, which should be available for modules, which imports this module
* - `components` - @deprecated the list of components that belong to this module. They can be injected between themselves.
* @param options {ModuleMetadata} Module metadata
*/
function Module(metadata) {
const propsKeys = Object.keys(metadata);
validateKeys(propsKeys);
showDeprecatedWarnings(metadata);
overrideModuleMetadata(metadata);
return (target) => {
for (const property in metadata) {
if (metadata.hasOwnProperty(property)) {
Reflect.defineMetadata(property, metadata[property], target);
}
}
};
}
exports.Module = Module;
function overrideModuleMetadata(moduleMetadata) {
moduleMetadata.modules = moduleMetadata.imports
? moduleMetadata.imports
: moduleMetadata.modules;
moduleMetadata.components = moduleMetadata.providers
? moduleMetadata.providers
: moduleMetadata.components;
}
function showDeprecatedWarnings(moduleMetadata) {
const modulesDeprecatedWarning = 'The "modules" key in the @Module() decorator is deprecated and will be removed within next major release. Use the "imports" key instead.';
const componentsDeprecatetWarning = 'The "components" key in the @Module() decorator is deprecated and will be removed within next major release. Use the "providers" key instead.';
moduleMetadata.modules && deprecate(modulesDeprecatedWarning);
moduleMetadata.components && deprecate(componentsDeprecatetWarning);
}

View File

@@ -1,6 +1,6 @@
import 'reflect-metadata';
/**
* Makes the module single-scoped (not singleton).
* Nest will always create the new instance of the module, when it's imported by another one.
* In this case, Nest will always create a new instance of this particular module when it's imported by another one.
*/
export declare function SingleScope(): ClassDecorator;

View File

@@ -4,7 +4,7 @@ require("reflect-metadata");
const constants_1 = require("../../constants");
/**
* Makes the module single-scoped (not singleton).
* Nest will always create the new instance of the module, when it's imported by another one.
* In this case, Nest will always create a new instance of this particular module when it's imported by another one.
*/
function SingleScope() {
return (target) => {

View File

@@ -0,0 +1,46 @@
export declare enum HttpStatus {
CONTINUE = 100,
SWITCHING_PROTOCOLS = 101,
PROCESSING = 102,
OK = 200,
CREATED = 201,
ACCEPTED = 202,
NON_AUTHORITATIVE_INFORMATION = 203,
NO_CONTENT = 204,
RESET_CONTENT = 205,
PARTIAL_CONTENT = 206,
AMBIGUOUS = 300,
MOVED_PERMANENTLY = 301,
FOUND = 302,
SEE_OTHER = 303,
NOT_MODIFIED = 304,
TEMPORARY_REDIRECT = 307,
PERMANENT_REDIRECT = 308,
BAD_REQUEST = 400,
UNAUTHORIZED = 401,
PAYMENT_REQUIRED = 402,
FORBIDDEN = 403,
NOT_FOUND = 404,
METHOD_NOT_ALLOWED = 405,
NOT_ACCEPTABLE = 406,
PROXY_AUTHENTICATION_REQUIRED = 407,
REQUEST_TIMEOUT = 408,
CONFLICT = 409,
GONE = 410,
LENGTH_REQUIRED = 411,
PRECONDITION_FAILED = 412,
PAYLOAD_TOO_LARGE = 413,
URI_TOO_LONG = 414,
UNSUPPORTED_MEDIA_TYPE = 415,
REQUESTED_RANGE_NOT_SATISFIABLE = 416,
EXPECTATION_FAILED = 417,
I_AM_A_TEAPOT = 418,
UNPROCESSABLE_ENTITY = 422,
TOO_MANY_REQUESTS = 429,
INTERNAL_SERVER_ERROR = 500,
NOT_IMPLEMENTED = 501,
BAD_GATEWAY = 502,
SERVICE_UNAVAILABLE = 503,
GATEWAY_TIMEOUT = 504,
HTTP_VERSION_NOT_SUPPORTED = 505,
}

View File

@@ -1,4 +1,4 @@
export declare enum NestEnvironment {
RUN = 0,
TEST = 1,
RUN = 0,
TEST = 1,
}

View File

@@ -0,0 +1,10 @@
export declare enum RequestMethod {
GET = 0,
POST = 1,
PUT = 2,
DELETE = 3,
PATCH = 4,
ALL = 5,
OPTIONS = 6,
HEAD = 7,
}

View File

@@ -0,0 +1,12 @@
export declare enum RouteParamtypes {
REQUEST = 0,
RESPONSE = 1,
NEXT = 2,
BODY = 3,
QUERY = 4,
PARAM = 5,
HEADERS = 6,
SESSION = 7,
FILE = 8,
FILES = 9,
}

View File

@@ -0,0 +1,7 @@
export declare enum Transport {
TCP = 0,
REDIS = 1,
NATS = 2,
MQTT = 3,
GRPC = 4,
}

View File

@@ -4,4 +4,7 @@ var Transport;
(function (Transport) {
Transport[Transport["TCP"] = 0] = "TCP";
Transport[Transport["REDIS"] = 1] = "REDIS";
Transport[Transport["NATS"] = 2] = "NATS";
Transport[Transport["MQTT"] = 3] = "MQTT";
Transport[Transport["GRPC"] = 4] = "GRPC";
})(Transport = exports.Transport || (exports.Transport = {}));

View File

@@ -1,4 +1,4 @@
import { HttpException } from './http.exception';
export declare class BadGatewayException extends HttpException {
constructor(message?: string | object | any, error?: string);
constructor(message?: string | object | any, error?: string);
}

View File

@@ -1,4 +1,4 @@
import { HttpException } from './http.exception';
export declare class BadRequestException extends HttpException {
constructor(message?: string | object | any, error?: string);
constructor(message?: string | object | any, error?: string);
}

View File

@@ -1,4 +1,4 @@
import { HttpException } from './http.exception';
export declare class ConflictException extends HttpException {
constructor(message?: string | object | any, error?: string);
constructor(message?: string | object | any, error?: string);
}

View File

@@ -1,4 +1,4 @@
import { HttpException } from './http.exception';
export declare class ForbiddenException extends HttpException {
constructor(message?: string | object | any, error?: string);
constructor(message?: string | object | any, error?: string);
}

View File

@@ -1,4 +1,4 @@
import { HttpException } from './http.exception';
export declare class GatewayTimeoutException extends HttpException {
constructor(message?: string | object | any, error?: string);
constructor(message?: string | object | any, error?: string);
}

View File

@@ -1,4 +1,4 @@
import { HttpException } from './http.exception';
export declare class GoneException extends HttpException {
constructor(message?: string | object | any, error?: string);
constructor(message?: string | object | any, error?: string);
}

View File

@@ -0,0 +1,22 @@
export declare class HttpException extends Error {
private readonly response;
private readonly status;
readonly message: any;
/**
* The base Nest Application exception, which is handled by the default Exceptions Handler.
* If you throw an exception from your HTTP route handlers, Nest will map them to the appropriate HTTP response and send to the client.
*
* When `response` is an object:
* - object will be stringified and returned to the user as a JSON response,
*
* When `response` is a string:
* - Nest will create a response with two properties:
* ```
* message: response,
* statusCode: X
* ```
*/
constructor(response: string | object, status: number);
getResponse(): string | object;
getStatus(): number;
}

View File

@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
class HttpException extends Error {
/**
* The base Nest Application exception, which is handled by the default Exceptions Handler.
* If you throw an exception from your HTTP route handler, Nest will map them to the appropriate HTTP response and send to the client.
* If you throw an exception from your HTTP route handlers, Nest will map them to the appropriate HTTP response and send to the client.
*
* When `response` is an object:
* - object will be stringified and returned to the user as a JSON response,

View File

@@ -1,4 +1,4 @@
import { HttpException } from './http.exception';
export declare class InternalServerErrorException extends HttpException {
constructor(message?: string | object | any, error?: string);
constructor(message?: string | object | any, error?: string);
}

View File

@@ -1,4 +1,4 @@
import { HttpException } from './http.exception';
export declare class MethodNotAllowedException extends HttpException {
constructor(message?: string | object | any, error?: string);
constructor(message?: string | object | any, error?: string);
}

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