@nestia/core 4.0.0-dev.20241022 → 4.0.0-dev.20241027
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/README.md +2 -2
- package/lib/adaptors/WebSocketAdaptor.js +1 -1
- package/lib/decorators/PlainBody.js +5 -1
- package/lib/decorators/PlainBody.js.map +1 -1
- package/lib/decorators/TypedBody.js +4 -1
- package/lib/decorators/TypedBody.js.map +1 -1
- package/lib/decorators/TypedParam.js +1 -1
- package/lib/decorators/internal/get_path_and_querify.js +1 -1
- package/lib/decorators/internal/get_path_and_stringify.js +1 -1
- package/lib/decorators/internal/is_request_body_undefined.d.ts +1 -0
- package/lib/decorators/internal/is_request_body_undefined.js +13 -0
- package/lib/decorators/internal/is_request_body_undefined.js.map +1 -0
- package/lib/decorators/internal/validate_request_body.js +1 -1
- package/lib/decorators/internal/validate_request_form_data.js +1 -1
- package/lib/decorators/internal/validate_request_headers.js +1 -1
- package/lib/decorators/internal/validate_request_query.js +1 -1
- package/lib/programmers/PlainBodyProgrammer.js +0 -2
- package/lib/programmers/PlainBodyProgrammer.js.map +1 -1
- package/lib/programmers/http/HttpQuerifyProgrammer.js +1 -1
- package/lib/programmers/http/HttpQuerifyProgrammer.js.map +1 -1
- package/package.json +6 -6
- package/src/decorators/PlainBody.ts +7 -1
- package/src/decorators/TypedBody.ts +4 -1
- package/src/decorators/internal/is_request_body_undefined.ts +14 -0
- package/src/programmers/PlainBodyProgrammer.ts +0 -1
- package/src/programmers/http/HttpQuerifyProgrammer.ts +1 -1
package/README.md
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|

|
|
3
3
|
|
|
4
4
|
[](https://github.com/samchon/nestia/blob/master/LICENSE)
|
|
5
|
-
[](https://www.npmjs.com/package/@nestia/fetcher)
|
|
6
|
+
[](https://www.npmjs.com/package/@nestia/fetcher)
|
|
7
7
|
[](https://github.com/samchon/nestia/actions?query=workflow%3Abuild)
|
|
8
8
|
[](https://nestia.io/docs/)
|
|
9
9
|
[](https://discord.com/channels/520622812742811698/1181877086797967420)
|
|
@@ -175,7 +175,7 @@ const visitController = (props) => __awaiter(void 0, void 0, void 0, function* (
|
|
|
175
175
|
const visitMethod = (props) => {
|
|
176
176
|
var _a, _b, _c;
|
|
177
177
|
const route = Reflect.getMetadata("nestia/WebSocketRoute", props.method.value);
|
|
178
|
-
if ((() => { const
|
|
178
|
+
if ((() => { const _io0 = input => Array.isArray(input.paths) && input.paths.every(elem => "string" === typeof elem); return input => "object" === typeof input && null !== input && _io0(input); })()(route) === false)
|
|
179
179
|
return;
|
|
180
180
|
const parameters = ((_a = Reflect.getMetadata("nestia/WebSocketRoute/Parameters", props.controller.prototype, props.method.key)) !== null && _a !== void 0 ? _a : []).sort((a, b) => a.index - b.index);
|
|
181
181
|
// acceptor must be
|
|
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.PlainBody = PlainBody;
|
|
13
13
|
const common_1 = require("@nestjs/common");
|
|
14
14
|
const get_text_body_1 = require("./internal/get_text_body");
|
|
15
|
+
const is_request_body_undefined_1 = require("./internal/is_request_body_undefined");
|
|
15
16
|
const validate_request_body_1 = require("./internal/validate_request_body");
|
|
16
17
|
/**
|
|
17
18
|
* @internal
|
|
@@ -28,7 +29,10 @@ function PlainBody(assert) {
|
|
|
28
29
|
const request = context
|
|
29
30
|
.switchToHttp()
|
|
30
31
|
.getRequest();
|
|
31
|
-
if (
|
|
32
|
+
if ((0, is_request_body_undefined_1.is_request_body_undefined)(request) &&
|
|
33
|
+
(checker !== null && checker !== void 0 ? checker : (() => null))(undefined) === null)
|
|
34
|
+
return undefined;
|
|
35
|
+
else if (!isTextPlain(request.headers["content-type"]))
|
|
32
36
|
throw new common_1.BadRequestException(`Request body type is not "text/plain".`);
|
|
33
37
|
const value = yield (0, get_text_body_1.get_text_body)(request);
|
|
34
38
|
if (checker) {
|
|
@@ -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":";;;;;;;;;;;AAsCA,8BA8BC;AApED,2CAIwB;AAIxB,4DAAyD;AACzD,oFAAiF;AACjF,4EAAyE;AAyBzE;;GAEG;AACH,SAAgB,SAAS,CACvB,MAAmC;IAEnC,MAAM,OAAO,GAAG,MAAM;QACpB,CAAC,CAAC,IAAA,6CAAqB,EAAC,WAAW,CAAC,CAAC;YACjC,IAAI,EAAE,QAAQ;YACd,MAAM;SACP,CAAC;QACJ,CAAC,CAAC,IAAI,CAAC;IACT,OAAO,IAAA,6BAAoB,EAAC,SAAe,SAAS,CAClD,KAAU,EACV,OAAyB;;YAEzB,MAAM,OAAO,GAAqC,OAAO;iBACtD,YAAY,EAAE;iBACd,UAAU,EAAE,CAAC;YAChB,IACE,IAAA,qDAAyB,EAAC,OAAO,CAAC;gBAClC,CAAC,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,SAAgB,CAAC,KAAK,IAAI;gBAEpD,OAAO,SAAS,CAAC;iBACd,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;gBACpD,MAAM,IAAI,4BAAmB,CAAC,wCAAwC,CAAC,CAAC;YAC1E,MAAM,KAAK,GAAW,MAAM,IAAA,6BAAa,EAAC,OAAO,CAAC,CAAC;YACnD,IAAI,OAAO,EAAE,CAAC;gBACZ,MAAM,KAAK,GAAiB,OAAO,CAAC,KAAK,CAAC,CAAC;gBAC3C,IAAI,KAAK,KAAK,IAAI;oBAAE,MAAM,KAAK,CAAC;YAClC,CAAC;YACD,OAAO,KAAK,CAAC;QACf,CAAC;KAAA,CAAC,EAAE,CAAC;AACP,CAAC;AAED;;GAEG;AACH,MAAM,WAAW,GAAG,CAAC,IAAa,EAAW,EAAE,CAC7C,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,YAAY,CAAC,CAAC"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TypedBody = TypedBody;
|
|
4
4
|
const common_1 = require("@nestjs/common");
|
|
5
|
+
const is_request_body_undefined_1 = require("./internal/is_request_body_undefined");
|
|
5
6
|
const validate_request_body_1 = require("./internal/validate_request_body");
|
|
6
7
|
/**
|
|
7
8
|
* Type safe body decorator.
|
|
@@ -23,7 +24,9 @@ function TypedBody(validator) {
|
|
|
23
24
|
const request = context
|
|
24
25
|
.switchToHttp()
|
|
25
26
|
.getRequest();
|
|
26
|
-
if (
|
|
27
|
+
if ((0, is_request_body_undefined_1.is_request_body_undefined)(request) && checker(undefined) === null)
|
|
28
|
+
return undefined;
|
|
29
|
+
else if (isApplicationJson(request.headers["content-type"]) === false)
|
|
27
30
|
throw new common_1.BadRequestException(`Request body type is not "application/json".`);
|
|
28
31
|
const error = checker(request.body);
|
|
29
32
|
if (error !== null)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypedBody.js","sourceRoot":"","sources":["../../src/decorators/TypedBody.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"TypedBody.js","sourceRoot":"","sources":["../../src/decorators/TypedBody.ts"],"names":[],"mappings":";;AA0BA,8BAsBC;AAhDD,2CAIwB;AAKxB,oFAAiF;AACjF,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,IAAA,qDAAyB,EAAC,OAAO,CAAC,IAAI,OAAO,CAAC,SAAc,CAAC,KAAK,IAAI;YACxE,OAAO,SAAS,CAAC;aACd,IAAI,iBAAiB,CAAC,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,KAAK,KAAK;YACnE,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;AAED;;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"}
|
|
@@ -44,7 +44,7 @@ function TypedParam(name, assert) {
|
|
|
44
44
|
return assert(str);
|
|
45
45
|
}
|
|
46
46
|
catch (exp) {
|
|
47
|
-
if ((() => { const
|
|
47
|
+
if ((() => { const _io0 = input => "string" === typeof input.method && (undefined === input.path || "string" === typeof input.path) && "string" === typeof input.expected && true && true && "string" === typeof input.name && "string" === typeof input.message && (undefined === input.stack || "string" === typeof input.stack); return input => "object" === typeof input && null !== input && _io0(input); })()(exp))
|
|
48
48
|
throw new common_1.BadRequestException({
|
|
49
49
|
path: exp.path,
|
|
50
50
|
reason: exp.message,
|
|
@@ -63,7 +63,7 @@ const assert = (closure) => (data) => {
|
|
|
63
63
|
return closure(data);
|
|
64
64
|
}
|
|
65
65
|
catch (exp) {
|
|
66
|
-
if ((() => { const
|
|
66
|
+
if ((() => { const _io0 = input => "string" === typeof input.method && (undefined === input.path || "string" === typeof input.path) && "string" === typeof input.expected && true && true && "string" === typeof input.name && "string" === typeof input.message && (undefined === input.stack || "string" === typeof input.stack); return input => "object" === typeof input && null !== input && _io0(input); })()(exp))
|
|
67
67
|
throw new common_1.InternalServerErrorException({
|
|
68
68
|
path: exp.path,
|
|
69
69
|
reason: exp.message,
|
|
@@ -50,7 +50,7 @@ const assert = (closure) => (data) => {
|
|
|
50
50
|
return closure(data);
|
|
51
51
|
}
|
|
52
52
|
catch (exp) {
|
|
53
|
-
if ((() => { const
|
|
53
|
+
if ((() => { const _io0 = input => "string" === typeof input.method && (undefined === input.path || "string" === typeof input.path) && "string" === typeof input.expected && true && true && "string" === typeof input.name && "string" === typeof input.message && (undefined === input.stack || "string" === typeof input.stack); return input => "object" === typeof input && null !== input && _io0(input); })()(exp))
|
|
54
54
|
throw new common_1.InternalServerErrorException({
|
|
55
55
|
path: exp.path,
|
|
56
56
|
reason: exp.message,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.is_request_body_undefined = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
const is_request_body_undefined = (request) => request.headers["content-type"] === undefined &&
|
|
8
|
+
(request.body === undefined ||
|
|
9
|
+
(typeof request.body === "object" &&
|
|
10
|
+
request.body !== null &&
|
|
11
|
+
Object.keys(request.body).length === 0));
|
|
12
|
+
exports.is_request_body_undefined = is_request_body_undefined;
|
|
13
|
+
//# sourceMappingURL=is_request_body_undefined.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is_request_body_undefined.js","sourceRoot":"","sources":["../../../src/decorators/internal/is_request_body_undefined.ts"],"names":[],"mappings":";;;AAGA;;GAEG;AACI,MAAM,yBAAyB,GAAG,CACvC,OAAyC,EAChC,EAAE,CACX,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC,KAAK,SAAS;IAC7C,CAAC,OAAO,CAAC,IAAI,KAAK,SAAS;QACzB,CAAC,OAAO,OAAO,CAAC,IAAI,KAAK,QAAQ;YAC/B,OAAO,CAAC,IAAI,KAAK,IAAI;YACrB,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC;AAPlC,QAAA,yBAAyB,6BAOS"}
|
|
@@ -33,7 +33,7 @@ const assert = (closure) => (input) => {
|
|
|
33
33
|
return null;
|
|
34
34
|
}
|
|
35
35
|
catch (exp) {
|
|
36
|
-
if ((() => { const
|
|
36
|
+
if ((() => { const _io0 = input => "string" === typeof input.method && (undefined === input.path || "string" === typeof input.path) && "string" === typeof input.expected && true && true && "string" === typeof input.name && "string" === typeof input.message && (undefined === input.stack || "string" === typeof input.stack); return input => "object" === typeof input && null !== input && _io0(input); })()(exp)) {
|
|
37
37
|
return new common_1.BadRequestException({
|
|
38
38
|
path: exp.path,
|
|
39
39
|
reason: exp.message,
|
|
@@ -32,7 +32,7 @@ const assert = (closure) => (input) => {
|
|
|
32
32
|
return closure(input);
|
|
33
33
|
}
|
|
34
34
|
catch (exp) {
|
|
35
|
-
if ((() => { const
|
|
35
|
+
if ((() => { const _io0 = input => "string" === typeof input.method && (undefined === input.path || "string" === typeof input.path) && "string" === typeof input.expected && true && true && "string" === typeof input.name && "string" === typeof input.message && (undefined === input.stack || "string" === typeof input.stack); return input => "object" === typeof input && null !== input && _io0(input); })()(exp)) {
|
|
36
36
|
return new common_1.BadRequestException({
|
|
37
37
|
path: exp.path,
|
|
38
38
|
reason: exp.message,
|
|
@@ -32,7 +32,7 @@ const assert = (closure) => (input) => {
|
|
|
32
32
|
return closure(input);
|
|
33
33
|
}
|
|
34
34
|
catch (exp) {
|
|
35
|
-
if ((() => { const
|
|
35
|
+
if ((() => { const _io0 = input => "string" === typeof input.method && (undefined === input.path || "string" === typeof input.path) && "string" === typeof input.expected && true && true && "string" === typeof input.name && "string" === typeof input.message && (undefined === input.stack || "string" === typeof input.stack); return input => "object" === typeof input && null !== input && _io0(input); })()(exp)) {
|
|
36
36
|
return new common_1.BadRequestException({
|
|
37
37
|
path: exp.path,
|
|
38
38
|
reason: exp.message,
|
|
@@ -32,7 +32,7 @@ const assert = (closure) => (input) => {
|
|
|
32
32
|
return closure(input);
|
|
33
33
|
}
|
|
34
34
|
catch (exp) {
|
|
35
|
-
if ((() => { const
|
|
35
|
+
if ((() => { const _io0 = input => "string" === typeof input.method && (undefined === input.path || "string" === typeof input.path) && "string" === typeof input.expected && true && true && "string" === typeof input.name && "string" === typeof input.message && (undefined === input.stack || "string" === typeof input.stack); return input => "object" === typeof input && null !== input && _io0(input); })()(exp)) {
|
|
36
36
|
return new common_1.BadRequestException({
|
|
37
37
|
path: exp.path,
|
|
38
38
|
reason: exp.message,
|
|
@@ -52,8 +52,6 @@ const validate = (metadata) => {
|
|
|
52
52
|
.reduce((a, b) => a + b, 0);
|
|
53
53
|
if (expected === 0 || expected !== metadata.size())
|
|
54
54
|
insert(`only string type is allowed`);
|
|
55
|
-
if (metadata.isRequired() === false)
|
|
56
|
-
insert(`do not allow undefindable type`);
|
|
57
55
|
if (metadata.nullable === true)
|
|
58
56
|
insert(`do not allow nullable type`);
|
|
59
57
|
else if (metadata.any === true)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlainBodyProgrammer.js","sourceRoot":"","sources":["../../src/programmers/PlainBodyProgrammer.ts"],"names":[],"mappings":";;;AACA,+EAA4E;AAC5E,yEAAsE;AACtE,6EAA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AC,CAAC,MAAM,CAAC,MAAM,CAAC;aAC3B,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;IAChC,IAAI,QAAQ,KAAK,CAAC,IAAI,QAAQ,KAAK,QAAQ,CAAC,IAAI,EAAE;QAChD,MAAM,CAAC,6BAA6B,CAAC,CAAC;IACxC,IAAI,QAAQ,CAAC,QAAQ,KAAK,IAAI;QAAE,MAAM,CAAC,4BAA4B,CAAC,CAAC;SAChE,IAAI,QAAQ,CAAC,GAAG,KAAK,IAAI;QAAE,MAAM,CAAC,uBAAuB,CAAC,CAAC;IAEhE,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC"}
|
|
@@ -32,7 +32,7 @@ var HttpQuerifyProgrammer;
|
|
|
32
32
|
});
|
|
33
33
|
if (result.success === false)
|
|
34
34
|
throw TransformerError_1.TransformerError.from({
|
|
35
|
-
code:
|
|
35
|
+
code: functor.method,
|
|
36
36
|
errors: result.errors,
|
|
37
37
|
});
|
|
38
38
|
const object = result.data.objects[0];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpQuerifyProgrammer.js","sourceRoot":"","sources":["../../../src/programmers/http/HttpQuerifyProgrammer.ts"],"names":[],"mappings":";;;;;;AAAA,4DAA4B;AAC5B,6EAA0E;AAC1E,+EAA4E;AAC5E,yEAAsE;AACtE,2EAAwE;AACxE,yFAAsF;AACtF,wFAAqF;AAIrF,8EAA2E;AAE3E,IAAiB,qBAAqB,CA+FrC;AA/FD,WAAiB,qBAAqB;IACvB,2BAAK,GAAG,CAAC,KAIrB,EAAoB,EAAE;QACrB,kBAAkB;QAClB,MAAM,OAAO,GAAuB,IAAI,uCAAkB,CACxD,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,CACvB,CAAC;QACF,MAAM,UAAU,GAAuB,IAAI,uCAAkB,EAAE,CAAC;QAChE,MAAM,MAAM,GAAG,iCAAe,CAAC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,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM;QACnB,CAAC,CAAC,oBAAE,CAAC,OAAO,CAAC,oBAAoB,CAC7B,qCAAiB,CAAC,MAAM,CACtB,qCAAiB,CAAC,MAAM,CACtB,oBAAE,CAAC,OAAO,CAAC,gBAAgB,CAAC,OAAO,CAAC,EACpC,GAAG,CACJ,EACD,SAAS,CACV,EACD,SAAS,EACT;YACE,oBAAE,CAAC,OAAO,CAAC,mBAAmB,CAC5B,SAAS,EACT,SAAS,EACT,CAAC,qCAAiB,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,EACrC,SAAS,EACT,SAAS,EACT,MAAM,CAAC,GAAG,CAAC,CAAC,oBAAE,CAAC,OAAO,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,CACjD;SACF,CACF;QACH,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CACT,qCAAiB,CAAC,MAAM,CAAC,oBAAE,CAAC,OAAO,CAAC,gBAAgB,CAAC,OAAO,CAAC,EAAE,GAAG,CAAC,CACpE,CAAC;IAEV,MAAM,MAAM,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,CAAC,IAAmB,EAAE,EAAE,CACtD,oBAAE,CAAC,OAAO,CAAC,oBAAoB,CAC7B,qCAAiB,CAAC,MAAM,CAAC,oBAAE,CAAC,OAAO,CAAC,gBAAgB,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC,EACzE,SAAS,EACT,CAAC,oBAAE,CAAC,OAAO,CAAC,mBAAmB,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,CAC5C,CAAC;AACN,CAAC,EA/FgB,qBAAqB,qCAArB,qBAAqB,QA+FrC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nestia/core",
|
|
3
|
-
"version": "4.0.0-dev.
|
|
3
|
+
"version": "4.0.0-dev.20241027",
|
|
4
4
|
"description": "Super-fast validation decorators of NestJS",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
@@ -36,10 +36,10 @@
|
|
|
36
36
|
},
|
|
37
37
|
"homepage": "https://nestia.io",
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@nestia/fetcher": "^4.0.0-dev.
|
|
39
|
+
"@nestia/fetcher": "^4.0.0-dev.20241027",
|
|
40
40
|
"@nestjs/common": ">=7.0.1",
|
|
41
41
|
"@nestjs/core": ">=7.0.1",
|
|
42
|
-
"@samchon/openapi": "^
|
|
42
|
+
"@samchon/openapi": "^2.0.0-dev.20241127-2",
|
|
43
43
|
"detect-ts-node": "^1.0.5",
|
|
44
44
|
"get-function-location": "^2.0.0",
|
|
45
45
|
"glob": "^7.2.0",
|
|
@@ -49,16 +49,16 @@
|
|
|
49
49
|
"reflect-metadata": ">=0.1.12",
|
|
50
50
|
"rxjs": ">=6.0.3",
|
|
51
51
|
"tgrid": "^1.0.0",
|
|
52
|
-
"typia": "^7.0.0-dev.
|
|
52
|
+
"typia": "^7.0.0-dev.20241027-2",
|
|
53
53
|
"ws": "^7.5.3"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@nestia/fetcher": ">=4.0.0-dev.
|
|
56
|
+
"@nestia/fetcher": ">=4.0.0-dev.20241027",
|
|
57
57
|
"@nestjs/common": ">=7.0.1",
|
|
58
58
|
"@nestjs/core": ">=7.0.1",
|
|
59
59
|
"reflect-metadata": ">=0.1.12",
|
|
60
60
|
"rxjs": ">=6.0.3",
|
|
61
|
-
"typia": ">=7.0.0-dev.
|
|
61
|
+
"typia": ">=7.0.0-dev.20241027-2 <8.0.0"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
64
|
"@fastify/multipart": "^8.1.0",
|
|
@@ -7,6 +7,7 @@ import type express from "express";
|
|
|
7
7
|
import type { FastifyRequest } from "fastify";
|
|
8
8
|
|
|
9
9
|
import { get_text_body } from "./internal/get_text_body";
|
|
10
|
+
import { is_request_body_undefined } from "./internal/is_request_body_undefined";
|
|
10
11
|
import { validate_request_body } from "./internal/validate_request_body";
|
|
11
12
|
|
|
12
13
|
/**
|
|
@@ -51,7 +52,12 @@ export function PlainBody(
|
|
|
51
52
|
const request: express.Request | FastifyRequest = context
|
|
52
53
|
.switchToHttp()
|
|
53
54
|
.getRequest();
|
|
54
|
-
if (
|
|
55
|
+
if (
|
|
56
|
+
is_request_body_undefined(request) &&
|
|
57
|
+
(checker ?? (() => null))(undefined as any) === null
|
|
58
|
+
)
|
|
59
|
+
return undefined;
|
|
60
|
+
else if (!isTextPlain(request.headers["content-type"]))
|
|
55
61
|
throw new BadRequestException(`Request body type is not "text/plain".`);
|
|
56
62
|
const value: string = await get_text_body(request);
|
|
57
63
|
if (checker) {
|
|
@@ -7,6 +7,7 @@ import type express from "express";
|
|
|
7
7
|
import type { FastifyRequest } from "fastify";
|
|
8
8
|
|
|
9
9
|
import { IRequestBodyValidator } from "../options/IRequestBodyValidator";
|
|
10
|
+
import { is_request_body_undefined } from "./internal/is_request_body_undefined";
|
|
10
11
|
import { validate_request_body } from "./internal/validate_request_body";
|
|
11
12
|
|
|
12
13
|
/**
|
|
@@ -34,7 +35,9 @@ export function TypedBody<T>(
|
|
|
34
35
|
const request: express.Request | FastifyRequest = context
|
|
35
36
|
.switchToHttp()
|
|
36
37
|
.getRequest();
|
|
37
|
-
if (
|
|
38
|
+
if (is_request_body_undefined(request) && checker(undefined as T) === null)
|
|
39
|
+
return undefined;
|
|
40
|
+
else if (isApplicationJson(request.headers["content-type"]) === false)
|
|
38
41
|
throw new BadRequestException(
|
|
39
42
|
`Request body type is not "application/json".`,
|
|
40
43
|
);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type express from "express";
|
|
2
|
+
import type { FastifyRequest } from "fastify";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
export const is_request_body_undefined = (
|
|
8
|
+
request: express.Request | FastifyRequest,
|
|
9
|
+
): boolean =>
|
|
10
|
+
request.headers["content-type"] === undefined &&
|
|
11
|
+
(request.body === undefined ||
|
|
12
|
+
(typeof request.body === "object" &&
|
|
13
|
+
request.body !== null &&
|
|
14
|
+
Object.keys(request.body).length === 0));
|
|
@@ -63,7 +63,6 @@ const validate = (metadata: Metadata): string[] => {
|
|
|
63
63
|
.reduce((a, b) => a + b, 0);
|
|
64
64
|
if (expected === 0 || expected !== metadata.size())
|
|
65
65
|
insert(`only string type is allowed`);
|
|
66
|
-
if (metadata.isRequired() === false) insert(`do not allow undefindable type`);
|
|
67
66
|
if (metadata.nullable === true) insert(`do not allow nullable type`);
|
|
68
67
|
else if (metadata.any === true) insert(`do not allow any type`);
|
|
69
68
|
|