@kaito-http/core 2.3.6 → 2.3.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.
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var http = require('http');
|
|
6
6
|
var fmw = require('find-my-way');
|
|
7
7
|
var tls = require('tls');
|
|
8
|
+
var contentType = require('content-type');
|
|
8
9
|
var getRawBody = require('raw-body');
|
|
9
10
|
|
|
10
11
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
@@ -187,7 +188,15 @@ function _getInput() {
|
|
|
187
188
|
|
|
188
189
|
var buffer = yield getRawBody__default["default"](req.raw);
|
|
189
190
|
|
|
190
|
-
|
|
191
|
+
if (!req.headers['content-type']) {
|
|
192
|
+
return null;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
var {
|
|
196
|
+
type
|
|
197
|
+
} = contentType.parse(req.headers['content-type']);
|
|
198
|
+
|
|
199
|
+
switch (type) {
|
|
191
200
|
case 'application/json':
|
|
192
201
|
{
|
|
193
202
|
return JSON.parse(buffer.toString());
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var http = require('http');
|
|
6
6
|
var fmw = require('find-my-way');
|
|
7
7
|
var tls = require('tls');
|
|
8
|
+
var contentType = require('content-type');
|
|
8
9
|
var getRawBody = require('raw-body');
|
|
9
10
|
|
|
10
11
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
@@ -187,7 +188,15 @@ function _getInput() {
|
|
|
187
188
|
|
|
188
189
|
var buffer = yield getRawBody__default["default"](req.raw);
|
|
189
190
|
|
|
190
|
-
|
|
191
|
+
if (!req.headers['content-type']) {
|
|
192
|
+
return null;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
var {
|
|
196
|
+
type
|
|
197
|
+
} = contentType.parse(req.headers['content-type']);
|
|
198
|
+
|
|
199
|
+
switch (type) {
|
|
191
200
|
case 'application/json':
|
|
192
201
|
{
|
|
193
202
|
return JSON.parse(buffer.toString());
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as http from 'http';
|
|
2
2
|
import fmw from 'find-my-way';
|
|
3
3
|
import { TLSSocket } from 'tls';
|
|
4
|
+
import { parse } from 'content-type';
|
|
4
5
|
import getRawBody from 'raw-body';
|
|
5
6
|
|
|
6
7
|
function createFMWServer(config) {
|
|
@@ -159,7 +160,15 @@ function _getInput() {
|
|
|
159
160
|
|
|
160
161
|
var buffer = yield getRawBody(req.raw);
|
|
161
162
|
|
|
162
|
-
|
|
163
|
+
if (!req.headers['content-type']) {
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
var {
|
|
168
|
+
type
|
|
169
|
+
} = parse(req.headers['content-type']);
|
|
170
|
+
|
|
171
|
+
switch (type) {
|
|
163
172
|
case 'application/json':
|
|
164
173
|
{
|
|
165
174
|
return JSON.parse(buffer.toString());
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kaito-http/core",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.7",
|
|
4
4
|
"description": "Functional HTTP Framework for TypeScript",
|
|
5
5
|
"repository": "https://github.com/kaito-http/kaito",
|
|
6
6
|
"author": "Alistair Smith <hi@alistair.sh>",
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
"module": "dist/kaito-http-core.esm.js",
|
|
10
10
|
"types": "dist/kaito-http-core.cjs.d.ts",
|
|
11
11
|
"devDependencies": {
|
|
12
|
+
"@types/content-type": "^1.1.5",
|
|
12
13
|
"@types/node": "^17.0.25",
|
|
13
14
|
"typescript": "4.6",
|
|
14
15
|
"zod": "^3.14.4"
|
|
@@ -31,6 +32,7 @@
|
|
|
31
32
|
"framework"
|
|
32
33
|
],
|
|
33
34
|
"dependencies": {
|
|
35
|
+
"content-type": "^1.0.4",
|
|
34
36
|
"find-my-way": "^5.5.0",
|
|
35
37
|
"raw-body": "^2.5.1"
|
|
36
38
|
}
|