Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/nestjs/nest
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilmysliwiec committed Sep 13, 2018
2 parents a9922da + b1f7096 commit 14f737f
Show file tree
Hide file tree
Showing 84 changed files with 7,005 additions and 109 deletions.
2 changes: 1 addition & 1 deletion packages/common/cache/interfaces/cache-module.interface.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ModuleMetadata, Type } from './../../interfaces';
import { ModuleMetadata, Type } from '../../interfaces';
import { CacheManagerOptions } from './cache-manager.interface';

export interface CacheModuleOptions extends CacheManagerOptions {
Expand Down
2 changes: 1 addition & 1 deletion packages/common/exceptions/bad-gateway.exception.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { HttpException } from './http.exception';
import { HttpStatus } from '../enums/http-status.enum';
import { createHttpExceptionBody } from './../utils/http-exception-body.util';
import { createHttpExceptionBody } from '../utils/http-exception-body.util';

export class BadGatewayException extends HttpException {
constructor(message?: string | object | any, error = 'Bad Gateway') {
Expand Down
2 changes: 1 addition & 1 deletion packages/common/exceptions/bad-request.exception.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { HttpException } from './http.exception';
import { HttpStatus } from '../enums/http-status.enum';
import { createHttpExceptionBody } from './../utils/http-exception-body.util';
import { createHttpExceptionBody } from '../utils/http-exception-body.util';

export class BadRequestException extends HttpException {
constructor(message?: string | object | any, error = 'Bad Request') {
Expand Down
2 changes: 1 addition & 1 deletion packages/common/exceptions/conflict.exception.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { HttpException } from './http.exception';
import { HttpStatus } from '../enums/http-status.enum';
import { createHttpExceptionBody } from './../utils/http-exception-body.util';
import { createHttpExceptionBody } from '../utils/http-exception-body.util';

export class ConflictException extends HttpException {
constructor(message?: string | object | any, error = 'Conflict') {
Expand Down
2 changes: 1 addition & 1 deletion packages/common/exceptions/forbidden.exception.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { HttpException } from './http.exception';
import { HttpStatus } from '../enums/http-status.enum';
import { createHttpExceptionBody } from './../utils/http-exception-body.util';
import { createHttpExceptionBody } from '../utils/http-exception-body.util';

export class ForbiddenException extends HttpException {
constructor(message?: string | object | any, error = 'Forbidden') {
Expand Down
2 changes: 1 addition & 1 deletion packages/common/exceptions/gateway-timeout.exception.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { HttpException } from './http.exception';
import { HttpStatus } from '../enums/http-status.enum';
import { createHttpExceptionBody } from './../utils/http-exception-body.util';
import { createHttpExceptionBody } from '../utils/http-exception-body.util';

export class GatewayTimeoutException extends HttpException {
constructor(message?: string | object | any, error = 'Gateway Timeout') {
Expand Down
2 changes: 1 addition & 1 deletion packages/common/exceptions/gone.exception.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { HttpException } from './http.exception';
import { HttpStatus } from '../enums/http-status.enum';
import { createHttpExceptionBody } from './../utils/http-exception-body.util';
import { createHttpExceptionBody } from '../utils/http-exception-body.util';

export class GoneException extends HttpException {
constructor(message?: string | object | any, error = 'Gone') {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { HttpException } from './http.exception';
import { HttpStatus } from '../enums/http-status.enum';
import { createHttpExceptionBody } from './../utils/http-exception-body.util';
import { createHttpExceptionBody } from '../utils/http-exception-body.util';

export class InternalServerErrorException extends HttpException {
constructor(
Expand Down
2 changes: 1 addition & 1 deletion packages/common/exceptions/method-not-allowed.exception.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { HttpException } from './http.exception';
import { HttpStatus } from '../enums/http-status.enum';
import { createHttpExceptionBody } from './../utils/http-exception-body.util';
import { createHttpExceptionBody } from '../utils/http-exception-body.util';

export class MethodNotAllowedException extends HttpException {
constructor(message?: string | object | any, error = 'Method Not Allowed') {
Expand Down
2 changes: 1 addition & 1 deletion packages/common/exceptions/not-acceptable.exception.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { HttpException } from './http.exception';
import { HttpStatus } from '../enums/http-status.enum';
import { createHttpExceptionBody } from './../utils/http-exception-body.util';
import { createHttpExceptionBody } from '../utils/http-exception-body.util';

export class NotAcceptableException extends HttpException {
constructor(message?: string | object | any, error = 'Not Acceptable') {
Expand Down
2 changes: 1 addition & 1 deletion packages/common/exceptions/not-found.exception.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { HttpException } from './http.exception';
import { HttpStatus } from '../enums/http-status.enum';
import { createHttpExceptionBody } from './../utils/http-exception-body.util';
import { createHttpExceptionBody } from '../utils/http-exception-body.util';

export class NotFoundException extends HttpException {
constructor(message?: string | object | any, error = 'Not Found') {
Expand Down
2 changes: 1 addition & 1 deletion packages/common/exceptions/not-implemented.exception.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { HttpException } from './http.exception';
import { HttpStatus } from '../enums/http-status.enum';
import { createHttpExceptionBody } from './../utils/http-exception-body.util';
import { createHttpExceptionBody } from '../utils/http-exception-body.util';

export class NotImplementedException extends HttpException {
constructor(message?: string | object | any, error = 'Not Implemented') {
Expand Down
2 changes: 1 addition & 1 deletion packages/common/exceptions/payload-too-large.exception.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { HttpException } from './http.exception';
import { HttpStatus } from '../enums/http-status.enum';
import { createHttpExceptionBody } from './../utils/http-exception-body.util';
import { createHttpExceptionBody } from '../utils/http-exception-body.util';

export class PayloadTooLargeException extends HttpException {
constructor(message?: string | object | any, error = 'Payload Too Large') {
Expand Down
2 changes: 1 addition & 1 deletion packages/common/exceptions/request-timeout.exception.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { HttpException } from './http.exception';
import { HttpStatus } from '../enums/http-status.enum';
import { createHttpExceptionBody } from './../utils/http-exception-body.util';
import { createHttpExceptionBody } from '../utils/http-exception-body.util';

export class RequestTimeoutException extends HttpException {
constructor(message?: string | object | any, error = 'Request Timeout') {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { HttpException } from './http.exception';
import { HttpStatus } from '../enums/http-status.enum';
import { createHttpExceptionBody } from './../utils/http-exception-body.util';
import { createHttpExceptionBody } from '../utils/http-exception-body.util';

export class ServiceUnavailableException extends HttpException {
constructor(message?: string | object | any, error = 'Service Unavailable') {
Expand Down
2 changes: 1 addition & 1 deletion packages/common/exceptions/unauthorized.exception.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { HttpException } from './http.exception';
import { HttpStatus } from '../enums/http-status.enum';
import { createHttpExceptionBody } from './../utils/http-exception-body.util';
import { createHttpExceptionBody } from '../utils/http-exception-body.util';

export class UnauthorizedException extends HttpException {
constructor(message?: string | object | any, error = 'Unauthorized') {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { HttpException } from './http.exception';
import { HttpStatus } from '../enums/http-status.enum';
import { createHttpExceptionBody } from './../utils/http-exception-body.util';
import { createHttpExceptionBody } from '../utils/http-exception-body.util';

export class UnprocessableEntityException extends HttpException {
constructor(message?: string | object | any, error = 'Unprocessable Entity') {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { HttpException } from './http.exception';
import { HttpStatus } from '../enums/http-status.enum';
import { createHttpExceptionBody } from './../utils/http-exception-body.util';
import { createHttpExceptionBody } from '../utils/http-exception-body.util';

export class UnsupportedMediaTypeException extends HttpException {
constructor(
Expand Down
8 changes: 4 additions & 4 deletions packages/common/files/interceptors/file-fields.interceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import {
MulterField,
MulterOptions,
} from '../../interfaces/external/multer-options.interface';
import { NestInterceptor } from './../../interfaces/features/nest-interceptor.interface';
import { MULTER_MODULE_OPTIONS } from './../files.constants';
import { MulterModuleOptions } from './../interfaces';
import { transformException } from './../multer/multer.utils';
import { NestInterceptor } from '../../interfaces/features/nest-interceptor.interface';
import { MULTER_MODULE_OPTIONS } from '../files.constants';
import { MulterModuleOptions } from '../interfaces';
import { transformException } from '../multer/multer.utils';

type MulterInstance = any;

Expand Down
8 changes: 4 additions & 4 deletions packages/common/files/interceptors/file.interceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import { Inject, Optional } from '../../decorators';
import { mixin } from '../../decorators/core/component.decorator';
import { ExecutionContext } from '../../interfaces';
import { MulterOptions } from '../../interfaces/external/multer-options.interface';
import { NestInterceptor } from './../../interfaces/features/nest-interceptor.interface';
import { MULTER_MODULE_OPTIONS } from './../files.constants';
import { MulterModuleOptions } from './../interfaces';
import { transformException } from './../multer/multer.utils';
import { NestInterceptor } from '../../interfaces/features/nest-interceptor.interface';
import { MULTER_MODULE_OPTIONS } from '../files.constants';
import { MulterModuleOptions } from '../interfaces';
import { transformException } from '../multer/multer.utils';

type MulterInstance = any;

Expand Down
8 changes: 4 additions & 4 deletions packages/common/files/interceptors/files.interceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import { Inject, Optional } from '../../decorators';
import { mixin } from '../../decorators/core/component.decorator';
import { ExecutionContext } from '../../interfaces';
import { MulterOptions } from '../../interfaces/external/multer-options.interface';
import { NestInterceptor } from './../../interfaces/features/nest-interceptor.interface';
import { MULTER_MODULE_OPTIONS } from './../files.constants';
import { MulterModuleOptions } from './../interfaces';
import { transformException } from './../multer/multer.utils';
import { NestInterceptor } from '../../interfaces/features/nest-interceptor.interface';
import { MULTER_MODULE_OPTIONS } from '../files.constants';
import { MulterModuleOptions } from '../interfaces';
import { transformException } from '../multer/multer.utils';

type MulterInstance = any;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ModuleMetadata, Type } from '@nestjs/common/interfaces';
import { MulterOptions } from './../../interfaces/external/multer-options.interface';
import { MulterOptions } from '../../interfaces/external/multer-options.interface';

export interface MulterModuleOptions extends MulterOptions {}

Expand Down
2 changes: 1 addition & 1 deletion packages/common/files/multer/multer.utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BadRequestException, HttpException, PayloadTooLargeException } from './../../exceptions';
import { BadRequestException, HttpException, PayloadTooLargeException } from '../../exceptions';
import { multerExceptions } from './multer.constants';

export function transformException(error: Error | undefined) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ArgumentsHost } from './../features/arguments-host.interface';
import { ArgumentsHost } from '../features/arguments-host.interface';

export interface ExceptionFilter<T = any> {
catch(exception: T, host: ArgumentsHost);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Observable } from 'rxjs';
import { ArgumentsHost } from './../features/arguments-host.interface';
import { ArgumentsHost } from '../features/arguments-host.interface';

export interface RpcExceptionFilter<T = any, R = any> {
catch(exception: T, host: ArgumentsHost): Observable<R>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ArgumentsHost } from './../features/arguments-host.interface';
import { ArgumentsHost } from '../features/arguments-host.interface';

export interface WsExceptionFilter<T = any> {
catch(exception: T, host: ArgumentsHost);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Type } from './../index';
import { Type } from '../index';
import { ArgumentsHost } from './arguments-host.interface';

export interface ExecutionContext extends ArgumentsHost {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Transport } from './../../enums/transport.enum';
import { Transport } from '../../enums/transport.enum';
import {
TcpOptions,
RedisOptions,
Expand Down
2 changes: 1 addition & 1 deletion packages/common/interfaces/modules/provider.interface.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Type } from './../type.interface';
import { Type } from '../type.interface';

export type Provider =
| Type<any>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LoggerService } from './../services/logger.service';
import { LoggerService } from '../services/logger.service';
import { Type } from './type.interface';

export interface INestApplicationContext {
Expand Down
2 changes: 1 addition & 1 deletion packages/common/pipes/validation.pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ValidatorOptions } from '../interfaces/external/validator-options.inter
import { PipeTransform } from '../interfaces/features/pipe-transform.interface';
import { loadPackage } from '../utils/load-package.util';
import { isNil } from '../utils/shared.utils';
import { Injectable } from './../decorators/core/component.decorator';
import { Injectable } from '../decorators/core/component.decorator';

export interface ValidationPipeOptions extends ValidatorOptions {
transform?: boolean;
Expand Down
2 changes: 1 addition & 1 deletion packages/common/test/cache/cache.module.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from 'chai';
import { CACHE_MODULE_OPTIONS } from '../../cache/cache.constants';
import { CacheModule } from './../../cache/cache.module';
import { CacheModule } from '../../cache/cache.module';

describe('CacheModule', () => {
describe('register', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ExecutionContextHost } from '@nestjs/core/helpers/execution-context.hos
import { expect } from 'chai';
import { of } from 'rxjs';
import * as sinon from 'sinon';
import { FileFieldsInterceptor } from './../../../files/interceptors/file-fields.interceptor';
import { FileFieldsInterceptor } from '../../../files/interceptors/file-fields.interceptor';

describe('FileFieldsInterceptor', () => {
it('should return metatype with expected structure', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ExecutionContextHost } from '@nestjs/core/helpers/execution-context.hos
import { expect } from 'chai';
import { of } from 'rxjs';
import * as sinon from 'sinon';
import { FileInterceptor } from './../../../files/interceptors/file.interceptor';
import { FileInterceptor } from '../../../files/interceptors/file.interceptor';

describe('FileInterceptor', () => {
it('should return metatype with expected structure', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ExecutionContextHost } from '@nestjs/core/helpers/execution-context.hos
import { expect } from 'chai';
import { of } from 'rxjs';
import * as sinon from 'sinon';
import { FilesInterceptor } from './../../../files/interceptors/files.interceptor';
import { FilesInterceptor } from '../../../files/interceptors/files.interceptor';

describe('FilesInterceptor', () => {
it('should return metatype with expected structure', async () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/common/test/files/multer.module.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from 'chai';
import { MULTER_MODULE_OPTIONS } from '../../files/files.constants';
import { MulterModule } from './../../files/multer.module';
import { MulterModule } from '../../files/multer.module';

describe('MulterModule', () => {
describe('register', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/common/test/files/multer/multer.utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
PayloadTooLargeException,
} from '../../../exceptions';
import { multerExceptions } from '../../../files/multer/multer.constants';
import { transformException } from './../../../files/multer/multer.utils';
import { transformException } from '../../../files/multer/multer.utils';

describe('transformException', () => {
describe('if error does not exist', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/common/test/pipes/parse-int.pipe.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as sinon from 'sinon';
import { expect } from 'chai';
import { ArgumentMetadata } from '../../interfaces';
import { ParseIntPipe } from './../../pipes/parse-int.pipe';
import { ParseIntPipe } from '../../pipes/parse-int.pipe';

describe('ParseIntPipe', () => {
let target: ParseIntPipe;
Expand Down
2 changes: 1 addition & 1 deletion packages/common/test/pipes/validation.pipe.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as sinon from 'sinon';
import { expect } from 'chai';
import { ArgumentMetadata } from '../../interfaces';
import { IsString } from 'class-validator';
import { ValidationPipe } from './../../pipes/validation.pipe';
import { ValidationPipe } from '../../pipes/validation.pipe';

class TestModel {
constructor() {}
Expand Down
2 changes: 1 addition & 1 deletion packages/common/test/utils/load-package.util.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect } from 'chai';
import { loadPackage } from './../../utils/load-package.util';
import { loadPackage } from '../../utils/load-package.util';

describe('loadPackage', () => {
describe('when package is available', () => {
Expand Down
12 changes: 1 addition & 11 deletions packages/core/injector/injector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,7 @@ export class Injector {
);
} else {
const factoryResult = currentMetatype.metatype(...instances);
currentMetatype.instance = await this.resolveFactoryInstance(
factoryResult,
);
currentMetatype.instance = await factoryResult;
}
currentMetatype.isResolved = true;
done();
Expand Down Expand Up @@ -330,12 +328,4 @@ export class Injector {
}
return componentRef;
}

public async resolveFactoryInstance(factoryResult): Promise<any> {
if (!(factoryResult instanceof Promise)) {
return factoryResult;
}
const result = await factoryResult;
return result;
}
}
2 changes: 1 addition & 1 deletion packages/core/middleware/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class MiddlewareBuilder implements MiddlewareConsumer {
private static ConfigProxy = class implements MiddlewareConfigProxy {
private contextParameters = null;
private excludedRoutes: RouteInfo[] = [];
private includedRoutes: any[];
private readonly includedRoutes: any[];

constructor(private readonly builder: MiddlewareBuilder, middleware) {
this.includedRoutes = filterMiddleware(middleware);
Expand Down
4 changes: 0 additions & 4 deletions packages/core/middleware/middleware-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,6 @@ export class MiddlewareModule {
);
const resolve = instance.resolve();

if (!(resolve instanceof Promise)) {
bindWithProxy(resolve);
return;
}
const middleware = await resolve;
bindWithProxy(middleware);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/test/exceptions/exceptions-handler.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Logger } from '../../../common/services/logger.service';
import { NestEnvironment } from '../../../common/enums/nest-environment.enum';
import { InvalidExceptionFilterException } from '../../errors/exceptions/invalid-exception-filter.exception';
import { HttpException } from '@nestjs/common';
import { ExpressAdapter } from './../../adapters/express-adapter';
import { ExpressAdapter } from '../../adapters/express-adapter';
import { ExecutionContextHost } from '../../helpers/execution-context.host';

describe('ExceptionsHandler', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/test/guards/guards-consumer.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as sinon from 'sinon';
import { expect } from 'chai';
import { GuardsConsumer } from './../../guards/guards-consumer';
import { GuardsConsumer } from '../../guards/guards-consumer';
import { Observable, of } from 'rxjs';

describe('GuardsConsumer', () => {
Expand Down
Loading

0 comments on commit 14f737f

Please sign in to comment.