@sourceregistry/node-webserver 1.6.6 → 1.7.1

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.es.js CHANGED
@@ -49,7 +49,7 @@ var E = class {
49
49
  this.cleanupInterval = setInterval(() => {
50
50
  let e = Date.now();
51
51
  for (let [t, { reset: n }] of this.data) e >= n && this.data.delete(t);
52
- }, Math.min(this.windowMs, 3e5));
52
+ }, Math.min(this.windowMs, 3e5)), this.cleanupInterval?.unref();
53
53
  }
54
54
  stop() {
55
55
  this.cleanupInterval && clearInterval(this.cleanupInterval);
@@ -77,7 +77,7 @@ var E = class {
77
77
  let r = e - this.windowMs, i = n.filter((e) => e > r);
78
78
  i.length === 0 ? this.data.delete(t) : this.data.set(t, i);
79
79
  }
80
- }, Math.min(this.windowMs, 3e5));
80
+ }, Math.min(this.windowMs, 3e5)), this.cleanupInterval.unref();
81
81
  }
82
82
  stop() {
83
83
  this.cleanupInterval && clearInterval(this.cleanupInterval);
@@ -351,7 +351,7 @@ var H = [
351
351
  static set(e, t) {
352
352
  this.cache.set(e, t);
353
353
  }
354
- }, W = class {
354
+ }, W = class e {
355
355
  constructor() {
356
356
  this._routes = [], this._wsRoutes = [], this._nestedRouters = [], this._middlewares = [], this._preHandlers = [], this._postHandlers = [], this.routesSorted = !1, this.wsRoutesSorted = !1;
357
357
  }
@@ -395,23 +395,29 @@ var H = [
395
395
  }
396
396
  }, n);
397
397
  }
398
- use(e, t, ...n) {
399
- let r, i, a = n;
400
- Array.isArray(e) ? ([r, i] = e, a = e.length > 2 ? e.slice(2) : []) : (r = e, i = t);
401
- let o = this.normalizePrefix(r), { regex: s, paramNames: c, isCatchAll: l, priority: u } = this.createPrefixRegex(o);
398
+ use(t, n, ...r) {
399
+ let i = "/", a, o = r;
400
+ if (Array.isArray(t)) {
401
+ let [n, r, ...s] = t;
402
+ n instanceof e ? (a = n, o = s) : (i = n, a = r, o = s);
403
+ } else t instanceof e ? (a = t, o = n ? [n, ...r] : r) : (i = t, a = n);
404
+ let s = this.normalizePrefix(i), { regex: c, paramNames: l, isCatchAll: u, priority: d } = this.createPrefixRegex(s);
402
405
  return this._nestedRouters.push({
403
- prefix: o,
404
- router: i,
405
- regex: s,
406
- paramNames: c,
407
- isCatchAll: l,
408
- priority: u,
409
- middlewares: a
406
+ prefix: s,
407
+ router: a,
408
+ regex: c,
409
+ paramNames: l,
410
+ isCatchAll: u,
411
+ priority: d,
412
+ middlewares: o
410
413
  }), this;
411
414
  }
412
415
  useMiddleware(...e) {
413
416
  return this._middlewares.push(...e), this;
414
417
  }
418
+ middleware(...e) {
419
+ return this._middlewares.push(...e), this;
420
+ }
415
421
  pre(...e) {
416
422
  return this._preHandlers.push(...e), this;
417
423
  }