mirror of
https://github.com/nestjs/nest.git
synced 2026-02-24 00:02:56 +00:00
Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cd30d7a4a5 | ||
|
|
a6d837e64a | ||
|
|
0904b0ba56 | ||
|
|
150c81e397 | ||
|
|
1717f35717 | ||
|
|
61b6b346da | ||
|
|
b02fb57d8f | ||
|
|
cb302e6719 | ||
|
|
1f9030c504 | ||
|
|
af5a4af675 | ||
|
|
664321465c | ||
|
|
f6d4b5e82a | ||
|
|
09c9f704e5 | ||
|
|
8a8b780273 | ||
|
|
afae462b6e | ||
|
|
2bdf47a572 |
@@ -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>
|
||||
@@ -58,7 +58,7 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
|
||||
|
||||
#### Sponsors
|
||||
|
||||
<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>
|
||||
<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
|
||||
|
||||
|
||||
@@ -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>
|
||||
@@ -58,7 +58,7 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
|
||||
|
||||
#### Sponsors
|
||||
|
||||
<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>
|
||||
<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
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nestjs/common",
|
||||
"version": "5.2.0",
|
||||
"version": "5.2.2",
|
||||
"description": "Nest - modern, fast, powerful node.js web framework (@common)",
|
||||
"author": "Kamil Mysliwiec",
|
||||
"license": "MIT",
|
||||
|
||||
@@ -61,7 +61,7 @@ let ValidationPipe = class ValidationPipe {
|
||||
return false;
|
||||
}
|
||||
const types = [String, Boolean, Number, Array, Object];
|
||||
return !types.find(t => metatype === t) && !shared_utils_1.isNil(metatype);
|
||||
return !types.some(t => metatype === t) && !shared_utils_1.isNil(metatype);
|
||||
}
|
||||
toEmptyIfNil(value) {
|
||||
return shared_utils_1.isNil(value) ? {} : value;
|
||||
|
||||
@@ -27,17 +27,16 @@ let Logger = Logger_1 = class Logger {
|
||||
Logger_1.log(message, context || this.context, this.isTimeDiffEnabled);
|
||||
return;
|
||||
}
|
||||
logger &&
|
||||
logger.log.call(logger, message, context || this.context, this.isTimeDiffEnabled);
|
||||
logger && logger.log.call(logger, message, context || this.context);
|
||||
}
|
||||
error(message, trace = '', context) {
|
||||
const { logger } = Logger_1;
|
||||
if (logger === this) {
|
||||
Logger_1.error(message, trace, context || this.context, this.isTimeDiffEnabled);
|
||||
Logger_1.error(message, trace, context || this.context);
|
||||
return;
|
||||
}
|
||||
logger &&
|
||||
logger.error.call(logger, message, trace, context || this.context, this.isTimeDiffEnabled);
|
||||
logger.error.call(logger, message, trace, context || this.context);
|
||||
}
|
||||
warn(message, context) {
|
||||
const { logger } = Logger_1;
|
||||
@@ -45,8 +44,7 @@ let Logger = Logger_1 = class Logger {
|
||||
Logger_1.warn(message, context || this.context, this.isTimeDiffEnabled);
|
||||
return;
|
||||
}
|
||||
logger &&
|
||||
logger.warn.call(logger, message, context || this.context, this.isTimeDiffEnabled);
|
||||
logger && logger.warn.call(logger, message, context || this.context);
|
||||
}
|
||||
static overrideLogger(logger) {
|
||||
this.logger = logger ? logger : null;
|
||||
|
||||
@@ -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>
|
||||
@@ -58,7 +58,7 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
|
||||
|
||||
#### Sponsors
|
||||
|
||||
<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>
|
||||
<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
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ class ExceptionsHandler extends base_exception_filter_1.BaseExceptionFilter {
|
||||
return false;
|
||||
const filter = this.filters.find(({ exceptionMetatypes, func }) => {
|
||||
const hasMetatype = !exceptionMetatypes.length ||
|
||||
!!exceptionMetatypes.find(ExceptionMetatype => exception instanceof ExceptionMetatype);
|
||||
exceptionMetatypes.some(ExceptionMetatype => exception instanceof ExceptionMetatype);
|
||||
return hasMetatype;
|
||||
});
|
||||
filter && filter.func(exception, response);
|
||||
|
||||
@@ -64,8 +64,8 @@ class ExternalContextCreator {
|
||||
}
|
||||
findComponentByClassName(module, className) {
|
||||
const { components } = module;
|
||||
const hasComponent = [...components.keys()].find(component => component === className);
|
||||
return !!hasComponent;
|
||||
const hasComponent = [...components.keys()].some(component => component === className);
|
||||
return hasComponent;
|
||||
}
|
||||
exchangeKeysForValues(keys, metadata, moduleContext, paramsFactory) {
|
||||
this.pipesContextCreator.setModuleContext(moduleContext);
|
||||
|
||||
@@ -108,7 +108,7 @@ class NestFactoryStatic {
|
||||
if (!options) {
|
||||
return;
|
||||
}
|
||||
logger_service_1.Logger.overrideLogger(options.logger);
|
||||
!shared_utils_1.isNil(options.logger) && logger_service_1.Logger.overrideLogger(options.logger);
|
||||
}
|
||||
applyExpressAdapter(httpAdapter) {
|
||||
const isAdapter = httpAdapter.getHttpServer;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nestjs/core",
|
||||
"version": "5.2.0",
|
||||
"version": "5.2.2",
|
||||
"description": "Nest - modern, fast, powerful node.js web framework (@core)",
|
||||
"author": "Kamil Mysliwiec",
|
||||
"license": "MIT",
|
||||
|
||||
@@ -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>
|
||||
@@ -58,7 +58,7 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
|
||||
|
||||
#### Sponsors
|
||||
|
||||
<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>
|
||||
<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
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ class RpcExceptionsHandler extends base_rpc_exception_filter_1.BaseRpcExceptionF
|
||||
return null;
|
||||
const filter = this.filters.find(({ exceptionMetatypes, func }) => {
|
||||
const hasMetatype = !exceptionMetatypes.length ||
|
||||
!!exceptionMetatypes.find(ExceptionMetatype => exception instanceof ExceptionMetatype);
|
||||
exceptionMetatypes.some(ExceptionMetatype => exception instanceof ExceptionMetatype);
|
||||
return hasMetatype;
|
||||
});
|
||||
return filter ? filter.func(exception, host) : null;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nestjs/microservices",
|
||||
"version": "5.2.0",
|
||||
"version": "5.2.2",
|
||||
"description": "Nest - modern, fast, powerful node.js web framework (@microservices)",
|
||||
"author": "Kamil Mysliwiec",
|
||||
"license": "MIT",
|
||||
|
||||
@@ -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>
|
||||
@@ -58,7 +58,7 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
|
||||
|
||||
#### Sponsors
|
||||
|
||||
<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>
|
||||
<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
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nestjs/testing",
|
||||
"version": "5.2.0",
|
||||
"version": "5.2.2",
|
||||
"description": "Nest - modern, fast, powerful node.js web framework (@testing)",
|
||||
"author": "Kamil Mysliwiec",
|
||||
"license": "MIT",
|
||||
|
||||
@@ -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>
|
||||
@@ -58,7 +58,7 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
|
||||
|
||||
#### Sponsors
|
||||
|
||||
<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>
|
||||
<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
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ class WsExceptionsHandler extends base_ws_exception_filter_1.BaseWsExceptionFilt
|
||||
return false;
|
||||
const filter = this.filters.find(({ exceptionMetatypes, func }) => {
|
||||
const hasMetatype = !exceptionMetatypes.length ||
|
||||
!!exceptionMetatypes.find(ExceptionMetatype => exception instanceof ExceptionMetatype);
|
||||
exceptionMetatypes.some(ExceptionMetatype => exception instanceof ExceptionMetatype);
|
||||
return hasMetatype;
|
||||
});
|
||||
filter && filter.func(exception, args);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nestjs/websockets",
|
||||
"version": "5.2.0",
|
||||
"version": "5.2.2",
|
||||
"description": "Nest - modern, fast, powerful node.js web framework (@websockets)",
|
||||
"author": "Kamil Mysliwiec",
|
||||
"license": "MIT",
|
||||
|
||||
36
integration/mongoose/e2e/async-class-options.spec.ts
Normal file
36
integration/mongoose/e2e/async-class-options.spec.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { INestApplication } from '@nestjs/common';
|
||||
import { Test } from '@nestjs/testing';
|
||||
import * as request from 'supertest';
|
||||
import { AsyncOptionsClassModule } from '../src/async-class-options.module';
|
||||
|
||||
describe('Mongoose', () => {
|
||||
let server;
|
||||
let app: INestApplication;
|
||||
|
||||
beforeEach(async () => {
|
||||
const module = await Test.createTestingModule({
|
||||
imports: [AsyncOptionsClassModule],
|
||||
}).compile();
|
||||
|
||||
app = module.createNestApplication();
|
||||
server = app.getHttpServer();
|
||||
await app.init();
|
||||
});
|
||||
|
||||
it(`should return created entity`, () => {
|
||||
const cat = {
|
||||
name: 'Nest',
|
||||
age: 20,
|
||||
breed: 'Awesome',
|
||||
};
|
||||
return request(server)
|
||||
.post('/cats')
|
||||
.send(cat)
|
||||
.expect(201)
|
||||
.expect(({ body }) => body.name === cat.name);
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
await app.close();
|
||||
});
|
||||
});
|
||||
36
integration/mongoose/e2e/async-existing-options.spec.ts
Normal file
36
integration/mongoose/e2e/async-existing-options.spec.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { INestApplication } from '@nestjs/common';
|
||||
import { Test } from '@nestjs/testing';
|
||||
import * as request from 'supertest';
|
||||
import { AsyncOptionsExistingModule } from '../src/async-existing-options.module';
|
||||
|
||||
describe('Mongoose', () => {
|
||||
let server;
|
||||
let app: INestApplication;
|
||||
|
||||
beforeEach(async () => {
|
||||
const module = await Test.createTestingModule({
|
||||
imports: [AsyncOptionsExistingModule],
|
||||
}).compile();
|
||||
|
||||
app = module.createNestApplication();
|
||||
server = app.getHttpServer();
|
||||
await app.init();
|
||||
});
|
||||
|
||||
it(`should return created entity`, () => {
|
||||
const cat = {
|
||||
name: 'Nest',
|
||||
age: 20,
|
||||
breed: 'Awesome',
|
||||
};
|
||||
return request(server)
|
||||
.post('/cats')
|
||||
.send(cat)
|
||||
.expect(201)
|
||||
.expect(({ body }) => body.name === cat.name);
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
await app.close();
|
||||
});
|
||||
});
|
||||
36
integration/mongoose/e2e/async-options.spec.ts
Normal file
36
integration/mongoose/e2e/async-options.spec.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { INestApplication } from '@nestjs/common';
|
||||
import { Test } from '@nestjs/testing';
|
||||
import * as request from 'supertest';
|
||||
import { AsyncOptionsFactoryModule } from '../src/async-options.module';
|
||||
|
||||
describe('Mongoose', () => {
|
||||
let server;
|
||||
let app: INestApplication;
|
||||
|
||||
beforeEach(async () => {
|
||||
const module = await Test.createTestingModule({
|
||||
imports: [AsyncOptionsFactoryModule],
|
||||
}).compile();
|
||||
|
||||
app = module.createNestApplication();
|
||||
server = app.getHttpServer();
|
||||
await app.init();
|
||||
});
|
||||
|
||||
it(`should return created entity`, () => {
|
||||
const cat = {
|
||||
name: 'Nest',
|
||||
age: 20,
|
||||
breed: 'Awesome',
|
||||
};
|
||||
return request(server)
|
||||
.post('/cats')
|
||||
.send(cat)
|
||||
.expect(201)
|
||||
.expect(({ body }) => body.name === cat.name);
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
await app.close();
|
||||
});
|
||||
});
|
||||
@@ -9,9 +9,9 @@
|
||||
"start:prod": "node dist/main.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@nestjs/common": "^5.0.0",
|
||||
"@nestjs/core": "^5.0.0",
|
||||
"@nestjs/mongoose": "^5.0.0",
|
||||
"@nestjs/common": "^5.2.0",
|
||||
"@nestjs/core": "^5.2.0",
|
||||
"@nestjs/mongoose": "^5.2.0",
|
||||
"mongoose": "^5.0.1",
|
||||
"reflect-metadata": "^0.1.12",
|
||||
"rxjs": "^6.0.0",
|
||||
|
||||
25
integration/mongoose/src/async-class-options.module.ts
Normal file
25
integration/mongoose/src/async-class-options.module.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import {
|
||||
MongooseModule,
|
||||
MongooseModuleOptions,
|
||||
MongooseOptionsFactory,
|
||||
} from '@nestjs/mongoose';
|
||||
import { CatsModule } from './cats/cats.module';
|
||||
|
||||
class ConfigService implements MongooseOptionsFactory {
|
||||
createMongooseOptions(): MongooseModuleOptions {
|
||||
return {
|
||||
uri: 'mongodb://localhost:27017/test',
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
MongooseModule.forRootAsync({
|
||||
useClass: ConfigService,
|
||||
}),
|
||||
CatsModule,
|
||||
],
|
||||
})
|
||||
export class AsyncOptionsClassModule {}
|
||||
32
integration/mongoose/src/async-existing-options.module.ts
Normal file
32
integration/mongoose/src/async-existing-options.module.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import {
|
||||
MongooseModule,
|
||||
MongooseModuleOptions,
|
||||
MongooseOptionsFactory,
|
||||
} from '@nestjs/mongoose';
|
||||
import { CatsModule } from './cats/cats.module';
|
||||
|
||||
class ConfigService implements MongooseOptionsFactory {
|
||||
createMongooseOptions(): MongooseModuleOptions {
|
||||
return {
|
||||
uri: 'mongodb://localhost:27017/test',
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@Module({
|
||||
providers: [ConfigService],
|
||||
exports: [ConfigService],
|
||||
})
|
||||
class ConfigModule {}
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
MongooseModule.forRootAsync({
|
||||
imports: [ConfigModule],
|
||||
useExisting: ConfigService,
|
||||
}),
|
||||
CatsModule,
|
||||
],
|
||||
})
|
||||
export class AsyncOptionsExistingModule {}
|
||||
15
integration/mongoose/src/async-options.module.ts
Normal file
15
integration/mongoose/src/async-options.module.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { MongooseModule } from '@nestjs/mongoose';
|
||||
import { CatsModule } from './cats/cats.module';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
MongooseModule.forRootAsync({
|
||||
useFactory: () => ({
|
||||
uri: 'mongodb://localhost:27017/test',
|
||||
}),
|
||||
}),
|
||||
CatsModule,
|
||||
],
|
||||
})
|
||||
export class AsyncOptionsFactoryModule {}
|
||||
29
integration/typeorm/e2e/typeorm-async-class.spec.ts
Normal file
29
integration/typeorm/e2e/typeorm-async-class.spec.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { INestApplication } from '@nestjs/common';
|
||||
import { Test } from '@nestjs/testing';
|
||||
import * as request from 'supertest';
|
||||
import { AsyncOptionsClassModule } from './../src/async-class-options.module';
|
||||
|
||||
describe('TypeOrm (async configuration)', () => {
|
||||
let server;
|
||||
let app: INestApplication;
|
||||
|
||||
beforeEach(async () => {
|
||||
const module = await Test.createTestingModule({
|
||||
imports: [AsyncOptionsClassModule],
|
||||
}).compile();
|
||||
|
||||
app = module.createNestApplication();
|
||||
server = app.getHttpServer();
|
||||
await app.init();
|
||||
});
|
||||
|
||||
it(`should return created entity`, () => {
|
||||
return request(server)
|
||||
.post('/photo')
|
||||
.expect(201, { name: 'Nest', description: 'Is great!', views: 6000 });
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
await app.close();
|
||||
});
|
||||
});
|
||||
29
integration/typeorm/e2e/typeorm-async-existing.spec.ts
Normal file
29
integration/typeorm/e2e/typeorm-async-existing.spec.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { INestApplication } from '@nestjs/common';
|
||||
import { Test } from '@nestjs/testing';
|
||||
import * as request from 'supertest';
|
||||
import { AsyncOptionsExistingModule } from './../src/async-existing-options.module';
|
||||
|
||||
describe('TypeOrm (async configuration)', () => {
|
||||
let server;
|
||||
let app: INestApplication;
|
||||
|
||||
beforeEach(async () => {
|
||||
const module = await Test.createTestingModule({
|
||||
imports: [AsyncOptionsExistingModule],
|
||||
}).compile();
|
||||
|
||||
app = module.createNestApplication();
|
||||
server = app.getHttpServer();
|
||||
await app.init();
|
||||
});
|
||||
|
||||
it(`should return created entity`, () => {
|
||||
return request(server)
|
||||
.post('/photo')
|
||||
.expect(201, { name: 'Nest', description: 'Is great!', views: 6000 });
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
await app.close();
|
||||
});
|
||||
});
|
||||
29
integration/typeorm/e2e/typeorm-async-options.spec.ts
Normal file
29
integration/typeorm/e2e/typeorm-async-options.spec.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { INestApplication } from '@nestjs/common';
|
||||
import { Test } from '@nestjs/testing';
|
||||
import * as request from 'supertest';
|
||||
import { AsyncOptionsFactoryModule } from './../src/async-options.module';
|
||||
|
||||
describe('TypeOrm (async configuration)', () => {
|
||||
let server;
|
||||
let app: INestApplication;
|
||||
|
||||
beforeEach(async () => {
|
||||
const module = await Test.createTestingModule({
|
||||
imports: [AsyncOptionsFactoryModule],
|
||||
}).compile();
|
||||
|
||||
app = module.createNestApplication();
|
||||
server = app.getHttpServer();
|
||||
await app.init();
|
||||
});
|
||||
|
||||
it(`should return created entity`, () => {
|
||||
return request(server)
|
||||
.post('/photo')
|
||||
.expect(201, { name: 'Nest', description: 'Is great!', views: 6000 });
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
await app.close();
|
||||
});
|
||||
});
|
||||
@@ -9,9 +9,9 @@
|
||||
"start:prod": "node dist/main.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@nestjs/common": "^5.0.0",
|
||||
"@nestjs/core": "^5.0.0",
|
||||
"@nestjs/typeorm": "^5.0.0",
|
||||
"@nestjs/common": "^5.2.0",
|
||||
"@nestjs/core": "^5.2.0",
|
||||
"@nestjs/typeorm": "^5.2.0",
|
||||
"mysql": "^2.15.0",
|
||||
"reflect-metadata": "^0.1.12",
|
||||
"rxjs": "^6.0.0",
|
||||
|
||||
36
integration/typeorm/src/async-class-options.module.ts
Normal file
36
integration/typeorm/src/async-class-options.module.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import {
|
||||
TypeOrmModule,
|
||||
TypeOrmModuleOptions,
|
||||
TypeOrmOptionsFactory,
|
||||
} from '@nestjs/typeorm';
|
||||
import { Photo } from './photo/photo.entity';
|
||||
import { PhotoModule } from './photo/photo.module';
|
||||
|
||||
class ConfigService implements TypeOrmOptionsFactory {
|
||||
createTypeOrmOptions(): TypeOrmModuleOptions {
|
||||
return {
|
||||
type: 'mysql',
|
||||
host: 'localhost',
|
||||
port: 3306,
|
||||
username: 'root',
|
||||
password: 'root',
|
||||
database: 'test',
|
||||
entities: [Photo],
|
||||
synchronize: true,
|
||||
keepConnectionAlive: true,
|
||||
retryAttempts: 2,
|
||||
retryDelay: 1000,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
TypeOrmModule.forRootAsync({
|
||||
useClass: ConfigService,
|
||||
}),
|
||||
PhotoModule,
|
||||
],
|
||||
})
|
||||
export class AsyncOptionsClassModule {}
|
||||
43
integration/typeorm/src/async-existing-options.module.ts
Normal file
43
integration/typeorm/src/async-existing-options.module.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import {
|
||||
TypeOrmModule,
|
||||
TypeOrmModuleOptions,
|
||||
TypeOrmOptionsFactory,
|
||||
} from '@nestjs/typeorm';
|
||||
import { Photo } from './photo/photo.entity';
|
||||
import { PhotoModule } from './photo/photo.module';
|
||||
|
||||
class ConfigService implements TypeOrmOptionsFactory {
|
||||
createTypeOrmOptions(): TypeOrmModuleOptions {
|
||||
return {
|
||||
type: 'mysql',
|
||||
host: 'localhost',
|
||||
port: 3306,
|
||||
username: 'root',
|
||||
password: 'root',
|
||||
database: 'test',
|
||||
entities: [Photo],
|
||||
synchronize: true,
|
||||
keepConnectionAlive: true,
|
||||
retryAttempts: 2,
|
||||
retryDelay: 1000,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@Module({
|
||||
providers: [ConfigService],
|
||||
exports: [ConfigService],
|
||||
})
|
||||
class ConfigModule {}
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
TypeOrmModule.forRootAsync({
|
||||
imports: [ConfigModule],
|
||||
useExisting: ConfigService,
|
||||
}),
|
||||
PhotoModule,
|
||||
],
|
||||
})
|
||||
export class AsyncOptionsExistingModule {}
|
||||
26
integration/typeorm/src/async-options.module.ts
Normal file
26
integration/typeorm/src/async-options.module.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { Photo } from './photo/photo.entity';
|
||||
import { PhotoModule } from './photo/photo.module';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
TypeOrmModule.forRootAsync({
|
||||
useFactory: () => ({
|
||||
type: 'mysql',
|
||||
host: 'localhost',
|
||||
port: 3306,
|
||||
username: 'root',
|
||||
password: 'root',
|
||||
database: 'test',
|
||||
entities: [Photo],
|
||||
synchronize: true,
|
||||
keepConnectionAlive: true,
|
||||
retryAttempts: 2,
|
||||
retryDelay: 1000,
|
||||
}),
|
||||
}),
|
||||
PhotoModule,
|
||||
],
|
||||
})
|
||||
export class AsyncOptionsFactoryModule {}
|
||||
@@ -3,5 +3,5 @@
|
||||
"packages": [
|
||||
"bundle/*"
|
||||
],
|
||||
"version": "5.2.0"
|
||||
"version": "5.2.2"
|
||||
}
|
||||
|
||||
49
package.json
49
package.json
@@ -1,14 +1,18 @@
|
||||
{
|
||||
"name": "nestjs",
|
||||
"version": "5.0.0",
|
||||
"version": "5.2.1",
|
||||
"description": "Modern, fast, powerful node.js web framework",
|
||||
"scripts": {
|
||||
"coverage": "nyc report --reporter=text-lcov | coveralls",
|
||||
"precommit": "lint-staged",
|
||||
"test": "nyc --require ts-node/register mocha packages/**/*.spec.ts --reporter spec",
|
||||
"integration-test": "mocha integration/**/*.spec.ts --reporter spec --require ts-node/register",
|
||||
"lint": "tslint -p tsconfig.json -c tslint.json \"packages/**/*.ts\" -e \"*.spec.ts\"",
|
||||
"format": "prettier **/**/*.ts --ignore-path ./.prettierignore --write && git status",
|
||||
"test":
|
||||
"nyc --require ts-node/register mocha packages/**/*.spec.ts --reporter spec",
|
||||
"integration-test":
|
||||
"mocha integration/**/*.spec.ts --reporter spec --require ts-node/register",
|
||||
"lint":
|
||||
"tslint -p tsconfig.json -c tslint.json \"packages/**/*.ts\" -e \"*.spec.ts\"",
|
||||
"format":
|
||||
"prettier **/**/*.ts --ignore-path ./.prettierignore --write && git status",
|
||||
"build": "gulp build && gulp move",
|
||||
"build:lib": "gulp build --dist bundle",
|
||||
"copy-docs": "gulp copy-docs",
|
||||
@@ -16,10 +20,14 @@
|
||||
"prepare:rc": "npm run build:lib && npm run copy-docs",
|
||||
"prepare:next": "npm run build:lib && npm run copy-docs",
|
||||
"prepare:beta": "npm run build:lib && npm run copy-docs",
|
||||
"publish": "./node_modules/.bin/lerna publish --exact -m \"chore(@nestjs) publish %s release\"",
|
||||
"publish:rc": "./node_modules/.bin/lerna publish --npm-tag=rc -m \"chore(@nestjs) publish %s release\"",
|
||||
"publish:next": "./node_modules/.bin/lerna publish --npm-tag=next --skip-git -m \"chore(@nestjs) publish %s release\"",
|
||||
"publish:beta": "./node_modules/.bin/lerna publish --npm-tag=beta -m \"chore(@nestjs) publish %s release\""
|
||||
"publish":
|
||||
"npm run prepare && ./node_modules/.bin/lerna publish --exact -m \"chore(@nestjs) publish %s release\"",
|
||||
"publish:rc":
|
||||
"npm run prepare && ./node_modules/.bin/lerna publish --npm-tag=rc -m \"chore(@nestjs) publish %s release\"",
|
||||
"publish:next":
|
||||
"npm run prepare && ./node_modules/.bin/lerna publish --npm-tag=next --skip-git -m \"chore(@nestjs) publish %s release\"",
|
||||
"publish:beta":
|
||||
"npm run prepare && ./node_modules/.bin/lerna publish --npm-tag=beta -m \"chore(@nestjs) publish %s release\""
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 8.9.0"
|
||||
@@ -122,9 +130,7 @@
|
||||
"logo": "https://opencollective.com/opencollective/logo.txt"
|
||||
},
|
||||
"nyc": {
|
||||
"include": [
|
||||
"packages/**/*.ts"
|
||||
],
|
||||
"include": ["packages/**/*.ts"],
|
||||
"exclude": [
|
||||
"node_modules/",
|
||||
"packages/**/*.spec.ts",
|
||||
@@ -134,29 +140,20 @@
|
||||
"packages/core/errors/**/*",
|
||||
"packages/common/exceptions/*.ts",
|
||||
"packages/common/http/*.ts",
|
||||
"packages/common/utils/load-package.util.ts",
|
||||
"packages/microservices/exceptions/",
|
||||
"packages/microservices/microservices-module.ts",
|
||||
"packages/core/middleware/middleware-module.ts",
|
||||
"packages/core/injector/module-ref.ts",
|
||||
"packages/common/services/logger.service.ts"
|
||||
],
|
||||
"extension": [
|
||||
".ts"
|
||||
],
|
||||
"require": [
|
||||
"ts-node/register"
|
||||
],
|
||||
"reporter": [
|
||||
"text-summary",
|
||||
"html"
|
||||
],
|
||||
"extension": [".ts"],
|
||||
"require": ["ts-node/register"],
|
||||
"reporter": ["text-summary", "html"],
|
||||
"sourceMap": true,
|
||||
"instrument": true
|
||||
},
|
||||
"lint-staged": {
|
||||
"packages/**/*.{ts,json}": [
|
||||
"npm run format",
|
||||
"git add"
|
||||
]
|
||||
"packages/**/*.{ts,json}": ["npm run format", "git add"]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
import * as deprecate from 'deprecate';
|
||||
import { CUSTOM_ROUTE_AGRS_METADATA, ROUTE_ARGS_METADATA } from '../../constants';
|
||||
import {
|
||||
CUSTOM_ROUTE_AGRS_METADATA,
|
||||
ROUTE_ARGS_METADATA,
|
||||
} from '../../constants';
|
||||
import { PipeTransform } from '../../index';
|
||||
import { Type } from '../../interfaces';
|
||||
import { CustomParamFactory } from '../../interfaces/features/custom-route-param-factory.interface';
|
||||
import { isNil, isString } from '../../utils/shared.utils';
|
||||
import { isFunction, isNil } from '../../utils/shared.utils';
|
||||
import { ParamData, RouteParamsMetadata } from './route-params.decorator';
|
||||
|
||||
const assignCustomMetadata = (
|
||||
@@ -37,7 +40,9 @@ export type ParamDecoratorEnhancer = ParameterDecorator;
|
||||
export function createParamDecorator(
|
||||
factory: CustomParamFactory,
|
||||
enhancers: ParamDecoratorEnhancer[] = [],
|
||||
): (...dataOrPipes: (Type<PipeTransform> | PipeTransform | string)[]) => ParameterDecorator {
|
||||
): (
|
||||
...dataOrPipes: (Type<PipeTransform> | PipeTransform | any)[],
|
||||
) => ParameterDecorator {
|
||||
const paramtype = randomString() + randomString();
|
||||
return (
|
||||
data?,
|
||||
@@ -46,7 +51,11 @@ export function createParamDecorator(
|
||||
const args =
|
||||
Reflect.getMetadata(ROUTE_ARGS_METADATA, target.constructor, key) || {};
|
||||
|
||||
const hasParamData = isNil(data) || isString(data);
|
||||
const isPipe = pipe =>
|
||||
pipe &&
|
||||
((isFunction(pipe) && pipe.prototype) || isFunction(pipe.transform));
|
||||
|
||||
const hasParamData = isNil(data) || !isPipe(data);
|
||||
const paramData = hasParamData ? data : undefined;
|
||||
const paramPipes = hasParamData ? pipes : [data, ...pipes];
|
||||
|
||||
@@ -58,7 +67,7 @@ export function createParamDecorator(
|
||||
index,
|
||||
factory,
|
||||
paramData,
|
||||
...paramPipes as any as PipeTransform[],
|
||||
...((paramPipes as any) as PipeTransform[]),
|
||||
),
|
||||
target.constructor,
|
||||
key,
|
||||
|
||||
@@ -66,4 +66,9 @@ 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;
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ export class ValidationPipe implements PipeTransform<any> {
|
||||
return false;
|
||||
}
|
||||
const types = [String, Boolean, Number, Array, Object];
|
||||
return !types.find(t => metatype === t) && !isNil(metatype);
|
||||
return !types.some(t => metatype === t) && !isNil(metatype);
|
||||
}
|
||||
|
||||
toEmptyIfNil<T = any, R = any>(value: T): R | {} {
|
||||
|
||||
@@ -29,34 +29,17 @@ export class Logger implements LoggerService {
|
||||
Logger.log(message, context || this.context, this.isTimeDiffEnabled);
|
||||
return;
|
||||
}
|
||||
logger &&
|
||||
logger.log.call(
|
||||
logger,
|
||||
message,
|
||||
context || this.context,
|
||||
this.isTimeDiffEnabled,
|
||||
);
|
||||
logger && logger.log.call(logger, message, context || this.context);
|
||||
}
|
||||
|
||||
error(message: any, trace = '', context?: string) {
|
||||
const { logger } = Logger;
|
||||
if (logger === this) {
|
||||
Logger.error(
|
||||
message,
|
||||
trace,
|
||||
context || this.context,
|
||||
this.isTimeDiffEnabled,
|
||||
);
|
||||
Logger.error(message, trace, context || this.context);
|
||||
return;
|
||||
}
|
||||
logger &&
|
||||
logger.error.call(
|
||||
logger,
|
||||
message,
|
||||
trace,
|
||||
context || this.context,
|
||||
this.isTimeDiffEnabled,
|
||||
);
|
||||
logger.error.call(logger, message, trace, context || this.context);
|
||||
}
|
||||
|
||||
warn(message: any, context?: string) {
|
||||
@@ -65,13 +48,7 @@ export class Logger implements LoggerService {
|
||||
Logger.warn(message, context || this.context, this.isTimeDiffEnabled);
|
||||
return;
|
||||
}
|
||||
logger &&
|
||||
logger.warn.call(
|
||||
logger,
|
||||
message,
|
||||
context || this.context,
|
||||
this.isTimeDiffEnabled,
|
||||
);
|
||||
logger && logger.warn.call(logger, message, context || this.context);
|
||||
}
|
||||
|
||||
static overrideLogger(logger: LoggerService | boolean) {
|
||||
|
||||
@@ -18,7 +18,7 @@ describe('createRouteParamDecorator', () => {
|
||||
const Decorator = createRouteParamDecorator(factoryFn);
|
||||
|
||||
describe('when 0 pipes have been passed', () => {
|
||||
const data = 'test';
|
||||
const data = { data: 'test' };
|
||||
class Test {
|
||||
public test(@Decorator(data) param) {}
|
||||
}
|
||||
@@ -26,7 +26,7 @@ describe('createRouteParamDecorator', () => {
|
||||
const metadata = Reflect.getMetadata(ROUTE_ARGS_METADATA, Test, 'test');
|
||||
const key = Object.keys(metadata)[0];
|
||||
expect(metadata[key]).to.be.eql({
|
||||
data: 'test',
|
||||
data,
|
||||
factory: factoryFn,
|
||||
index: 0,
|
||||
pipes: [],
|
||||
@@ -44,6 +44,8 @@ describe('createRouteParamDecorator', () => {
|
||||
) {}
|
||||
|
||||
public testNoData(@Decorator(pipe) param) {}
|
||||
|
||||
public testNoDataClass(@Decorator(ParseIntPipe) param) {}
|
||||
}
|
||||
it('should enhance param with "data" and ParseIntPipe', () => {
|
||||
const metadata = Reflect.getMetadata(ROUTE_ARGS_METADATA, Test, 'test');
|
||||
@@ -70,6 +72,21 @@ describe('createRouteParamDecorator', () => {
|
||||
pipes: [pipe],
|
||||
});
|
||||
});
|
||||
|
||||
it('should enhance param with ParseIntPipe metatype', () => {
|
||||
const metadata = Reflect.getMetadata(
|
||||
ROUTE_ARGS_METADATA,
|
||||
Test,
|
||||
'testNoDataClass',
|
||||
);
|
||||
const key = Object.keys(metadata)[0];
|
||||
expect(metadata[key]).to.be.eql({
|
||||
data: undefined,
|
||||
factory: factoryFn,
|
||||
index: 0,
|
||||
pipes: [ParseIntPipe],
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -115,6 +115,9 @@ export class ExpressAdapter implements HttpServer {
|
||||
}
|
||||
|
||||
useStaticAssets(path: string, options: ServeStaticOptions) {
|
||||
if (options && options.prefix) {
|
||||
return this.use(options.prefix, express.static(path, options));
|
||||
}
|
||||
return this.use(express.static(path, options));
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ export class ExceptionsHandler extends BaseExceptionFilter {
|
||||
const filter = this.filters.find(({ exceptionMetatypes, func }) => {
|
||||
const hasMetatype =
|
||||
!exceptionMetatypes.length ||
|
||||
!!exceptionMetatypes.find(
|
||||
exceptionMetatypes.some(
|
||||
ExceptionMetatype => exception instanceof ExceptionMetatype,
|
||||
);
|
||||
return hasMetatype;
|
||||
|
||||
@@ -120,10 +120,10 @@ export class ExternalContextCreator {
|
||||
|
||||
public findComponentByClassName(module: Module, className: string): boolean {
|
||||
const { components } = module;
|
||||
const hasComponent = [...components.keys()].find(
|
||||
const hasComponent = [...components.keys()].some(
|
||||
component => component === className,
|
||||
);
|
||||
return !!hasComponent;
|
||||
return hasComponent;
|
||||
}
|
||||
|
||||
public exchangeKeysForValues<TMetadata = any>(
|
||||
|
||||
@@ -12,7 +12,7 @@ import { INestExpressApplication } from '@nestjs/common/interfaces/nest-express-
|
||||
import { INestFastifyApplication } from '@nestjs/common/interfaces/nest-fastify-application.interface';
|
||||
import { Logger } from '@nestjs/common/services/logger.service';
|
||||
import { loadPackage } from '@nestjs/common/utils/load-package.util';
|
||||
import { isFunction } from '@nestjs/common/utils/shared.utils';
|
||||
import { isFunction, isNil } from '@nestjs/common/utils/shared.utils';
|
||||
import { ExpressAdapter } from './adapters/express-adapter';
|
||||
import { ExpressFactory } from './adapters/express-factory';
|
||||
import { FastifyAdapter } from './adapters/fastify-adapter';
|
||||
@@ -178,7 +178,7 @@ export class NestFactoryStatic {
|
||||
if (!options) {
|
||||
return;
|
||||
}
|
||||
Logger.overrideLogger(options.logger);
|
||||
!isNil(options.logger) && Logger.overrideLogger(options.logger);
|
||||
}
|
||||
|
||||
private applyExpressAdapter(httpAdapter: HttpServer): HttpServer {
|
||||
|
||||
@@ -36,7 +36,7 @@ export class RpcExceptionsHandler extends BaseRpcExceptionFilter {
|
||||
const filter = this.filters.find(({ exceptionMetatypes, func }) => {
|
||||
const hasMetatype =
|
||||
!exceptionMetatypes.length ||
|
||||
!!exceptionMetatypes.find(
|
||||
exceptionMetatypes.some(
|
||||
ExceptionMetatype => exception instanceof ExceptionMetatype,
|
||||
);
|
||||
return hasMetatype;
|
||||
|
||||
@@ -29,7 +29,7 @@ export class WsExceptionsHandler extends BaseWsExceptionFilter {
|
||||
const filter = this.filters.find(({ exceptionMetatypes, func }) => {
|
||||
const hasMetatype =
|
||||
!exceptionMetatypes.length ||
|
||||
!!exceptionMetatypes.find(
|
||||
exceptionMetatypes.some(
|
||||
ExceptionMetatype => exception instanceof ExceptionMetatype,
|
||||
);
|
||||
return hasMetatype;
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
"start:prod": "node dist/main.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@nestjs/common": "^5.1.0",
|
||||
"@nestjs/core": "^5.1.0",
|
||||
"@nestjs/typeorm": "^5.0.0",
|
||||
"@nestjs/common": "^5.2.0",
|
||||
"@nestjs/core": "^5.2.0",
|
||||
"@nestjs/typeorm": "^5.2.0",
|
||||
"mysql": "^2.15.0",
|
||||
"reflect-metadata": "^0.1.12",
|
||||
"rxjs": "^6.0.0",
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
"start:prod": "node dist/main.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@nestjs/common": "^5.1.0",
|
||||
"@nestjs/core": "^5.1.0",
|
||||
"@nestjs/mongoose": "^5.0.0",
|
||||
"@nestjs/common": "^5.2.0",
|
||||
"@nestjs/core": "^5.2.0",
|
||||
"@nestjs/mongoose": "^5.2.0",
|
||||
"mongoose": "^5.0.1",
|
||||
"reflect-metadata": "^0.1.12",
|
||||
"rxjs": "^6.0.0",
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
"start:prod": "node dist/main.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@nestjs/common": "^5.1.0",
|
||||
"@nestjs/core": "^5.1.0",
|
||||
"@nestjs/typeorm": "^5.0.0",
|
||||
"@nestjs/common": "^5.2.0",
|
||||
"@nestjs/core": "^5.2.0",
|
||||
"@nestjs/typeorm": "^5.2.0",
|
||||
"mongodb": "^2.2.31",
|
||||
"reflect-metadata": "^0.1.12",
|
||||
"rxjs": "^6.0.0",
|
||||
|
||||
859
sample/19-auth/package-lock.json
generated
859
sample/19-auth/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -11,6 +11,7 @@
|
||||
"dependencies": {
|
||||
"@nestjs/common": "^5.1.0",
|
||||
"@nestjs/core": "^5.1.0",
|
||||
"@nestjs/jwt": "0.0.1",
|
||||
"@nestjs/passport": "^1.0.6",
|
||||
"passport": "^0.4.0",
|
||||
"passport-http-bearer": "^1.0.1",
|
||||
|
||||
Reference in New Issue
Block a user