@radatek/microserver 2.3.4 → 2.3.6
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 +1 -1
- package/microserver.js +13 -6
- package/package.json +1 -1
package/microserver.d.ts
CHANGED
package/microserver.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* MicroServer
|
|
3
|
-
* @version 2.3.
|
|
3
|
+
* @version 2.3.6
|
|
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
|
-
|
|
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) {
|
|
@@ -1366,10 +1369,14 @@ export class Router extends EventEmitter {
|
|
|
1366
1369
|
/** Add hook */
|
|
1367
1370
|
hook(url, ...mid) {
|
|
1368
1371
|
const m = url.match(/^([A-Z]+) (.*)/);
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1372
|
+
if (m) {
|
|
1373
|
+
const [method, url] = [m[1], m[2]];
|
|
1374
|
+
this._add(method, url, 'hook', mid);
|
|
1375
|
+
}
|
|
1376
|
+
else {
|
|
1377
|
+
for (const method of ['*', 'GET', 'POST', 'PUT', 'DELETE', 'PATCH'])
|
|
1378
|
+
this._add(method, url, 'hook', mid);
|
|
1379
|
+
}
|
|
1373
1380
|
}
|
|
1374
1381
|
/** Check if middleware allready added */
|
|
1375
1382
|
has(mid) {
|