Skip to content

Commit

Permalink
chore(): publish 6.2.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilmysliwiec committed May 11, 2019
1 parent 5fce020 commit 5e2727b
Show file tree
Hide file tree
Showing 13 changed files with 201 additions and 165 deletions.
62 changes: 35 additions & 27 deletions integration/typegraphql/e2e/pipes.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Test } from '@nestjs/testing';
import * as request from 'supertest';
import { ApplicationModule } from '../src/app.module';

describe('GraphQL - Pipes', () => {
describe('GraphQL Pipes', () => {
let app: INestApplication;

beforeEach(async () => {
Expand Down Expand Up @@ -32,20 +32,24 @@ describe('GraphQL - Pipes', () => {
extensions: {
code: 'INTERNAL_SERVER_ERROR',
exception: {
message: [
{
children: [],
constraints: {
length:
'description must be longer than or equal to 30 characters',
},
property: 'description',
target: {
ingredients: [],
title: 'test',
message: {
error: 'Bad Request',
message: [
{
children: [],
constraints: {
length:
'description must be longer than or equal to 30 characters',
},
property: 'description',
target: {
ingredients: [],
title: 'test',
},
},
},
],
],
statusCode: 400,
},
response: {
error: 'Bad Request',
message: [
Expand Down Expand Up @@ -73,20 +77,24 @@ describe('GraphQL - Pipes', () => {
line: 2,
},
],
message: [
{
children: [],
constraints: {
length:
'description must be longer than or equal to 30 characters',
},
property: 'description',
target: {
ingredients: [],
title: 'test',
message: {
error: 'Bad Request',
message: [
{
children: [],
constraints: {
length:
'description must be longer than or equal to 30 characters',
},
property: 'description',
target: {
ingredients: [],
title: 'test',
},
},
},
],
],
statusCode: 400,
},
path: ['addRecipe'],
},
],
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nestjs",
"version": "6.1.1",
"version": "6.2.0",
"description": "Modern, fast, powerful node.js web framework",
"scripts": {
"coverage": "nyc report --reporter=text-lcov | coveralls",
Expand Down
26 changes: 13 additions & 13 deletions packages/common/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,30 +53,30 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors

<a href="https://valor-software.com/" target="_blank"><img src="https://docs.nestjs.com/assets/sponsors/valor-software.png" width="320" /></a>

#### Base Sponsor

<a href="https://blueanchor.io/" target="_blank"><img src="https://nestjs.com/img/blueanchor.png" width="300" /></a> &nbsp;
<a href="https://www.novologic.com/" target="_blank"><img src="https://nestjs.com/img/novologic.png" width="200" /></a>

#### Silver Sponsors
<a href="https://neoteric.eu/" target="_blank"><img src="https://nestjs.com/img/neoteric-cut.png" width="120" valign="middle" /></a> &nbsp;
<a href="http://gojob.com" target="_blank"><img src="http://nestjs.com/img/gojob-logo.png" valign="middle" height="95" /></a> &nbsp; <a href="https://www.swingdev.io" target="_blank"><img src="https://nestjs.com/img/swingdev-logo.svg#1" width="150" valign="middle" /> </a> &nbsp; &nbsp;
<a href="https://yakaz.com/" target="_blank"><img src="https://nestjs.com/img/yakaz.png" width="100" valign="middle" /></a> &nbsp;
<a href="https://trilon.io" target="_blank"><img src="https://nestjs.com/img/trilon.svg" width="150" valign="middle" /></a>
<a href="http://xtremis.com/" target="_blank"><img src="https://nestjs.com/img/logo-xtremis.svg" width="150" valign="middle" /></a>
<a href="http://gojob.com" target="_blank"><img src="http://nestjs.com/img/gojob-logo.png" valign="middle" height="95" /></a> &nbsp;
<a href="https://trilon.io" target="_blank"><img src="https://nestjs.com/img/trilon.svg" width="150" valign="middle" /></a> &nbsp;
<a href="http://www.leogistics.com" target="_blank"><img src="https://nestjs.com/img/leogistics-logo.jpeg" width="150" valign="middle" /></a>

#### Sponsors

<a href="https://scal.io" target="_blank"><img src="https://nestjs.com/img/scalio-logo.svg" width="110" valign="middle" /></a> &nbsp; <a href="http://angularity.io" target="_blank"><img src="http://angularity.io/media/logo.svg" height="26" valign="middle" /></a> &nbsp; <!--<a href="https://keycdn.com"><img src="https://nestjs.com/img/keycdn.svg" height="30" /></a> &nbsp;--> <a href="https://hostpresto.com" target="_blank"><img src="https://nestjs.com/img/hostpresto.png" height="30" valign="middle" /></a> &nbsp; <a href="https://genuinebee.com/" target="_blank"><img src="https://nestjs.com/img/genuinebee.svg" height="36" valign="middle" /></a> &nbsp; <a href="http://architectnow.net/" target="_blank"><img src="https://nestjs.com/img/architectnow.png" height="24" valign="middle" /></a> &nbsp; <a href="https://quander.io/" target="_blank"><img src="https://nestjs.com/img/quander.png" height="28" valign="middle" /></a> &nbsp; <a href="https://mantro.net/" target="_blank"><img src="https://nestjs.com/img/mantro-logo.svg" height="20" valign="middle" /></a> &nbsp;
<a href="https://www.swingdev.io" target="_blank"><img src="https://nestjs.com/img/swingdev-logo.svg#1" width="125" valign="middle" /> </a> &nbsp; <a href="https://blueanchor.io/" target="_blank"><img src="https://nestjs.com/img/blueanchor.png" width="180" valign="middle" /></a> &nbsp;
<a href="https://www.novologic.com/" target="_blank"><img src="https://nestjs.com/img/novologic.png" width="130" valign="middle" /></a> &nbsp;
<a href="https://scal.io" target="_blank"><img src="https://nestjs.com/img/scalio-logo.svg" width="110" valign="middle" /></a> &nbsp; <a href="http://angularity.io" target="_blank"><img src="http://angularity.io/media/logo.svg" height="26" valign="middle" /></a> &nbsp; <!--<a href="https://keycdn.com"><img src="https://nestjs.com/img/keycdn.svg" height="30" /></a> &nbsp;--> <a href="https://hostpresto.com" target="_blank"><img src="https://nestjs.com/img/hostpresto.png" height="30" valign="middle" /></a>

<a href="https://triplebyte.com/" target="_blank"><img src="https://nestjs.com/img/triplebyte.png" height="30" valign="middle" /></a> &nbsp;
&nbsp; <a href="https://genuinebee.com/" target="_blank"><img src="https://nestjs.com/img/genuinebee.svg" height="36" valign="middle" /></a> &nbsp; <a href="http://architectnow.net/" target="_blank"><img src="https://nestjs.com/img/architectnow.png" height="24" valign="middle" /></a> &nbsp; <a href="https://quander.io/" target="_blank"><img src="https://nestjs.com/img/quander.png" height="28" valign="middle" /></a> &nbsp; <a href="https://mantro.net/" target="_blank"><img src="https://nestjs.com/img/mantro-logo.svg" height="20" valign="middle" /></a> &nbsp; <a href="https://triplebyte.com/" target="_blank"><img src="https://nestjs.com/img/triplebyte.png" height="30" valign="middle" /></a> &nbsp;
<a href="https://ever.co/" target="_blank"><img src="https://nestjs.com/img/ever-logo.png" height="20" valign="middle" /></a> &nbsp;
<a href="https://buddy.works/" target="_blank"><img src="https://nestjs.com/img/buddy-logo.svg" height="35" valign="middle" /></a>
<a href="https://buddy.works/" target="_blank"><img src="https://nestjs.com/img/buddy-logo.svg" height="35" valign="middle" /></a> &nbsp;
<a href="https://blokt.com" target="_blank"><img src="https://nestjs.com/img/blokt-logo.png" height="31" valign="middle" /></a> &nbsp;
<a href="https://reposit.co.uk/" target="_blank"><img src="https://nestjs.com/img/reposit-logo.png" height="28" valign="middle" /></a> &nbsp; &nbsp; <a href="https://yakaz.com/" target="_blank"><img src="https://nestjs.com/img/yakaz.png" width="80" valign="middle" /></a> &nbsp;
<a href="http://xtremis.com/" target="_blank"><img src="https://nestjs.com/img/logo-xtremis.svg" width="145" valign="middle" /></a>



## Backers

<a href="https://opencollective.com/nest" target="_blank"><img src="https://opencollective.com/nest/backers.svg?width=890"></a>
<a href="https://opencollective.com/nest" target="_blank"><img src="https://opencollective.com/nest/backers.svg?width=1600"></a>

## Stay in touch

Expand Down
2 changes: 1 addition & 1 deletion packages/common/pipes/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from './validation.pipe';
export * from './parse-int.pipe';
export * from './validation.pipe';
26 changes: 13 additions & 13 deletions packages/core/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,30 +53,30 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors

<a href="https://valor-software.com/" target="_blank"><img src="https://docs.nestjs.com/assets/sponsors/valor-software.png" width="320" /></a>

#### Base Sponsor

<a href="https://blueanchor.io/" target="_blank"><img src="https://nestjs.com/img/blueanchor.png" width="300" /></a> &nbsp;
<a href="https://www.novologic.com/" target="_blank"><img src="https://nestjs.com/img/novologic.png" width="200" /></a>

#### Silver Sponsors
<a href="https://neoteric.eu/" target="_blank"><img src="https://nestjs.com/img/neoteric-cut.png" width="120" valign="middle" /></a> &nbsp;
<a href="http://gojob.com" target="_blank"><img src="http://nestjs.com/img/gojob-logo.png" valign="middle" height="95" /></a> &nbsp; <a href="https://www.swingdev.io" target="_blank"><img src="https://nestjs.com/img/swingdev-logo.svg#1" width="150" valign="middle" /> </a> &nbsp; &nbsp;
<a href="https://yakaz.com/" target="_blank"><img src="https://nestjs.com/img/yakaz.png" width="100" valign="middle" /></a> &nbsp;
<a href="https://trilon.io" target="_blank"><img src="https://nestjs.com/img/trilon.svg" width="150" valign="middle" /></a>
<a href="http://xtremis.com/" target="_blank"><img src="https://nestjs.com/img/logo-xtremis.svg" width="150" valign="middle" /></a>
<a href="http://gojob.com" target="_blank"><img src="http://nestjs.com/img/gojob-logo.png" valign="middle" height="95" /></a> &nbsp;
<a href="https://trilon.io" target="_blank"><img src="https://nestjs.com/img/trilon.svg" width="150" valign="middle" /></a> &nbsp;
<a href="http://www.leogistics.com" target="_blank"><img src="https://nestjs.com/img/leogistics-logo.jpeg" width="150" valign="middle" /></a>

#### Sponsors

<a href="https://scal.io" target="_blank"><img src="https://nestjs.com/img/scalio-logo.svg" width="110" valign="middle" /></a> &nbsp; <a href="http://angularity.io" target="_blank"><img src="http://angularity.io/media/logo.svg" height="26" valign="middle" /></a> &nbsp; <!--<a href="https://keycdn.com"><img src="https://nestjs.com/img/keycdn.svg" height="30" /></a> &nbsp;--> <a href="https://hostpresto.com" target="_blank"><img src="https://nestjs.com/img/hostpresto.png" height="30" valign="middle" /></a> &nbsp; <a href="https://genuinebee.com/" target="_blank"><img src="https://nestjs.com/img/genuinebee.svg" height="36" valign="middle" /></a> &nbsp; <a href="http://architectnow.net/" target="_blank"><img src="https://nestjs.com/img/architectnow.png" height="24" valign="middle" /></a> &nbsp; <a href="https://quander.io/" target="_blank"><img src="https://nestjs.com/img/quander.png" height="28" valign="middle" /></a> &nbsp; <a href="https://mantro.net/" target="_blank"><img src="https://nestjs.com/img/mantro-logo.svg" height="20" valign="middle" /></a> &nbsp;
<a href="https://www.swingdev.io" target="_blank"><img src="https://nestjs.com/img/swingdev-logo.svg#1" width="125" valign="middle" /> </a> &nbsp; <a href="https://blueanchor.io/" target="_blank"><img src="https://nestjs.com/img/blueanchor.png" width="180" valign="middle" /></a> &nbsp;
<a href="https://www.novologic.com/" target="_blank"><img src="https://nestjs.com/img/novologic.png" width="130" valign="middle" /></a> &nbsp;
<a href="https://scal.io" target="_blank"><img src="https://nestjs.com/img/scalio-logo.svg" width="110" valign="middle" /></a> &nbsp; <a href="http://angularity.io" target="_blank"><img src="http://angularity.io/media/logo.svg" height="26" valign="middle" /></a> &nbsp; <!--<a href="https://keycdn.com"><img src="https://nestjs.com/img/keycdn.svg" height="30" /></a> &nbsp;--> <a href="https://hostpresto.com" target="_blank"><img src="https://nestjs.com/img/hostpresto.png" height="30" valign="middle" /></a>

<a href="https://triplebyte.com/" target="_blank"><img src="https://nestjs.com/img/triplebyte.png" height="30" valign="middle" /></a> &nbsp;
&nbsp; <a href="https://genuinebee.com/" target="_blank"><img src="https://nestjs.com/img/genuinebee.svg" height="36" valign="middle" /></a> &nbsp; <a href="http://architectnow.net/" target="_blank"><img src="https://nestjs.com/img/architectnow.png" height="24" valign="middle" /></a> &nbsp; <a href="https://quander.io/" target="_blank"><img src="https://nestjs.com/img/quander.png" height="28" valign="middle" /></a> &nbsp; <a href="https://mantro.net/" target="_blank"><img src="https://nestjs.com/img/mantro-logo.svg" height="20" valign="middle" /></a> &nbsp; <a href="https://triplebyte.com/" target="_blank"><img src="https://nestjs.com/img/triplebyte.png" height="30" valign="middle" /></a> &nbsp;
<a href="https://ever.co/" target="_blank"><img src="https://nestjs.com/img/ever-logo.png" height="20" valign="middle" /></a> &nbsp;
<a href="https://buddy.works/" target="_blank"><img src="https://nestjs.com/img/buddy-logo.svg" height="35" valign="middle" /></a>
<a href="https://buddy.works/" target="_blank"><img src="https://nestjs.com/img/buddy-logo.svg" height="35" valign="middle" /></a> &nbsp;
<a href="https://blokt.com" target="_blank"><img src="https://nestjs.com/img/blokt-logo.png" height="31" valign="middle" /></a> &nbsp;
<a href="https://reposit.co.uk/" target="_blank"><img src="https://nestjs.com/img/reposit-logo.png" height="28" valign="middle" /></a> &nbsp; &nbsp; <a href="https://yakaz.com/" target="_blank"><img src="https://nestjs.com/img/yakaz.png" width="80" valign="middle" /></a> &nbsp;
<a href="http://xtremis.com/" target="_blank"><img src="https://nestjs.com/img/logo-xtremis.svg" width="145" valign="middle" /></a>



## Backers

<a href="https://opencollective.com/nest" target="_blank"><img src="https://opencollective.com/nest/backers.svg?width=890"></a>
<a href="https://opencollective.com/nest" target="_blank"><img src="https://opencollective.com/nest/backers.svg?width=1600"></a>

## Stay in touch

Expand Down
66 changes: 47 additions & 19 deletions packages/core/helpers/external-context-creator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ export interface ExternalHandlerMetadata {
) => (ParamProperties & { metatype?: any })[];
}

export interface ExternalContextOptions {
guards?: boolean;
interceptors?: boolean;
filters?: boolean;
}

export class ExternalContextCreator {
private readonly contextUtils = new ContextUtils();
private readonly externalErrorProxy = new ExternalErrorProxy();
Expand Down Expand Up @@ -98,6 +104,11 @@ export class ExternalContextCreator {
paramsFactory?: ParamsFactory,
contextId = STATIC_CONTEXT,
inquirerId?: string,
options: ExternalContextOptions = {
interceptors: true,
guards: true,
filters: true,
},
) {
const module = this.findContextModuleName(instance.constructor);
const { argsLength, paramtypes, getParamsMetadata } = this.getMetadata<T>(
Expand All @@ -106,42 +117,45 @@ export class ExternalContextCreator {
metadataKey,
paramsFactory,
);

const pipes = this.pipesContextCreator.create(
instance,
callback,
module,
contextId,
inquirerId,
);

const guards = this.guardsContextCreator.create(
instance,
callback,
module,
contextId,
inquirerId,
);
const interceptors = this.interceptorsContextCreator.create(
instance,
callback,
module,
contextId,
inquirerId,
);
const exceptionFilter = this.filtersContextCreator.create(
instance,
callback,
module,
contextId,
inquirerId,
);
const interceptors = options.interceptors
? this.interceptorsContextCreator.create(
instance,
callback,
module,
contextId,
inquirerId,
)
: [];

const paramsMetadata = getParamsMetadata(module, contextId, inquirerId);
const paramsOptions = paramsMetadata
? this.contextUtils.mergeParamsMetatypes(paramsMetadata, paramtypes)
: [];

const fnCanActivate = options.guards
? this.createGuardsFn(guards, instance, callback)
: null;
const fnApplyPipes = this.createPipesFn(pipes, paramsOptions);
const handler = (initialArgs: any[], ...args: any[]) => async () => {
if (fnApplyPipes) {
Expand All @@ -153,15 +167,8 @@ export class ExternalContextCreator {

const target = async (...args: any[]) => {
const initialArgs = this.contextUtils.createNullArray(argsLength);
const canActivate = await this.guardsConsumer.tryActivate(
guards,
args,
instance,
callback,
);
if (!canActivate) {
throw new ForbiddenException(FORBIDDEN_MESSAGE);
}
fnCanActivate && (await fnCanActivate(args));

const result = await this.interceptorsConsumer.intercept(
interceptors,
args,
Expand All @@ -171,7 +178,9 @@ export class ExternalContextCreator {
);
return this.transformToResult(result);
};
return this.externalErrorProxy.createProxy(target, exceptionFilter);
return options.filters
? this.externalErrorProxy.createProxy(target, exceptionFilter)
: target;
}

public getMetadata<T>(
Expand Down Expand Up @@ -328,4 +337,23 @@ export class ExternalContextCreator {
}
return resultOrDeffered;
}

public createGuardsFn(
guards: any[],
instance: Controller,
callback: (...args: any[]) => any,
): Function | null {
const canActivateFn = async (args: any[]) => {
const canActivate = await this.guardsConsumer.tryActivate(
guards,
args,
instance,
callback,
);
if (!canActivate) {
throw new ForbiddenException(FORBIDDEN_MESSAGE);
}
};
return guards.length ? canActivateFn : null;
}
}
Loading

0 comments on commit 5e2727b

Please sign in to comment.