@aeriajs/common 0.0.52 → 0.0.54
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/error.js +2 -2
- package/dist/error.mjs +2 -2
- package/dist/schema.d.ts +11 -0
- package/dist/schema.js +16 -3
- package/dist/schema.mjs +16 -3
- package/package.json +2 -2
package/dist/error.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isError = exports.error = void 0;
|
|
4
4
|
const error = (error, context) => {
|
|
5
|
-
const {
|
|
6
|
-
context.response.writeHead(
|
|
5
|
+
const { httpStatus = 500 } = error;
|
|
6
|
+
context.response.writeHead(httpStatus, {
|
|
7
7
|
'content-type': 'application/json',
|
|
8
8
|
});
|
|
9
9
|
return {
|
package/dist/error.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
export const error = (error2, context) => {
|
|
3
|
-
const {
|
|
4
|
-
context.response.writeHead(
|
|
3
|
+
const { httpStatus = 500 } = error2;
|
|
4
|
+
context.response.writeHead(httpStatus, {
|
|
5
5
|
"content-type": "application/json"
|
|
6
6
|
});
|
|
7
7
|
return {
|
package/dist/schema.d.ts
CHANGED
|
@@ -31,4 +31,15 @@ export declare const endpointErrorSchema: (error: EndpointErrorContent) => {
|
|
|
31
31
|
readonly const: string;
|
|
32
32
|
};
|
|
33
33
|
};
|
|
34
|
+
} | {
|
|
35
|
+
readonly type: "object";
|
|
36
|
+
readonly properties: {
|
|
37
|
+
readonly httpCode: {
|
|
38
|
+
readonly const: string;
|
|
39
|
+
};
|
|
40
|
+
readonly code: {
|
|
41
|
+
readonly const: string;
|
|
42
|
+
};
|
|
43
|
+
readonly message?: undefined;
|
|
44
|
+
};
|
|
34
45
|
};
|
package/dist/schema.js
CHANGED
|
@@ -73,6 +73,22 @@ const rightSchema = (object) => {
|
|
|
73
73
|
};
|
|
74
74
|
exports.rightSchema = rightSchema;
|
|
75
75
|
const endpointErrorSchema = (error) => {
|
|
76
|
+
if (error.message) {
|
|
77
|
+
return {
|
|
78
|
+
type: 'object',
|
|
79
|
+
properties: {
|
|
80
|
+
httpCode: {
|
|
81
|
+
const: error.code,
|
|
82
|
+
},
|
|
83
|
+
code: {
|
|
84
|
+
const: error.code,
|
|
85
|
+
},
|
|
86
|
+
message: {
|
|
87
|
+
const: error.message,
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
}
|
|
76
92
|
return {
|
|
77
93
|
type: 'object',
|
|
78
94
|
properties: {
|
|
@@ -82,9 +98,6 @@ const endpointErrorSchema = (error) => {
|
|
|
82
98
|
code: {
|
|
83
99
|
const: error.code,
|
|
84
100
|
},
|
|
85
|
-
message: {
|
|
86
|
-
const: error.message,
|
|
87
|
-
},
|
|
88
101
|
},
|
|
89
102
|
};
|
|
90
103
|
};
|
package/dist/schema.mjs
CHANGED
|
@@ -68,6 +68,22 @@ export const rightSchema = (object) => {
|
|
|
68
68
|
};
|
|
69
69
|
};
|
|
70
70
|
export const endpointErrorSchema = (error) => {
|
|
71
|
+
if (error.message) {
|
|
72
|
+
return {
|
|
73
|
+
type: "object",
|
|
74
|
+
properties: {
|
|
75
|
+
httpCode: {
|
|
76
|
+
const: error.code
|
|
77
|
+
},
|
|
78
|
+
code: {
|
|
79
|
+
const: error.code
|
|
80
|
+
},
|
|
81
|
+
message: {
|
|
82
|
+
const: error.message
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
}
|
|
71
87
|
return {
|
|
72
88
|
type: "object",
|
|
73
89
|
properties: {
|
|
@@ -76,9 +92,6 @@ export const endpointErrorSchema = (error) => {
|
|
|
76
92
|
},
|
|
77
93
|
code: {
|
|
78
94
|
const: error.code
|
|
79
|
-
},
|
|
80
|
-
message: {
|
|
81
|
-
const: error.message
|
|
82
95
|
}
|
|
83
96
|
}
|
|
84
97
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aeriajs/common",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.54",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"bson": "^6.5.0"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
|
-
"@aeriajs/types": "^0.0.
|
|
34
|
+
"@aeriajs/types": "^0.0.51",
|
|
35
35
|
"bson": "^6.5.0"
|
|
36
36
|
},
|
|
37
37
|
"scripts": {
|