binhend 1.1.10 → 1.1.12
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/package.json +1 -1
- package/src/api.js +3 -3
- package/src/binh.js +5 -1
- package/src/code.js +2 -2
- package/src/enum.httpCodes.js +49 -0
package/package.json
CHANGED
package/src/api.js
CHANGED
|
@@ -88,17 +88,17 @@ function trycatch(callback, onerror) {
|
|
|
88
88
|
catch (error) {
|
|
89
89
|
if (onerror instanceof Function) return onerror(error);
|
|
90
90
|
var message = error instanceof HttpError && error.message || 'Internal Server Error';
|
|
91
|
-
response.status(error.
|
|
91
|
+
response.status(error.httpCode || 500).json({ error: message });
|
|
92
92
|
if (onerror === true) console.error('\x1b[31m', error);
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
class HttpError extends Error {
|
|
98
|
-
constructor(
|
|
98
|
+
constructor(httpCode, message) {
|
|
99
99
|
super(message);
|
|
100
100
|
this.name = 'HttpError';
|
|
101
|
-
this.
|
|
101
|
+
this.httpCode = httpCode;
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
|
package/src/binh.js
CHANGED
|
@@ -45,4 +45,8 @@ function Binh() {
|
|
|
45
45
|
global.config = binh.config;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
|
|
49
|
+
const { HttpError } = require('./api');
|
|
50
|
+
const { HttpCodes } = require('./enum.httpCodes');
|
|
51
|
+
|
|
52
|
+
module.exports = { Binh, HTTPS, ConfigLoader, Crypto, HttpError, HttpCodes };
|
package/src/code.js
CHANGED
|
@@ -62,8 +62,8 @@ function dependencies(component, root, metadata) {
|
|
|
62
62
|
};
|
|
63
63
|
|
|
64
64
|
code += IIF([
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
dependencies(component, root, Object.assign({}, global, local)),
|
|
66
|
+
declaration
|
|
67
67
|
]);
|
|
68
68
|
|
|
69
69
|
code += '\r\n\r\n';
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
|
|
2
|
+
const HttpCodes = {
|
|
3
|
+
CONTINUE: 100,
|
|
4
|
+
SWITCHING_PROTOCOLS: 101,
|
|
5
|
+
PROCESSING: 102,
|
|
6
|
+
EARLY_HINTS: 103,
|
|
7
|
+
|
|
8
|
+
OK: 200,
|
|
9
|
+
CREATED: 201,
|
|
10
|
+
ACCEPTED: 202,
|
|
11
|
+
NON_AUTHORITATIVE_INFORMATION: 203,
|
|
12
|
+
NO_CONTENT: 204,
|
|
13
|
+
RESET_CONTENT: 205,
|
|
14
|
+
PARTIAL_CONTENT: 206,
|
|
15
|
+
MULTI_STATUS: 207,
|
|
16
|
+
ALREADY_REPORTED: 208,
|
|
17
|
+
IM_USED: 226,
|
|
18
|
+
|
|
19
|
+
MULTIPLE_CHOICES: 300,
|
|
20
|
+
MOVED_PERMANENTLY: 301,
|
|
21
|
+
FOUND: 302,
|
|
22
|
+
SEE_OTHER: 303,
|
|
23
|
+
NOT_MODIFIED: 304,
|
|
24
|
+
USE_PROXY: 305,
|
|
25
|
+
UNUSED: 306,
|
|
26
|
+
TEMPORARY_REDIRECT: 307,
|
|
27
|
+
PERMANENT_REDIRECT: 308,
|
|
28
|
+
|
|
29
|
+
BAD_REQUEST: 400,
|
|
30
|
+
UNAUTHORIZED: 401,
|
|
31
|
+
|
|
32
|
+
FORBIDDEN: 403,
|
|
33
|
+
NOT_FOUND: 404,
|
|
34
|
+
METHOD_NOT_ALLOWED: 405,
|
|
35
|
+
NOT_ACCEPTABLE: 406,
|
|
36
|
+
|
|
37
|
+
REQUEST_TIMEOUT: 408,
|
|
38
|
+
I_AM_A_TEAPOT: 418,
|
|
39
|
+
|
|
40
|
+
INTERNAL_SERVER_ERROR: 500,
|
|
41
|
+
NOT_IMPLEMENTED: 501,
|
|
42
|
+
BAD_GATEWAY: 502,
|
|
43
|
+
SERVICE_UNAVAILABLE: 503,
|
|
44
|
+
GATEWAY_TIMEOUT: 504
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
module.exports = {
|
|
48
|
+
HttpCodes
|
|
49
|
+
};
|