Skip to content

Commit

Permalink
fix(@nestjs) fix merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilmysliwiec committed Mar 8, 2018
2 parents 1746fb4 + 981104a commit 2ebfca2
Show file tree
Hide file tree
Showing 53 changed files with 880 additions and 82 deletions.
Binary file modified .DS_Store
Binary file not shown.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# dependencies
node_modules/
package-lock.json

# IDE
/.idea
/.awcache
Expand All @@ -9,6 +10,7 @@ package-lock.json
# misc
lerna-debug.log
npm-debug.log
yarn-error.log
/src/common/npm-debug.log
/src/core/npm-debug.log
/src/testing/npm-debug.log
Expand Down
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
## 4.6.6
### Bug Fixes:
- **common**: `File(s)Interceptor` throws http status code 500 [#465](https://github.com/nestjs/nest/issues/437)

## 4.6.5
### Bug Fixes
- **common**: `File(s)Interceptor` does not populate thrown exception [#437](https://github.com/nestjs/nest/issues/437)
- **core**: `NestFactory.create()` returns `any`
- **core**: use `ApplicationConfig` within `ExternalContextCreator` [#434](https://github.com/nestjs/nest/issues/434)

### Improvements
- **common**: `HttpException` extends `Error`
- **core**: make `cors` middleware customizable (`enableCors()`, `{ cors }`) [#457](https://github.com/nestjs/nest/issues/437)
- **microservices**: `RpcException` extends `Error`
- **websockets**: `WsException` extends `Error`

## 4.6.4
### Bug Fixes
- **common**: logger overrides custom logger scope [#435](https://github.com/nestjs/nest/issues/435)
- **common**: `FileInterceptor` supports only one options at once [#429](https://github.com/nestjs/nest/issues/429)
- **common**: support `symbol` as a token (`NestApplicationContext`)
- **core**: fix exception handler (exceception thrown in the `done()` callback) [#431](https://github.com/nestjs/nest/issues/431)
- **core**: incorrect HTTP response on `SyntaxError` [#430](https://github.com/nestjs/nest/issues/430)
- **microservices**: can't select/get from context when using `NestFactory.createMicroservice` [#398](https://github.com/nestjs/nest/issues/398)

## 4.6.3
Expand Down
16 changes: 15 additions & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ To check out the [guide](https://docs.nestjs.com), visit [docs.nestjs.com](https

## Sponsors

Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://opencollective.com/nest). Thanks! :heart_eyes:
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://opencollective.com/nest).

<a href="https://valor-software.com/"><img src="https://docs.nestjs.com/assets/sponsors/valor-software.png" width="210" /></a> &nbsp; &nbsp; <a href="https://scal.io"><img src="https://nestjs.com/img/scalio-logo.png" width="160" /></a>

Expand Down Expand Up @@ -74,6 +74,18 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
<a href="https://opencollective.com/nest/backer/27/website" target="_blank"><img src="https://opencollective.com/nest/backer/27/avatar.svg"></a>
<a href="https://opencollective.com/nest/backer/28/website" target="_blank"><img src="https://opencollective.com/nest/backer/28/avatar.svg"></a>
<a href="https://opencollective.com/nest/backer/29/website" target="_blank"><img src="https://opencollective.com/nest/backer/29/avatar.svg"></a>
<a href="https://opencollective.com/nest/backer/30/website" target="_blank"><img src="https://opencollective.com/nest/backer/30/avatar.svg"></a>
<a href="https://opencollective.com/nest/backer/31/website" target="_blank"><img src="https://opencollective.com/nest/backer/31/avatar.svg"></a>
<a href="https://opencollective.com/nest/backer/32/website" target="_blank"><img src="https://opencollective.com/nest/backer/32/avatar.svg"></a>
<a href="https://opencollective.com/nest/backer/33/website" target="_blank"><img src="https://opencollective.com/nest/backer/33/avatar.svg"></a>
<a href="https://opencollective.com/nest/backer/34/website" target="_blank"><img src="https://opencollective.com/nest/backer/34/avatar.svg"></a>
<a href="https://opencollective.com/nest/backer/35/website" target="_blank"><img src="https://opencollective.com/nest/backer/35/avatar.svg"></a>
<a href="https://opencollective.com/nest/backer/36/website" target="_blank"><img src="https://opencollective.com/nest/backer/36/avatar.svg"></a>
<a href="https://opencollective.com/nest/backer/37/website" target="_blank"><img src="https://opencollective.com/nest/backer/37/avatar.svg"></a>
<a href="https://opencollective.com/nest/backer/38/website" target="_blank"><img src="https://opencollective.com/nest/backer/38/avatar.svg"></a>
<a href="https://opencollective.com/nest/backer/39/website" target="_blank"><img src="https://opencollective.com/nest/backer/39/avatar.svg"></a>
<a href="https://opencollective.com/nest/backer/40/website" target="_blank"><img src="https://opencollective.com/nest/backer/40/avatar.svg"></a>
<a href="https://opencollective.com/nest/backer/41/website" target="_blank"><img src="https://opencollective.com/nest/backer/41/avatar.svg"></a>

## People

Expand All @@ -83,3 +95,5 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
## License

Nest is [MIT licensed](LICENSE).

<h4 align="center"> <a href="readme_zh.md">中文说明</a></h4>
2 changes: 1 addition & 1 deletion examples/05-sql-typeorm/src/photo/photo.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Injectable, Inject } from '@nestjs/common';
import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
import { Photo } from './photo.entity';
Expand Down
3 changes: 1 addition & 2 deletions examples/11-swagger/src/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Module, NestModule, MiddlewaresConsumer } from '@nestjs/common';
import { Module } from '@nestjs/common';
import { CatsModule } from './cats/cats.module';
import { CatsController } from './cats/cats.controller';

@Module({
imports: [CatsModule],
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
"packages": [
"lib/*"
],
"version": "4.6.3"
"version": "4.6.5"
}
Binary file added lib/.DS_Store
Binary file not shown.
9 changes: 7 additions & 2 deletions lib/common/exceptions/http.exception.d.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
export declare class HttpException {
export declare class HttpException extends Error {
private readonly response;
private readonly status;
private readonly message;
readonly message: any;
/**
<<<<<<< HEAD
* The base Nest Application exception which is handled by the default Exceptions Handler.
* If you throw an exception from your HTTP route handlers, Nest will map them to the appropriate HTTP response and send to the client.
=======
* The base Nest Application exception, which is handled by the default Exceptions Handler.
* If you throw an exception from your HTTP route handler, Nest will map them to the appropriate HTTP response and send to the client.
>>>>>>> master
*
* When `response` is an object:
* - object will be stringified and returned to the user as a JSON response,
Expand Down
8 changes: 7 additions & 1 deletion lib/common/exceptions/http.exception.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class HttpException {
class HttpException extends Error {
/**
<<<<<<< HEAD
* The base Nest Application exception which is handled by the default Exceptions Handler.
* If you throw an exception from your HTTP route handlers, Nest will map them to the appropriate HTTP response and send to the client.
=======
* The base Nest Application exception, which is handled by the default Exceptions Handler.
* If you throw an exception from your HTTP route handler, Nest will map them to the appropriate HTTP response and send to the client.
>>>>>>> master
*
* When `response` is an object:
* - object will be stringified and returned to the user as a JSON response,
Expand All @@ -16,6 +21,7 @@ class HttpException {
* ```
*/
constructor(response, status) {
super();
this.response = response;
this.status = status;
this.message = response;
Expand Down
7 changes: 6 additions & 1 deletion lib/common/interceptors/file.interceptor.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ function FileInterceptor(fieldName, options) {
}
intercept(request, context, stream$) {
return __awaiter(this, void 0, void 0, function* () {
yield new Promise((resolve, reject) => this.upload.single(fieldName)(request, request.res, resolve));
yield new Promise((resolve, reject) => this.upload.single(fieldName)(request, request.res, err => {
if (err) {
return reject(err);
}
resolve();
}));
return stream$;
});
}
Expand Down
7 changes: 6 additions & 1 deletion lib/common/interceptors/files.interceptor.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ function FilesInterceptor(fieldName, maxCount, options) {
}
intercept(request, context, stream$) {
return __awaiter(this, void 0, void 0, function* () {
yield new Promise((resolve, reject) => this.upload.array(fieldName, maxCount)(request, request.res, resolve));
yield new Promise((resolve, reject) => this.upload.array(fieldName, maxCount)(request, request.res, err => {
if (err) {
return reject(err);
}
resolve();
}));
return stream$;
});
}
Expand Down
4 changes: 4 additions & 0 deletions lib/common/interfaces/nest-application-context.interface.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@ export interface INestApplicationContext {
* Retrieves an instance of either injectable or controller available inside the processed module, otherwise, returns null.
* @returns T
*/
<<<<<<< HEAD
get<T>(typeOrToken: Type<T> | string | symbol): T | null;
/**
* Retrieves an instance of either injectable or controller available inside any module, otherwise, returns null.
* @returns T
*/
find<T>(typeOrToken: Type<T> | string | symbol): T | null;
=======
get<T>(metatypeOrToken: Metatype<T> | string | symbol): T;
>>>>>>> master
}
2 changes: 1 addition & 1 deletion lib/common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nestjs/common",
"version": "4.6.3",
"version": "4.6.5",
"description": "Nest - modern, fast, powerful node.js web framework (@common)",
"author": "Kamil Mysliwiec",
"license": "MIT",
Expand Down
6 changes: 3 additions & 3 deletions lib/common/services/logger.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ class Logger {
}
log(message) {
const { logger } = Logger;
logger.log(message, this.context, this.isTimeDiffEnabled);
logger.log.call(logger, message, this.context, this.isTimeDiffEnabled);
}
error(message, trace = '') {
const { logger } = Logger;
logger.error(message, trace, this.context, this.isTimeDiffEnabled);
logger.error.call(logger, message, trace, this.context, this.isTimeDiffEnabled);
}
warn(message) {
const { logger } = Logger;
logger.warn(message, this.context, this.isTimeDiffEnabled);
logger.warn.call(logger, message, this.context, this.isTimeDiffEnabled);
}
static overrideLogger(logger) {
this.logger = logger;
Expand Down
4 changes: 4 additions & 0 deletions lib/core/injector/container.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@ import { Type } from '@nestjs/common/interfaces/type.interface';
import { Module } from './module';
import { DynamicModule } from '@nestjs/common';
import { ModulesContainer } from './modules-container';
import { ApplicationConfig } from './../application-config';
export declare class NestContainer {
private readonly _applicationConfig;
private readonly globalModules;
private readonly modules;
private readonly dynamicModulesMetadata;
private readonly moduleTokenFactory;
private applicationRef;
constructor(_applicationConfig?: ApplicationConfig);
readonly applicationConfig: ApplicationConfig | undefined;
setApplicationRef(applicationRef: any): void;
getApplicationRef(): any;
addModule(metatype: Type<any> | DynamicModule, scope: Type<any>[]): void;
Expand Down
6 changes: 5 additions & 1 deletion lib/core/injector/container.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,16 @@ const module_token_factory_1 = require("./module-token-factory");
const invalid_module_exception_1 = require("./../errors/exceptions/invalid-module.exception");
const modules_container_1 = require("./modules-container");
class NestContainer {
constructor() {
constructor(_applicationConfig = void 0) {
this._applicationConfig = _applicationConfig;
this.globalModules = new Set();
this.modules = new modules_container_1.ModulesContainer();
this.dynamicModulesMetadata = new Map();
this.moduleTokenFactory = new module_token_factory_1.ModuleTokenFactory();
}
get applicationConfig() {
return this._applicationConfig;
}
setApplicationRef(applicationRef) {
this.applicationRef = applicationRef;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/core/injector/module.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ export declare type CustomValue = CustomComponent & {
};
export declare type ComponentMetatype = Type<Injectable> | CustomFactory | CustomValue | CustomClass;
export declare class Module {
private _metatype;
private _scope;
private readonly _metatype;
private readonly _scope;
private _relatedModules;
private _components;
private _injectables;
Expand Down
2 changes: 1 addition & 1 deletion lib/core/injector/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class Module {
name: external_context_creator_1.ExternalContextCreator.name,
metatype: external_context_creator_1.ExternalContextCreator,
isResolved: true,
instance: new external_context_creator_1.ExternalContextCreator(new guards_context_creator_1.GuardsContextCreator(container), new guards_consumer_1.GuardsConsumer(), new interceptors_context_creator_1.InterceptorsContextCreator(container), new interceptors_consumer_1.InterceptorsConsumer(), container.getModules()),
instance: new external_context_creator_1.ExternalContextCreator(new guards_context_creator_1.GuardsContextCreator(container, container.applicationConfig), new guards_consumer_1.GuardsConsumer(), new interceptors_context_creator_1.InterceptorsContextCreator(container, container.applicationConfig), new interceptors_consumer_1.InterceptorsConsumer(), container.getModules()),
});
}
addModulesContainer(container) {
Expand Down
8 changes: 8 additions & 0 deletions lib/core/nest-application-context.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,18 @@ export declare class NestApplicationContext implements INestApplicationContext {
private readonly scope;
protected contextModule: any;
private readonly moduleTokenFactory;
<<<<<<< HEAD
constructor(container: NestContainer, scope: Type<any>[], contextModule: any);
selectContextModule(): void;
select<T>(module: Type<T>): INestApplicationContext;
get<T>(typeOrToken: Type<T> | string | symbol): T | null;
find<T>(typeOrToken: Type<T> | string | symbol): T | null;
private findInstanceByPrototypeOrToken<T>(metatypeOrToken, contextModule);
=======
constructor(container: NestContainer, scope: NestModuleMetatype[], contextModule: any);
selectContextModule(): void;
select<T>(module: Metatype<T>): INestApplicationContext;
get<T>(metatypeOrToken: Metatype<T> | string | symbol): T;
private findInstanceByPrototypeOrToken<T>(metatypeOrToken);
>>>>>>> master
}
8 changes: 7 additions & 1 deletion lib/core/nest-application.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { ApplicationConfig } from './application-config';
import { NestContainer } from './injector/container';
import { NestApplicationContext } from './nest-application-context';
import { NestApplicationOptions } from '@nestjs/common/interfaces/nest-application-options.interface';
import { CorsOptions } from '@nestjs/common/interfaces/external/cors-options.interface';
export declare class NestApplication extends NestApplicationContext implements INestApplication {
private readonly httpAdapter;
private readonly config;
Expand All @@ -20,9 +21,14 @@ export declare class NestApplication extends NestApplicationContext implements I
private readonly microservices;
private httpServer;
private isInitialized;
<<<<<<< HEAD
constructor(container: NestContainer, httpAdapter: any, config: ApplicationConfig, appOptions?: NestApplicationOptions);
registerHttpServer(): void;
applyOptions(): any;
=======
constructor(container: NestContainer, express: any, config: ApplicationConfig, appOptions?: NestApplicationOptions);
applyOptions(): this;
>>>>>>> master
createServer(): any;
getUnderlyingHttpServer(): any;
registerModules(): Promise<void>;
Expand All @@ -40,7 +46,7 @@ export declare class NestApplication extends NestApplicationContext implements I
set(...args: any[]): this;
disable(...args: any[]): this;
enable(...args: any[]): this;
enableCors(): this;
enableCors(options?: CorsOptions): this;
listen(port: number | string, callback?: () => void): any;
listen(port: number | string, hostname: string, callback?: () => void): any;
listenAsync(port: number | string, hostname?: string): Promise<any>;
Expand Down
8 changes: 6 additions & 2 deletions lib/core/nest-application.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,14 @@ class NestApplication extends nest_application_context_1.NestApplicationContext
this.config.setIoAdapter(ioAdapter);
}
applyOptions() {
if (!this.appOptions) {
if (!this.appOptions || !this.appOptions.cors) {
return undefined;
}
this.appOptions.cors && this.enableCors();
const isCorsOptionsObj = shared_utils_1.isObject(this.appOptions.cors);
if (!isCorsOptionsObj) {
return this.enableCors();
}
this.enableCors(this.appOptions.cors);
}
createServer() {
const isHttpsEnabled = this.appOptions && this.appOptions.httpsOptions;
Expand Down
10 changes: 9 additions & 1 deletion lib/core/nest-factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,20 @@ class NestFactoryStatic {
}
create(module, serverOrOptions, options) {
return __awaiter(this, void 0, void 0, function* () {
<<<<<<< HEAD
const isHttpServer = serverOrOptions && serverOrOptions.patch;
const [httpServer, appOptions] = isHttpServer
? [serverOrOptions, options]
: [express_factory_1.ExpressFactory.create(), serverOrOptions];
const container = new container_1.NestContainer();
=======
const isExpressInstance = expressOrOptions && expressOrOptions.response;
const [expressInstance, appOptions] = isExpressInstance
? [expressOrOptions, options]
: [express_adapter_1.ExpressAdapter.create(), expressOrOptions];
>>>>>>> master
const applicationConfig = new application_config_1.ApplicationConfig();
const container = new container_1.NestContainer(applicationConfig);
this.applyLogger(appOptions);
yield this.initialize(module, container, applicationConfig, httpServer);
return this.createNestInstance(new nest_application_1.NestApplication(container, httpServer, applicationConfig, appOptions));
Expand All @@ -52,8 +60,8 @@ class NestFactoryStatic {
if (!NestMicroservice) {
throw new microservices_package_not_found_exception_1.MicroservicesPackageNotFoundException();
}
const container = new container_1.NestContainer();
const applicationConfig = new application_config_1.ApplicationConfig();
const container = new container_1.NestContainer(applicationConfig);
this.applyLogger(options);
yield this.initialize(module, container, applicationConfig);
return this.createNestInstance(new NestMicroservice(container, options, applicationConfig));
Expand Down
2 changes: 1 addition & 1 deletion lib/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nestjs/core",
"version": "4.6.3",
"version": "4.6.5",
"description": "Nest - modern, fast, powerful node.js web framework (@core)",
"author": "Kamil Mysliwiec",
"license": "MIT",
Expand Down
8 changes: 8 additions & 0 deletions lib/core/router/routes-resolver.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,18 @@ export declare class RoutesResolver implements Resolver {
private readonly routerProxy;
private readonly routerExceptionsFilter;
private readonly routerBuilder;
<<<<<<< HEAD
constructor(container: NestContainer, config: ApplicationConfig);
resolve(appInstance: any, basePath: string): void;
registerRouters(routes: Map<string, InstanceWrapper<Controller>>, moduleName: string, basePath: string, appInstance: HttpServer): void;
registerNotFoundHandler(): void;
registerExceptionHandler(): void;
=======
constructor(container: NestContainer, expressAdapter: any, config: ApplicationConfig);
resolve(router: any, express: Application): void;
setupRouters(routes: Map<string, InstanceWrapper<Controller>>, moduleName: string, modulePath: string, express: Application): void;
setupNotFoundHandler(express: Application): void;
setupExceptionHandler(express: Application): void;
>>>>>>> master
mapExternalException(err: any): any;
}
Loading

0 comments on commit 2ebfca2

Please sign in to comment.