@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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -19,33 +8,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
19
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
9
|
});
|
|
21
10
|
};
|
|
22
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
-
function step(op) {
|
|
27
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
-
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;
|
|
30
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
-
switch (op[0]) {
|
|
32
|
-
case 0: case 1: t = op; break;
|
|
33
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
-
default:
|
|
37
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
-
if (t[2]) _.ops.pop();
|
|
42
|
-
_.trys.pop(); continue;
|
|
43
|
-
}
|
|
44
|
-
op = body.call(thisArg, _);
|
|
45
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
11
|
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
50
12
|
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
51
13
|
var m = o[Symbol.asyncIterator], i;
|
|
@@ -53,43 +15,16 @@ var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
|
53
15
|
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
54
16
|
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
55
17
|
};
|
|
56
|
-
var __values = (this && this.__values) || function(o) {
|
|
57
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
58
|
-
if (m) return m.call(o);
|
|
59
|
-
if (o && typeof o.length === "number") return {
|
|
60
|
-
next: function () {
|
|
61
|
-
if (o && i >= o.length) o = void 0;
|
|
62
|
-
return { value: o && o[i++], done: !o };
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
66
|
-
};
|
|
67
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
68
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
69
|
-
if (!m) return o;
|
|
70
|
-
var i = m.call(o), r, ar = [], e;
|
|
71
|
-
try {
|
|
72
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
73
|
-
}
|
|
74
|
-
catch (error) { e = { error: error }; }
|
|
75
|
-
finally {
|
|
76
|
-
try {
|
|
77
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
78
|
-
}
|
|
79
|
-
finally { if (e) throw e.error; }
|
|
80
|
-
}
|
|
81
|
-
return ar;
|
|
82
|
-
};
|
|
83
18
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
84
19
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
85
20
|
};
|
|
86
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
87
22
|
exports.TypedFormData = void 0;
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
23
|
+
const common_1 = require("@nestjs/common");
|
|
24
|
+
const multer_1 = __importDefault(require("multer"));
|
|
25
|
+
const typia_1 = __importDefault(require("typia"));
|
|
26
|
+
const Singleton_1 = require("../utils/Singleton");
|
|
27
|
+
const validate_request_form_data_1 = require("./internal/validate_request_form_data");
|
|
93
28
|
/**
|
|
94
29
|
* Type safe multipart/form-data decorator.
|
|
95
30
|
*
|
|
@@ -149,37 +84,25 @@ var TypedFormData;
|
|
|
149
84
|
* @param props Automatically filled by transformer
|
|
150
85
|
*/
|
|
151
86
|
function Body(props) {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
return new Singleton_1.Singleton(function () {
|
|
155
|
-
return type === "express" ? decodeExpress(props) : decodeFastify(props);
|
|
156
|
-
});
|
|
157
|
-
};
|
|
87
|
+
const checker = (0, validate_request_form_data_1.validate_request_form_data)(props);
|
|
88
|
+
const predicator = (type) => new Singleton_1.Singleton(() => type === "express" ? decodeExpress(props) : decodeFastify(props));
|
|
158
89
|
return (0, common_1.createParamDecorator)(function TypedFormDataBody(_unknown, context) {
|
|
159
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
: predicator("fastify").get();
|
|
171
|
-
return [4 /*yield*/, decoder({
|
|
172
|
-
request: request,
|
|
173
|
-
response: http.getResponse(),
|
|
174
|
-
})];
|
|
175
|
-
case 1:
|
|
176
|
-
data = _a.sent();
|
|
177
|
-
output = checker(data);
|
|
178
|
-
if (output instanceof Error)
|
|
179
|
-
throw output;
|
|
180
|
-
return [2 /*return*/, output];
|
|
181
|
-
}
|
|
90
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
91
|
+
const http = context.switchToHttp();
|
|
92
|
+
const request = http.getRequest();
|
|
93
|
+
if (isMultipartFormData(request.headers["content-type"]) === false)
|
|
94
|
+
throw new common_1.BadRequestException(`Request body type is not "multipart/form-data".`);
|
|
95
|
+
const decoder = isExpressRequest(request)
|
|
96
|
+
? predicator("express").get()
|
|
97
|
+
: predicator("fastify").get();
|
|
98
|
+
const data = yield decoder({
|
|
99
|
+
request: request,
|
|
100
|
+
response: http.getResponse(),
|
|
182
101
|
});
|
|
102
|
+
const output = checker(data);
|
|
103
|
+
if (output instanceof Error)
|
|
104
|
+
throw output;
|
|
105
|
+
return output;
|
|
183
106
|
});
|
|
184
107
|
})();
|
|
185
108
|
}
|
|
@@ -191,213 +114,87 @@ var TypedFormData;
|
|
|
191
114
|
/**
|
|
192
115
|
* @internal
|
|
193
116
|
*/
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
case 1:
|
|
213
|
-
_h.sent();
|
|
214
|
-
data = new FormData();
|
|
215
|
-
try {
|
|
216
|
-
for (_a = __values(Object.entries(socket.request.body)), _b = _a.next(); !_b.done; _b = _a.next()) {
|
|
217
|
-
_c = __read(_b.value, 2), key = _c[0], value = _c[1];
|
|
218
|
-
try {
|
|
219
|
-
for (_d = (e_2 = void 0, __values(String(value).split(","))), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
220
|
-
elem = _e.value;
|
|
221
|
-
data.append(key, elem);
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
225
|
-
finally {
|
|
226
|
-
try {
|
|
227
|
-
if (_e && !_e.done && (_g = _d.return)) _g.call(_d);
|
|
228
|
-
}
|
|
229
|
-
finally { if (e_2) throw e_2.error; }
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
234
|
-
finally {
|
|
235
|
-
try {
|
|
236
|
-
if (_b && !_b.done && (_f = _a.return)) _f.call(_a);
|
|
237
|
-
}
|
|
238
|
-
finally { if (e_1) throw e_1.error; }
|
|
239
|
-
}
|
|
240
|
-
if (socket.request.files)
|
|
241
|
-
parseFiles(data)(socket.request.files);
|
|
242
|
-
return [2 /*return*/, data];
|
|
243
|
-
}
|
|
244
|
-
});
|
|
245
|
-
}); };
|
|
117
|
+
const decodeExpress = (props) => {
|
|
118
|
+
const upload = multerApplication.get().fields(props.files.map((file) => (Object.assign({ name: file.name }, (file.limit === 1 ? { maxCount: 1 } : {})))));
|
|
119
|
+
const interceptor = (request, response) => new Promise((resolve, reject) => upload(request, response, (error) => {
|
|
120
|
+
if (error)
|
|
121
|
+
reject(error);
|
|
122
|
+
else
|
|
123
|
+
resolve();
|
|
124
|
+
}));
|
|
125
|
+
return (socket) => __awaiter(void 0, void 0, void 0, function* () {
|
|
126
|
+
yield interceptor(socket.request, socket.response);
|
|
127
|
+
const data = new FormData();
|
|
128
|
+
for (const [key, value] of Object.entries(socket.request.body))
|
|
129
|
+
for (const elem of String(value).split(","))
|
|
130
|
+
data.append(key, elem);
|
|
131
|
+
if (socket.request.files)
|
|
132
|
+
parseFiles(data)(socket.request.files);
|
|
133
|
+
return data;
|
|
134
|
+
});
|
|
246
135
|
};
|
|
247
136
|
/**
|
|
248
137
|
* @internal
|
|
249
138
|
*/
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
282
|
-
finally {
|
|
283
|
-
try {
|
|
284
|
-
if (_b && !_b.done && (_o = _a.return)) _o.call(_a);
|
|
285
|
-
}
|
|
286
|
-
finally { if (e_4) throw e_4.error; }
|
|
287
|
-
}
|
|
288
|
-
_u.label = 1;
|
|
289
|
-
case 1:
|
|
290
|
-
_u.trys.push([1, 7, 8, 13]);
|
|
291
|
-
_f = true, _g = __asyncValues(socket.request.files());
|
|
292
|
-
_u.label = 2;
|
|
293
|
-
case 2: return [4 /*yield*/, _g.next()];
|
|
294
|
-
case 3:
|
|
295
|
-
if (!(_h = _u.sent(), _q = _h.done, !_q)) return [3 /*break*/, 6];
|
|
296
|
-
_s = _h.value;
|
|
297
|
-
_f = false;
|
|
298
|
-
file = _s;
|
|
299
|
-
_k = (_j = data).append;
|
|
300
|
-
_l = [file.fieldname];
|
|
301
|
-
_m = File.bind;
|
|
302
|
-
return [4 /*yield*/, file.toBuffer()];
|
|
303
|
-
case 4:
|
|
304
|
-
_k.apply(_j, _l.concat([new (_m.apply(File, [void 0, [_u.sent()], file.filename, {
|
|
305
|
-
type: file.mimetype,
|
|
306
|
-
}]))()]));
|
|
307
|
-
_u.label = 5;
|
|
308
|
-
case 5:
|
|
309
|
-
_f = true;
|
|
310
|
-
return [3 /*break*/, 2];
|
|
311
|
-
case 6: return [3 /*break*/, 13];
|
|
312
|
-
case 7:
|
|
313
|
-
e_3_1 = _u.sent();
|
|
314
|
-
e_3 = { error: e_3_1 };
|
|
315
|
-
return [3 /*break*/, 13];
|
|
316
|
-
case 8:
|
|
317
|
-
_u.trys.push([8, , 11, 12]);
|
|
318
|
-
if (!(!_f && !_q && (_r = _g.return))) return [3 /*break*/, 10];
|
|
319
|
-
return [4 /*yield*/, _r.call(_g)];
|
|
320
|
-
case 9:
|
|
321
|
-
_u.sent();
|
|
322
|
-
_u.label = 10;
|
|
323
|
-
case 10: return [3 /*break*/, 12];
|
|
324
|
-
case 11:
|
|
325
|
-
if (e_3) throw e_3.error;
|
|
326
|
-
return [7 /*endfinally*/];
|
|
327
|
-
case 12: return [7 /*endfinally*/];
|
|
328
|
-
case 13: return [2 /*return*/, data];
|
|
329
|
-
}
|
|
330
|
-
});
|
|
331
|
-
}); };
|
|
332
|
-
};
|
|
139
|
+
const decodeFastify = (_props) => (socket) => __awaiter(void 0, void 0, void 0, function* () {
|
|
140
|
+
var _a, e_1, _b, _c;
|
|
141
|
+
var _d;
|
|
142
|
+
if (socket.request.files === undefined ||
|
|
143
|
+
typeof socket.request.files !== "function")
|
|
144
|
+
throw new common_1.InternalServerErrorException("Have not configured the `fastify-multipart` plugin yet. Inquiry to the backend developer.");
|
|
145
|
+
const data = new FormData();
|
|
146
|
+
for (const [key, value] of Object.entries((_d = socket.request.body) !== null && _d !== void 0 ? _d : {}))
|
|
147
|
+
for (const elem of String(value).split(","))
|
|
148
|
+
data.append(key, elem);
|
|
149
|
+
try {
|
|
150
|
+
for (var _e = true, _f = __asyncValues(socket.request.files()), _g; _g = yield _f.next(), _a = _g.done, !_a; _e = true) {
|
|
151
|
+
_c = _g.value;
|
|
152
|
+
_e = false;
|
|
153
|
+
const file = _c;
|
|
154
|
+
data.append(file.fieldname, new File([yield file.toBuffer()], file.filename, {
|
|
155
|
+
type: file.mimetype,
|
|
156
|
+
}));
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
160
|
+
finally {
|
|
161
|
+
try {
|
|
162
|
+
if (!_e && !_a && (_b = _f.return)) yield _b.call(_f);
|
|
163
|
+
}
|
|
164
|
+
finally { if (e_1) throw e_1.error; }
|
|
165
|
+
}
|
|
166
|
+
return data;
|
|
167
|
+
});
|
|
333
168
|
/**
|
|
334
169
|
* @internal
|
|
335
170
|
*/
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
349
|
-
finally {
|
|
350
|
-
try {
|
|
351
|
-
if (files_1_1 && !files_1_1.done && (_a = files_1.return)) _a.call(files_1);
|
|
352
|
-
}
|
|
353
|
-
finally { if (e_6) throw e_6.error; }
|
|
354
|
-
}
|
|
355
|
-
else
|
|
356
|
-
try {
|
|
357
|
-
for (var _d = __values(Object.entries(files)), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
358
|
-
var _f = __read(_e.value, 2), key = _f[0], value = _f[1];
|
|
359
|
-
try {
|
|
360
|
-
for (var value_1 = (e_8 = void 0, __values(value)), value_1_1 = value_1.next(); !value_1_1.done; value_1_1 = value_1.next()) {
|
|
361
|
-
var file = value_1_1.value;
|
|
362
|
-
data.append(key, new File([file.buffer], file.originalname, {
|
|
363
|
-
type: file.mimetype,
|
|
364
|
-
}));
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
catch (e_8_1) { e_8 = { error: e_8_1 }; }
|
|
368
|
-
finally {
|
|
369
|
-
try {
|
|
370
|
-
if (value_1_1 && !value_1_1.done && (_c = value_1.return)) _c.call(value_1);
|
|
371
|
-
}
|
|
372
|
-
finally { if (e_8) throw e_8.error; }
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
377
|
-
finally {
|
|
378
|
-
try {
|
|
379
|
-
if (_e && !_e.done && (_b = _d.return)) _b.call(_d);
|
|
380
|
-
}
|
|
381
|
-
finally { if (e_7) throw e_7.error; }
|
|
382
|
-
}
|
|
383
|
-
};
|
|
171
|
+
const parseFiles = (data) => (files) => {
|
|
172
|
+
if (Array.isArray(files))
|
|
173
|
+
for (const file of files)
|
|
174
|
+
data.append(file.fieldname, new File([file.buffer], file.originalname, {
|
|
175
|
+
type: file.mimetype,
|
|
176
|
+
}));
|
|
177
|
+
else
|
|
178
|
+
for (const [key, value] of Object.entries(files))
|
|
179
|
+
for (const file of value)
|
|
180
|
+
data.append(key, new File([file.buffer], file.originalname, {
|
|
181
|
+
type: file.mimetype,
|
|
182
|
+
}));
|
|
384
183
|
};
|
|
385
184
|
/**
|
|
386
185
|
* @internal
|
|
387
186
|
*/
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
.some(function (str) { return str === "multipart/form-data"; });
|
|
394
|
-
};
|
|
187
|
+
const isMultipartFormData = (text) => text !== undefined &&
|
|
188
|
+
text
|
|
189
|
+
.split(";")
|
|
190
|
+
.map((str) => str.trim())
|
|
191
|
+
.some((str) => str === "multipart/form-data");
|
|
395
192
|
/**
|
|
396
193
|
* @internal
|
|
397
194
|
*/
|
|
398
|
-
|
|
195
|
+
const isExpressRequest = (request) => request.app !== undefined;
|
|
399
196
|
/**
|
|
400
197
|
* @internal
|
|
401
198
|
*/
|
|
402
|
-
|
|
199
|
+
const multerApplication = new Singleton_1.Singleton(() => (0, multer_1.default)());
|
|
403
200
|
//# sourceMappingURL=TypedFormData.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypedFormData.js","sourceRoot":"","sources":["../../src/decorators/TypedFormData.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TypedFormData.js","sourceRoot":"","sources":["../../src/decorators/TypedFormData.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AACA,2CAKwB;AAIxB,oDAA4B;AAC5B,kDAA0B;AAG1B,kDAA+C;AAC/C,sFAAmF;AAEnF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,IAAiB,aAAa,CA4C7B;AA5CD,WAAiB,aAAa;IAC5B;;;;;;;;OAQG;IACH,SAAgB,IAAI,CAClB,KAAgC;QAEhC,MAAM,OAAO,GAAG,IAAA,uDAA0B,EAAC,KAAK,CAAC,CAAC;QAClD,MAAM,UAAU,GAAG,CAAC,IAA2B,EAAE,EAAE,CACjD,IAAI,qBAAS,CAAC,GAAG,EAAE,CACjB,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,aAAa,CAAC,KAAM,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,KAAM,CAAC,CACnE,CAAC;QACJ,OAAO,IAAA,6BAAoB,EAAC,SAAe,iBAAiB,CAC1D,QAAa,EACb,OAAyB;;gBAEzB,MAAM,IAAI,GAAsB,OAAO,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CACH,CAAC;;QAEJ,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC;YAC9C,KAAK,MAAM,IAAI,IAAI,KAAK;gBACtB,IAAI,CAAC,MAAM,CACT,GAAG,EACH,IAAI,IAAI,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,YAAY,EAAE;oBACzC,IAAI,EAAE,IAAI,CAAC,QAAQ;iBACpB,CAAC,CACH,CAAC;AACV,CAAC,CAAC;AAEJ;;GAEG;AACH,MAAM,mBAAmB,GAAG,CAAC,IAAa,EAAW,EAAE,CACrD,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,qBAAqB,CAAC,CAAC;AAElD;;GAEG;AACH,MAAM,gBAAgB,GAAG,CACvB,OAAyC,EACb,EAAE,CAAE,OAA2B,CAAC,GAAG,KAAK,SAAS,CAAC;AAEhF;;GAEG;AACH,MAAM,iBAAiB,GAAG,IAAI,qBAAS,CAAC,GAAG,EAAE,CAAC,IAAA,gBAAM,GAAE,CAAC,CAAC"}
|
|
@@ -4,9 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.TypedHeaders = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
const common_1 = require("@nestjs/common");
|
|
8
|
+
const typia_1 = __importDefault(require("typia"));
|
|
9
|
+
const validate_request_headers_1 = require("./internal/validate_request_headers");
|
|
10
10
|
/**
|
|
11
11
|
* Type safe HTTP headers decorator.
|
|
12
12
|
*
|
|
@@ -49,12 +49,12 @@ var validate_request_headers_1 = require("./internal/validate_request_headers");
|
|
|
49
49
|
* @author Jeongho Nam - https://github.com/samchon
|
|
50
50
|
*/
|
|
51
51
|
function TypedHeaders(validator) {
|
|
52
|
-
|
|
52
|
+
const checker = (0, validate_request_headers_1.validate_request_headers)(validator);
|
|
53
53
|
return (0, common_1.createParamDecorator)(function TypedHeaders(_unknown, context) {
|
|
54
|
-
|
|
54
|
+
const request = context
|
|
55
55
|
.switchToHttp()
|
|
56
56
|
.getRequest();
|
|
57
|
-
|
|
57
|
+
const output = checker(request.headers);
|
|
58
58
|
if (output instanceof Error)
|
|
59
59
|
throw output;
|
|
60
60
|
return output;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypedHeaders.js","sourceRoot":"","sources":["../../src/decorators/TypedHeaders.ts"],"names":[],"mappings":";;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"TypedHeaders.js","sourceRoot":"","sources":["../../src/decorators/TypedHeaders.ts"],"names":[],"mappings":";;;;;;AAAA,2CAAwE;AAGxE,kDAA0B;AAG1B,kFAA+E;AAE/E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,SAAgB,YAAY,CAC1B,SAAuC;IAEvC,MAAM,OAAO,GAAG,IAAA,mDAAwB,EAAC,SAAS,CAAC,CAAC;IACpD,OAAO,IAAA,6BAAoB,EAAC,SAAS,YAAY,CAC/C,QAAa,EACb,OAAyB;QAEzB,MAAM,OAAO,GAAqC,OAAO;aACtD,YAAY,EAAE;aACd,UAAU,EAAE,CAAC;QAEhB,MAAM,MAAM,GAAc,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QACnD,IAAI,MAAM,YAAY,KAAK;YAAE,MAAM,MAAM,CAAC;QAC1C,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC,EAAE,CAAC;AACP,CAAC;AAhBD,oCAgBC;AACD,MAAM,CAAC,MAAM,CAAC,YAAY,EAAE,eAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;AACtD,MAAM,CAAC,MAAM,CAAC,YAAY,EAAE,eAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;AAClD,MAAM,CAAC,MAAM,CAAC,YAAY,EAAE,eAAK,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC"}
|
|
@@ -9,12 +9,11 @@
|
|
|
9
9
|
* import { tags } from "typia";
|
|
10
10
|
*
|
|
11
11
|
* \@TypedRoute.Get("shopping/sales/:id/:no/:paused")
|
|
12
|
-
* public async pause
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* ): Promise<void>;
|
|
12
|
+
* public async pause(
|
|
13
|
+
* \@TypedParam("id", "uuid"), id: string & tags.Format<"uuid">,
|
|
14
|
+
* \@TypedParam("no") id: number & tags.Type<"uint32">
|
|
15
|
+
* \@TypedParam("paused") paused: boolean | null
|
|
16
|
+
* ): Promise<void>;
|
|
18
17
|
* ```
|
|
19
18
|
*
|
|
20
19
|
* @param name URL Parameter name
|
|
@@ -4,9 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.TypedParam = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
const common_1 = require("@nestjs/common");
|
|
8
|
+
const typia_1 = __importDefault(require("typia"));
|
|
9
|
+
const NoTransformConfigureError_1 = require("./internal/NoTransformConfigureError");
|
|
10
10
|
/**
|
|
11
11
|
* Type safe URL parameter decorator.
|
|
12
12
|
*
|
|
@@ -18,12 +18,11 @@ var NoTransformConfigureError_1 = require("./internal/NoTransformConfigureError"
|
|
|
18
18
|
* import { tags } from "typia";
|
|
19
19
|
*
|
|
20
20
|
* \@TypedRoute.Get("shopping/sales/:id/:no/:paused")
|
|
21
|
-
* public async pause
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* ): Promise<void>;
|
|
21
|
+
* public async pause(
|
|
22
|
+
* \@TypedParam("id", "uuid"), id: string & tags.Format<"uuid">,
|
|
23
|
+
* \@TypedParam("no") id: number & tags.Type<"uint32">
|
|
24
|
+
* \@TypedParam("paused") paused: boolean | null
|
|
25
|
+
* ): Promise<void>;
|
|
27
26
|
* ```
|
|
28
27
|
*
|
|
29
28
|
* @param name URL Parameter name
|
|
@@ -34,17 +33,17 @@ var NoTransformConfigureError_1 = require("./internal/NoTransformConfigureError"
|
|
|
34
33
|
function TypedParam(name, assert) {
|
|
35
34
|
if (assert === undefined)
|
|
36
35
|
throw (0, NoTransformConfigureError_1.NoTransformConfigureError)("TypedParam");
|
|
37
|
-
return (0, common_1.createParamDecorator)(function TypedParam(
|
|
38
|
-
|
|
36
|
+
return (0, common_1.createParamDecorator)(function TypedParam({}, context) {
|
|
37
|
+
const request = context
|
|
39
38
|
.switchToHttp()
|
|
40
39
|
.getRequest();
|
|
41
|
-
|
|
40
|
+
const str = request.params[name];
|
|
42
41
|
try {
|
|
43
42
|
return assert(str);
|
|
44
43
|
}
|
|
45
44
|
catch (exp) {
|
|
46
|
-
if ((
|
|
47
|
-
|
|
45
|
+
if ((input => {
|
|
46
|
+
const $io0 = input => "string" === typeof input.method && (undefined === input.path || "string" === typeof input.path) && "string" === typeof input.expected && true && "string" === typeof input.name && "string" === typeof input.message && (undefined === input.stack || "string" === typeof input.stack);
|
|
48
47
|
return "object" === typeof input && null !== input && $io0(input);
|
|
49
48
|
})(exp))
|
|
50
49
|
throw new common_1.BadRequestException({
|
|
@@ -52,7 +51,7 @@ function TypedParam(name, assert) {
|
|
|
52
51
|
reason: exp.message,
|
|
53
52
|
expected: exp.expected,
|
|
54
53
|
value: exp.value,
|
|
55
|
-
message:
|
|
54
|
+
message: `Invalid URL parameter value on "${name}".`,
|
|
56
55
|
});
|
|
57
56
|
throw exp;
|
|
58
57
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypedParam.js","sourceRoot":"","sources":["../../src/decorators/TypedParam.ts"],"names":[],"mappings":";;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"TypedParam.js","sourceRoot":"","sources":["../../src/decorators/TypedParam.ts"],"names":[],"mappings":";;;;;;AAAA,2CAIwB;AAGxB,kDAA8C;AAE9C,oFAAiF;AAEjF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,SAAgB,UAAU,CACxB,IAAY,EACZ,MAA6B;IAE7B,IAAI,MAAM,KAAK,SAAS;QAAE,MAAM,IAAA,qDAAyB,EAAC,YAAY,CAAC,CAAC;IAExE,OAAO,IAAA,6BAAoB,EAAC,SAAS,UAAU,CAC7C,EAAO,EACP,OAAyB;QAEzB,MAAM,OAAO,GAAqC,OAAO;aACtD,YAAY,EAAE;aACd,UAAU,EAAE,CAAC;QAChB,MAAM,GAAG,GAAY,OAAO,CAAC,MAAc,CAAC,IAAI,CAAC,CAAC;QAClD,IAAI,CAAC;YACH,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;QACrB,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb;;;eAA6B,GAAG;gBAC9B,MAAM,IAAI,4BAAmB,CAAC;oBAC5B,IAAI,EAAE,GAAG,CAAC,IAAI;oBACd,MAAM,EAAE,GAAG,CAAC,OAAO;oBACnB,QAAQ,EAAE,GAAG,CAAC,QAAQ;oBACtB,KAAK,EAAE,GAAG,CAAC,KAAK;oBAChB,OAAO,EAAE,mCAAmC,IAAI,IAAI;iBACrD,CAAC,CAAC;YACL,MAAM,GAAG,CAAC;QACZ,CAAC;IACH,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AACX,CAAC;AA5BD,gCA4BC;AACD,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,eAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC"}
|
|
@@ -7,8 +7,8 @@ import { IResponseBodyQuerifier } from "../options/IResponseBodyQuerifier";
|
|
|
7
7
|
* same with {@link nest.Query}, but it can automatically cast property type following
|
|
8
8
|
* its DTO definition. Also, `TypedQuery` performs type validation.
|
|
9
9
|
*
|
|
10
|
-
* For reference, target type `T` must follow such restriction. Also, if
|
|
11
|
-
* query parameter values are different with their promised type `T`,
|
|
10
|
+
* For reference, target type `T` must follow such restriction. Also, if
|
|
11
|
+
* actual URL query parameter values are different with their promised type `T`,
|
|
12
12
|
* `BadRequestException` error (status code: 400) would be thrown.
|
|
13
13
|
*
|
|
14
14
|
* 1. Type `T` must be an object type
|