Skip to content

Commit 5c7f9fa

Browse files
Merge branch 'master' into update/version-5
2 parents 9b83487 + 35fef2f commit 5c7f9fa

12 files changed

Lines changed: 99 additions & 43 deletions

File tree

CHANGELOG.md

Lines changed: 41 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,51 @@
1+
## 4.6.4
2+
### Bug Fixes
3+
- **microservices**: can't select/get from context when using `NestFactory.createMicroservice` [#398](https://github.com/nestjs/nest/issues/398)
4+
5+
## 4.6.3
6+
### Bug Fixes
7+
- **core**: error thrown when connecting to microservice (hybrid applicaton) [#425](https://github.com/nestjs/nest/issues/425)
8+
19
## 4.6.2
2-
- **core**: [improvement] simplify `NestFactory.create(...args)` signature
10+
### Improvements
11+
- **core**: simplify `NestFactory.create(...args)` signature
312

413
## 4.6.1
5-
- **common**: [improvement] create `ModuleMetadata` interface
6-
- **common**: [bugfix] update `class-validator` [#417](https://github.com/nestjs/nest/issues/417)
14+
### Improvements
15+
- **common**: create `ModuleMetadata` interface
16+
- **core**: majority of methods (`INestApplication`, `INestMicroservice`, and `INestApplicationContext`) return `this` instead of `void`
17+
- **core**: remove static dependencies & relationships inside `NestFactory`
18+
19+
### Features
720
- **core**: [feature] add `appOptions` property to `create[..]` methods of `NestFactory`
8-
- **core**: [improvement] majority of methods (`INestApplication`, `INestMicroservice`, and `INestApplicationContext`) return `this` instead of `void`
9-
- **core**: [refactor] remove static dependencies & relationships
21+
22+
### Bug Fixes
23+
- **common**: [bugfix] update `class-validator` [#417](https://github.com/nestjs/nest/issues/417)
1024
- **core**: [bugfix] catch error thrown by `bodyParser` in exception filter [#422](https://github.com/nestjs/nest/issues/422)
1125

1226
## 4.6.0
13-
- **common**: [feature] `ValidationPipe` improvements [#383](https://github.com/nestjs/nest/pull/383)
14-
- **common**: [feature] `ParseIntPipe` improvements [#385](https://github.com/nestjs/nest/pull/385)
15-
- **common**: [feature] add `FileInterceptor`, `FilesInterceptor`, `@UploadedFile()` and `@UploadedFiles()` (`multer` integration)
16-
- **common**: [feature] add `HttpModule` that exposes `HttpService` (`axios` integration)
17-
- **core**: [feature] add `app.disable()` and `app.enable()` wrappers around `express` app
18-
- **core**: [feature] add ability to inject `express` reference (`EXPRESS_REF` token)
19-
- **core**: [feature] enable possibility to extend metadata (inheritance support) [#228](https://github.com/nestjs/nest/issues/228)
20-
- **core**: [feature] `NestFactory.create()` now accepts third argument `HttpsOptions`
21-
- **core**: [feature] add `app.enableCors()` to `INestApplication` (`cors` integration)
22-
- **core**: [feature] add `@Render()` decorator (MVC applications)
23-
- **core**: [feature] provide `Logger.overrideLogger()` [#247](https://github.com/nestjs/nest/issues/247)
24-
- **core**: [improvement] simplify HTTPS usage
25-
- **core**: [bugfix] custom transport strategy - thrown exceptions issue [#290](https://github.com/nestjs/nest/issues/290)
26-
- **core**: [bugfix] injector fails silently [#287](https://github.com/nestjs/nest/issues/287)
27-
- **core**: [bugfix] secure websockets (`wss://`) [#384](https://github.com/nestjs/nest/issues/384)
28-
- **core**: [bugfix] can't select/get from context when using `NestFactory.createMicroservice()` [#398](https://github.com/nestjs/nest/issues/398)
29-
- **core**: [bugfix] interceptor `$stream` observable returns another observable instead of the response object [#376](https://github.com/nestjs/nest/issues/376)
30-
- **core**: [bugfix] `Observable.throw` from controller results in unhandled rejection promise [#373](https://github.com/nestjs/nest/issues/373)
31-
- **microservices**: [feature]: add `listenAsync()` to `INestMicroservice` instance
27+
### Features
28+
- **common**: `ValidationPipe` improvements [#383](https://github.com/nestjs/nest/pull/383)
29+
- **common**: `ParseIntPipe` improvements [#385](https://github.com/nestjs/nest/pull/385)
30+
- **common**: add `FileInterceptor`, `FilesInterceptor`, `@UploadedFile()` and `@UploadedFiles()` (`multer` integration)
31+
- **common**: add `HttpModule` that exposes `HttpService` (`axios` integration)
32+
- **core**: add `app.disable()` and `app.enable()` wrappers around `express` app
33+
- **core**: add ability to inject `express` reference (`EXPRESS_REF` token)
34+
- **core**: enable possibility to extend metadata (inheritance support) [#228](https://github.com/nestjs/nest/issues/228)
35+
- **core**: `NestFactory.create()` now accepts third argument `HttpsOptions`
36+
- **core**: add `app.enableCors()` to `INestApplication` (`cors` integration)
37+
- **core**: add `@Render()` decorator (MVC applications)
38+
- **core**: provide `Logger.overrideLogger()` [#247](https://github.com/nestjs/nest/issues/247)
39+
- **microservices**: add `listenAsync()` to `INestMicroservice` instance
40+
41+
### Bug Fixes
42+
- **core**: simplify HTTPS protocol usage
43+
- **core**: custom transport strategy - thrown exceptions issue [#290](https://github.com/nestjs/nest/issues/290)
44+
- **core**: injector fails silently [#287](https://github.com/nestjs/nest/issues/287)
45+
- **core**: secure websockets (`wss://`) [#384](https://github.com/nestjs/nest/issues/384)
46+
- **core**: can't select/get from context when using `NestFactory.createMicroservice()` [#398](https://github.com/nestjs/nest/issues/398)
47+
- **core**: interceptor `$stream` observable returns another observable instead of the response object [#376](https://github.com/nestjs/nest/issues/376)
48+
- **core**: `Observable.throw` from controller results in unhandled rejection promise [#373](https://github.com/nestjs/nest/issues/373)
3249

3350
## 4.5.10
3451
- **core**: [bugfix] #343

lerna.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
"packages": [
44
"lib/*"
55
],
6-
"version": "4.6.2"
6+
"version": "4.6.3"
77
}

lib/common/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@nestjs/common",
3-
"version": "4.6.2",
3+
"version": "4.6.3",
44
"description": "Nest - modern, fast, powerful node.js web framework (@common)",
55
"author": "Kamil Mysliwiec",
66
"license": "MIT",

lib/core/nest-application.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const iterare_1 = require("iterare");
1717
const logger_service_1 = require("@nestjs/common/services/logger.service");
1818
const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
1919
const express_adapter_1 = require("./adapters/express-adapter");
20+
const application_config_1 = require("./application-config");
2021
const constants_1 = require("./constants");
2122
const middlewares_module_1 = require("./middlewares/middlewares-module");
2223
const routes_resolver_1 = require("./router/routes-resolver");
@@ -114,7 +115,8 @@ class NestApplication extends nest_application_context_1.NestApplicationContext
114115
if (!NestMicroservice) {
115116
throw new microservices_package_not_found_exception_1.MicroservicesPackageNotFoundException();
116117
}
117-
const instance = new NestMicroservice(this.container, config);
118+
const applicationConfig = new application_config_1.ApplicationConfig();
119+
const instance = new NestMicroservice(this.container, config, applicationConfig);
118120
instance.setupListeners();
119121
instance.setIsInitialized(true);
120122
instance.setIsInitHookCalled(true);

lib/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@nestjs/core",
3-
"version": "4.6.2",
3+
"version": "4.6.3",
44
"description": "Nest - modern, fast, powerful node.js web framework (@core)",
55
"author": "Kamil Mysliwiec",
66
"license": "MIT",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nestjs",
3-
"version": "4.6.2",
3+
"version": "4.6.3",
44
"description": "Modern, fast, powerful node.js web framework",
55
"main": "index.js",
66
"scripts": {

src/common/interceptors/file.interceptor.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ import * as multer from 'multer';
22
import { NestInterceptor } from './../interfaces/features/nest-interceptor.interface';
33
import { Observable } from 'rxjs/Observable';
44
import { MulterOptions } from '../interfaces/external/multer-options.interface';
5+
import { mixin } from '../decorators/core/component.decorator';
56

67
export function FileInterceptor(fieldName: string, options?: MulterOptions) {
7-
const Interceptor = class implements NestInterceptor {
8+
return mixin(class implements NestInterceptor {
89
readonly upload = multer(options);
910

1011
async intercept(
@@ -17,6 +18,5 @@ export function FileInterceptor(fieldName: string, options?: MulterOptions) {
1718
);
1819
return stream$;
1920
}
20-
};
21-
return Interceptor;
21+
});
2222
}

src/core/nest-application-context.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@ export class NestApplicationContext implements INestApplicationContext {
1313
protected contextModule,
1414
) {}
1515

16-
public select<T>(module: Type<T>): INestApplicationContext {
16+
public selectContextModule() {
17+
const modules = this.container.getModules().values();
18+
this.contextModule = modules.next().value;
19+
}
20+
21+
public select<T>(module: Metatype<T>): INestApplicationContext {
1722
const modules = this.container.getModules();
1823
const moduleMetatype = this.contextModule.metatype;
1924
const scope = this.scope.concat(moduleMetatype);

src/core/nest-application.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,6 @@ export class NestApplication extends NestApplicationContext
8282
);
8383
}
8484

85-
public selectContextModule() {
86-
const modules = this.container.getModules().values();
87-
this.contextModule = modules.next().value;
88-
}
89-
9085
public applyOptions() {
9186
if (!this.appOptions) {
9287
return undefined;
@@ -116,7 +111,8 @@ export class NestApplication extends NestApplicationContext
116111
}
117112

118113
public async init(): Promise<this> {
119-
const useBodyParser = this.appOptions && this.appOptions.bodyParser !== false;
114+
const useBodyParser =
115+
this.appOptions && this.appOptions.bodyParser !== false;
120116
useBodyParser && this.setupParserMiddlewares();
121117

122118
await this.setupModules();
@@ -161,7 +157,12 @@ export class NestApplication extends NestApplicationContext
161157
if (!NestMicroservice) {
162158
throw new MicroservicesPackageNotFoundException();
163159
}
164-
const instance = new NestMicroservice(this.container as any, config as any);
160+
const applicationConfig = new ApplicationConfig();
161+
const instance = new NestMicroservice(
162+
this.container as any,
163+
config as any,
164+
applicationConfig,
165+
);
165166
instance.setupListeners();
166167
instance.setIsInitialized(true);
167168
instance.setIsInitHookCalled(true);

src/core/router/routes-resolver.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { MetadataScanner } from '../metadata-scanner';
1010
import { RouterExplorer } from './interfaces/explorer.inteface';
1111
import { ExpressRouterExplorer } from './router-explorer';
1212
import { ApplicationConfig } from './../application-config';
13-
import { NotFoundException } from '@nestjs/common';
13+
import { NotFoundException, BadRequestException } from '@nestjs/common';
1414
import { MODULE_PATH } from '@nestjs/common/constants';
1515

1616
export class RoutesResolver implements Resolver {
@@ -43,8 +43,8 @@ export class RoutesResolver implements Resolver {
4343
: undefined;
4444
this.setupRouters(routes, moduleName, path, router);
4545
});
46-
4746
this.setupNotFoundHandler(router);
47+
this.setupExceptionHandler(router);
4848
this.setupExceptionHandler(express);
4949
}
5050

@@ -79,7 +79,7 @@ export class RoutesResolver implements Resolver {
7979

8080
public setupExceptionHandler(express: Application) {
8181
const callback = (err, req, res, next) => {
82-
throw err;
82+
throw this.mapExternalException(err);
8383
};
8484
const exceptionHandler = this.routerExceptionsFilter.create(
8585
{},
@@ -91,4 +91,13 @@ export class RoutesResolver implements Resolver {
9191
);
9292
express.use(proxy);
9393
}
94+
95+
public mapExternalException(err: any) {
96+
switch (true) {
97+
case (err instanceof SyntaxError):
98+
return new BadRequestException(err.message);
99+
default:
100+
return err;
101+
}
102+
}
94103
}

0 commit comments

Comments
 (0)