@aeriajs/node-http 0.0.62 → 0.0.63
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/dist/driver.js +18 -3
- package/dist/driver.mjs +17 -3
- package/package.json +2 -2
package/dist/driver.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.registerServer = exports.abstractResponse = exports.abstractRequest = void 0;
|
|
4
|
+
const types_1 = require("@aeriajs/types");
|
|
5
|
+
const common_1 = require("@aeriajs/common");
|
|
4
6
|
const http = require("http");
|
|
5
7
|
const url_1 = require("url");
|
|
6
8
|
const getBody = async ($req) => {
|
|
@@ -37,9 +39,22 @@ const abstractResponse = (response) => {
|
|
|
37
39
|
end: (value) => {
|
|
38
40
|
if (typeof value === 'object' && !(value instanceof Buffer)) {
|
|
39
41
|
if (!response.headersSent) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
if ((0, common_1.isError)(value)) {
|
|
43
|
+
const error = (0, common_1.unwrapError)(value);
|
|
44
|
+
if (error.httpStatus) {
|
|
45
|
+
response.writeHead(error.httpStatus, {
|
|
46
|
+
'content-type': 'application/json',
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
Object.assign(value, {
|
|
50
|
+
[types_1.ERROR_SYMBOL_DESCRIPTION]: true,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
response.writeHead(200, {
|
|
55
|
+
'content-type': 'application/json',
|
|
56
|
+
});
|
|
57
|
+
}
|
|
43
58
|
}
|
|
44
59
|
return end.bind(response)(JSON.stringify(value));
|
|
45
60
|
}
|
package/dist/driver.mjs
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
import { ERROR_SYMBOL_DESCRIPTION } from "@aeriajs/types";
|
|
3
|
+
import { isError, unwrapError } from "@aeriajs/common";
|
|
2
4
|
import * as http from "http";
|
|
3
5
|
import { parse as parseUrl } from "url";
|
|
4
6
|
const getBody = async ($req) => {
|
|
@@ -30,9 +32,21 @@ export const abstractResponse = (response) => {
|
|
|
30
32
|
end: (value) => {
|
|
31
33
|
if (typeof value === "object" && !(value instanceof Buffer)) {
|
|
32
34
|
if (!response.headersSent) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
35
|
+
if (isError(value)) {
|
|
36
|
+
const error = unwrapError(value);
|
|
37
|
+
if (error.httpStatus) {
|
|
38
|
+
response.writeHead(error.httpStatus, {
|
|
39
|
+
"content-type": "application/json"
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
Object.assign(value, {
|
|
43
|
+
[ERROR_SYMBOL_DESCRIPTION]: true
|
|
44
|
+
});
|
|
45
|
+
} else {
|
|
46
|
+
response.writeHead(200, {
|
|
47
|
+
"content-type": "application/json"
|
|
48
|
+
});
|
|
49
|
+
}
|
|
36
50
|
}
|
|
37
51
|
return end.bind(response)(JSON.stringify(value));
|
|
38
52
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aeriajs/node-http",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.63",
|
|
4
4
|
"description": "## Installation",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"@aeriajs/http": "link:../http"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
|
-
"@aeriajs/http": "^0.0.
|
|
28
|
+
"@aeriajs/http": "^0.0.63"
|
|
29
29
|
},
|
|
30
30
|
"scripts": {
|
|
31
31
|
"test": "echo skipping",
|