Skip to content

Commit 382d999

Browse files
bugfix(@nestjs/websockets) lifecycle hooks multi execution
1 parent 154b865 commit 382d999

32 files changed

Lines changed: 58 additions & 489 deletions

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
language: node_js
22
node_js:
3-
- "7"
3+
- "8"
4+
- "10"
45
addons:
56
firefox: "latest"
67
before_script:

CHANGELOG.md

Lines changed: 0 additions & 429 deletions
This file was deleted.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"publish:beta": "./node_modules/.bin/lerna publish --npm-tag=beta -m \"chore(release) publish %s\""
2222
},
2323
"engines": {
24-
"node": ">=6.11.0"
24+
"node": ">= 8.9.0"
2525
},
2626
"repository": {
2727
"type": "git",

packages/common/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ export {
2929
DynamicModule,
3030
INestApplicationContext,
3131
HttpServer,
32+
Provider,
33+
Type,
3234
HttpServerFactory,
3335
ArgumentsHost,
3436
INestExpressApplication,

packages/common/interfaces/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,6 @@ export * from './http/http-server.interface';
2727
export * from './http/http-server-factory.interface';
2828
export * from './features/arguments-host.interface';
2929
export * from './nest-express-application.interface';
30-
export * from './nest-fastify-application.interface';
30+
export * from './nest-fastify-application.interface';
31+
export * from './modules/provider.interface';
32+
export * from './type.interface';

packages/common/interfaces/modules/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ export * from './module-metadata.interface';
22
export * from './nest-module.interface';
33
export * from './on-init.interface';
44
export * from './dynamic-module.interface';
5+
export * from './provider.interface';

packages/common/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"noLib": false,
99
"emitDecoratorMetadata": true,
1010
"experimentalDecorators": true,
11-
"target": "es6",
11+
"target": "es2017",
1212
"sourceMap": false,
1313
"allowJs": false,
1414
"rootDir": "./",

packages/core/router/router-execution-context.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,21 +95,21 @@ export class RouterExecutionContext {
9595
isResponseHandled,
9696
httpStatusCode,
9797
);
98+
const handler = (args, req, res, next) => async () => {
99+
fnApplyPipes && (await fnApplyPipes(args, req, res, next));
100+
return callback.apply(instance, args);
101+
};
98102

99103
return async (req, res, next) => {
100104
const args = this.createNullArray(argsLength);
101105
fnCanActivate && (await fnCanActivate([req, res]));
102106

103-
const handler = async () => {
104-
fnApplyPipes && (await fnApplyPipes(args, req, res, next));
105-
return callback.apply(instance, args);
106-
};
107107
const result = await this.interceptorsConsumer.intercept(
108108
interceptors,
109109
[req, res],
110110
instance,
111111
callback,
112-
handler,
112+
handler(args, req, res, next),
113113
);
114114
await fnHandleResponse(result, res);
115115
};

packages/core/router/router-proxy.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,11 @@ export class RouterProxy {
88
targetCallback: RouterProxyCallback,
99
exceptionsHandler: ExceptionsHandler,
1010
) {
11-
return (req, res, next) => {
12-
const host = new ExecutionContextHost([req, res]);
11+
return async (req, res, next) => {
1312
try {
14-
Promise.resolve(targetCallback(req, res, next)).catch(e => {
15-
exceptionsHandler.next(e, host);
16-
});
13+
await targetCallback(req, res, next);
1714
} catch (e) {
15+
const host = new ExecutionContextHost([req, res]);
1816
exceptionsHandler.next(e, host);
1917
}
2018
};
@@ -24,13 +22,11 @@ export class RouterProxy {
2422
targetCallback: (err, req, res, next) => void,
2523
exceptionsHandler: ExceptionsHandler,
2624
) {
27-
return (err, req, res, next) => {
28-
const host = new ExecutionContextHost([req, res]);
25+
return async (err, req, res, next) => {
2926
try {
30-
Promise.resolve(targetCallback(err, req, res, next)).catch(e => {
31-
exceptionsHandler.next(e, host);
32-
});
27+
await targetCallback(err, req, res, next);
3328
} catch (e) {
29+
const host = new ExecutionContextHost([req, res]);
3430
exceptionsHandler.next(e, host);
3531
}
3632
};

packages/core/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"noLib": false,
99
"emitDecoratorMetadata": true,
1010
"experimentalDecorators": true,
11-
"target": "es6",
11+
"target": "es2017",
1212
"sourceMap": false,
1313
"allowJs": false,
1414
"rootDir": "./",

0 commit comments

Comments
 (0)