@nestia/core 3.0.5 → 3.1.0-dev.20240429
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/lib/adaptors/WebSocketAdaptor.d.ts +21 -0
- package/lib/adaptors/WebSocketAdaptor.js +275 -0
- package/lib/adaptors/WebSocketAdaptor.js.map +1 -0
- package/lib/decorators/DynamicModule.js +12 -59
- package/lib/decorators/DynamicModule.js.map +1 -1
- package/lib/decorators/EncryptedBody.js +36 -73
- package/lib/decorators/EncryptedBody.js.map +1 -1
- package/lib/decorators/EncryptedController.js +2 -2
- package/lib/decorators/EncryptedController.js.map +1 -1
- package/lib/decorators/EncryptedModule.js +24 -107
- package/lib/decorators/EncryptedModule.js.map +1 -1
- package/lib/decorators/EncryptedRoute.js +43 -119
- package/lib/decorators/EncryptedRoute.js.map +1 -1
- package/lib/decorators/PlainBody.js +24 -61
- package/lib/decorators/PlainBody.js.map +1 -1
- package/lib/decorators/SwaggerCustomizer.js +2 -2
- package/lib/decorators/SwaggerCustomizer.js.map +1 -1
- package/lib/decorators/TypedBody.js +12 -14
- package/lib/decorators/TypedBody.js.map +1 -1
- package/lib/decorators/TypedException.js +5 -5
- package/lib/decorators/TypedException.js.map +1 -1
- package/lib/decorators/TypedFormData.js +88 -291
- package/lib/decorators/TypedFormData.js.map +1 -1
- package/lib/decorators/TypedHeaders.js +6 -6
- package/lib/decorators/TypedHeaders.js.map +1 -1
- package/lib/decorators/TypedParam.d.ts +5 -6
- package/lib/decorators/TypedParam.js +14 -15
- package/lib/decorators/TypedParam.js.map +1 -1
- package/lib/decorators/TypedQuery.d.ts +2 -2
- package/lib/decorators/TypedQuery.js +52 -129
- package/lib/decorators/TypedQuery.js.map +1 -1
- package/lib/decorators/TypedRoute.js +31 -107
- package/lib/decorators/TypedRoute.js.map +1 -1
- package/lib/decorators/WebSocketRoute.d.ts +120 -0
- package/lib/decorators/WebSocketRoute.js +202 -0
- package/lib/decorators/WebSocketRoute.js.map +1 -0
- package/lib/decorators/internal/IWebSocketRouteReflect.d.ts +25 -0
- package/lib/decorators/internal/IWebSocketRouteReflect.js +3 -0
- package/lib/decorators/internal/IWebSocketRouteReflect.js.map +1 -0
- package/lib/decorators/internal/NoTransformConfigureError.js +1 -1
- package/lib/decorators/internal/NoTransformConfigureError.js.map +1 -1
- package/lib/decorators/internal/get_path_and_querify.js +67 -131
- package/lib/decorators/internal/get_path_and_querify.js.map +1 -1
- package/lib/decorators/internal/get_path_and_stringify.js +57 -71
- package/lib/decorators/internal/get_path_and_stringify.js.map +1 -1
- package/lib/decorators/internal/get_text_body.js +7 -46
- package/lib/decorators/internal/get_text_body.js.map +1 -1
- package/lib/decorators/internal/headers_to_object.js +3 -42
- package/lib/decorators/internal/headers_to_object.js.map +1 -1
- package/lib/decorators/internal/load_controller.js +29 -106
- package/lib/decorators/internal/load_controller.js.map +1 -1
- package/lib/decorators/internal/route_error.js +15 -65
- package/lib/decorators/internal/route_error.js.map +1 -1
- package/lib/decorators/internal/validate_request_body.js +44 -54
- package/lib/decorators/internal/validate_request_body.js.map +1 -1
- package/lib/decorators/internal/validate_request_form_data.js +36 -44
- package/lib/decorators/internal/validate_request_form_data.js.map +1 -1
- package/lib/decorators/internal/validate_request_headers.js +36 -44
- package/lib/decorators/internal/validate_request_headers.js.map +1 -1
- package/lib/decorators/internal/validate_request_query.js +36 -44
- package/lib/decorators/internal/validate_request_query.js.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/module.d.ts +10 -9
- package/lib/module.js +10 -9
- package/lib/module.js.map +1 -1
- package/lib/programmers/PlainBodyProgrammer.js +29 -44
- package/lib/programmers/PlainBodyProgrammer.js.map +1 -1
- package/lib/programmers/TypedBodyProgrammer.js +57 -82
- package/lib/programmers/TypedBodyProgrammer.js.map +1 -1
- package/lib/programmers/TypedExceptionProgrammer.js +51 -54
- package/lib/programmers/TypedExceptionProgrammer.js.map +1 -1
- package/lib/programmers/TypedFormDataBodyProgrammer.js +50 -73
- package/lib/programmers/TypedFormDataBodyProgrammer.js.map +1 -1
- package/lib/programmers/TypedHeadersProgrammer.js +24 -43
- package/lib/programmers/TypedHeadersProgrammer.js.map +1 -1
- package/lib/programmers/TypedParamProgrammer.js +11 -28
- package/lib/programmers/TypedParamProgrammer.js.map +1 -1
- package/lib/programmers/TypedQueryBodyProgrammer.js +24 -43
- package/lib/programmers/TypedQueryBodyProgrammer.js.map +1 -1
- package/lib/programmers/TypedQueryProgrammer.js +24 -43
- package/lib/programmers/TypedQueryProgrammer.js.map +1 -1
- package/lib/programmers/TypedQueryRouteProgrammer.js +22 -39
- package/lib/programmers/TypedQueryRouteProgrammer.js.map +1 -1
- package/lib/programmers/TypedRouteProgrammer.js +22 -39
- package/lib/programmers/TypedRouteProgrammer.js.map +1 -1
- package/lib/programmers/http/HttpAssertQuerifyProgrammer.js +12 -29
- package/lib/programmers/http/HttpAssertQuerifyProgrammer.js.map +1 -1
- package/lib/programmers/http/HttpIsQuerifyProgrammer.js +10 -27
- package/lib/programmers/http/HttpIsQuerifyProgrammer.js.map +1 -1
- package/lib/programmers/http/HttpQuerifyProgrammer.js +33 -69
- package/lib/programmers/http/HttpQuerifyProgrammer.js.map +1 -1
- package/lib/programmers/http/HttpValidateQuerifyProgrammer.js +11 -28
- package/lib/programmers/http/HttpValidateQuerifyProgrammer.js.map +1 -1
- package/lib/programmers/internal/CoreMetadataUtil.js +12 -37
- package/lib/programmers/internal/CoreMetadataUtil.js.map +1 -1
- package/lib/transform.js +8 -8
- package/lib/transform.js.map +1 -1
- package/lib/transformers/FileTransformer.js +35 -66
- package/lib/transformers/FileTransformer.js.map +1 -1
- package/lib/transformers/MethodTransformer.js +39 -50
- package/lib/transformers/MethodTransformer.js.map +1 -1
- package/lib/transformers/NodeTransformer.js +8 -12
- package/lib/transformers/NodeTransformer.js.map +1 -1
- package/lib/transformers/ParameterDecoratorTransformer.js +75 -90
- package/lib/transformers/ParameterDecoratorTransformer.js.map +1 -1
- package/lib/transformers/ParameterTransformer.js +18 -24
- package/lib/transformers/ParameterTransformer.js.map +1 -1
- package/lib/transformers/TypedExceptionTransformer.js +24 -27
- package/lib/transformers/TypedExceptionTransformer.js.map +1 -1
- package/lib/transformers/TypedRouteTransformer.js +50 -88
- package/lib/transformers/TypedRouteTransformer.js.map +1 -1
- package/lib/transformers/WebSocketRouteTransformer.d.ts +6 -0
- package/lib/transformers/WebSocketRouteTransformer.js +72 -0
- package/lib/transformers/WebSocketRouteTransformer.js.map +1 -0
- package/lib/utils/ArrayUtil.d.ts +3 -0
- package/lib/utils/ArrayUtil.js +11 -0
- package/lib/utils/ArrayUtil.js.map +1 -0
- package/lib/utils/ExceptionManager.js +9 -31
- package/lib/utils/ExceptionManager.js.map +1 -1
- package/lib/utils/Singleton.js +6 -7
- package/lib/utils/Singleton.js.map +1 -1
- package/lib/utils/SourceFinder.js +38 -215
- package/lib/utils/SourceFinder.js.map +1 -1
- package/lib/utils/VersioningStrategy.d.ts +9 -0
- package/lib/utils/VersioningStrategy.js +17 -0
- package/lib/utils/VersioningStrategy.js.map +1 -0
- package/package.json +10 -6
- package/src/adaptors/WebSocketAdaptor.ts +416 -0
- package/src/decorators/TypedParam.ts +5 -6
- package/src/decorators/TypedQuery.ts +251 -251
- package/src/decorators/WebSocketRoute.ts +249 -0
- package/src/decorators/internal/IWebSocketRouteReflect.ts +23 -0
- package/src/decorators/internal/validate_request_body.ts +72 -72
- package/src/decorators/internal/validate_request_form_data.ts +75 -75
- package/src/decorators/internal/validate_request_headers.ts +83 -83
- package/src/decorators/internal/validate_request_query.ts +71 -71
- package/src/module.ts +20 -16
- package/src/transformers/MethodTransformer.ts +7 -4
- package/src/transformers/ParameterDecoratorTransformer.ts +129 -120
- package/src/transformers/TypedExceptionTransformer.ts +9 -13
- package/src/transformers/TypedRouteTransformer.ts +1 -8
- package/src/transformers/WebSocketRouteTransformer.ts +103 -0
- package/src/typings/get-function-location.d.ts +7 -0
- package/src/utils/ArrayUtil.ts +7 -0
- package/src/utils/VersioningStrategy.ts +27 -0
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
2
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
14
3
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
15
4
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -25,49 +14,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
25
14
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
26
15
|
});
|
|
27
16
|
};
|
|
28
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
29
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
30
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
31
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
32
|
-
function step(op) {
|
|
33
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
34
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
35
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
36
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
37
|
-
switch (op[0]) {
|
|
38
|
-
case 0: case 1: t = op; break;
|
|
39
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
40
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
41
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
42
|
-
default:
|
|
43
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
44
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
45
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
46
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
47
|
-
if (t[2]) _.ops.pop();
|
|
48
|
-
_.trys.pop(); continue;
|
|
49
|
-
}
|
|
50
|
-
op = body.call(thisArg, _);
|
|
51
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
52
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
var __values = (this && this.__values) || function(o) {
|
|
56
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
57
|
-
if (m) return m.call(o);
|
|
58
|
-
if (o && typeof o.length === "number") return {
|
|
59
|
-
next: function () {
|
|
60
|
-
if (o && i >= o.length) o = void 0;
|
|
61
|
-
return { value: o && o[i++], done: !o };
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
65
|
-
};
|
|
66
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
67
18
|
exports.EncryptedModule = void 0;
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
19
|
+
const common_1 = require("@nestjs/common");
|
|
20
|
+
const EncryptedConstant_1 = require("./internal/EncryptedConstant");
|
|
21
|
+
const load_controller_1 = require("./internal/load_controller");
|
|
71
22
|
/**
|
|
72
23
|
* Encrypted module.
|
|
73
24
|
*
|
|
@@ -120,25 +71,16 @@ exports.EncryptedModule = EncryptedModule;
|
|
|
120
71
|
* @returns Class decorated module instance
|
|
121
72
|
*/
|
|
122
73
|
function dynamic(path_1, password_1) {
|
|
123
|
-
return __awaiter(this, arguments, void 0, function (path, password, options) {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}
|
|
134
|
-
NestiaModule = __decorate([
|
|
135
|
-
EncryptedModule(__assign(__assign({}, options), { controllers: controllers }), typeof password === "object" ? function () { return password; } : password)
|
|
136
|
-
], NestiaModule);
|
|
137
|
-
return NestiaModule;
|
|
138
|
-
}());
|
|
139
|
-
return [2 /*return*/, NestiaModule];
|
|
140
|
-
}
|
|
141
|
-
});
|
|
74
|
+
return __awaiter(this, arguments, void 0, function* (path, password, options = {}) {
|
|
75
|
+
// LOAD CONTROLLERS
|
|
76
|
+
const controllers = yield (0, load_controller_1.load_controllers)(path);
|
|
77
|
+
// RETURNS WITH DECORATING
|
|
78
|
+
let NestiaModule = class NestiaModule {
|
|
79
|
+
};
|
|
80
|
+
NestiaModule = __decorate([
|
|
81
|
+
EncryptedModule(Object.assign(Object.assign({}, options), { controllers }), typeof password === "object" ? () => password : password)
|
|
82
|
+
], NestiaModule);
|
|
83
|
+
return NestiaModule;
|
|
142
84
|
});
|
|
143
85
|
}
|
|
144
86
|
EncryptedModule.dynamic = dynamic;
|
|
@@ -146,41 +88,16 @@ exports.EncryptedModule = EncryptedModule;
|
|
|
146
88
|
/**
|
|
147
89
|
* @internal
|
|
148
90
|
*/
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
}
|
|
161
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
162
|
-
finally {
|
|
163
|
-
try {
|
|
164
|
-
if (imports_1_1 && !imports_1_1.done && (_a = imports_1.return)) _a.call(imports_1);
|
|
165
|
-
}
|
|
166
|
-
finally { if (e_1) throw e_1.error; }
|
|
167
|
-
}
|
|
168
|
-
var controllers = Reflect.getMetadata("controllers", modulo);
|
|
169
|
-
if (Array.isArray(controllers))
|
|
170
|
-
try {
|
|
171
|
-
for (var controllers_1 = __values(controllers), controllers_1_1 = controllers_1.next(); !controllers_1_1.done; controllers_1_1 = controllers_1.next()) {
|
|
172
|
-
var c = controllers_1_1.value;
|
|
173
|
-
if (typeof c === "function")
|
|
174
|
-
Reflect.defineMetadata(EncryptedConstant_1.ENCRYPTION_METADATA_KEY, password, c);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
178
|
-
finally {
|
|
179
|
-
try {
|
|
180
|
-
if (controllers_1_1 && !controllers_1_1.done && (_b = controllers_1.return)) _b.call(controllers_1);
|
|
181
|
-
}
|
|
182
|
-
finally { if (e_2) throw e_2.error; }
|
|
183
|
-
}
|
|
184
|
-
};
|
|
91
|
+
const iterate = (password) => (modulo) => {
|
|
92
|
+
const imports = Reflect.getMetadata("imports", modulo);
|
|
93
|
+
if (Array.isArray(imports))
|
|
94
|
+
for (const imp of imports)
|
|
95
|
+
if (typeof imp === "function")
|
|
96
|
+
iterate(password)(imp);
|
|
97
|
+
const controllers = Reflect.getMetadata("controllers", modulo);
|
|
98
|
+
if (Array.isArray(controllers))
|
|
99
|
+
for (const c of controllers)
|
|
100
|
+
if (typeof c === "function")
|
|
101
|
+
Reflect.defineMetadata(EncryptedConstant_1.ENCRYPTION_METADATA_KEY, password, c);
|
|
185
102
|
};
|
|
186
103
|
//# sourceMappingURL=EncryptedModule.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EncryptedModule.js","sourceRoot":"","sources":["../../src/decorators/EncryptedModule.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"EncryptedModule.js","sourceRoot":"","sources":["../../src/decorators/EncryptedModule.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AACA,2CAAwC;AAGxC,oEAAuE;AACvE,gEAA8D;AAE9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,SAAgB,eAAe,CAC7B,QAAsC,EACtC,QAAqC;IAErC,OAAO,UAAU,MAAW;QAC1B,IAAA,eAAM,EAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC;QACzB,OAAO,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC;IAC5B,CAAC,CAAC;AACJ,CAAC;AARD,0CAQC;AAED,WAAiB,eAAe;IAC9B;;;;;;;;;;;;OAYG;IACH,SAAsB,OAAO;6DAC3B,IAAmE,EACnE,QAA2D,EAC3D,UAA6D,EAAE;YAE/D,mBAAmB;YACnB,MAAM,WAAW,GAAsB,MAAM,IAAA,kCAAgB,EAAC,IAAI,CAAC,CAAC;YAEpE,0BAA0B;YAK1B,IAAM,YAAY,GAAlB,MAAM,YAAY;aAAG,CAAA;YAAf,YAAY;gBAJjB,eAAe,iCACT,OAAO,KAAE,WAAW,KACzB,OAAO,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CACzD;eACK,YAAY,CAAG;YACrB,OAAO,YAAY,CAAC;QACtB,CAAC;KAAA;IAfqB,uBAAO,UAe5B,CAAA;AACH,CAAC,EA9BgB,eAAe,+BAAf,eAAe,QA8B/B;AAED;;GAEG;AACH,MAAM,OAAO,GACX,CAAC,QAAqC,EAAE,EAAE,CAC1C,CAAC,MAAW,EAAQ,EAAE;IACpB,MAAM,OAAO,GAAG,OAAO,CAAC,WAAW,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IACvD,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC;QACxB,KAAK,MAAM,GAAG,IAAI,OAAO;YACvB,IAAI,OAAO,GAAG,KAAK,UAAU;gBAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC;IAE1D,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;IAC/D,IAAI,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC;QAC5B,KAAK,MAAM,CAAC,IAAI,WAAW;YACzB,IAAI,OAAO,CAAC,KAAK,UAAU;gBACzB,OAAO,CAAC,cAAc,CAAC,2CAAuB,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC;AACrE,CAAC,CAAC"}
|
|
@@ -1,56 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
3
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
4
|
-
if (!m) return o;
|
|
5
|
-
var i = m.call(o), r, ar = [], e;
|
|
6
|
-
try {
|
|
7
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
8
|
-
}
|
|
9
|
-
catch (error) { e = { error: error }; }
|
|
10
|
-
finally {
|
|
11
|
-
try {
|
|
12
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
13
|
-
}
|
|
14
|
-
finally { if (e) throw e.error; }
|
|
15
|
-
}
|
|
16
|
-
return ar;
|
|
17
|
-
};
|
|
18
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
19
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
20
|
-
if (ar || !(i in from)) {
|
|
21
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
22
|
-
ar[i] = from[i];
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
26
|
-
};
|
|
27
|
-
var __values = (this && this.__values) || function(o) {
|
|
28
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
29
|
-
if (m) return m.call(o);
|
|
30
|
-
if (o && typeof o.length === "number") return {
|
|
31
|
-
next: function () {
|
|
32
|
-
if (o && i >= o.length) o = void 0;
|
|
33
|
-
return { value: o && o[i++], done: !o };
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
37
|
-
};
|
|
38
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
4
|
};
|
|
41
|
-
var e_1, _a, e_2, _b, e_3, _c;
|
|
42
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
6
|
exports.EncryptedRoute = void 0;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
7
|
+
const AesPkcs5_1 = require("@nestia/fetcher/lib/AesPkcs5");
|
|
8
|
+
const common_1 = require("@nestjs/common");
|
|
9
|
+
const operators_1 = require("rxjs/operators");
|
|
10
|
+
const typia_1 = __importDefault(require("typia"));
|
|
11
|
+
const Singleton_1 = require("../utils/Singleton");
|
|
12
|
+
const EncryptedConstant_1 = require("./internal/EncryptedConstant");
|
|
13
|
+
const NoTransformConfigureError_1 = require("./internal/NoTransformConfigureError");
|
|
14
|
+
const get_path_and_stringify_1 = require("./internal/get_path_and_stringify");
|
|
15
|
+
const headers_to_object_1 = require("./internal/headers_to_object");
|
|
16
|
+
const route_error_1 = require("./internal/route_error");
|
|
54
17
|
/**
|
|
55
18
|
* Encrypted router decorator functions.
|
|
56
19
|
*
|
|
@@ -109,103 +72,64 @@ var EncryptedRoute;
|
|
|
109
72
|
*/
|
|
110
73
|
EncryptedRoute.Delete = Generator("Delete");
|
|
111
74
|
function Generator(method) {
|
|
112
|
-
function route() {
|
|
113
|
-
|
|
114
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
115
|
-
args[_i] = arguments[_i];
|
|
116
|
-
}
|
|
117
|
-
var _a = __read((0, get_path_and_stringify_1.get_path_and_stringify)("EncryptedRoute.".concat(method)).apply(void 0, __spreadArray([], __read(args), false)), 2), path = _a[0], stringify = _a[1];
|
|
75
|
+
function route(...args) {
|
|
76
|
+
const [path, stringify] = (0, get_path_and_stringify_1.get_path_and_stringify)(`EncryptedRoute.${method}`)(...args);
|
|
118
77
|
return (0, common_1.applyDecorators)(ROUTERS[method](path), (0, common_1.UseInterceptors)(new EncryptedRouteInterceptor(method, stringify)));
|
|
119
78
|
}
|
|
120
79
|
return route;
|
|
121
80
|
}
|
|
122
81
|
})(EncryptedRoute || (exports.EncryptedRoute = EncryptedRoute = {}));
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
EncryptedRoute.Post,
|
|
139
|
-
EncryptedRoute.Put,
|
|
140
|
-
EncryptedRoute.Patch,
|
|
141
|
-
])), _k = _j.next(); !_k.done; _k = _j.next()) {
|
|
142
|
-
var deco = _k.value;
|
|
143
|
-
deco[key] = value;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
147
|
-
finally {
|
|
148
|
-
try {
|
|
149
|
-
if (_k && !_k.done && (_c = _j.return)) _c.call(_j);
|
|
150
|
-
}
|
|
151
|
-
finally { if (e_3) throw e_3.error; }
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
156
|
-
finally {
|
|
157
|
-
try {
|
|
158
|
-
if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
|
|
159
|
-
}
|
|
160
|
-
finally { if (e_2) throw e_2.error; }
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
165
|
-
finally {
|
|
166
|
-
try {
|
|
167
|
-
if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
|
|
168
|
-
}
|
|
169
|
-
finally { if (e_1) throw e_1.error; }
|
|
170
|
-
}
|
|
82
|
+
for (const method of [
|
|
83
|
+
typia_1.default.json.isStringify,
|
|
84
|
+
typia_1.default.json.assertStringify,
|
|
85
|
+
typia_1.default.json.validateStringify,
|
|
86
|
+
typia_1.default.json.stringify,
|
|
87
|
+
])
|
|
88
|
+
for (const [key, value] of Object.entries(method))
|
|
89
|
+
for (const deco of [
|
|
90
|
+
EncryptedRoute.Get,
|
|
91
|
+
EncryptedRoute.Delete,
|
|
92
|
+
EncryptedRoute.Post,
|
|
93
|
+
EncryptedRoute.Put,
|
|
94
|
+
EncryptedRoute.Patch,
|
|
95
|
+
])
|
|
96
|
+
deco[key] = value;
|
|
171
97
|
/**
|
|
172
98
|
* @internal
|
|
173
99
|
*/
|
|
174
|
-
|
|
175
|
-
|
|
100
|
+
class EncryptedRouteInterceptor {
|
|
101
|
+
constructor(method, stringify) {
|
|
176
102
|
this.method = method;
|
|
177
103
|
this.stringify = stringify;
|
|
178
104
|
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
var param = Reflect.getMetadata(EncryptedConstant_1.ENCRYPTION_METADATA_KEY, context.getClass());
|
|
105
|
+
intercept(context, next) {
|
|
106
|
+
const http = context.switchToHttp();
|
|
107
|
+
return next.handle().pipe((0, operators_1.map)((value) => {
|
|
108
|
+
const param = Reflect.getMetadata(EncryptedConstant_1.ENCRYPTION_METADATA_KEY, context.getClass());
|
|
184
109
|
if (!param)
|
|
185
|
-
throw (0, NoTransformConfigureError_1.NoTransformConfigureError)(
|
|
186
|
-
|
|
187
|
-
|
|
110
|
+
throw (0, NoTransformConfigureError_1.NoTransformConfigureError)(`EncryptedRoute.${this.method}`);
|
|
111
|
+
const headers = new Singleton_1.Singleton(() => {
|
|
112
|
+
const request = http.getRequest();
|
|
188
113
|
return (0, headers_to_object_1.headers_to_object)(request.headers);
|
|
189
114
|
});
|
|
190
|
-
|
|
191
|
-
|
|
115
|
+
const body = this.stringify(value);
|
|
116
|
+
const password = typeof param === "function"
|
|
192
117
|
? param({
|
|
193
118
|
headers: headers.get(),
|
|
194
|
-
body
|
|
119
|
+
body,
|
|
195
120
|
direction: "encode",
|
|
196
121
|
})
|
|
197
122
|
: param;
|
|
198
123
|
if (body === undefined)
|
|
199
124
|
return body;
|
|
200
125
|
return AesPkcs5_1.AesPkcs5.encrypt(body, password.key, password.iv);
|
|
201
|
-
}), (0, operators_1.catchError)(
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
}());
|
|
126
|
+
}), (0, operators_1.catchError)((err) => (0, route_error_1.route_error)(http.getRequest(), err)));
|
|
127
|
+
}
|
|
128
|
+
}
|
|
205
129
|
/**
|
|
206
130
|
* @internal
|
|
207
131
|
*/
|
|
208
|
-
|
|
132
|
+
const ROUTERS = {
|
|
209
133
|
Get: common_1.Get,
|
|
210
134
|
Post: common_1.Post,
|
|
211
135
|
Put: common_1.Put,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EncryptedRoute.js","sourceRoot":"","sources":["../../src/decorators/EncryptedRoute.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"EncryptedRoute.js","sourceRoot":"","sources":["../../src/decorators/EncryptedRoute.ts"],"names":[],"mappings":";;;;;;AAAA,2DAAwD;AAExD,2CAWwB;AAGxB,8CAAiD;AACjD,kDAA0B;AAG1B,kDAA+C;A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O,IAAI,CAAC;YACpC,OAAO,mBAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC;QAC3D,CAAC,CAAC,EACF,IAAA,sBAAU,EAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAA,yBAAW,EAAC,IAAI,CAAC,UAAU,EAAE,EAAE,GAAG,CAAC,CAAC,CACzD,CAAC;IACJ,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,GAAG;IACd,GAAG,EAAH,YAAG;IACH,IAAI,EAAJ,aAAI;IACJ,GAAG,EAAH,YAAG;IACH,KAAK,EAAL,cAAK;IACL,MAAM,EAAN,eAAM;CACP,CAAC"}
|
|
@@ -8,71 +8,36 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
12
|
exports.PlainBody = void 0;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const typia_1 = require("typia");
|
|
15
|
+
const get_text_body_1 = require("./internal/get_text_body");
|
|
16
|
+
const validate_request_body_1 = require("./internal/validate_request_body");
|
|
44
17
|
/**
|
|
45
18
|
* @internal
|
|
46
19
|
*/
|
|
47
20
|
function PlainBody(assert) {
|
|
48
|
-
|
|
21
|
+
const checker = assert
|
|
49
22
|
? (0, validate_request_body_1.validate_request_body)("PlainBody")({
|
|
50
23
|
type: "assert",
|
|
51
|
-
assert
|
|
24
|
+
assert,
|
|
52
25
|
})
|
|
53
26
|
: null;
|
|
54
27
|
return (0, common_1.createParamDecorator)(function PlainBody(_data, context) {
|
|
55
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
if (checker) {
|
|
69
|
-
error = checker(value);
|
|
70
|
-
if (error !== null)
|
|
71
|
-
throw error;
|
|
72
|
-
}
|
|
73
|
-
return [2 /*return*/, value];
|
|
74
|
-
}
|
|
75
|
-
});
|
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
const request = context
|
|
30
|
+
.switchToHttp()
|
|
31
|
+
.getRequest();
|
|
32
|
+
if (!isTextPlain(request.headers["content-type"]))
|
|
33
|
+
throw new common_1.BadRequestException(`Request body type is not "text/plain".`);
|
|
34
|
+
const value = yield (0, get_text_body_1.get_text_body)(request);
|
|
35
|
+
if (checker) {
|
|
36
|
+
const error = checker(value);
|
|
37
|
+
if (error !== null)
|
|
38
|
+
throw error;
|
|
39
|
+
}
|
|
40
|
+
return value;
|
|
76
41
|
});
|
|
77
42
|
})();
|
|
78
43
|
}
|
|
@@ -81,11 +46,9 @@ Object.assign(PlainBody, typia_1.assert);
|
|
|
81
46
|
/**
|
|
82
47
|
* @internal
|
|
83
48
|
*/
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
.some(function (str) { return str === "text/plain"; });
|
|
90
|
-
};
|
|
49
|
+
const isTextPlain = (text) => text !== undefined &&
|
|
50
|
+
text
|
|
51
|
+
.split(";")
|
|
52
|
+
.map((str) => str.trim())
|
|
53
|
+
.some((str) => str === "text/plain");
|
|
91
54
|
//# sourceMappingURL=PlainBody.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlainBody.js","sourceRoot":"","sources":["../../src/decorators/PlainBody.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PlainBody.js","sourceRoot":"","sources":["../../src/decorators/PlainBody.ts"],"names":[],"mappings":";;;;;;;;;;;;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ustomizer = void 0;
|
|
|
17
17
|
*/
|
|
18
18
|
function SwaggerCustomizer(closure) {
|
|
19
19
|
return function SwaggerCustomizer(target, propertyKey, descriptor) {
|
|
20
|
-
|
|
20
|
+
const array = (() => {
|
|
21
21
|
if (Reflect.hasMetadata("nestia/SwaggerCustomizer", target, propertyKey))
|
|
22
22
|
return Reflect.getMetadata("nestia/SwaggerCustomizer", target, propertyKey);
|
|
23
|
-
|
|
23
|
+
const array = [];
|
|
24
24
|
Reflect.defineMetadata("nestia/SwaggerCustomizer", array, target, propertyKey);
|
|
25
25
|
return array;
|
|
26
26
|
})();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SwaggerCustomizer.js","sourceRoot":"","sources":["../../src/decorators/SwaggerCustomizer.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;;;GAaG;AACH,SAAgB,iBAAiB,CAC/B,OAAqD;IAErD,OAAO,SAAS,iBAAiB,CAC/B,MAAc,EACd,WAA4B,EAC5B,UAAwC;QAExC,
|
|
1
|
+
{"version":3,"file":"SwaggerCustomizer.js","sourceRoot":"","sources":["../../src/decorators/SwaggerCustomizer.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;;;GAaG;AACH,SAAgB,iBAAiB,CAC/B,OAAqD;IAErD,OAAO,SAAS,iBAAiB,CAC/B,MAAc,EACd,WAA4B,EAC5B,UAAwC;QAExC,MAAM,KAAK,GAAwD,CAAC,GAAG,EAAE;YACvE,IAAI,OAAO,CAAC,WAAW,CAAC,0BAA0B,EAAE,MAAM,EAAE,WAAW,CAAC;gBACtE,OAAO,OAAO,CAAC,WAAW,CACxB,0BAA0B,EAC1B,MAAM,EACN,WAAW,CACZ,CAAC;YACJ,MAAM,KAAK,GAAwD,EAAE,CAAC;YACtE,OAAO,CAAC,cAAc,CACpB,0BAA0B,EAC1B,KAAK,EACL,MAAM,EACN,WAAW,CACZ,CAAC;YACF,OAAO,KAAK,CAAC;QACf,CAAC,CAAC,EAAE,CAAC;QACL,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACpB,OAAO,UAAU,CAAC;IACpB,CAAC,CAAC;AACJ,CAAC;AA3BD,8CA2BC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TypedBody = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
const typia_1 = require("typia");
|
|
6
|
+
const validate_request_body_1 = require("./internal/validate_request_body");
|
|
7
7
|
/**
|
|
8
8
|
* Type safe body decorator.
|
|
9
9
|
*
|
|
@@ -19,14 +19,14 @@ var validate_request_body_1 = require("./internal/validate_request_body");
|
|
|
19
19
|
* @author Jeongho Nam - https://github.com/samchon
|
|
20
20
|
*/
|
|
21
21
|
function TypedBody(validator) {
|
|
22
|
-
|
|
22
|
+
const checker = (0, validate_request_body_1.validate_request_body)("TypedBody")(validator);
|
|
23
23
|
return (0, common_1.createParamDecorator)(function TypedBody(_unknown, context) {
|
|
24
|
-
|
|
24
|
+
const request = context
|
|
25
25
|
.switchToHttp()
|
|
26
26
|
.getRequest();
|
|
27
27
|
if (isApplicationJson(request.headers["content-type"]) === false)
|
|
28
|
-
throw new common_1.BadRequestException(
|
|
29
|
-
|
|
28
|
+
throw new common_1.BadRequestException(`Request body type is not "application/json".`);
|
|
29
|
+
const error = checker(request.body);
|
|
30
30
|
if (error !== null)
|
|
31
31
|
throw error;
|
|
32
32
|
return request.body;
|
|
@@ -40,11 +40,9 @@ Object.assign(TypedBody, typia_1.validate);
|
|
|
40
40
|
/**
|
|
41
41
|
* @internal
|
|
42
42
|
*/
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
.some(function (str) { return str === "application/json"; });
|
|
49
|
-
};
|
|
43
|
+
const isApplicationJson = (text) => text !== undefined &&
|
|
44
|
+
text
|
|
45
|
+
.split(";")
|
|
46
|
+
.map((str) => str.trim())
|
|
47
|
+
.some((str) => str === "application/json");
|
|
50
48
|
//# sourceMappingURL=TypedBody.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypedBody.js","sourceRoot":"","sources":["../../src/decorators/TypedBody.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"TypedBody.js","sourceRoot":"","sources":["../../src/decorators/TypedBody.ts"],"names":[],"mappings":";;;AAAA,2CAIwB;AAGxB,iCAAmD;AAGnD,4EAAyE;AAEzE;;;;;;;;;;;;;GAaG;AACH,SAAgB,SAAS,CACvB,SAAoC;IAEpC,MAAM,OAAO,GAAG,IAAA,6CAAqB,EAAC,WAAW,CAAC,CAAC,SAAS,CAAC,CAAC;IAC9D,OAAO,IAAA,6BAAoB,EAAC,SAAS,SAAS,CAC5C,QAAa,EACb,OAAyB;QAEzB,MAAM,OAAO,GAAqC,OAAO;aACtD,YAAY,EAAE;aACd,UAAU,EAAE,CAAC;QAChB,IAAI,iBAAiB,CAAC,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,KAAK,KAAK;YAC9D,MAAM,IAAI,4BAAmB,CAC3B,8CAA8C,CAC/C,CAAC;QAEJ,MAAM,KAAK,GAAiB,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAClD,IAAI,KAAK,KAAK,IAAI;YAAE,MAAM,KAAK,CAAC;QAChC,OAAO,OAAO,CAAC,IAAI,CAAC;IACtB,CAAC,CAAC,EAAE,CAAC;AACP,CAAC;AApBD,8BAoBC;AAED,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,YAAI,CAAC,KAAK,CAAC,CAAC;AACrC,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,UAAE,CAAC,CAAC;AAC7B,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,cAAM,CAAC,CAAC;AACjC,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,gBAAQ,CAAC,CAAC;AAEnC;;GAEG;AACH,MAAM,iBAAiB,GAAG,CAAC,IAAa,EAAW,EAAE,CACnD,IAAI,KAAK,SAAS;IAClB,IAAI;SACD,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;SACxB,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,KAAK,kBAAkB,CAAC,CAAC"}
|
|
@@ -6,17 +6,17 @@ exports.TypedException = void 0;
|
|
|
6
6
|
*/
|
|
7
7
|
function TypedException(status, description, type) {
|
|
8
8
|
return function TypedException(target, propertyKey, descriptor) {
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
const array = (() => {
|
|
10
|
+
const oldbie = Reflect.getMetadata("nestia/TypedException", target[propertyKey]);
|
|
11
11
|
if (oldbie !== undefined)
|
|
12
12
|
return oldbie;
|
|
13
|
-
|
|
13
|
+
const newbie = [];
|
|
14
14
|
Reflect.defineMetadata("nestia/TypedException", newbie, target[propertyKey]);
|
|
15
15
|
return newbie;
|
|
16
16
|
})();
|
|
17
17
|
array.push({
|
|
18
|
-
status
|
|
19
|
-
description
|
|
18
|
+
status,
|
|
19
|
+
description,
|
|
20
20
|
type: type,
|
|
21
21
|
});
|
|
22
22
|
return descriptor;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypedException.js","sourceRoot":"","sources":["../../src/decorators/TypedException.ts"],"names":[],"mappings":";;;AA6CA;;GAEG;AACH,SAAgB,cAAc,CAC5B,MAA8C,EAC9C,WAAgC,EAChC,IAAyB;IAEzB,OAAO,SAAS,cAAc,CAC5B,MAAkB,EAClB,WAA4B,EAC5B,UAAwC;QAExC,
|
|
1
|
+
{"version":3,"file":"TypedException.js","sourceRoot":"","sources":["../../src/decorators/TypedException.ts"],"names":[],"mappings":";;;AA6CA;;GAEG;AACH,SAAgB,cAAc,CAC5B,MAA8C,EAC9C,WAAgC,EAChC,IAAyB;IAEzB,OAAO,SAAS,cAAc,CAC5B,MAAkB,EAClB,WAA4B,EAC5B,UAAwC;QAExC,MAAM,KAAK,GAAa,CAAC,GAAG,EAAE;YAC5B,MAAM,MAAM,GAAyB,OAAO,CAAC,WAAW,CACtD,uBAAuB,EACtB,MAAc,CAAC,WAAW,CAAC,CAC7B,CAAC;YACF,IAAI,MAAM,KAAK,SAAS;gBAAE,OAAO,MAAM,CAAC;YAExC,MAAM,MAAM,GAAa,EAAE,CAAC;YAC5B,OAAO,CAAC,cAAc,CACpB,uBAAuB,EACvB,MAAM,EACL,MAAc,CAAC,WAAW,CAAC,CAC7B,CAAC;YACF,OAAO,MAAM,CAAC;QAChB,CAAC,CAAC,EAAE,CAAC;QACL,KAAK,CAAC,IAAI,CAAC;YACT,MAAM;YACN,WAAW;YACX,IAAI,EAAE,IAAK;SACZ,CAAC,CAAC;QACH,OAAO,UAAU,CAAC;IACpB,CAAC,CAAC;AACJ,CAAC;AAhCD,wCAgCC"}
|