@radatek/microserver 2.3.3 → 2.3.5

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/microserver.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * MicroServer
3
- * @version 2.3.3
3
+ * @version 2.3.5
4
4
  * @package @radatek/microserver
5
5
  * @copyright Darius Kisonas 2022
6
6
  * @license MIT
@@ -231,7 +231,7 @@ export declare class Router extends EventEmitter {
231
231
  /** bind middleware or create one from string like: 'redirect:302,https://redirect.to', 'error:422', 'param:name=value', 'acl:users/get', 'model:User', 'group:Users', 'user:admin' */
232
232
  bind(fn: string | Function | object): Function;
233
233
  /** Handler */
234
- handler(req: ServerRequest, res: ServerResponse, next: Function, method?: string): any;
234
+ handler(req: ServerRequest, res: ServerResponse, next: Function, method?: string): void;
235
235
  /** Clear routes and middlewares */
236
236
  clear(): this;
237
237
  /**
package/microserver.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * MicroServer
3
- * @version 2.3.3
3
+ * @version 2.3.5
4
4
  * @package @radatek/microserver
5
5
  * @copyright Darius Kisonas 2022
6
6
  * @license MIT
@@ -22,7 +22,10 @@ const defaultMaxBodySize = 5 * 1024 * 1024;
22
22
  const defaultMethods = 'HEAD,GET,POST,PUT,PATCH,DELETE';
23
23
  function NOOP(...args) { }
24
24
  function isFunction(fn) {
25
- return typeof fn === 'function' && !fn.prototype?.constructor;
25
+ if (typeof fn !== 'function')
26
+ return false;
27
+ const descriptor = Object.getOwnPropertyDescriptor(fn, 'prototype');
28
+ return !descriptor || descriptor.writable === true;
26
29
  }
27
30
  export class Warning extends Error {
28
31
  constructor(text) {
@@ -1066,13 +1069,10 @@ export class Router extends EventEmitter {
1066
1069
  handler(req, res, next, method) {
1067
1070
  const nextAfter = next;
1068
1071
  next = () => this._walkStack(this._stackAfter, req, res, nextAfter);
1069
- if (method)
1070
- return !this._walkTree(this._tree[method], req, res, next) && next();
1071
- const walk = () => {
1072
- if (!this._walkTree(this._tree[req.method || 'GET'], req, res, next) &&
1073
- !this._walkTree(this._tree['*'], req, res, next))
1074
- next();
1075
- };
1072
+ const walkTree = (method) => this._walkTree(this._tree[method], req, res, next);
1073
+ const walk = method ?
1074
+ () => { !walkTree(method) && next(); } :
1075
+ () => { !walkTree(req.method || 'GET') && !walkTree('*') && next(); };
1076
1076
  req.rewrite = (url) => {
1077
1077
  if (req.originalUrl)
1078
1078
  res.error(508);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@radatek/microserver",
3
- "version": "2.3.3",
3
+ "version": "2.3.5",
4
4
  "description": "HTTP MicroServer",
5
5
  "author": "Darius Kisonas",
6
6
  "license": "MIT",