Skip to content

Commit

Permalink
chore(release) publish v5.0.0-beta.0
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilmysliwiec committed Apr 17, 2018
1 parent eff9942 commit b144dbe
Show file tree
Hide file tree
Showing 64 changed files with 3,900 additions and 206 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 9 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"name": "nestjs",
"version": "4.6.6",
"description": "Modern, fast, powerful node.js web framework",
"main": "index.js",
"scripts": {
"precommit": "lint-staged",
"test":
Expand All @@ -18,7 +17,9 @@
"publish":
"./node_modules/.bin/lerna publish --exact -m \"chore(release) publish %s\"",
"publish:next":
"./node_modules/.bin/lerna publish --npm-tag=next --skip-git"
"./node_modules/.bin/lerna publish --npm-tag=next --skip-git -m \"chore(release) publish %s\"",
"publish:beta":
"./node_modules/.bin/lerna publish --npm-tag=beta -m \"chore(release) publish %s\""
},
"engines": {
"node": ">=6.11.0"
Expand All @@ -30,11 +31,11 @@
"author": "Kamil Mysliwiec",
"license": "MIT",
"dependencies": {
"@nestjs/common": "^5.0.0",
"@nestjs/core": "^5.0.0",
"@nestjs/microservices": "^5.0.0",
"@nestjs/testing": "^5.0.0",
"@nestjs/websockets": "^5.0.0",
"@nestjs/common": "beta",
"@nestjs/core": "beta",
"@nestjs/microservices": "beta",
"@nestjs/testing": "beta",
"@nestjs/websockets": "beta",
"axios": "^0.17.1",
"class-transformer": "^0.1.8",
"class-validator": "^0.8.1",
Expand All @@ -59,7 +60,7 @@
"pump": "^3.0.0",
"redis": "^2.7.1",
"reflect-metadata": "^0.1.10",
"rxjs": "^5.5.6",
"rxjs": "^5.5.8",
"rxjs-grpc": "^0.1.6",
"socket.io": "^2.0.4",
"trouter": "^1.0.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const randomString = () =>
Math.random()
.toString(36)
.substring(2, 15);

/**
* Creates HTTP route param decorator
* @param factory
Expand All @@ -54,13 +54,15 @@ export function createParamDecorator(
}

/**
* Creates route params custom decorator
* Creates HTTP route param decorator
* @deprecated
* @param factory
*/
export function createRouteParamDecorator(
factory: CustomParamFactory,
): (data?: any, ...pipes: PipeTransform<any>[]) => ParameterDecorator {
deprecate('The "createRouteParamDecorator" function is deprecated and will be removed within next major release. Use "createParamDecorator" instead.')
deprecate(
'The "createRouteParamDecorator" function is deprecated and will be removed within next major release. Use "createParamDecorator" instead.',
);
return createParamDecorator(factory);
}
38 changes: 24 additions & 14 deletions packages/common/decorators/http/route-params.decorator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { ROUTE_ARGS_METADATA } from '../../constants';
import { RouteParamtypes } from '../../enums/route-paramtypes.enum';
import { PipeTransform } from '../../index';
import { isNil, isString } from '../../utils/shared.utils';
import { Type } from '../../interfaces';

export type ParamData = object | string | number;
export interface RouteParamsMetadata {
Expand All @@ -17,7 +18,7 @@ const assignMetadata = (
paramtype: RouteParamtypes,
index: number,
data?: ParamData,
...pipes: PipeTransform<any>[]
...pipes: (Type<PipeTransform> | PipeTransform)[]
) => ({
...args,
[`${paramtype}:${index}`]: {
Expand All @@ -41,7 +42,7 @@ const createRouteParamDecorator = (paramtype: RouteParamtypes) => {

const createPipesRouteParamDecorator = (paramtype: RouteParamtypes) => (
data?,
...pipes: PipeTransform<any>[]
...pipes: (Type<PipeTransform> | PipeTransform)[]
): ParameterDecorator => (target, key, index) => {
const args = Reflect.getMetadata(ROUTE_ARGS_METADATA, target, key) || {};
const hasParamData = isNil(data) || isString(data);
Expand Down Expand Up @@ -79,11 +80,14 @@ export const Headers: (
) => ParameterDecorator = createRouteParamDecorator(RouteParamtypes.HEADERS);

export function Query();
export function Query(...pipes: PipeTransform<any>[]);
export function Query(property: string, ...pipes: PipeTransform<any>[]);
export function Query(...pipes: (Type<PipeTransform> | PipeTransform)[]);
export function Query(
property?: string | PipeTransform<any>,
...pipes: PipeTransform<any>[]
property: string,
...pipes: (Type<PipeTransform> | PipeTransform)[]
);
export function Query(
property?: string | (Type<PipeTransform> | PipeTransform),
...pipes: (Type<PipeTransform> | PipeTransform)[]
) {
return createPipesRouteParamDecorator(RouteParamtypes.QUERY)(
property,
Expand All @@ -92,11 +96,14 @@ export function Query(
}

export function Body();
export function Body(...pipes: PipeTransform<any>[]);
export function Body(property: string, ...pipes: PipeTransform<any>[]);
export function Body(...pipes: (Type<PipeTransform> | PipeTransform)[]);
export function Body(
property: string,
...pipes: (Type<PipeTransform> | PipeTransform)[]
);
export function Body(
property?: string | PipeTransform<any>,
...pipes: PipeTransform<any>[]
property?: string | (Type<PipeTransform> | PipeTransform),
...pipes: (Type<PipeTransform> | PipeTransform)[]
) {
return createPipesRouteParamDecorator(RouteParamtypes.BODY)(
property,
Expand All @@ -105,11 +112,14 @@ export function Body(
}

export function Param();
export function Param(...pipes: PipeTransform<any>[]);
export function Param(property: string, ...pipes: PipeTransform<any>[]);
export function Param(...pipes: (Type<PipeTransform> | PipeTransform)[]);
export function Param(
property: string,
...pipes: (Type<PipeTransform> | PipeTransform)[]
);
export function Param(
property?: string | PipeTransform<any>,
...pipes: PipeTransform<any>[]
property?: string | (Type<PipeTransform> | PipeTransform),
...pipes: (Type<PipeTransform> | PipeTransform)[]
) {
return createPipesRouteParamDecorator(RouteParamtypes.PARAM)(
property,
Expand Down
1 change: 1 addition & 0 deletions packages/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,4 @@ export * from './services/logger.service';
export * from './pipes';
export * from './utils';
export * from './exceptions';
export * from './http';
6 changes: 3 additions & 3 deletions packages/common/interceptors/file.interceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ export function FileInterceptor(fieldName: string, options?: MulterOptions) {

async intercept(
context: ExecutionContext,
stream$: Observable<any>,
call$: Observable<any>,
): Promise<Observable<any>> {
const ctx = context.switchToHttp();

await new Promise((resolve, reject) =>
this.upload.single(fieldName)(
ctx.getRequest(),
Expand All @@ -30,7 +30,7 @@ export function FileInterceptor(fieldName: string, options?: MulterOptions) {
},
),
);
return stream$;
return call$;
}
},
);
Expand Down
6 changes: 3 additions & 3 deletions packages/common/interceptors/files.interceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ export function FilesInterceptor(

async intercept(
context: ExecutionContext,
stream$: Observable<any>,
call$: Observable<any>,
): Promise<Observable<any>> {
const ctx = context.switchToHttp();

await new Promise((resolve, reject) =>
this.upload.array(fieldName, maxCount)(
ctx.getRequest(),
Expand All @@ -32,7 +32,7 @@ export function FilesInterceptor(
},
),
);
return stream$;
return call$;
}
};
return Interceptor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ import { ExecutionContext } from './execution-context.interface';
export interface NestInterceptor<T = any, R = any> {
intercept(
context: ExecutionContext,
stream$: Observable<T>,
call$: Observable<T>,
): Observable<R> | Promise<Observable<R>>;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { LoggerService } from '../services/logger.service';

export class NestApplicationContextOptions {
logger?: LoggerService;
logger?: LoggerService | boolean;
}
13 changes: 5 additions & 8 deletions packages/common/interfaces/nest-application-context.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,11 @@ export interface INestApplicationContext {
select<T>(module: Type<T>): INestApplicationContext;

/**
* Retrieves an instance of either injectable or controller available inside the processed module, otherwise, returns null.
* Retrieves an instance of either injectable or controller available anywhere, otherwise, throws exception.
* @returns {T}
*/
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>(
typeOrToken: Type<T> | string | symbol,
options?: { strict: boolean },
): T;
}
4 changes: 3 additions & 1 deletion packages/common/pipes/parse-int.pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ export class ParseIntPipe implements PipeTransform<string> {
!isNaN(parseFloat(value)) &&
isFinite(value as any);
if (!isNumeric) {
throw new BadRequestException('Numeric string is expected');
throw new BadRequestException(
'Validation failed (numeric string is expected)',
);
}
return parseInt(value, 10);
}
Expand Down
41 changes: 17 additions & 24 deletions packages/common/services/logger.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import { Constructor } from '../utils/merge-with-values.util';
declare const process;

export interface LoggerService {
log(message: string): void;
error(message: string, trace: string): void;
warn(message: string): void;
log(message: string);
error(message: string, trace: string);
warn(message: string);
}

export class Logger implements LoggerService {
Expand All @@ -24,37 +24,30 @@ export class Logger implements LoggerService {

log(message: string) {
const { logger } = Logger;
(logger as typeof Logger).log.call(
logger,
message,
this.context,
this.isTimeDiffEnabled,
);
logger &&
logger.log.call(logger, message, this.context, this.isTimeDiffEnabled);
}

error(message: string, trace = '') {
const { logger } = Logger;
(logger as typeof Logger).error.call(
logger,
message,
trace,
this.context,
this.isTimeDiffEnabled,
);
logger &&
logger.error.call(
logger,
message,
trace,
this.context,
this.isTimeDiffEnabled,
);
}

warn(message: string) {
const { logger } = Logger;
(logger as typeof Logger).warn.call(
logger,
message,
this.context,
this.isTimeDiffEnabled,
);
logger &&
logger.warn.call(logger, message, this.context, this.isTimeDiffEnabled);
}

static overrideLogger(logger: LoggerService) {
this.logger = logger;
static overrideLogger(logger: LoggerService | boolean) {
this.logger = logger ? (logger as LoggerService) : null;
}

static setMode(mode: NestEnvironment) {
Expand Down
5 changes: 2 additions & 3 deletions packages/common/test/decorators/use-guards.decorator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,8 @@ describe('@UseGuards', () => {

it('when object is invalid should throw exception', () => {
try {
UseGuards('test')({});
}
catch (e) {
UseGuards('test' as any)({});
} catch (e) {
expect(e).to.be.instanceof(InvalidDecoratorItemException);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@ describe('@UseInterceptors', () => {

it('when object is invalid should throw exception', () => {
try {
UseInterceptors('test')({});
}
catch (e) {
UseInterceptors('test' as any)({});
} catch (e) {
expect(e).to.be.instanceof(InvalidDecoratorItemException);
}
});
Expand Down
6 changes: 3 additions & 3 deletions packages/core/adapters/fastify-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import { MissingRequiredDependencyException } from '../errors/exceptions/missing

export class FastifyAdapter {
private readonly logger = new Logger(FastifyAdapter.name);
protected readonly instance;
protected readonly instance: any;

constructor() {
constructor(options?: any) {
try {
this.instance = require('fastify')();
this.instance = require('fastify')(options);
} catch (e) {
throw new MissingRequiredDependencyException('fastify', 'FastifyAdapter');
}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/guards/guards-context-creator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export class GuardsContextCreator extends ContextCreator {
}

public getGuardInstance(guard: Function | CanActivate) {
const isObject = !!(guard as CanActivate).canActivate;
const isObject = (guard as CanActivate).canActivate;
if (isObject) {
return guard;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/interceptors/interceptors-context-creator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class InterceptorsContextCreator extends ContextCreator {
}

public getInterceptorInstance(interceptor: Function | NestInterceptor) {
const isObject = !!(interceptor as NestInterceptor).intercept;
const isObject = (interceptor as NestInterceptor).intercept;
if (isObject) {
return interceptor;
}
Expand Down
Loading

0 comments on commit b144dbe

Please sign in to comment.