@aeriajs/http 0.0.61 → 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/next.js +3 -0
- package/dist/next.mjs +3 -0
- package/dist/routing.d.ts +1 -1
- package/dist/routing.js +9 -5
- package/dist/routing.mjs +9 -5
- package/package.json +5 -5
package/dist/next.js
CHANGED
package/dist/next.mjs
CHANGED
package/dist/routing.d.ts
CHANGED
|
@@ -36,6 +36,6 @@ export declare const createRouter: (options?: Partial<RouterOptions>) => Proxied
|
|
|
36
36
|
install: (context: RouteContext, options?: RouterOptions) => any;
|
|
37
37
|
routesMeta: RoutesMeta;
|
|
38
38
|
}>(exp: RouteUri, router: TRouter, middleware?: Middleware) => void;
|
|
39
|
-
install: (_context: RouteContext, _options?: RouterOptions) => Promise<
|
|
39
|
+
install: (_context: RouteContext, _options?: RouterOptions) => Promise<any>;
|
|
40
40
|
}>;
|
|
41
41
|
export {};
|
package/dist/routing.js
CHANGED
|
@@ -11,6 +11,12 @@ const next_js_1 = require("./next.js");
|
|
|
11
11
|
const checkUnprocessable = (validationEither, context) => {
|
|
12
12
|
if ((0, common_1.isLeft)(validationEither)) {
|
|
13
13
|
const validationError = (0, common_1.unwrapEither)(validationEither);
|
|
14
|
+
if ('code' in validationError) {
|
|
15
|
+
return context.error(types_1.HTTPStatus.UnprocessableContent, {
|
|
16
|
+
code: validationError.code,
|
|
17
|
+
details: validationError.errors,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
14
20
|
return context.error(types_1.HTTPStatus.UnprocessableContent, {
|
|
15
21
|
code: 'UNPROCESSABLE_ENTITY',
|
|
16
22
|
message: 'the provided payload is unprocessable',
|
|
@@ -102,8 +108,8 @@ const wrapRouteExecution = async (response, cb) => {
|
|
|
102
108
|
if (result === null) {
|
|
103
109
|
if (!response.headersSent) {
|
|
104
110
|
response.writeHead(204);
|
|
105
|
-
response.end();
|
|
106
111
|
}
|
|
112
|
+
response.end(result);
|
|
107
113
|
return;
|
|
108
114
|
}
|
|
109
115
|
if (result instanceof stream_1.Stream) {
|
|
@@ -126,11 +132,9 @@ const wrapRouteExecution = async (response, cb) => {
|
|
|
126
132
|
}
|
|
127
133
|
if (!response.writableEnded) {
|
|
128
134
|
return (0, common_1.error)({
|
|
129
|
-
|
|
135
|
+
httpStatus: 500,
|
|
130
136
|
code: 'UNKNOWN_ERROR',
|
|
131
137
|
message: 'Internal server error',
|
|
132
|
-
}, {
|
|
133
|
-
response,
|
|
134
138
|
});
|
|
135
139
|
}
|
|
136
140
|
}
|
|
@@ -178,7 +182,7 @@ const createRouter = (options = {}) => {
|
|
|
178
182
|
};
|
|
179
183
|
const routerPipe = (0, common_1.pipe)(routes, {
|
|
180
184
|
returnFirst: (value) => {
|
|
181
|
-
if (value && !(0, next_js_1.isNext)(value)) {
|
|
185
|
+
if (value !== undefined && !(0, next_js_1.isNext)(value)) {
|
|
182
186
|
return value;
|
|
183
187
|
}
|
|
184
188
|
},
|
package/dist/routing.mjs
CHANGED
|
@@ -9,6 +9,12 @@ import { isNext } from "./next.mjs";
|
|
|
9
9
|
const checkUnprocessable = (validationEither, context) => {
|
|
10
10
|
if (isLeft(validationEither)) {
|
|
11
11
|
const validationError = unwrapEither(validationEither);
|
|
12
|
+
if ("code" in validationError) {
|
|
13
|
+
return context.error(HTTPStatus.UnprocessableContent, {
|
|
14
|
+
code: validationError.code,
|
|
15
|
+
details: validationError.errors
|
|
16
|
+
});
|
|
17
|
+
}
|
|
12
18
|
return context.error(HTTPStatus.UnprocessableContent, {
|
|
13
19
|
code: "UNPROCESSABLE_ENTITY",
|
|
14
20
|
message: "the provided payload is unprocessable",
|
|
@@ -97,8 +103,8 @@ export const wrapRouteExecution = async (response, cb) => {
|
|
|
97
103
|
if (result === null) {
|
|
98
104
|
if (!response.headersSent) {
|
|
99
105
|
response.writeHead(204);
|
|
100
|
-
response.end();
|
|
101
106
|
}
|
|
107
|
+
response.end(result);
|
|
102
108
|
return;
|
|
103
109
|
}
|
|
104
110
|
if (result instanceof Stream) {
|
|
@@ -119,11 +125,9 @@ export const wrapRouteExecution = async (response, cb) => {
|
|
|
119
125
|
}
|
|
120
126
|
if (!response.writableEnded) {
|
|
121
127
|
return error({
|
|
122
|
-
|
|
128
|
+
httpStatus: 500,
|
|
123
129
|
code: "UNKNOWN_ERROR",
|
|
124
130
|
message: "Internal server error"
|
|
125
|
-
}, {
|
|
126
|
-
response
|
|
127
131
|
});
|
|
128
132
|
}
|
|
129
133
|
}
|
|
@@ -174,7 +178,7 @@ export const createRouter = (options = {}) => {
|
|
|
174
178
|
};
|
|
175
179
|
const routerPipe = pipe(routes, {
|
|
176
180
|
returnFirst: (value) => {
|
|
177
|
-
if (value && !isNext(value)) {
|
|
181
|
+
if (value !== void 0 && !isNext(value)) {
|
|
178
182
|
return value;
|
|
179
183
|
}
|
|
180
184
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aeriajs/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",
|
|
@@ -28,10 +28,10 @@
|
|
|
28
28
|
"@aeriajs/validation": "link:../validation"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
|
-
"@aeriajs/common": "^0.0.
|
|
32
|
-
"@aeriajs/entrypoint": "^0.0.
|
|
33
|
-
"@aeriajs/types": "^0.0.
|
|
34
|
-
"@aeriajs/validation": "^0.0.
|
|
31
|
+
"@aeriajs/common": "^0.0.55",
|
|
32
|
+
"@aeriajs/entrypoint": "^0.0.55",
|
|
33
|
+
"@aeriajs/types": "^0.0.52",
|
|
34
|
+
"@aeriajs/validation": "^0.0.58"
|
|
35
35
|
},
|
|
36
36
|
"scripts": {
|
|
37
37
|
"test": "echo skipping",
|