@nestia/core 1.0.6 → 1.0.7

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 CHANGED
@@ -67,12 +67,15 @@ npx ttsc
67
67
  npx ts-node -C ttypescript src/index.ts
68
68
  ```
69
69
 
70
- Also, you can specify package manager by `--manage` argument like below:
70
+ Also, you can specify package manager or target `tsconfig.json` file like below:
71
71
 
72
72
  ```bash
73
73
  npx @nestia/core setup --manager npm
74
74
  npx @nestia/core setup --manager pnpm
75
75
  npx @nestia/core setup --manager yarn
76
+
77
+ npx @nestia/core setup --project tsconfig.json
78
+ npx @nestia/core setup --project tsconfig.test.json
76
79
  ```
77
80
 
78
81
  ### Manual Setup
@@ -65,7 +65,7 @@ function TypedBody(validator) {
65
65
  switch (_d.label) {
66
66
  case 0:
67
67
  request = context.switchToHttp().getRequest();
68
- if (request.headers["content-type"] !== "application/json") {
68
+ if (isApplicationJson(request.headers["content-type"]) === false) {
69
69
  throw new common_1.BadRequestException("Request body is not the application/json.");
70
70
  }
71
71
  if (!request.body) return [3 /*break*/, 1];
@@ -90,4 +90,11 @@ exports.TypedBody = TypedBody;
90
90
  Object.assign(TypedBody, typia_1.assert);
91
91
  Object.assign(TypedBody, typia_1.is);
92
92
  Object.assign(TypedBody, typia_1.validate);
93
+ var isApplicationJson = function (text) {
94
+ return text !== undefined &&
95
+ text
96
+ .split(";")
97
+ .map(function (str) { return str.trim(); })
98
+ .some(function (str) { return str === "application/json"; });
99
+ };
93
100
  //# sourceMappingURL=TypedBody.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"TypedBody.js","sourceRoot":"","sources":["../../src/decorators/TypedBody.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAIwB;AAExB,sDAA2B;AAC3B,+BAA6C;AAG7C,0EAAyE;AAEzE;;;;;;;;;;;GAWG;AACH,SAAgB,SAAS,CACrB,SAAoC;IA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package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nestia/core",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "Super-fast validation decorators of NestJS",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
@@ -31,7 +31,7 @@ export function TypedBody<T>(
31
31
  context: ExecutionContext,
32
32
  ) {
33
33
  const request: express.Request = context.switchToHttp().getRequest();
34
- if (request.headers["content-type"] !== "application/json") {
34
+ if (isApplicationJson(request.headers["content-type"]) === false) {
35
35
  throw new BadRequestException(
36
36
  "Request body is not the application/json.",
37
37
  );
@@ -47,3 +47,10 @@ export function TypedBody<T>(
47
47
  Object.assign(TypedBody, assert);
48
48
  Object.assign(TypedBody, is);
49
49
  Object.assign(TypedBody, validate);
50
+
51
+ const isApplicationJson = (text?: string) =>
52
+ text !== undefined &&
53
+ text
54
+ .split(";")
55
+ .map((str) => str.trim())
56
+ .some((str) => str === "application/json");