Skip to content

Commit 5e2727b

Browse files
chore(): publish 6.2.0 release
1 parent 5fce020 commit 5e2727b

13 files changed

Lines changed: 201 additions & 165 deletions

File tree

integration/typegraphql/e2e/pipes.spec.ts

Lines changed: 35 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Test } from '@nestjs/testing';
33
import * as request from 'supertest';
44
import { ApplicationModule } from '../src/app.module';
55

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

99
beforeEach(async () => {
@@ -32,20 +32,24 @@ describe('GraphQL - Pipes', () => {
3232
extensions: {
3333
code: 'INTERNAL_SERVER_ERROR',
3434
exception: {
35-
message: [
36-
{
37-
children: [],
38-
constraints: {
39-
length:
40-
'description must be longer than or equal to 30 characters',
41-
},
42-
property: 'description',
43-
target: {
44-
ingredients: [],
45-
title: 'test',
35+
message: {
36+
error: 'Bad Request',
37+
message: [
38+
{
39+
children: [],
40+
constraints: {
41+
length:
42+
'description must be longer than or equal to 30 characters',
43+
},
44+
property: 'description',
45+
target: {
46+
ingredients: [],
47+
title: 'test',
48+
},
4649
},
47-
},
48-
],
50+
],
51+
statusCode: 400,
52+
},
4953
response: {
5054
error: 'Bad Request',
5155
message: [
@@ -73,20 +77,24 @@ describe('GraphQL - Pipes', () => {
7377
line: 2,
7478
},
7579
],
76-
message: [
77-
{
78-
children: [],
79-
constraints: {
80-
length:
81-
'description must be longer than or equal to 30 characters',
82-
},
83-
property: 'description',
84-
target: {
85-
ingredients: [],
86-
title: 'test',
80+
message: {
81+
error: 'Bad Request',
82+
message: [
83+
{
84+
children: [],
85+
constraints: {
86+
length:
87+
'description must be longer than or equal to 30 characters',
88+
},
89+
property: 'description',
90+
target: {
91+
ingredients: [],
92+
title: 'test',
93+
},
8794
},
88-
},
89-
],
95+
],
96+
statusCode: 400,
97+
},
9098
path: ['addRecipe'],
9199
},
92100
],

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nestjs",
3-
"version": "6.1.1",
3+
"version": "6.2.0",
44
"description": "Modern, fast, powerful node.js web framework",
55
"scripts": {
66
"coverage": "nyc report --reporter=text-lcov | coveralls",

packages/common/Readme.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,30 +53,30 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
5353

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

56-
#### Base Sponsor
57-
58-
<a href="https://blueanchor.io/" target="_blank"><img src="https://nestjs.com/img/blueanchor.png" width="300" /></a> &nbsp;
59-
<a href="https://www.novologic.com/" target="_blank"><img src="https://nestjs.com/img/novologic.png" width="200" /></a>
60-
6156
#### Silver Sponsors
6257
<a href="https://neoteric.eu/" target="_blank"><img src="https://nestjs.com/img/neoteric-cut.png" width="120" valign="middle" /></a> &nbsp;
63-
<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;
64-
<a href="https://yakaz.com/" target="_blank"><img src="https://nestjs.com/img/yakaz.png" width="100" valign="middle" /></a> &nbsp;
65-
<a href="https://trilon.io" target="_blank"><img src="https://nestjs.com/img/trilon.svg" width="150" valign="middle" /></a>
66-
<a href="http://xtremis.com/" target="_blank"><img src="https://nestjs.com/img/logo-xtremis.svg" width="150" valign="middle" /></a>
58+
<a href="http://gojob.com" target="_blank"><img src="http://nestjs.com/img/gojob-logo.png" valign="middle" height="95" /></a> &nbsp;
59+
<a href="https://trilon.io" target="_blank"><img src="https://nestjs.com/img/trilon.svg" width="150" valign="middle" /></a> &nbsp;
60+
<a href="http://www.leogistics.com" target="_blank"><img src="https://nestjs.com/img/leogistics-logo.jpeg" width="150" valign="middle" /></a>
6761

6862
#### Sponsors
6963

70-
<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;
64+
<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;
65+
<a href="https://www.novologic.com/" target="_blank"><img src="https://nestjs.com/img/novologic.png" width="130" valign="middle" /></a> &nbsp;
66+
<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>
7167

72-
<a href="https://triplebyte.com/" target="_blank"><img src="https://nestjs.com/img/triplebyte.png" height="30" valign="middle" /></a> &nbsp;
68+
&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;
7369
<a href="https://ever.co/" target="_blank"><img src="https://nestjs.com/img/ever-logo.png" height="20" valign="middle" /></a> &nbsp;
74-
<a href="https://buddy.works/" target="_blank"><img src="https://nestjs.com/img/buddy-logo.svg" height="35" valign="middle" /></a>
70+
<a href="https://buddy.works/" target="_blank"><img src="https://nestjs.com/img/buddy-logo.svg" height="35" valign="middle" /></a> &nbsp;
71+
<a href="https://blokt.com" target="_blank"><img src="https://nestjs.com/img/blokt-logo.png" height="31" valign="middle" /></a> &nbsp;
72+
<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;
73+
<a href="http://xtremis.com/" target="_blank"><img src="https://nestjs.com/img/logo-xtremis.svg" width="145" valign="middle" /></a>
74+
7575

7676

7777
## Backers
7878

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

8181
## Stay in touch
8282

packages/common/pipes/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
export * from './validation.pipe';
21
export * from './parse-int.pipe';
2+
export * from './validation.pipe';

packages/core/Readme.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,30 +53,30 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
5353

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

56-
#### Base Sponsor
57-
58-
<a href="https://blueanchor.io/" target="_blank"><img src="https://nestjs.com/img/blueanchor.png" width="300" /></a> &nbsp;
59-
<a href="https://www.novologic.com/" target="_blank"><img src="https://nestjs.com/img/novologic.png" width="200" /></a>
60-
6156
#### Silver Sponsors
6257
<a href="https://neoteric.eu/" target="_blank"><img src="https://nestjs.com/img/neoteric-cut.png" width="120" valign="middle" /></a> &nbsp;
63-
<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;
64-
<a href="https://yakaz.com/" target="_blank"><img src="https://nestjs.com/img/yakaz.png" width="100" valign="middle" /></a> &nbsp;
65-
<a href="https://trilon.io" target="_blank"><img src="https://nestjs.com/img/trilon.svg" width="150" valign="middle" /></a>
66-
<a href="http://xtremis.com/" target="_blank"><img src="https://nestjs.com/img/logo-xtremis.svg" width="150" valign="middle" /></a>
58+
<a href="http://gojob.com" target="_blank"><img src="http://nestjs.com/img/gojob-logo.png" valign="middle" height="95" /></a> &nbsp;
59+
<a href="https://trilon.io" target="_blank"><img src="https://nestjs.com/img/trilon.svg" width="150" valign="middle" /></a> &nbsp;
60+
<a href="http://www.leogistics.com" target="_blank"><img src="https://nestjs.com/img/leogistics-logo.jpeg" width="150" valign="middle" /></a>
6761

6862
#### Sponsors
6963

70-
<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;
64+
<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;
65+
<a href="https://www.novologic.com/" target="_blank"><img src="https://nestjs.com/img/novologic.png" width="130" valign="middle" /></a> &nbsp;
66+
<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>
7167

72-
<a href="https://triplebyte.com/" target="_blank"><img src="https://nestjs.com/img/triplebyte.png" height="30" valign="middle" /></a> &nbsp;
68+
&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;
7369
<a href="https://ever.co/" target="_blank"><img src="https://nestjs.com/img/ever-logo.png" height="20" valign="middle" /></a> &nbsp;
74-
<a href="https://buddy.works/" target="_blank"><img src="https://nestjs.com/img/buddy-logo.svg" height="35" valign="middle" /></a>
70+
<a href="https://buddy.works/" target="_blank"><img src="https://nestjs.com/img/buddy-logo.svg" height="35" valign="middle" /></a> &nbsp;
71+
<a href="https://blokt.com" target="_blank"><img src="https://nestjs.com/img/blokt-logo.png" height="31" valign="middle" /></a> &nbsp;
72+
<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;
73+
<a href="http://xtremis.com/" target="_blank"><img src="https://nestjs.com/img/logo-xtremis.svg" width="145" valign="middle" /></a>
74+
7575

7676

7777
## Backers
7878

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

8181
## Stay in touch
8282

packages/core/helpers/external-context-creator.ts

Lines changed: 47 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ export interface ExternalHandlerMetadata {
4040
) => (ParamProperties & { metatype?: any })[];
4141
}
4242

43+
export interface ExternalContextOptions {
44+
guards?: boolean;
45+
interceptors?: boolean;
46+
filters?: boolean;
47+
}
48+
4349
export class ExternalContextCreator {
4450
private readonly contextUtils = new ContextUtils();
4551
private readonly externalErrorProxy = new ExternalErrorProxy();
@@ -98,6 +104,11 @@ export class ExternalContextCreator {
98104
paramsFactory?: ParamsFactory,
99105
contextId = STATIC_CONTEXT,
100106
inquirerId?: string,
107+
options: ExternalContextOptions = {
108+
interceptors: true,
109+
guards: true,
110+
filters: true,
111+
},
101112
) {
102113
const module = this.findContextModuleName(instance.constructor);
103114
const { argsLength, paramtypes, getParamsMetadata } = this.getMetadata<T>(
@@ -106,42 +117,45 @@ export class ExternalContextCreator {
106117
metadataKey,
107118
paramsFactory,
108119
);
109-
110120
const pipes = this.pipesContextCreator.create(
111121
instance,
112122
callback,
113123
module,
114124
contextId,
115125
inquirerId,
116126
);
117-
118127
const guards = this.guardsContextCreator.create(
119128
instance,
120129
callback,
121130
module,
122131
contextId,
123132
inquirerId,
124133
);
125-
const interceptors = this.interceptorsContextCreator.create(
126-
instance,
127-
callback,
128-
module,
129-
contextId,
130-
inquirerId,
131-
);
132134
const exceptionFilter = this.filtersContextCreator.create(
133135
instance,
134136
callback,
135137
module,
136138
contextId,
137139
inquirerId,
138140
);
141+
const interceptors = options.interceptors
142+
? this.interceptorsContextCreator.create(
143+
instance,
144+
callback,
145+
module,
146+
contextId,
147+
inquirerId,
148+
)
149+
: [];
139150

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

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

154168
const target = async (...args: any[]) => {
155169
const initialArgs = this.contextUtils.createNullArray(argsLength);
156-
const canActivate = await this.guardsConsumer.tryActivate(
157-
guards,
158-
args,
159-
instance,
160-
callback,
161-
);
162-
if (!canActivate) {
163-
throw new ForbiddenException(FORBIDDEN_MESSAGE);
164-
}
170+
fnCanActivate && (await fnCanActivate(args));
171+
165172
const result = await this.interceptorsConsumer.intercept(
166173
interceptors,
167174
args,
@@ -171,7 +178,9 @@ export class ExternalContextCreator {
171178
);
172179
return this.transformToResult(result);
173180
};
174-
return this.externalErrorProxy.createProxy(target, exceptionFilter);
181+
return options.filters
182+
? this.externalErrorProxy.createProxy(target, exceptionFilter)
183+
: target;
175184
}
176185

177186
public getMetadata<T>(
@@ -328,4 +337,23 @@ export class ExternalContextCreator {
328337
}
329338
return resultOrDeffered;
330339
}
340+
341+
public createGuardsFn(
342+
guards: any[],
343+
instance: Controller,
344+
callback: (...args: any[]) => any,
345+
): Function | null {
346+
const canActivateFn = async (args: any[]) => {
347+
const canActivate = await this.guardsConsumer.tryActivate(
348+
guards,
349+
args,
350+
instance,
351+
callback,
352+
);
353+
if (!canActivate) {
354+
throw new ForbiddenException(FORBIDDEN_MESSAGE);
355+
}
356+
};
357+
return guards.length ? canActivateFn : null;
358+
}
331359
}

0 commit comments

Comments
 (0)