@wabot-dev/framework 0.5.5 → 0.5.6
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/dist/src/addon/auth/api-key/@apiKeyGuard.js +1 -1
- package/dist/src/addon/auth/jwt/@jwtGuard.js +1 -1
- package/dist/src/feature/rest-controller/RestRequest.js +0 -10
- package/dist/src/feature/rest-controller/runRestControllers.js +16 -10
- package/dist/src/index.d.ts +0 -1
- package/package.json +1 -1
|
@@ -7,7 +7,7 @@ import '../../../core/validation/metadata/ValidationMetadataStore.js';
|
|
|
7
7
|
import '../../../feature/express/ExpressProvider.js';
|
|
8
8
|
import 'express';
|
|
9
9
|
import 'path';
|
|
10
|
-
import '
|
|
10
|
+
import 'http';
|
|
11
11
|
import { ApiKeyGuardMiddleware } from './ApiKeyGuardMiddleware.js';
|
|
12
12
|
|
|
13
13
|
function apiKeyGuard() {
|
|
@@ -7,7 +7,7 @@ import '../../../core/validation/metadata/ValidationMetadataStore.js';
|
|
|
7
7
|
import '../../../feature/express/ExpressProvider.js';
|
|
8
8
|
import 'express';
|
|
9
9
|
import 'path';
|
|
10
|
-
import '
|
|
10
|
+
import 'http';
|
|
11
11
|
import { JwtGuardMiddleware } from './JwtGuardMiddleware.js';
|
|
12
12
|
|
|
13
13
|
function jwtGuard() {
|
|
@@ -1,14 +1,4 @@
|
|
|
1
|
-
import { __decorate, __metadata } from 'tslib';
|
|
2
|
-
import '../../core/injection/index.js';
|
|
3
|
-
import '../../core/validation/metadata/ValidationMetadataStore.js';
|
|
4
|
-
import { isRecord } from '../../core/validation/validators/is-record/@isRecord.js';
|
|
5
|
-
|
|
6
1
|
class RestRequest {
|
|
7
|
-
headers;
|
|
8
2
|
}
|
|
9
|
-
__decorate([
|
|
10
|
-
isRecord('string', 'string'),
|
|
11
|
-
__metadata("design:type", Object)
|
|
12
|
-
], RestRequest.prototype, "headers", void 0);
|
|
13
3
|
|
|
14
4
|
export { RestRequest };
|
|
@@ -10,6 +10,7 @@ import path__default from 'path';
|
|
|
10
10
|
import { EXPRESS_REQ, EXPRESS_RES } from './injection-tokens.js';
|
|
11
11
|
import { RestControllerMetadataStore } from './metadata/RestControllerMetadataStore.js';
|
|
12
12
|
import { RestRequest } from './RestRequest.js';
|
|
13
|
+
import { IncomingMessage } from 'http';
|
|
13
14
|
|
|
14
15
|
function buildRequest(req) {
|
|
15
16
|
return Object.assign({}, req.body, req.query, req.params);
|
|
@@ -51,18 +52,23 @@ function runRestControllers(controllers) {
|
|
|
51
52
|
}
|
|
52
53
|
if (endPoint.paramsTypes.length === 1) {
|
|
53
54
|
const paramType = endPoint.paramsTypes[0];
|
|
54
|
-
if (
|
|
55
|
-
|
|
55
|
+
if (paramType === IncomingMessage) {
|
|
56
|
+
endPointArgs.push(req);
|
|
56
57
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
58
|
+
else {
|
|
59
|
+
if (typeof paramType !== 'function') {
|
|
60
|
+
throw new Error(`invalid rest controller endpoint parameter type`);
|
|
61
|
+
}
|
|
62
|
+
const paramInfo = validationMetadataStore.getModelValidatorsInfo(paramType);
|
|
63
|
+
const validableReq = paramInfo.modelHierarchy.includes(RestRequest)
|
|
64
|
+
? req
|
|
65
|
+
: buildRequest(req);
|
|
66
|
+
const { value, error } = validateModel(validableReq, paramInfo);
|
|
67
|
+
if (error) {
|
|
68
|
+
throw new CustomError({ httpCode: 400, message: error.description, info: error });
|
|
69
|
+
}
|
|
70
|
+
endPointArgs.push(value);
|
|
64
71
|
}
|
|
65
|
-
endPointArgs.push(value);
|
|
66
72
|
}
|
|
67
73
|
const response = await controllerInstance[endPoint.functionName].apply(controllerInstance, endPointArgs);
|
|
68
74
|
res.status(200).json(response ?? null);
|
package/dist/src/index.d.ts
CHANGED