Compare commits

...

16 Commits

Author SHA1 Message Date
Kamil Myśliwiec
cd30d7a4a5 chore(@nestjs) publish v5.2.2 release 2018-08-24 12:42:29 +02:00
Kamil Myśliwiec
a6d837e64a bugfix(@nestjs/common) fix custom decorators (data isnt always string) 2018-08-24 12:13:48 +02:00
Kamil Myśliwiec
0904b0ba56 Merge branch 'master' of https://github.com/nestjs/nest 2018-08-24 10:38:12 +02:00
Kamil Myśliwiec
150c81e397 feature(@nestjs/core) add prefix property to ServeStaticOptions 2018-08-24 10:35:04 +02:00
Kamil Myśliwiec
1717f35717 Merge pull request #997 from alerosa/fix-auth-sample-missing-dependency
example(@nestjs) add @nestjs/jwt to auth sample dependencies
2018-08-23 08:53:01 +02:00
alerosa
61b6b346da add @nestjs/jwt to auth sample dependencies 2018-08-23 00:55:19 +01:00
Kamil Myśliwiec
b02fb57d8f chore(@nestjs) publish 2.3.1 patch release 2018-08-22 22:00:42 +02:00
Kamil Myśliwiec
cb302e6719 chore(@nestjs) publish v5.2.1 release 2018-08-22 21:59:35 +02:00
Kamil Myśliwiec
1f9030c504 Merge branch 'master' of https://github.com/nestjs/nest 2018-08-22 21:58:18 +02:00
Kamil Myśliwiec
af5a4af675 chore(@nestjs) publish v5.2.1 release 2018-08-22 21:57:52 +02:00
Kamil Myśliwiec
664321465c Update Readme.md 2018-08-22 21:16:43 +02:00
Kamil Myśliwiec
f6d4b5e82a test(@nestjs/common) exclude load package 2018-08-22 20:21:55 +02:00
Kamil Myśliwiec
09c9f704e5 Merge pull request #909 from nestjs/5.2.0
chore(@nestjs) publish 5.2.0 minor release
2018-08-22 15:47:53 +02:00
Kamil Myśliwiec
8a8b780273 chore(@nestjs) publish 5.2.0 minor release 2018-08-22 15:44:30 +02:00
Kamil Myśliwiec
afae462b6e Merge pull request #955 from jbpionnier/refactor/use_some_method
refactor(@nestjs) use some() method (arrays)
2018-08-16 14:08:36 +02:00
Jean-Baptiste Pionnier
2bdf47a572 refactor: use some method 2018-08-09 08:27:39 +02:00
50 changed files with 1325 additions and 141 deletions

View File

@@ -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> &nbsp; <a href="http://angularity.io"><img src="http://angularity.io/media/logo.svg" height="30" /></a> &nbsp; <a href="http://gojob.com"><img src="https://gojob.com/w/wp-content/uploads/2017/02/cropped-Logo-web-home.png" height="40" /> &nbsp; <a href="https://keycdn.com"><img src="https://nestjs.com/img/keycdn.svg" height="30" /></a> &nbsp; <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> &nbsp; <a href="http://angularity.io"><img src="http://angularity.io/media/logo.svg" height="30" /></a> &nbsp; <a href="http://gojob.com"><img src="https://gojob.com/w/wp-content/uploads/2017/02/cropped-Logo-web-home.png" height="40" /> &nbsp; <!--<a href="https://keycdn.com"><img src="https://nestjs.com/img/keycdn.svg" height="30" /></a> &nbsp;--> <a href="https://hostpresto.com"><img src="https://nestjs.com/img/hostpresto.png" height="30" /></a>
## Backers

View File

@@ -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> &nbsp; <a href="http://angularity.io"><img src="http://angularity.io/media/logo.svg" height="30" /></a> &nbsp; <a href="http://gojob.com"><img src="https://gojob.com/w/wp-content/uploads/2017/02/cropped-Logo-web-home.png" height="40" /> &nbsp; <a href="https://keycdn.com"><img src="https://nestjs.com/img/keycdn.svg" height="30" /></a> &nbsp; <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> &nbsp; <a href="http://angularity.io"><img src="http://angularity.io/media/logo.svg" height="30" /></a> &nbsp; <a href="http://gojob.com"><img src="https://gojob.com/w/wp-content/uploads/2017/02/cropped-Logo-web-home.png" height="40" /> &nbsp; <!--<a href="https://keycdn.com"><img src="https://nestjs.com/img/keycdn.svg" height="30" /></a> &nbsp;--> <a href="https://hostpresto.com"><img src="https://nestjs.com/img/hostpresto.png" height="30" /></a>
## Backers

View File

@@ -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",

View File

@@ -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;

View File

@@ -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;

View File

@@ -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> &nbsp; <a href="http://angularity.io"><img src="http://angularity.io/media/logo.svg" height="30" /></a> &nbsp; <a href="http://gojob.com"><img src="https://gojob.com/w/wp-content/uploads/2017/02/cropped-Logo-web-home.png" height="40" /> &nbsp; <a href="https://keycdn.com"><img src="https://nestjs.com/img/keycdn.svg" height="30" /></a> &nbsp; <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> &nbsp; <a href="http://angularity.io"><img src="http://angularity.io/media/logo.svg" height="30" /></a> &nbsp; <a href="http://gojob.com"><img src="https://gojob.com/w/wp-content/uploads/2017/02/cropped-Logo-web-home.png" height="40" /> &nbsp; <!--<a href="https://keycdn.com"><img src="https://nestjs.com/img/keycdn.svg" height="30" /></a> &nbsp;--> <a href="https://hostpresto.com"><img src="https://nestjs.com/img/hostpresto.png" height="30" /></a>
## Backers

View File

@@ -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);

View File

@@ -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);

View File

@@ -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;

View File

@@ -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",

View File

@@ -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> &nbsp; <a href="http://angularity.io"><img src="http://angularity.io/media/logo.svg" height="30" /></a> &nbsp; <a href="http://gojob.com"><img src="https://gojob.com/w/wp-content/uploads/2017/02/cropped-Logo-web-home.png" height="40" /> &nbsp; <a href="https://keycdn.com"><img src="https://nestjs.com/img/keycdn.svg" height="30" /></a> &nbsp; <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> &nbsp; <a href="http://angularity.io"><img src="http://angularity.io/media/logo.svg" height="30" /></a> &nbsp; <a href="http://gojob.com"><img src="https://gojob.com/w/wp-content/uploads/2017/02/cropped-Logo-web-home.png" height="40" /> &nbsp; <!--<a href="https://keycdn.com"><img src="https://nestjs.com/img/keycdn.svg" height="30" /></a> &nbsp;--> <a href="https://hostpresto.com"><img src="https://nestjs.com/img/hostpresto.png" height="30" /></a>
## Backers

View File

@@ -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;

View File

@@ -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",

View File

@@ -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> &nbsp; <a href="http://angularity.io"><img src="http://angularity.io/media/logo.svg" height="30" /></a> &nbsp; <a href="http://gojob.com"><img src="https://gojob.com/w/wp-content/uploads/2017/02/cropped-Logo-web-home.png" height="40" /> &nbsp; <a href="https://keycdn.com"><img src="https://nestjs.com/img/keycdn.svg" height="30" /></a> &nbsp; <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> &nbsp; <a href="http://angularity.io"><img src="http://angularity.io/media/logo.svg" height="30" /></a> &nbsp; <a href="http://gojob.com"><img src="https://gojob.com/w/wp-content/uploads/2017/02/cropped-Logo-web-home.png" height="40" /> &nbsp; <!--<a href="https://keycdn.com"><img src="https://nestjs.com/img/keycdn.svg" height="30" /></a> &nbsp;--> <a href="https://hostpresto.com"><img src="https://nestjs.com/img/hostpresto.png" height="30" /></a>
## Backers

View File

@@ -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",

View File

@@ -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> &nbsp; <a href="http://angularity.io"><img src="http://angularity.io/media/logo.svg" height="30" /></a> &nbsp; <a href="http://gojob.com"><img src="https://gojob.com/w/wp-content/uploads/2017/02/cropped-Logo-web-home.png" height="40" /> &nbsp; <a href="https://keycdn.com"><img src="https://nestjs.com/img/keycdn.svg" height="30" /></a> &nbsp; <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> &nbsp; <a href="http://angularity.io"><img src="http://angularity.io/media/logo.svg" height="30" /></a> &nbsp; <a href="http://gojob.com"><img src="https://gojob.com/w/wp-content/uploads/2017/02/cropped-Logo-web-home.png" height="40" /> &nbsp; <!--<a href="https://keycdn.com"><img src="https://nestjs.com/img/keycdn.svg" height="30" /></a> &nbsp;--> <a href="https://hostpresto.com"><img src="https://nestjs.com/img/hostpresto.png" height="30" /></a>
## Backers

View File

@@ -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);

View File

@@ -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",

View 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();
});
});

View 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();
});
});

View 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();
});
});

View File

@@ -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",

View 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 {}

View 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 {}

View 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 {}

View 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();
});
});

View 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();
});
});

View 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();
});
});

View File

@@ -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",

View 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 {}

View 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 {}

View 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 {}

View File

@@ -3,5 +3,5 @@
"packages": [
"bundle/*"
],
"version": "5.2.0"
"version": "5.2.2"
}

View File

@@ -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"]
}
}

View File

@@ -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,

View File

@@ -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;
}

View File

@@ -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 | {} {

View File

@@ -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) {

View File

@@ -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],
});
});
});
});
});

View File

@@ -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));
}

View File

@@ -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;

View File

@@ -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>(

View File

@@ -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 {

View File

@@ -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;

View File

@@ -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;

View File

@@ -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",

View File

@@ -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",

View File

@@ -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",

File diff suppressed because it is too large Load Diff

View File

@@ -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",