Skip to content

Commit b20b3cb

Browse files
bugfix(@nestjs/common) populate multer exceptions
1 parent 9bfb941 commit b20b3cb

16 files changed

Lines changed: 57 additions & 36 deletions

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
## 4.6.4
22
### Bug Fixes
3+
- **common**: logger overrides custom logger scope [#435](https://github.com/nestjs/nest/issues/435)
4+
- **common**: `FileInterceptor` supports only one options at once [#429](https://github.com/nestjs/nest/issues/429)
5+
- **common**: support `symbol` as a token (`NestApplicationContext`)
6+
- **core**: fix exception handler (exceception thrown in the `done()` callback) [#431](https://github.com/nestjs/nest/issues/431)
7+
- **core**: incorrect HTTP response on `SyntaxError` [#430](https://github.com/nestjs/nest/issues/430)
38
- **microservices**: can't select/get from context when using `NestFactory.createMicroservice` [#398](https://github.com/nestjs/nest/issues/398)
49

510
## 4.6.3
Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,2 @@
1-
import { Observable } from 'rxjs/Observable';
21
import { MulterOptions } from '../interfaces/external/multer-options.interface';
3-
export declare function FileInterceptor(fieldName: string, options?: MulterOptions): {
4-
new (): {
5-
readonly upload: any;
6-
intercept(request: any, context: any, stream$: Observable<any>): Promise<Observable<any>>;
7-
};
8-
};
2+
export declare function FileInterceptor(fieldName: string, options?: MulterOptions): any;

lib/common/interceptors/file.interceptor.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
99
};
1010
Object.defineProperty(exports, "__esModule", { value: true });
1111
const multer = require("multer");
12+
const component_decorator_1 = require("../decorators/core/component.decorator");
1213
function FileInterceptor(fieldName, options) {
13-
const Interceptor = class {
14+
return component_decorator_1.mixin(class {
1415
constructor() {
1516
this.upload = multer(options);
1617
}
@@ -20,7 +21,6 @@ function FileInterceptor(fieldName, options) {
2021
return stream$;
2122
});
2223
}
23-
};
24-
return Interceptor;
24+
});
2525
}
2626
exports.FileInterceptor = FileInterceptor;

lib/common/interfaces/nest-application-context.interface.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ export interface INestApplicationContext {
99
* Makes possible to retrieve the instance of the component or controller available inside the processed module.
1010
* @returns T
1111
*/
12-
get<T>(metatypeOrToken: Metatype<T> | string): T;
12+
get<T>(metatypeOrToken: Metatype<T> | string | symbol): T;
1313
}

lib/common/services/logger.service.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ class Logger {
99
}
1010
log(message) {
1111
const { logger } = Logger;
12-
logger.log(message, this.context, this.isTimeDiffEnabled);
12+
logger.log.call(logger, message, this.context, this.isTimeDiffEnabled);
1313
}
1414
error(message, trace = '') {
1515
const { logger } = Logger;
16-
logger.error(message, trace, this.context, this.isTimeDiffEnabled);
16+
logger.error.call(logger, message, trace, this.context, this.isTimeDiffEnabled);
1717
}
1818
warn(message) {
1919
const { logger } = Logger;
20-
logger.warn(message, this.context, this.isTimeDiffEnabled);
20+
logger.warn.call(logger, message, this.context, this.isTimeDiffEnabled);
2121
}
2222
static overrideLogger(logger) {
2323
this.logger = logger;

lib/core/nest-application-context.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export declare class NestApplicationContext implements INestApplicationContext {
88
protected contextModule: any;
99
private readonly moduleTokenFactory;
1010
constructor(container: NestContainer, scope: NestModuleMetatype[], contextModule: any);
11+
selectContextModule(): void;
1112
select<T>(module: Metatype<T>): INestApplicationContext;
1213
get<T>(metatypeOrToken: Metatype<T> | string | symbol): T;
1314
private findInstanceByPrototypeOrToken<T>(metatypeOrToken);

lib/core/nest-application-context.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ class NestApplicationContext {
99
this.contextModule = contextModule;
1010
this.moduleTokenFactory = new module_token_factory_1.ModuleTokenFactory();
1111
}
12+
selectContextModule() {
13+
const modules = this.container.getModules().values();
14+
this.contextModule = modules.next().value;
15+
}
1216
select(module) {
1317
const modules = this.container.getModules();
1418
const moduleMetatype = this.contextModule.metatype;

lib/core/nest-application.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ export declare class NestApplication extends NestApplicationContext implements I
2121
private readonly microservices;
2222
private isInitialized;
2323
constructor(container: NestContainer, express: any, config: ApplicationConfig, appOptions?: NestApplicationOptions);
24-
selectContextModule(): void;
2524
applyOptions(): any;
2625
createServer(): any;
2726
setupModules(): Promise<void>;

lib/core/nest-application.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,6 @@ class NestApplication extends nest_application_context_1.NestApplicationContext
5252
this.config.setIoAdapter(ioAdapter);
5353
this.routesResolver = new routes_resolver_1.RoutesResolver(container, express_adapter_1.ExpressAdapter, this.config);
5454
}
55-
selectContextModule() {
56-
const modules = this.container.getModules().values();
57-
this.contextModule = modules.next().value;
58-
}
5955
applyOptions() {
6056
if (!this.appOptions) {
6157
return undefined;

lib/core/router/routes-resolver.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ export declare class RoutesResolver implements Resolver {
1717
setupRouters(routes: Map<string, InstanceWrapper<Controller>>, moduleName: string, modulePath: string, express: Application): void;
1818
setupNotFoundHandler(express: Application): void;
1919
setupExceptionHandler(express: Application): void;
20+
mapExternalException(err: any): any;
2021
}

0 commit comments

Comments
 (0)