@wooksjs/event-http 0.5.9 → 0.5.11

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/index.cjs CHANGED
@@ -579,7 +579,7 @@ class HttpErrorRenderer extends BaseHttpResponseRenderer {
579
579
  `<head><title>${data.statusCode} ${httpStatusCodes[data.statusCode]}</title></head>` +
580
580
  `<body><center><h1>${data.statusCode} ${httpStatusCodes[data.statusCode]}</h1></center>` +
581
581
  `<center><h4>${data.message}</h1></center><hr color="#666">` +
582
- `<center style="color: #666;"> Wooks v${"0.5.9"} </center>` +
582
+ `<center style="color: #666;"> Wooks v${"0.5.11"} </center>` +
583
583
  `${keys.length > 0
584
584
  ? `<pre style="${preStyles}">${JSON.stringify({
585
585
  ...data,
@@ -951,20 +951,23 @@ class WooksHttp extends wooks.WooksAdapterBase {
951
951
  getServerCb() {
952
952
  return (req, res) => {
953
953
  const runInContext = createHttpContext({ req, res }, this.mergeEventOptions(this.opts?.eventOptions));
954
- return runInContext(async () => {
954
+ runInContext(async () => {
955
955
  const { handlers } = this.wooks.lookup(req.method, req.url);
956
956
  if (handlers || this.opts?.onNotFound) {
957
957
  try {
958
- await this.processHandlers(handlers || [this.opts?.onNotFound]);
958
+ return await this.processHandlers(handlers || [this.opts?.onNotFound]);
959
959
  }
960
960
  catch (error) {
961
961
  this.logger.error('Internal error, please report', error);
962
962
  this.respond(error);
963
+ return error;
963
964
  }
964
965
  }
965
966
  else {
966
967
  this.logger.debug(`404 Not found (${req.method})${req.url}`);
967
- this.respond(new HttpError(404));
968
+ const error = new HttpError(404);
969
+ this.respond(error);
970
+ return error;
968
971
  }
969
972
  });
970
973
  };
package/dist/index.d.ts CHANGED
@@ -692,7 +692,7 @@ declare class WooksHttp extends WooksAdapterBase {
692
692
  * server.listen(3000)
693
693
  * ```
694
694
  */
695
- getServerCb(): (req: IncomingMessage, res: ServerResponse) => Promise<void>;
695
+ getServerCb(): (req: IncomingMessage, res: ServerResponse) => void;
696
696
  protected processHandlers(handlers: TWooksHandler[]): Promise<void>;
697
697
  }
698
698
  /**
package/dist/index.mjs CHANGED
@@ -577,7 +577,7 @@ class HttpErrorRenderer extends BaseHttpResponseRenderer {
577
577
  `<head><title>${data.statusCode} ${httpStatusCodes[data.statusCode]}</title></head>` +
578
578
  `<body><center><h1>${data.statusCode} ${httpStatusCodes[data.statusCode]}</h1></center>` +
579
579
  `<center><h4>${data.message}</h1></center><hr color="#666">` +
580
- `<center style="color: #666;"> Wooks v${"0.5.9"} </center>` +
580
+ `<center style="color: #666;"> Wooks v${"0.5.11"} </center>` +
581
581
  `${keys.length > 0
582
582
  ? `<pre style="${preStyles}">${JSON.stringify({
583
583
  ...data,
@@ -949,20 +949,23 @@ class WooksHttp extends WooksAdapterBase {
949
949
  getServerCb() {
950
950
  return (req, res) => {
951
951
  const runInContext = createHttpContext({ req, res }, this.mergeEventOptions(this.opts?.eventOptions));
952
- return runInContext(async () => {
952
+ runInContext(async () => {
953
953
  const { handlers } = this.wooks.lookup(req.method, req.url);
954
954
  if (handlers || this.opts?.onNotFound) {
955
955
  try {
956
- await this.processHandlers(handlers || [this.opts?.onNotFound]);
956
+ return await this.processHandlers(handlers || [this.opts?.onNotFound]);
957
957
  }
958
958
  catch (error) {
959
959
  this.logger.error('Internal error, please report', error);
960
960
  this.respond(error);
961
+ return error;
961
962
  }
962
963
  }
963
964
  else {
964
965
  this.logger.debug(`404 Not found (${req.method})${req.url}`);
965
- this.respond(new HttpError(404));
966
+ const error = new HttpError(404);
967
+ this.respond(error);
968
+ return error;
966
969
  }
967
970
  });
968
971
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wooksjs/event-http",
3
- "version": "0.5.9",
3
+ "version": "0.5.11",
4
4
  "description": "@wooksjs/event-http",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",
@@ -39,9 +39,9 @@
39
39
  "url": "https://github.com/wooksjs/wooksjs/issues"
40
40
  },
41
41
  "peerDependencies": {
42
- "wooks": "0.5.9",
42
+ "wooks": "0.5.11",
43
43
  "@prostojs/router": "^0.2.1",
44
- "@wooksjs/event-core": "0.5.9"
44
+ "@wooksjs/event-core": "0.5.11"
45
45
  },
46
46
  "dependencies": {
47
47
  "@prostojs/logger": "^0.4.0"