@eleven-am/pondsocket-nest 0.0.51 → 0.0.53
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/helpers/createParamDecorator.js +3 -1
- package/index.d.ts +1 -1
- package/package.json +2 -2
- package/performers/action.js +16 -11
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createParamDecorator = void 0;
|
|
4
|
+
require("reflect-metadata");
|
|
4
5
|
const parametres_1 = require("../managers/parametres");
|
|
5
6
|
function createParamDecorator(callback) {
|
|
6
7
|
return (data) => (target, propertyKey, index) => {
|
|
7
8
|
const { set } = (0, parametres_1.manageParameters)(target, propertyKey);
|
|
8
|
-
|
|
9
|
+
const type = Reflect.getMetadata('design:paramtypes', target, propertyKey)[index];
|
|
10
|
+
set(index, (context) => callback(data, context, type));
|
|
9
11
|
};
|
|
10
12
|
}
|
|
11
13
|
exports.createParamDecorator = createParamDecorator;
|
package/index.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ import type { DynamicModule, ModuleMetadata } from '@nestjs/common';
|
|
|
18
18
|
|
|
19
19
|
type Constructor<T> = new (...args: any[]) => T;
|
|
20
20
|
|
|
21
|
-
type ParamDecoratorCallback<Input> = (data: Input, context: Context) => unknown | Promise<unknown>;
|
|
21
|
+
type ParamDecoratorCallback<Input, ParamType = unknown> = (data: Input, context: Context, type: ParamType) => unknown | Promise<unknown>;
|
|
22
22
|
|
|
23
23
|
interface CanActivate {
|
|
24
24
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eleven-am/pondsocket-nest",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.53",
|
|
4
4
|
"description": "PondSocket is a fast simple socket server",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"socket",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"pipeline": "npm run lint && npm run build && npm run push"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@eleven-am/pondsocket": "^0.1.
|
|
31
|
+
"@eleven-am/pondsocket": "^0.1.154",
|
|
32
32
|
"@golevelup/nestjs-discovery": "^4.0.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
package/performers/action.js
CHANGED
|
@@ -16,16 +16,21 @@ const response_1 = require("./response");
|
|
|
16
16
|
const context_1 = require("../context/context");
|
|
17
17
|
const parametres_1 = require("../managers/parametres");
|
|
18
18
|
function retrieveParameters(context) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
19
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
var _a;
|
|
21
|
+
const gottenValues = (_a = (0, parametres_1.manageParameters)(context.getInstance(), context.getMethod()).get()) !== null && _a !== void 0 ? _a : [];
|
|
22
|
+
const promises = gottenValues
|
|
23
|
+
.map((_b) => __awaiter(this, [_b], void 0, function* ({ callback, index }) {
|
|
24
|
+
return ({
|
|
25
|
+
value: yield callback(context),
|
|
26
|
+
index,
|
|
27
|
+
});
|
|
28
|
+
}));
|
|
29
|
+
const values = yield Promise.all(promises);
|
|
30
|
+
return values
|
|
31
|
+
.sort((a, b) => a.index - b.index)
|
|
32
|
+
.map(({ value }) => value);
|
|
33
|
+
});
|
|
29
34
|
}
|
|
30
35
|
function performAction(instance, moduleRef, originalMethod, propertyKey, leaveEvent, request, response) {
|
|
31
36
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -53,7 +58,7 @@ function performAction(instance, moduleRef, originalMethod, propertyKey, leaveEv
|
|
|
53
58
|
const socketId = context.user.id;
|
|
54
59
|
const canProceed = yield (0, guards_1.performGuards)(moduleRef, context);
|
|
55
60
|
if (canProceed) {
|
|
56
|
-
const data = yield originalMethod.apply(instance, retrieveParameters(context));
|
|
61
|
+
const data = yield originalMethod.apply(instance, yield retrieveParameters(context));
|
|
57
62
|
(0, response_1.performResponse)(socketId, channel, data, response);
|
|
58
63
|
}
|
|
59
64
|
else if (response && ((0, narrow_1.isJoinResponse)(response) || (0, narrow_1.isConnectionResponse)(response))) {
|