@tsed/platform-params 8.0.0-alpha.4 → 8.0.0-alpha.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/package.json +15 -16
- package/lib/cjs/builder/PlatformParams.js +0 -75
- package/lib/cjs/builder/PlatformParams.js.map +0 -1
- package/lib/cjs/decorators/bodyParams.js +0 -28
- package/lib/cjs/decorators/bodyParams.js.map +0 -1
- package/lib/cjs/decorators/context.js +0 -18
- package/lib/cjs/decorators/context.js.map +0 -1
- package/lib/cjs/decorators/cookies.js +0 -23
- package/lib/cjs/decorators/cookies.js.map +0 -1
- package/lib/cjs/decorators/headerParams.js +0 -18
- package/lib/cjs/decorators/headerParams.js.map +0 -1
- package/lib/cjs/decorators/locals.js +0 -18
- package/lib/cjs/decorators/locals.js.map +0 -1
- package/lib/cjs/decorators/paramFn.js +0 -17
- package/lib/cjs/decorators/paramFn.js.map +0 -1
- package/lib/cjs/decorators/pathParams.js +0 -28
- package/lib/cjs/decorators/pathParams.js.map +0 -1
- package/lib/cjs/decorators/queryParams.js +0 -28
- package/lib/cjs/decorators/queryParams.js.map +0 -1
- package/lib/cjs/decorators/session.js +0 -18
- package/lib/cjs/decorators/session.js.map +0 -1
- package/lib/cjs/decorators/useDeserialization.js +0 -18
- package/lib/cjs/decorators/useDeserialization.js.map +0 -1
- package/lib/cjs/decorators/useParam.js +0 -38
- package/lib/cjs/decorators/useParam.js.map +0 -1
- package/lib/cjs/decorators/useParamExpression.js +0 -20
- package/lib/cjs/decorators/useParamExpression.js.map +0 -1
- package/lib/cjs/decorators/useParamType.js +0 -31
- package/lib/cjs/decorators/useParamType.js.map +0 -1
- package/lib/cjs/decorators/usePipe.js +0 -22
- package/lib/cjs/decorators/usePipe.js.map +0 -1
- package/lib/cjs/decorators/useType.js +0 -34
- package/lib/cjs/decorators/useType.js.map +0 -1
- package/lib/cjs/decorators/useValidation.js +0 -22
- package/lib/cjs/decorators/useValidation.js.map +0 -1
- package/lib/cjs/domain/ParamMetadata.js +0 -6
- package/lib/cjs/domain/ParamMetadata.js.map +0 -1
- package/lib/cjs/domain/ParamOptions.js +0 -3
- package/lib/cjs/domain/ParamOptions.js.map +0 -1
- package/lib/cjs/domain/ParamTypes.js +0 -40
- package/lib/cjs/domain/ParamTypes.js.map +0 -1
- package/lib/cjs/errors/ParamValidationError.js +0 -36
- package/lib/cjs/errors/ParamValidationError.js.map +0 -1
- package/lib/cjs/errors/RequiredValidationError.js +0 -32
- package/lib/cjs/errors/RequiredValidationError.js.map +0 -1
- package/lib/cjs/errors/ValidationError.js +0 -13
- package/lib/cjs/errors/ValidationError.js.map +0 -1
- package/lib/cjs/exports.js +0 -3
- package/lib/cjs/exports.js.map +0 -1
- package/lib/cjs/index.js +0 -35
- package/lib/cjs/index.js.map +0 -1
- package/lib/cjs/package.json +0 -3
- package/lib/cjs/pipes/DeserializerPipe.js +0 -21
- package/lib/cjs/pipes/DeserializerPipe.js.map +0 -1
- package/lib/cjs/pipes/ParseExpressionPipe.js +0 -32
- package/lib/cjs/pipes/ParseExpressionPipe.js.map +0 -1
- package/lib/cjs/pipes/ValidationPipe.js +0 -80
- package/lib/cjs/pipes/ValidationPipe.js.map +0 -1
- package/lib/cjs/utils/mapParamsOptions.js +0 -32
- package/lib/cjs/utils/mapParamsOptions.js.map +0 -1
- package/lib/esm/package.json +0 -3
- package/lib/types-esm/builder/PlatformParams.d.ts +0 -25
- package/lib/types-esm/decorators/bodyParams.d.ts +0 -66
- package/lib/types-esm/decorators/context.d.ts +0 -53
- package/lib/types-esm/decorators/cookies.d.ts +0 -81
- package/lib/types-esm/decorators/headerParams.d.ts +0 -33
- package/lib/types-esm/decorators/locals.d.ts +0 -42
- package/lib/types-esm/decorators/paramFn.d.ts +0 -11
- package/lib/types-esm/decorators/pathParams.d.ts +0 -70
- package/lib/types-esm/decorators/queryParams.d.ts +0 -75
- package/lib/types-esm/decorators/session.d.ts +0 -36
- package/lib/types-esm/decorators/useDeserialization.d.ts +0 -9
- package/lib/types-esm/decorators/useParam.d.ts +0 -18
- package/lib/types-esm/decorators/useParamExpression.d.ts +0 -10
- package/lib/types-esm/decorators/useParamType.d.ts +0 -10
- package/lib/types-esm/decorators/usePipe.d.ts +0 -13
- package/lib/types-esm/decorators/useType.d.ts +0 -13
- package/lib/types-esm/decorators/useValidation.d.ts +0 -9
- package/lib/types-esm/domain/ParamMetadata.d.ts +0 -1
- package/lib/types-esm/domain/ParamOptions.d.ts +0 -10
- package/lib/types-esm/domain/ParamTypes.d.ts +0 -25
- package/lib/types-esm/errors/ParamValidationError.d.ts +0 -8
- package/lib/types-esm/errors/RequiredValidationError.d.ts +0 -6
- package/lib/types-esm/errors/ValidationError.d.ts +0 -6
- package/lib/types-esm/exports.d.ts +0 -1
- package/lib/types-esm/index.d.ts +0 -31
- package/lib/types-esm/pipes/DeserializerPipe.d.ts +0 -4
- package/lib/types-esm/pipes/ParseExpressionPipe.d.ts +0 -6
- package/lib/types-esm/pipes/ValidationPipe.d.ts +0 -12
- package/lib/types-esm/utils/mapParamsOptions.d.ts +0 -5
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PARAM_TYPES_DATA_PATH = exports.ParamTypes = void 0;
|
|
4
|
-
var ParamTypes;
|
|
5
|
-
(function (ParamTypes) {
|
|
6
|
-
ParamTypes["$CTX"] = "$CTX";
|
|
7
|
-
ParamTypes["BODY"] = "BODY";
|
|
8
|
-
ParamTypes["PATH"] = "PATH";
|
|
9
|
-
ParamTypes["QUERY"] = "QUERY";
|
|
10
|
-
ParamTypes["HEADER"] = "HEADER";
|
|
11
|
-
ParamTypes["RAW_BODY"] = "RAW_BODY";
|
|
12
|
-
ParamTypes["COOKIES"] = "COOKIES";
|
|
13
|
-
ParamTypes["LOCALS"] = "LOCALS";
|
|
14
|
-
ParamTypes["SESSION"] = "SESSION";
|
|
15
|
-
ParamTypes["FILES"] = "FILES";
|
|
16
|
-
/// NOT STD
|
|
17
|
-
ParamTypes["NEXT_FN"] = "NEXT_FN";
|
|
18
|
-
ParamTypes["ERR"] = "ERR";
|
|
19
|
-
ParamTypes["REQUEST"] = "REQUEST";
|
|
20
|
-
ParamTypes["PLATFORM_REQUEST"] = "PLATFORM_REQUEST";
|
|
21
|
-
ParamTypes["NODE_REQUEST"] = "NODE_REQUEST";
|
|
22
|
-
ParamTypes["RESPONSE"] = "RESPONSE";
|
|
23
|
-
ParamTypes["PLATFORM_RESPONSE"] = "PLATFORM_RESPONSE";
|
|
24
|
-
ParamTypes["NODE_RESPONSE"] = "NODE_RESPONSE";
|
|
25
|
-
ParamTypes["RESPONSE_DATA"] = "RESPONSE_DATA";
|
|
26
|
-
ParamTypes["ENDPOINT_INFO"] = "ENDPOINT_INFO";
|
|
27
|
-
ParamTypes["RES"] = "RES";
|
|
28
|
-
ParamTypes["REQ"] = "REQ";
|
|
29
|
-
})(ParamTypes = exports.ParamTypes || (exports.ParamTypes = {}));
|
|
30
|
-
exports.PARAM_TYPES_DATA_PATH = {
|
|
31
|
-
[ParamTypes.HEADER]: "$ctx.request.headers",
|
|
32
|
-
[ParamTypes.RAW_BODY]: "$ctx.request.rawBody",
|
|
33
|
-
[ParamTypes.BODY]: "$ctx.request.body",
|
|
34
|
-
[ParamTypes.QUERY]: "$ctx.request.query",
|
|
35
|
-
[ParamTypes.PATH]: "$ctx.request.params",
|
|
36
|
-
[ParamTypes.COOKIES]: "$ctx.request.cookies",
|
|
37
|
-
[ParamTypes.SESSION]: "$ctx.request.session",
|
|
38
|
-
[ParamTypes.LOCALS]: "$ctx.response.locals"
|
|
39
|
-
};
|
|
40
|
-
//# sourceMappingURL=ParamTypes.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ParamTypes.js","sourceRoot":"","sources":["../../../src/domain/ParamTypes.ts"],"names":[],"mappings":";;;AAAA,IAAY,UAyBX;AAzBD,WAAY,UAAU;IACpB,2BAAa,CAAA;IACb,2BAAa,CAAA;IACb,2BAAa,CAAA;IACb,6BAAe,CAAA;IACf,+BAAiB,CAAA;IACjB,mCAAqB,CAAA;IACrB,iCAAmB,CAAA;IACnB,+BAAiB,CAAA;IACjB,iCAAmB,CAAA;IACnB,6BAAe,CAAA;IAEf,WAAW;IACX,iCAAmB,CAAA;IACnB,yBAAW,CAAA;IACX,iCAAmB,CAAA;IACnB,mDAAqC,CAAA;IACrC,2CAA6B,CAAA;IAC7B,mCAAqB,CAAA;IACrB,qDAAuC,CAAA;IACvC,6CAA+B,CAAA;IAC/B,6CAA+B,CAAA;IAC/B,6CAA+B,CAAA;IAC/B,yBAAW,CAAA;IACX,yBAAW,CAAA;AACb,CAAC,EAzBW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAyBrB;AAEY,QAAA,qBAAqB,GAA2B;IAC3D,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,sBAAsB;IAC3C,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,sBAAsB;IAC7C,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,mBAAmB;IACtC,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,oBAAoB;IACxC,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,qBAAqB;IACxC,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,sBAAsB;IAC5C,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,sBAAsB;IAC5C,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,sBAAsB;CAC5C,CAAC"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ParamValidationError = void 0;
|
|
4
|
-
const core_1 = require("@tsed/core");
|
|
5
|
-
const exceptions_1 = require("@tsed/exceptions");
|
|
6
|
-
const ValidationError_js_1 = require("./ValidationError.js");
|
|
7
|
-
class ParamValidationError extends exceptions_1.BadRequest {
|
|
8
|
-
constructor() {
|
|
9
|
-
super(...arguments);
|
|
10
|
-
this.name = "PARAM_VALIDATION_ERROR";
|
|
11
|
-
}
|
|
12
|
-
static from(metadata, origin = {}) {
|
|
13
|
-
if (origin instanceof ValidationError_js_1.ValidationError || origin instanceof exceptions_1.BadRequest) {
|
|
14
|
-
const name = (0, core_1.nameOf)(metadata.paramType)
|
|
15
|
-
.toLowerCase()
|
|
16
|
-
.replace(/parse|params|filter/gi, "");
|
|
17
|
-
const expression = metadata.expression;
|
|
18
|
-
const dataPath = `${name}${expression ? "." + expression : ""}`;
|
|
19
|
-
const message = `Bad request on parameter "request.${dataPath}".\n${origin.message}`.trim();
|
|
20
|
-
const error = new ParamValidationError(message);
|
|
21
|
-
error.dataPath = String(metadata.expression) || "";
|
|
22
|
-
error.requestType = (0, core_1.nameOf)(metadata.paramType);
|
|
23
|
-
error.origin = origin.origin || origin;
|
|
24
|
-
if (error.origin?.errors) {
|
|
25
|
-
error.origin?.errors.forEach((error) => {
|
|
26
|
-
error.requestPath = name;
|
|
27
|
-
error.dataPath = error.dataPath || (expression ? `.${expression}` : "");
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
return error;
|
|
31
|
-
}
|
|
32
|
-
return origin;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
exports.ParamValidationError = ParamValidationError;
|
|
36
|
-
//# sourceMappingURL=ParamValidationError.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ParamValidationError.js","sourceRoot":"","sources":["../../../src/errors/ParamValidationError.ts"],"names":[],"mappings":";;;AAAA,qCAAkC;AAClC,iDAA4C;AAE5C,6DAAqD;AAErD,MAAa,oBAAqB,SAAQ,uBAAU;IAApD;;QACS,SAAI,GAAW,wBAAwB,CAAC;IA8BjD,CAAC;IA1BC,MAAM,CAAC,IAAI,CAAC,QAA4B,EAAE,SAAc,EAAE;QACxD,IAAI,MAAM,YAAY,oCAAe,IAAI,MAAM,YAAY,uBAAU,EAAE;YACrE,MAAM,IAAI,GAAG,IAAA,aAAM,EAAC,QAAQ,CAAC,SAAS,CAAC;iBACpC,WAAW,EAAE;iBACb,OAAO,CAAC,uBAAuB,EAAE,EAAE,CAAC,CAAC;YACxC,MAAM,UAAU,GAAG,QAAQ,CAAC,UAAU,CAAC;YACvC,MAAM,QAAQ,GAAG,GAAG,IAAI,GAAG,UAAU,CAAC,CAAC,CAAC,GAAG,GAAG,UAAU,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;YAChE,MAAM,OAAO,GAAG,qCAAqC,QAAQ,OAAO,MAAM,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,CAAC;YAE5F,MAAM,KAAK,GAAG,IAAI,oBAAoB,CAAC,OAAO,CAAC,CAAC;YAChD,KAAK,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC;YACnD,KAAK,CAAC,WAAW,GAAG,IAAA,aAAM,EAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;YAC/C,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC;YAEvC,IAAI,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE;gBACxB,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC,KAAU,EAAE,EAAE;oBAC1C,KAAK,CAAC,WAAW,GAAG,IAAI,CAAC;oBACzB,KAAK,CAAC,QAAQ,GAAG,KAAK,CAAC,QAAQ,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;gBAC1E,CAAC,CAAC,CAAC;aACJ;YAED,OAAO,KAAK,CAAC;SACd;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AA/BD,oDA+BC"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RequiredValidationError = void 0;
|
|
4
|
-
const core_1 = require("@tsed/core");
|
|
5
|
-
const ValidationError_js_1 = require("./ValidationError.js");
|
|
6
|
-
class RequiredValidationError extends ValidationError_js_1.ValidationError {
|
|
7
|
-
constructor() {
|
|
8
|
-
super(...arguments);
|
|
9
|
-
this.name = "REQUIRED_VALIDATION_ERROR";
|
|
10
|
-
}
|
|
11
|
-
static from(metadata) {
|
|
12
|
-
const name = (0, core_1.nameOf)(metadata.paramType);
|
|
13
|
-
const expression = metadata.expression;
|
|
14
|
-
const type = name.toLowerCase().replace(/parse|params|filter/gi, "");
|
|
15
|
-
const message = `It should have required parameter '${expression}'`;
|
|
16
|
-
const errors = [
|
|
17
|
-
{
|
|
18
|
-
dataPath: "",
|
|
19
|
-
keyword: "required",
|
|
20
|
-
message,
|
|
21
|
-
modelName: type,
|
|
22
|
-
params: {
|
|
23
|
-
missingProperty: expression
|
|
24
|
-
},
|
|
25
|
-
schemaPath: "#/required"
|
|
26
|
-
}
|
|
27
|
-
];
|
|
28
|
-
return new RequiredValidationError(message, errors);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
exports.RequiredValidationError = RequiredValidationError;
|
|
32
|
-
//# sourceMappingURL=RequiredValidationError.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RequiredValidationError.js","sourceRoot":"","sources":["../../../src/errors/RequiredValidationError.ts"],"names":[],"mappings":";;;AAAA,qCAAkC;AAClC,6DAAqD;AAGrD,MAAa,uBAAwB,SAAQ,oCAAe;IAA5D;;QACS,SAAI,GAAW,2BAA2B,CAAC;IAuBpD,CAAC;IArBC,MAAM,CAAC,IAAI,CAAC,QAA4B;QACtC,MAAM,IAAI,GAAG,IAAA,aAAM,EAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;QACxC,MAAM,UAAU,GAAG,QAAQ,CAAC,UAAU,CAAC;QACvC,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,uBAAuB,EAAE,EAAE,CAAC,CAAC;QACrE,MAAM,OAAO,GAAG,sCAAsC,UAAU,GAAG,CAAC;QAEpE,MAAM,MAAM,GAAG;YACb;gBACE,QAAQ,EAAE,EAAE;gBACZ,OAAO,EAAE,UAAU;gBACnB,OAAO;gBACP,SAAS,EAAE,IAAI;gBACf,MAAM,EAAE;oBACN,eAAe,EAAE,UAAU;iBAC5B;gBACD,UAAU,EAAE,YAAY;aACzB;SACF,CAAC;QAEF,OAAO,IAAI,uBAAuB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACtD,CAAC;CACF;AAxBD,0DAwBC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ValidationError = void 0;
|
|
4
|
-
const exceptions_1 = require("@tsed/exceptions");
|
|
5
|
-
class ValidationError extends exceptions_1.BadRequest {
|
|
6
|
-
constructor(message, errors = []) {
|
|
7
|
-
super(message);
|
|
8
|
-
this.name = "VALIDATION_ERROR";
|
|
9
|
-
this.errors = errors;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
exports.ValidationError = ValidationError;
|
|
13
|
-
//# sourceMappingURL=ValidationError.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ValidationError.js","sourceRoot":"","sources":["../../../src/errors/ValidationError.ts"],"names":[],"mappings":";;;AAAA,iDAA4C;AAE5C,MAAa,eAAgB,SAAQ,uBAAU;IAI7C,YAAY,OAAe,EAAE,SAAgB,EAAE;QAC7C,KAAK,CAAC,OAAO,CAAC,CAAC;QAJV,SAAI,GAAW,kBAAkB,CAAC;QAKvC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF;AARD,0CAQC"}
|
package/lib/cjs/exports.js
DELETED
package/lib/cjs/exports.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"exports.js","sourceRoot":"","sources":["../../src/exports.ts"],"names":[],"mappings":""}
|
package/lib/cjs/index.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
/**
|
|
5
|
-
* @file Automatically generated by @tsed/barrels.
|
|
6
|
-
*/
|
|
7
|
-
tslib_1.__exportStar(require("./builder/PlatformParams.js"), exports);
|
|
8
|
-
tslib_1.__exportStar(require("./decorators/bodyParams.js"), exports);
|
|
9
|
-
tslib_1.__exportStar(require("./decorators/context.js"), exports);
|
|
10
|
-
tslib_1.__exportStar(require("./decorators/cookies.js"), exports);
|
|
11
|
-
tslib_1.__exportStar(require("./decorators/headerParams.js"), exports);
|
|
12
|
-
tslib_1.__exportStar(require("./decorators/locals.js"), exports);
|
|
13
|
-
tslib_1.__exportStar(require("./decorators/paramFn.js"), exports);
|
|
14
|
-
tslib_1.__exportStar(require("./decorators/pathParams.js"), exports);
|
|
15
|
-
tslib_1.__exportStar(require("./decorators/queryParams.js"), exports);
|
|
16
|
-
tslib_1.__exportStar(require("./decorators/session.js"), exports);
|
|
17
|
-
tslib_1.__exportStar(require("./decorators/useDeserialization.js"), exports);
|
|
18
|
-
tslib_1.__exportStar(require("./decorators/useParam.js"), exports);
|
|
19
|
-
tslib_1.__exportStar(require("./decorators/useParamExpression.js"), exports);
|
|
20
|
-
tslib_1.__exportStar(require("./decorators/useParamType.js"), exports);
|
|
21
|
-
tslib_1.__exportStar(require("./decorators/usePipe.js"), exports);
|
|
22
|
-
tslib_1.__exportStar(require("./decorators/useType.js"), exports);
|
|
23
|
-
tslib_1.__exportStar(require("./decorators/useValidation.js"), exports);
|
|
24
|
-
tslib_1.__exportStar(require("./domain/ParamMetadata.js"), exports);
|
|
25
|
-
tslib_1.__exportStar(require("./domain/ParamOptions.js"), exports);
|
|
26
|
-
tslib_1.__exportStar(require("./domain/ParamTypes.js"), exports);
|
|
27
|
-
tslib_1.__exportStar(require("./errors/ParamValidationError.js"), exports);
|
|
28
|
-
tslib_1.__exportStar(require("./errors/RequiredValidationError.js"), exports);
|
|
29
|
-
tslib_1.__exportStar(require("./errors/ValidationError.js"), exports);
|
|
30
|
-
tslib_1.__exportStar(require("./exports.js"), exports);
|
|
31
|
-
tslib_1.__exportStar(require("./pipes/DeserializerPipe.js"), exports);
|
|
32
|
-
tslib_1.__exportStar(require("./pipes/ParseExpressionPipe.js"), exports);
|
|
33
|
-
tslib_1.__exportStar(require("./pipes/ValidationPipe.js"), exports);
|
|
34
|
-
tslib_1.__exportStar(require("./utils/mapParamsOptions.js"), exports);
|
|
35
|
-
//# sourceMappingURL=index.js.map
|
package/lib/cjs/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,sEAA4C;AAC5C,qEAA2C;AAC3C,kEAAwC;AACxC,kEAAwC;AACxC,uEAA6C;AAC7C,iEAAuC;AACvC,kEAAwC;AACxC,qEAA2C;AAC3C,sEAA4C;AAC5C,kEAAwC;AACxC,6EAAmD;AACnD,mEAAyC;AACzC,6EAAmD;AACnD,uEAA6C;AAC7C,kEAAwC;AACxC,kEAAwC;AACxC,wEAA8C;AAC9C,oEAA0C;AAC1C,mEAAyC;AACzC,iEAAuC;AACvC,2EAAiD;AACjD,8EAAoD;AACpD,sEAA4C;AAC5C,uDAA6B;AAC7B,sEAA4C;AAC5C,yEAA+C;AAC/C,oEAA0C;AAC1C,sEAA4C"}
|
package/lib/cjs/package.json
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var DeserializerPipe_1;
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.DeserializerPipe = void 0;
|
|
5
|
-
const tslib_1 = require("tslib");
|
|
6
|
-
const di_1 = require("@tsed/di");
|
|
7
|
-
const json_mapper_1 = require("@tsed/json-mapper");
|
|
8
|
-
let DeserializerPipe = DeserializerPipe_1 = class DeserializerPipe {
|
|
9
|
-
transform(value, param) {
|
|
10
|
-
return (0, json_mapper_1.deserialize)(value, {
|
|
11
|
-
useAlias: true,
|
|
12
|
-
store: param,
|
|
13
|
-
...(param.store.get(DeserializerPipe_1) || {})
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
DeserializerPipe = DeserializerPipe_1 = tslib_1.__decorate([
|
|
18
|
-
(0, di_1.Injectable)()
|
|
19
|
-
], DeserializerPipe);
|
|
20
|
-
exports.DeserializerPipe = DeserializerPipe;
|
|
21
|
-
//# sourceMappingURL=DeserializerPipe.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DeserializerPipe.js","sourceRoot":"","sources":["../../../src/pipes/DeserializerPipe.ts"],"names":[],"mappings":";;;;;AAAA,iCAAoC;AACpC,mDAA8C;AAIvC,IAAM,gBAAgB,wBAAtB,MAAM,gBAAgB;IAC3B,SAAS,CAAC,KAAU,EAAE,KAAyB;QAC7C,OAAO,IAAA,yBAAW,EAAC,KAAK,EAAE;YACxB,QAAQ,EAAE,IAAI;YACd,KAAK,EAAE,KAAK;YACZ,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,kBAAgB,CAAC,IAAI,EAAE,CAAC;SAC7C,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AARY,gBAAgB;IAD5B,IAAA,eAAU,GAAE;GACA,gBAAgB,CAQ5B;AARY,4CAAgB"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ParseExpressionPipe = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const core_1 = require("@tsed/core");
|
|
6
|
-
const di_1 = require("@tsed/di");
|
|
7
|
-
const ParamTypes_js_1 = require("../domain/ParamTypes.js");
|
|
8
|
-
let ParseExpressionPipe = class ParseExpressionPipe {
|
|
9
|
-
transform(scope, param) {
|
|
10
|
-
const { paramType, type } = param;
|
|
11
|
-
const value = (0, core_1.getValue)(scope, this.getKey(param));
|
|
12
|
-
if ([ParamTypes_js_1.ParamTypes.QUERY, ParamTypes_js_1.ParamTypes.PATH].includes(paramType) && value === "" && type !== String) {
|
|
13
|
-
return undefined;
|
|
14
|
-
}
|
|
15
|
-
return value;
|
|
16
|
-
}
|
|
17
|
-
getKey(param) {
|
|
18
|
-
let { expression, paramType, dataPath } = param;
|
|
19
|
-
paramType = paramType || param.parameter.get("in").toUpperCase();
|
|
20
|
-
if (expression && paramType === ParamTypes_js_1.ParamTypes.HEADER) {
|
|
21
|
-
expression = String(expression).toLowerCase();
|
|
22
|
-
}
|
|
23
|
-
return [dataPath, expression].filter(Boolean).join(".");
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
ParseExpressionPipe = tslib_1.__decorate([
|
|
27
|
-
(0, di_1.Injectable)({
|
|
28
|
-
priority: -1000
|
|
29
|
-
})
|
|
30
|
-
], ParseExpressionPipe);
|
|
31
|
-
exports.ParseExpressionPipe = ParseExpressionPipe;
|
|
32
|
-
//# sourceMappingURL=ParseExpressionPipe.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ParseExpressionPipe.js","sourceRoot":"","sources":["../../../src/pipes/ParseExpressionPipe.ts"],"names":[],"mappings":";;;;AAAA,qCAAoC;AACpC,iCAAoC;AAGpC,2DAAmD;AAK5C,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAC9B,SAAS,CAAC,KAA0B,EAAE,KAAyB;QAC7D,MAAM,EAAC,SAAS,EAAE,IAAI,EAAC,GAAG,KAAK,CAAC;QAEhC,MAAM,KAAK,GAAG,IAAA,eAAQ,EAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QAElD,IAAI,CAAC,0BAAU,CAAC,KAAK,EAAE,0BAAU,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,SAAuB,CAAC,IAAI,KAAK,KAAK,EAAE,IAAI,IAAI,KAAK,MAAM,EAAE;YAC5G,OAAO,SAAS,CAAC;SAClB;QAED,OAAO,KAAK,CAAC;IACf,CAAC;IAES,MAAM,CAAC,KAAyB;QACxC,IAAI,EAAC,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAC,GAAG,KAAK,CAAC;QAC9C,SAAS,GAAG,SAAS,IAAI,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;QAEjE,IAAI,UAAU,IAAI,SAAS,KAAK,0BAAU,CAAC,MAAM,EAAE;YACjD,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC,WAAW,EAAE,CAAC;SAC/C;QAED,OAAO,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC1D,CAAC;CACF,CAAA;AAvBY,mBAAmB;IAH/B,IAAA,eAAU,EAAC;QACV,QAAQ,EAAE,CAAC,IAAI;KAChB,CAAC;GACW,mBAAmB,CAuB/B;AAvBY,kDAAmB"}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ValidationPipe = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const di_1 = require("@tsed/di");
|
|
6
|
-
const json_mapper_1 = require("@tsed/json-mapper");
|
|
7
|
-
const schema_1 = require("@tsed/schema");
|
|
8
|
-
const ParamTypes_js_1 = require("../domain/ParamTypes.js");
|
|
9
|
-
const RequiredValidationError_js_1 = require("../errors/RequiredValidationError.js");
|
|
10
|
-
function cast(value, metadata) {
|
|
11
|
-
try {
|
|
12
|
-
return (0, json_mapper_1.deserialize)(value, {
|
|
13
|
-
type: metadata.type
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
catch (er) {
|
|
17
|
-
return value;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
let ValidationPipe = class ValidationPipe {
|
|
21
|
-
constructor(validators) {
|
|
22
|
-
this.validator = validators[0];
|
|
23
|
-
}
|
|
24
|
-
coerceTypes(value, metadata) {
|
|
25
|
-
if (value === undefined) {
|
|
26
|
-
return value;
|
|
27
|
-
}
|
|
28
|
-
if (value === "null") {
|
|
29
|
-
return null;
|
|
30
|
-
}
|
|
31
|
-
if (metadata.isArray) {
|
|
32
|
-
return [].concat(value);
|
|
33
|
-
}
|
|
34
|
-
if (metadata.isPrimitive) {
|
|
35
|
-
return cast(value, metadata);
|
|
36
|
-
}
|
|
37
|
-
return value;
|
|
38
|
-
}
|
|
39
|
-
skip(value, metadata) {
|
|
40
|
-
return metadata.paramType === ParamTypes_js_1.ParamTypes.PATH && !metadata.isPrimitive;
|
|
41
|
-
}
|
|
42
|
-
transform(value, metadata) {
|
|
43
|
-
if (!this.validator) {
|
|
44
|
-
this.checkIsRequired(value, metadata);
|
|
45
|
-
return value;
|
|
46
|
-
}
|
|
47
|
-
// FIXME See if it's necessary ?
|
|
48
|
-
if (this.skip(value, metadata)) {
|
|
49
|
-
return value;
|
|
50
|
-
}
|
|
51
|
-
value = this.coerceTypes(value, metadata);
|
|
52
|
-
this.checkIsRequired(value, metadata);
|
|
53
|
-
if (value === undefined) {
|
|
54
|
-
return value;
|
|
55
|
-
}
|
|
56
|
-
const schema = (0, schema_1.getJsonSchema)(metadata, {
|
|
57
|
-
customKeys: true
|
|
58
|
-
});
|
|
59
|
-
return this.validator.validate(value, {
|
|
60
|
-
schema,
|
|
61
|
-
type: metadata.isClass ? metadata.type : undefined,
|
|
62
|
-
collectionType: metadata.collectionType
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
checkIsRequired(value, metadata) {
|
|
66
|
-
if (metadata.isRequired(value)) {
|
|
67
|
-
throw RequiredValidationError_js_1.RequiredValidationError.from(metadata);
|
|
68
|
-
}
|
|
69
|
-
return true;
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
ValidationPipe = tslib_1.__decorate([
|
|
73
|
-
(0, di_1.Injectable)({
|
|
74
|
-
type: "validator"
|
|
75
|
-
}),
|
|
76
|
-
tslib_1.__param(0, (0, di_1.Inject)("validator:service")),
|
|
77
|
-
tslib_1.__metadata("design:paramtypes", [Array])
|
|
78
|
-
], ValidationPipe);
|
|
79
|
-
exports.ValidationPipe = ValidationPipe;
|
|
80
|
-
//# sourceMappingURL=ValidationPipe.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ValidationPipe.js","sourceRoot":"","sources":["../../../src/pipes/ValidationPipe.ts"],"names":[],"mappings":";;;;AAAA,iCAA4C;AAC5C,mDAA8C;AAC9C,yCAA4E;AAC5E,2DAAmD;AACnD,qFAA6E;AAE7E,SAAS,IAAI,CAAC,KAAU,EAAE,QAA4B;IACpD,IAAI;QACF,OAAO,IAAA,yBAAW,EAAC,KAAK,EAAE;YACxB,IAAI,EAAE,QAAQ,CAAC,IAAI;SACpB,CAAC,CAAC;KACJ;IAAC,OAAO,EAAE,EAAE;QACX,OAAO,KAAK,CAAC;KACd;AACH,CAAC;AAOM,IAAM,cAAc,GAApB,MAAM,cAAc;IAGzB,YAAyC,UAAqC;QAC5E,IAAI,CAAC,SAAS,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;IACjC,CAAC;IAED,WAAW,CAAC,KAAU,EAAE,QAA4B;QAClD,IAAI,KAAK,KAAK,SAAS,EAAE;YACvB,OAAO,KAAK,CAAC;SACd;QAED,IAAI,KAAK,KAAK,MAAM,EAAE;YACpB,OAAO,IAAI,CAAC;SACb;QAED,IAAI,QAAQ,CAAC,OAAO,EAAE;YACpB,OAAO,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;SACzB;QAED,IAAI,QAAQ,CAAC,WAAW,EAAE;YACxB,OAAO,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;SAC9B;QAED,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,CAAC,KAAU,EAAE,QAA4B;QAC3C,OAAO,QAAQ,CAAC,SAAS,KAAK,0BAAU,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC;IACzE,CAAC;IAED,SAAS,CAAC,KAAU,EAAE,QAA4B;QAChD,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;YACnB,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;YACtC,OAAO,KAAK,CAAC;SACd;QAED,gCAAgC;QAChC,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,EAAE;YAC9B,OAAO,KAAK,CAAC;SACd;QAED,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;QAE1C,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;QAEtC,IAAI,KAAK,KAAK,SAAS,EAAE;YACvB,OAAO,KAAK,CAAC;SACd;QAED,MAAM,MAAM,GAAG,IAAA,sBAAa,EAAC,QAAQ,EAAE;YACrC,UAAU,EAAE,IAAI;SACjB,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE;YACpC,MAAM;YACN,IAAI,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;YAClD,cAAc,EAAE,QAAQ,CAAC,cAAc;SACxC,CAAC,CAAC;IACL,CAAC;IAES,eAAe,CAAC,KAAU,EAAE,QAA4B;QAChE,IAAI,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE;YAC9B,MAAM,oDAAuB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;SAC9C;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAA;AApEY,cAAc;IAH1B,IAAA,eAAU,EAAC;QACV,IAAI,EAAE,WAAW;KAClB,CAAC;IAIa,mBAAA,IAAA,WAAM,EAAC,mBAAmB,CAAC,CAAA;;GAH7B,cAAc,CAoE1B;AApEY,wCAAc"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.mapParamsOptions = void 0;
|
|
4
|
-
const core_1 = require("@tsed/core");
|
|
5
|
-
/**
|
|
6
|
-
* @ignore
|
|
7
|
-
*/
|
|
8
|
-
function mapParamsOptions(args) {
|
|
9
|
-
if (args.length === 1) {
|
|
10
|
-
if (typeof args[0] === "string") {
|
|
11
|
-
return {
|
|
12
|
-
expression: args[0]
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
if (!(0, core_1.isObject)(args[0])) {
|
|
16
|
-
return {
|
|
17
|
-
useType: args[0]
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
const opts = args[0];
|
|
21
|
-
return {
|
|
22
|
-
...opts,
|
|
23
|
-
useMapper: opts.useMapper
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
return {
|
|
27
|
-
expression: args[0],
|
|
28
|
-
useType: args[1]
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
exports.mapParamsOptions = mapParamsOptions;
|
|
32
|
-
//# sourceMappingURL=mapParamsOptions.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mapParamsOptions.js","sourceRoot":"","sources":["../../../src/utils/mapParamsOptions.ts"],"names":[],"mappings":";;;AAAA,qCAAoC;AAGpC;;GAEG;AACH,SAAgB,gBAAgB,CAAC,IAAW;IAC1C,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;QACrB,IAAI,OAAO,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ,EAAE;YAC/B,OAAO;gBACL,UAAU,EAAE,IAAI,CAAC,CAAC,CAAC;aACpB,CAAC;SACH;QAED,IAAI,CAAC,IAAA,eAAQ,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE;YACtB,OAAO;gBACL,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC;aACjB,CAAC;SACH;QAED,MAAM,IAAI,GAAG,IAAI,CAAC,CAAC,CAAiB,CAAC;QAErC,OAAO;YACL,GAAG,IAAI;YACP,SAAS,EAAE,IAAI,CAAC,SAAS;SAC1B,CAAC;KACH;IAED,OAAO;QACL,UAAU,EAAE,IAAI,CAAC,CAAC,CAAC;QACnB,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC;KACjB,CAAC;AACJ,CAAC;AA1BD,4CA0BC"}
|
package/lib/esm/package.json
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { DIContext, InjectorService } from "@tsed/di";
|
|
2
|
-
import { JsonMethodStore, JsonParameterStore, PipeMethods } from "@tsed/schema";
|
|
3
|
-
export type PlatformParamsScope<Context extends DIContext = DIContext> = {
|
|
4
|
-
$ctx: Context;
|
|
5
|
-
} & Record<string, any>;
|
|
6
|
-
export type PlatformParamsCallback<Context extends DIContext = DIContext> = (scope: PlatformParamsScope<Context>) => Promise<any>;
|
|
7
|
-
/**
|
|
8
|
-
* Platform Params abstraction layer.
|
|
9
|
-
* @platform
|
|
10
|
-
*/
|
|
11
|
-
export declare class PlatformParams {
|
|
12
|
-
protected injector: InjectorService;
|
|
13
|
-
getPipes(param: JsonParameterStore): PipeMethods<any, any>[];
|
|
14
|
-
/**
|
|
15
|
-
* Return a handler with injectable parameters
|
|
16
|
-
* @param handlerMetadata
|
|
17
|
-
*/
|
|
18
|
-
compileHandler<Context extends DIContext = DIContext>({ propertyKey, token, handler }: {
|
|
19
|
-
propertyKey?: string | symbol;
|
|
20
|
-
token?: any;
|
|
21
|
-
handler?: any;
|
|
22
|
-
}): PlatformParamsCallback<Context>;
|
|
23
|
-
compile<Context extends DIContext = DIContext>(entity: JsonMethodStore): PlatformParamsCallback<Context>;
|
|
24
|
-
getArg<Context extends DIContext = DIContext>(scope: PlatformParamsScope, pipes: PipeMethods[], param: JsonParameterStore): Promise<any>;
|
|
25
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { Type } from "@tsed/core";
|
|
2
|
-
import { ParamOptions } from "../domain/ParamOptions.js";
|
|
3
|
-
/**
|
|
4
|
-
* BodyParams return the value from [request.body](http://expressjs.com/en/4x/api.html#req.body) object.
|
|
5
|
-
*
|
|
6
|
-
* #### Example
|
|
7
|
-
*
|
|
8
|
-
* ```typescript
|
|
9
|
-
* @Controller('/')
|
|
10
|
-
* class MyCtrl {
|
|
11
|
-
* @Post('/')
|
|
12
|
-
* create(@BodyParams() body: any) {
|
|
13
|
-
* console.log('Entire body', body);
|
|
14
|
-
* }
|
|
15
|
-
*
|
|
16
|
-
* @Post('/')
|
|
17
|
-
* create(@BodyParams('id') id: string) {
|
|
18
|
-
* console.log('ID', id);
|
|
19
|
-
* }
|
|
20
|
-
*
|
|
21
|
-
* @Post('/')
|
|
22
|
-
* create(@BodyParams('user') user: User) { // with deserialization
|
|
23
|
-
* console.log('user', user);
|
|
24
|
-
* }
|
|
25
|
-
*
|
|
26
|
-
* @Post('/')
|
|
27
|
-
* create(@BodyParams('users', User) users: User[]) { // with deserialization
|
|
28
|
-
* console.log('users', users);
|
|
29
|
-
* }
|
|
30
|
-
* }
|
|
31
|
-
* ```
|
|
32
|
-
* > For more information on deserialization see [converters](/docs/json-mapper.md) page.
|
|
33
|
-
*
|
|
34
|
-
* @param expression The path of the property to get.
|
|
35
|
-
* @param useType The type of the class that to be used to deserialize the data.
|
|
36
|
-
* @decorator
|
|
37
|
-
* @operation
|
|
38
|
-
* @input
|
|
39
|
-
*/
|
|
40
|
-
export declare function BodyParams(expression: string, useType: Type<any>): ParameterDecorator;
|
|
41
|
-
export declare function BodyParams(expression: string): ParameterDecorator;
|
|
42
|
-
export declare function BodyParams(useType: Type<any>): ParameterDecorator;
|
|
43
|
-
export declare function BodyParams(options: Partial<ParamOptions>): ParameterDecorator;
|
|
44
|
-
export declare function BodyParams(): ParameterDecorator;
|
|
45
|
-
/**
|
|
46
|
-
* RawBodyParams return the value from [request.body](http://expressjs.com/en/4x/api.html#req.body) as a Buffer.
|
|
47
|
-
*
|
|
48
|
-
* #### Example
|
|
49
|
-
*
|
|
50
|
-
* ```typescript
|
|
51
|
-
* @Controller('/')
|
|
52
|
-
* class MyCtrl {
|
|
53
|
-
* @Post('/')
|
|
54
|
-
* create(@RawBodyParams() body: Buffer) {
|
|
55
|
-
* console.log('Entire body', body.toString("utf8"));
|
|
56
|
-
* }
|
|
57
|
-
* }
|
|
58
|
-
* ```
|
|
59
|
-
*
|
|
60
|
-
* @decorator
|
|
61
|
-
* @operation
|
|
62
|
-
* @input
|
|
63
|
-
* @alias BodyParams Example: @BodyParams() payload: Buffer
|
|
64
|
-
*/
|
|
65
|
-
export declare function RawBodyParams(options: Partial<Omit<ParamOptions, "expression">>): ParameterDecorator;
|
|
66
|
-
export declare function RawBodyParams(): ParameterDecorator;
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { BaseContext } from "@tsed/di";
|
|
2
|
-
/**
|
|
3
|
-
* Context decorator return the @@PlatformContext@@ created by Ts.ED when request is handled by the server.
|
|
4
|
-
*
|
|
5
|
-
* It contains some information as following:
|
|
6
|
-
*
|
|
7
|
-
* - The request id,
|
|
8
|
-
* - The request container used by the Ts.ED DI. It contain all services annotated with `@Scope(ProviderScope.REQUEST)`,
|
|
9
|
-
* - The current @@EndpointMetadata@@ resolved by Ts.ED during the request,
|
|
10
|
-
* - The data return by the previous endpoint if you use multiple handler on the same route. By default data is empty.
|
|
11
|
-
*
|
|
12
|
-
* ::: tip
|
|
13
|
-
* The @@PlatformContext@@ inherit from Map class. So you can store any information with.
|
|
14
|
-
* :::
|
|
15
|
-
*
|
|
16
|
-
* #### Example
|
|
17
|
-
*
|
|
18
|
-
* ```typescript
|
|
19
|
-
* @Middleware()
|
|
20
|
-
* class AuthTokenMiddleware {
|
|
21
|
-
* use(@Req() request: Req, @Context() context: PlatformContext) {
|
|
22
|
-
* if (!context.has("auth")){
|
|
23
|
-
* context.set('auth', new AuthToken(request))
|
|
24
|
-
* }
|
|
25
|
-
*
|
|
26
|
-
* try {
|
|
27
|
-
* context.get("auth").claims() // check token
|
|
28
|
-
* } catch(er){
|
|
29
|
-
* throw new Forbidden("Access forbidden - Bad token")
|
|
30
|
-
* }
|
|
31
|
-
* }
|
|
32
|
-
* }
|
|
33
|
-
*
|
|
34
|
-
* @Controller('/')
|
|
35
|
-
* @UseBefore(AuthTokenMiddleware) // protect all routes for this controller
|
|
36
|
-
* class MyCtrl {
|
|
37
|
-
* @Get('/')
|
|
38
|
-
* get(@Context('auth') auth: AuthToken) {
|
|
39
|
-
* console.log('auth', auth);
|
|
40
|
-
* console.log('auth.accessToken', auth.accessToken);
|
|
41
|
-
* console.log('auth.idToken', auth.idToken);
|
|
42
|
-
* }
|
|
43
|
-
* }
|
|
44
|
-
* ```
|
|
45
|
-
*
|
|
46
|
-
* @param expression The path of the property to get.
|
|
47
|
-
* @decorator
|
|
48
|
-
* @operation
|
|
49
|
-
* @input
|
|
50
|
-
*/
|
|
51
|
-
export declare function Context(expression: string): ParameterDecorator;
|
|
52
|
-
export declare function Context(): ParameterDecorator;
|
|
53
|
-
export type Context = BaseContext;
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { Type } from "@tsed/core";
|
|
2
|
-
import { ParamOptions } from "../domain/ParamOptions.js";
|
|
3
|
-
/**
|
|
4
|
-
* Cookies or CookiesParams return the value from [request.cookies](http://expressjs.com/en/4x/api.html#req.cookies) object.
|
|
5
|
-
*
|
|
6
|
-
* #### Example
|
|
7
|
-
*
|
|
8
|
-
* ```typescript
|
|
9
|
-
* @Controller('/')
|
|
10
|
-
* class MyCtrl {
|
|
11
|
-
* @Post('/')
|
|
12
|
-
* create(@Cookies() cookies: any) {
|
|
13
|
-
* console.log('Entire cookies', cookies);
|
|
14
|
-
* }
|
|
15
|
-
*
|
|
16
|
-
* @Post('/')
|
|
17
|
-
* create(@Cookies('id') id: string) {
|
|
18
|
-
* console.log('ID', id);
|
|
19
|
-
* }
|
|
20
|
-
*
|
|
21
|
-
* @Post('/')
|
|
22
|
-
* create(@Cookies('user') user: IUser) {
|
|
23
|
-
* console.log('user', user);
|
|
24
|
-
* }
|
|
25
|
-
* }
|
|
26
|
-
* ```
|
|
27
|
-
* > For more information on deserialization see [converters](/docs/json-mapper.md) page.
|
|
28
|
-
*
|
|
29
|
-
* @param expression The path of the property to get.
|
|
30
|
-
* @param useType The type of the class that to be used to deserialize the data.
|
|
31
|
-
* @decorator
|
|
32
|
-
* @operation
|
|
33
|
-
* @input
|
|
34
|
-
*/
|
|
35
|
-
export declare function CookiesParams(expression: string | any, useType: any): ParameterDecorator;
|
|
36
|
-
export declare function CookiesParams(): ParameterDecorator;
|
|
37
|
-
export declare function CookiesParams(expression: string | any): ParameterDecorator;
|
|
38
|
-
export declare function CookiesParams(options: ParamOptions<any>): ParameterDecorator;
|
|
39
|
-
/**
|
|
40
|
-
* Cookies or CookiesParams return the value from [request.cookies](http://expressjs.com/en/4x/api.html#req.cookies) object.
|
|
41
|
-
*
|
|
42
|
-
* #### Example
|
|
43
|
-
*
|
|
44
|
-
* ```typescript
|
|
45
|
-
* @Controller('/')
|
|
46
|
-
* class MyCtrl {
|
|
47
|
-
* @Post('/')
|
|
48
|
-
* create(@Cookies() body: any) {
|
|
49
|
-
* console.log('Entire body', body);
|
|
50
|
-
* }
|
|
51
|
-
*
|
|
52
|
-
* @Post('/')
|
|
53
|
-
* create(@Cookies('id') id: string) {
|
|
54
|
-
* console.log('ID', id);
|
|
55
|
-
* }
|
|
56
|
-
*
|
|
57
|
-
* @Post('/')
|
|
58
|
-
* create(@Cookies('user') user: User) { // with deserialization
|
|
59
|
-
* console.log('user', user);
|
|
60
|
-
* }
|
|
61
|
-
*
|
|
62
|
-
* @Post('/')
|
|
63
|
-
* create(@Cookies('users', User) users: User[]) { // with deserialization
|
|
64
|
-
* console.log('users', users);
|
|
65
|
-
* }
|
|
66
|
-
* }
|
|
67
|
-
* ```
|
|
68
|
-
* > For more information on deserialization see [converters](/docs/json-mapper.md) page.
|
|
69
|
-
*
|
|
70
|
-
* @param expression The path of the property to get.
|
|
71
|
-
* @param useType The type of the class that to be used to deserialize the data.
|
|
72
|
-
* @decorator
|
|
73
|
-
* @aliasof CookiesParams
|
|
74
|
-
* @operation
|
|
75
|
-
* @input
|
|
76
|
-
*/
|
|
77
|
-
export declare function Cookies(expression: string, useType: Type<any>): ParameterDecorator;
|
|
78
|
-
export declare function Cookies(expression: string): ParameterDecorator;
|
|
79
|
-
export declare function Cookies(useType: Type<any>): ParameterDecorator;
|
|
80
|
-
export declare function Cookies(options: Partial<ParamOptions>): ParameterDecorator;
|
|
81
|
-
export declare function Cookies(): ParameterDecorator;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { Type } from "@tsed/core";
|
|
2
|
-
import { ParamOptions } from "../domain/ParamOptions.js";
|
|
3
|
-
/**
|
|
4
|
-
* HeaderParams return the value from [`request.get()`](http://expressjs.com/en/4x/api.html#req.get) method.
|
|
5
|
-
*
|
|
6
|
-
* #### Example
|
|
7
|
-
*
|
|
8
|
-
* ```typescript
|
|
9
|
-
* @Controller('/')
|
|
10
|
-
* class MyCtrl {
|
|
11
|
-
* @Get('/')
|
|
12
|
-
* get(@HeaderParams() body: any) {
|
|
13
|
-
* console.log('Entire body', body);
|
|
14
|
-
* }
|
|
15
|
-
*
|
|
16
|
-
* @Get('/')
|
|
17
|
-
* get(@HeaderParams('x-token') token: string) {
|
|
18
|
-
* console.log('token', id);
|
|
19
|
-
* }
|
|
20
|
-
* }
|
|
21
|
-
* ```
|
|
22
|
-
*
|
|
23
|
-
* @param expression The path of the property to get.
|
|
24
|
-
* @param useType
|
|
25
|
-
* @decorator
|
|
26
|
-
* @operation
|
|
27
|
-
* @input
|
|
28
|
-
*/
|
|
29
|
-
export declare function HeaderParams(expression: string, useType: Type<any>): ParameterDecorator;
|
|
30
|
-
export declare function HeaderParams(expression: string): ParameterDecorator;
|
|
31
|
-
export declare function HeaderParams(useType: Type<any>): ParameterDecorator;
|
|
32
|
-
export declare function HeaderParams(options: Partial<ParamOptions>): ParameterDecorator;
|
|
33
|
-
export declare function HeaderParams(): ParameterDecorator;
|