@aeriajs/http 0.0.62 → 0.0.64

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 CHANGED
@@ -9,6 +9,9 @@ const next = () => {
9
9
  };
10
10
  exports.next = next;
11
11
  const isNext = (object) => {
12
+ if (!object) {
13
+ return false;
14
+ }
12
15
  const sym = Object.getOwnPropertyDescriptor(object, exports.NEXT_SYMBOL);
13
16
  return !!sym;
14
17
  };
package/dist/next.mjs CHANGED
@@ -6,6 +6,9 @@ export const next = () => {
6
6
  };
7
7
  };
8
8
  export const isNext = (object) => {
9
+ if (!object) {
10
+ return false;
11
+ }
9
12
  const sym = Object.getOwnPropertyDescriptor(object, NEXT_SYMBOL);
10
13
  return !!sym;
11
14
  };
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<true | Promise<any>>;
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
- httpCode: 500,
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
- httpCode: 500,
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.62",
3
+ "version": "0.0.64",
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.54",
32
- "@aeriajs/entrypoint": "^0.0.54",
33
- "@aeriajs/types": "^0.0.51",
34
- "@aeriajs/validation": "^0.0.57"
31
+ "@aeriajs/common": "^0.0.56",
32
+ "@aeriajs/entrypoint": "^0.0.56",
33
+ "@aeriajs/types": "^0.0.53",
34
+ "@aeriajs/validation": "^0.0.59"
35
35
  },
36
36
  "scripts": {
37
37
  "test": "echo skipping",