@catbee/utils 0.0.8-rc.1 → 0.0.8-rc.3

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.
Files changed (280) hide show
  1. package/build/{esnext → cjs}/config.d.ts +0 -1
  2. package/build/{src → cjs}/config.js +0 -1
  3. package/build/{esnext → cjs}/index.d.ts +0 -1
  4. package/build/{src → cjs}/index.js +0 -1
  5. package/build/{esnext → cjs}/servers/server.builder.d.ts +0 -1
  6. package/build/{src → cjs}/servers/server.builder.js +10 -13
  7. package/build/{src → cjs}/servers/server.d.ts +0 -1
  8. package/build/{src → cjs}/servers/server.js +83 -75
  9. package/build/{src → cjs}/types/api-response.d.ts +0 -1
  10. package/build/{src → cjs}/types/api-response.js +0 -1
  11. package/build/{src → cjs}/types/index.d.ts +0 -1
  12. package/build/{src → cjs}/types/index.js +0 -1
  13. package/build/{src → cjs}/types/server.d.ts +0 -1
  14. package/build/{src → cjs}/types/server.js +0 -1
  15. package/build/{src → cjs}/utils/array.utils.d.ts +0 -1
  16. package/build/{src → cjs}/utils/array.utils.js +0 -1
  17. package/build/{src → cjs}/utils/async.utils.d.ts +0 -1
  18. package/build/{src → cjs}/utils/async.utils.js +2 -3
  19. package/build/{esnext → cjs}/utils/cache.utils.d.ts +0 -1
  20. package/build/{src → cjs}/utils/cache.utils.js +7 -6
  21. package/build/{esnext → cjs}/utils/context-store.utils.d.ts +1 -2
  22. package/build/{src → cjs}/utils/context-store.utils.js +10 -9
  23. package/build/{esnext → cjs}/utils/crypto.utils.d.ts +0 -1
  24. package/build/{src → cjs}/utils/crypto.utils.js +5 -3
  25. package/build/{src → cjs}/utils/date.utils.d.ts +0 -1
  26. package/build/{src → cjs}/utils/date.utils.js +1 -2
  27. package/build/{src → cjs}/utils/decorators.utils.d.ts +30 -27
  28. package/build/{src → cjs}/utils/decorators.utils.js +169 -30
  29. package/build/{esnext → cjs}/utils/dir.utils.d.ts +0 -1
  30. package/build/{src → cjs}/utils/dir.utils.js +6 -7
  31. package/build/{esnext → cjs}/utils/env.utils.d.ts +0 -1
  32. package/build/{src → cjs}/utils/env.utils.js +5 -8
  33. package/build/{src → cjs}/utils/exception.utils.d.ts +0 -1
  34. package/build/{src → cjs}/utils/exception.utils.js +2 -1
  35. package/build/{src → cjs}/utils/fs.utils.d.ts +0 -1
  36. package/build/{src → cjs}/utils/fs.utils.js +12 -13
  37. package/build/{esnext → cjs}/utils/http-status-codes.d.ts +0 -1
  38. package/build/{src → cjs}/utils/http-status-codes.js +0 -1
  39. package/build/{esnext → cjs}/utils/id.utils.d.ts +0 -1
  40. package/build/{src → cjs}/utils/id.utils.js +0 -1
  41. package/build/{src → cjs}/utils/logger.utils.d.ts +0 -1
  42. package/build/{src → cjs}/utils/logger.utils.js +10 -6
  43. package/build/{esnext → cjs}/utils/middleware.utils.d.ts +0 -1
  44. package/build/{src → cjs}/utils/middleware.utils.js +16 -17
  45. package/build/{esnext → cjs}/utils/obj.utils.d.ts +0 -1
  46. package/build/{src → cjs}/utils/obj.utils.js +1 -2
  47. package/build/{src → cjs}/utils/performance.utils.d.ts +0 -1
  48. package/build/{src → cjs}/utils/performance.utils.js +6 -4
  49. package/build/{esnext → cjs}/utils/request.utils.d.ts +0 -1
  50. package/build/{src → cjs}/utils/request.utils.js +7 -3
  51. package/build/{esnext → cjs}/utils/response.utils.d.ts +0 -1
  52. package/build/{src → cjs}/utils/response.utils.js +42 -28
  53. package/build/{esnext → cjs}/utils/stream.utils.d.ts +0 -1
  54. package/build/{src → cjs}/utils/stream.utils.js +0 -1
  55. package/build/{esnext → cjs}/utils/string.utils.d.ts +0 -1
  56. package/build/{src → cjs}/utils/string.utils.js +0 -1
  57. package/build/{src → cjs}/utils/type.utils.d.ts +0 -1
  58. package/build/{src → cjs}/utils/type.utils.js +2 -3
  59. package/build/{src → cjs}/utils/url.utils.d.ts +0 -1
  60. package/build/{src → cjs}/utils/url.utils.js +8 -9
  61. package/build/{src → cjs}/utils/validate.utils.d.ts +0 -1
  62. package/build/{src → cjs}/utils/validate.utils.js +2 -3
  63. package/build/esm/config.d.ts +0 -1
  64. package/build/esm/config.js +6 -7
  65. package/build/esm/index.d.ts +0 -1
  66. package/build/esm/index.js +0 -1
  67. package/build/esm/servers/server.builder.d.ts +0 -1
  68. package/build/esm/servers/server.builder.js +99 -147
  69. package/build/esm/servers/server.d.ts +0 -1
  70. package/build/esm/servers/server.js +591 -876
  71. package/build/esm/types/api-response.d.ts +0 -1
  72. package/build/esm/types/api-response.js +0 -1
  73. package/build/esm/types/index.d.ts +0 -1
  74. package/build/esm/types/index.js +0 -1
  75. package/build/esm/types/server.d.ts +0 -1
  76. package/build/esm/types/server.js +0 -1
  77. package/build/esm/utils/array.utils.d.ts +0 -1
  78. package/build/esm/utils/array.utils.js +48 -86
  79. package/build/esm/utils/async.utils.d.ts +0 -1
  80. package/build/esm/utils/async.utils.js +247 -524
  81. package/build/esm/utils/cache.utils.d.ts +0 -1
  82. package/build/esm/utils/cache.utils.js +96 -301
  83. package/build/esm/utils/context-store.utils.d.ts +1 -2
  84. package/build/esm/utils/context-store.utils.js +62 -79
  85. package/build/esm/utils/crypto.utils.d.ts +0 -1
  86. package/build/esm/utils/crypto.utils.js +78 -175
  87. package/build/esm/utils/date.utils.d.ts +0 -1
  88. package/build/esm/utils/date.utils.js +47 -53
  89. package/build/esm/utils/decorators.utils.d.ts +30 -27
  90. package/build/esm/utils/decorators.utils.js +417 -461
  91. package/build/esm/utils/dir.utils.d.ts +0 -1
  92. package/build/esm/utils/dir.utils.js +264 -786
  93. package/build/esm/utils/env.utils.d.ts +0 -1
  94. package/build/esm/utils/env.utils.js +180 -271
  95. package/build/esm/utils/exception.utils.d.ts +0 -1
  96. package/build/esm/utils/exception.utils.js +112 -289
  97. package/build/esm/utils/fs.utils.d.ts +0 -1
  98. package/build/esm/utils/fs.utils.js +169 -401
  99. package/build/esm/utils/http-status-codes.d.ts +0 -1
  100. package/build/esm/utils/http-status-codes.js +0 -1
  101. package/build/esm/utils/id.utils.d.ts +0 -1
  102. package/build/esm/utils/id.utils.js +5 -9
  103. package/build/esm/utils/logger.utils.d.ts +0 -1
  104. package/build/esm/utils/logger.utils.js +34 -71
  105. package/build/esm/utils/middleware.utils.d.ts +0 -1
  106. package/build/esm/utils/middleware.utils.js +65 -155
  107. package/build/esm/utils/obj.utils.d.ts +0 -1
  108. package/build/esm/utils/obj.utils.js +69 -176
  109. package/build/esm/utils/performance.utils.d.ts +0 -1
  110. package/build/esm/utils/performance.utils.js +92 -195
  111. package/build/esm/utils/request.utils.d.ts +0 -1
  112. package/build/esm/utils/request.utils.js +41 -74
  113. package/build/esm/utils/response.utils.d.ts +0 -1
  114. package/build/esm/utils/response.utils.js +84 -107
  115. package/build/esm/utils/stream.utils.d.ts +0 -1
  116. package/build/esm/utils/stream.utils.js +38 -113
  117. package/build/esm/utils/string.utils.d.ts +0 -1
  118. package/build/esm/utils/string.utils.js +6 -11
  119. package/build/esm/utils/type.utils.d.ts +0 -1
  120. package/build/esm/utils/type.utils.js +8 -12
  121. package/build/esm/utils/url.utils.d.ts +0 -1
  122. package/build/esm/utils/url.utils.js +49 -127
  123. package/build/esm/utils/validate.utils.d.ts +0 -1
  124. package/build/esm/utils/validate.utils.js +23 -40
  125. package/package.json +288 -63
  126. package/build/esm/config.js.map +0 -1
  127. package/build/esm/index.js.map +0 -1
  128. package/build/esm/servers/server.builder.js.map +0 -1
  129. package/build/esm/servers/server.js.map +0 -1
  130. package/build/esm/types/api-response.js.map +0 -1
  131. package/build/esm/types/index.js.map +0 -1
  132. package/build/esm/types/server.js.map +0 -1
  133. package/build/esm/utils/array.utils.js.map +0 -1
  134. package/build/esm/utils/async.utils.js.map +0 -1
  135. package/build/esm/utils/cache.utils.js.map +0 -1
  136. package/build/esm/utils/context-store.utils.js.map +0 -1
  137. package/build/esm/utils/crypto.utils.js.map +0 -1
  138. package/build/esm/utils/date.utils.js.map +0 -1
  139. package/build/esm/utils/decorators.utils.js.map +0 -1
  140. package/build/esm/utils/dir.utils.js.map +0 -1
  141. package/build/esm/utils/env.utils.js.map +0 -1
  142. package/build/esm/utils/exception.utils.js.map +0 -1
  143. package/build/esm/utils/fs.utils.js.map +0 -1
  144. package/build/esm/utils/http-status-codes.js.map +0 -1
  145. package/build/esm/utils/id.utils.js.map +0 -1
  146. package/build/esm/utils/logger.utils.js.map +0 -1
  147. package/build/esm/utils/middleware.utils.js.map +0 -1
  148. package/build/esm/utils/obj.utils.js.map +0 -1
  149. package/build/esm/utils/performance.utils.js.map +0 -1
  150. package/build/esm/utils/request.utils.js.map +0 -1
  151. package/build/esm/utils/response.utils.js.map +0 -1
  152. package/build/esm/utils/stream.utils.js.map +0 -1
  153. package/build/esm/utils/string.utils.js.map +0 -1
  154. package/build/esm/utils/type.utils.js.map +0 -1
  155. package/build/esm/utils/url.utils.js.map +0 -1
  156. package/build/esm/utils/validate.utils.js.map +0 -1
  157. package/build/esnext/config.js +0 -133
  158. package/build/esnext/config.js.map +0 -1
  159. package/build/esnext/index.js +0 -50
  160. package/build/esnext/index.js.map +0 -1
  161. package/build/esnext/servers/server.builder.js +0 -657
  162. package/build/esnext/servers/server.builder.js.map +0 -1
  163. package/build/esnext/servers/server.d.ts +0 -256
  164. package/build/esnext/servers/server.js +0 -955
  165. package/build/esnext/servers/server.js.map +0 -1
  166. package/build/esnext/types/api-response.d.ts +0 -152
  167. package/build/esnext/types/api-response.js +0 -34
  168. package/build/esnext/types/api-response.js.map +0 -1
  169. package/build/esnext/types/index.d.ts +0 -125
  170. package/build/esnext/types/index.js +0 -25
  171. package/build/esnext/types/index.js.map +0 -1
  172. package/build/esnext/types/server.d.ts +0 -268
  173. package/build/esnext/types/server.js +0 -25
  174. package/build/esnext/types/server.js.map +0 -1
  175. package/build/esnext/utils/array.utils.d.ts +0 -168
  176. package/build/esnext/utils/array.utils.js +0 -345
  177. package/build/esnext/utils/array.utils.js.map +0 -1
  178. package/build/esnext/utils/async.utils.d.ts +0 -265
  179. package/build/esnext/utils/async.utils.js +0 -620
  180. package/build/esnext/utils/async.utils.js.map +0 -1
  181. package/build/esnext/utils/cache.utils.js +0 -293
  182. package/build/esnext/utils/cache.utils.js.map +0 -1
  183. package/build/esnext/utils/context-store.utils.js +0 -289
  184. package/build/esnext/utils/context-store.utils.js.map +0 -1
  185. package/build/esnext/utils/crypto.utils.js +0 -276
  186. package/build/esnext/utils/crypto.utils.js.map +0 -1
  187. package/build/esnext/utils/date.utils.d.ts +0 -159
  188. package/build/esnext/utils/date.utils.js +0 -384
  189. package/build/esnext/utils/date.utils.js.map +0 -1
  190. package/build/esnext/utils/decorators.utils.d.ts +0 -508
  191. package/build/esnext/utils/decorators.utils.js +0 -877
  192. package/build/esnext/utils/decorators.utils.js.map +0 -1
  193. package/build/esnext/utils/dir.utils.js +0 -477
  194. package/build/esnext/utils/dir.utils.js.map +0 -1
  195. package/build/esnext/utils/env.utils.js +0 -785
  196. package/build/esnext/utils/env.utils.js.map +0 -1
  197. package/build/esnext/utils/exception.utils.d.ts +0 -230
  198. package/build/esnext/utils/exception.utils.js +0 -381
  199. package/build/esnext/utils/exception.utils.js.map +0 -1
  200. package/build/esnext/utils/fs.utils.d.ts +0 -164
  201. package/build/esnext/utils/fs.utils.js +0 -349
  202. package/build/esnext/utils/fs.utils.js.map +0 -1
  203. package/build/esnext/utils/http-status-codes.js +0 -295
  204. package/build/esnext/utils/http-status-codes.js.map +0 -1
  205. package/build/esnext/utils/id.utils.js +0 -84
  206. package/build/esnext/utils/id.utils.js.map +0 -1
  207. package/build/esnext/utils/logger.utils.d.ts +0 -160
  208. package/build/esnext/utils/logger.utils.js +0 -300
  209. package/build/esnext/utils/logger.utils.js.map +0 -1
  210. package/build/esnext/utils/middleware.utils.js +0 -236
  211. package/build/esnext/utils/middleware.utils.js.map +0 -1
  212. package/build/esnext/utils/obj.utils.js +0 -413
  213. package/build/esnext/utils/obj.utils.js.map +0 -1
  214. package/build/esnext/utils/performance.utils.d.ts +0 -136
  215. package/build/esnext/utils/performance.utils.js +0 -271
  216. package/build/esnext/utils/performance.utils.js.map +0 -1
  217. package/build/esnext/utils/request.utils.js +0 -186
  218. package/build/esnext/utils/request.utils.js.map +0 -1
  219. package/build/esnext/utils/response.utils.js +0 -247
  220. package/build/esnext/utils/response.utils.js.map +0 -1
  221. package/build/esnext/utils/stream.utils.js +0 -210
  222. package/build/esnext/utils/stream.utils.js.map +0 -1
  223. package/build/esnext/utils/string.utils.js +0 -165
  224. package/build/esnext/utils/string.utils.js.map +0 -1
  225. package/build/esnext/utils/type.utils.d.ts +0 -90
  226. package/build/esnext/utils/type.utils.js +0 -187
  227. package/build/esnext/utils/type.utils.js.map +0 -1
  228. package/build/esnext/utils/url.utils.d.ts +0 -141
  229. package/build/esnext/utils/url.utils.js +0 -304
  230. package/build/esnext/utils/url.utils.js.map +0 -1
  231. package/build/esnext/utils/validate.utils.d.ts +0 -177
  232. package/build/esnext/utils/validate.utils.js +0 -320
  233. package/build/esnext/utils/validate.utils.js.map +0 -1
  234. package/build/src/config.d.ts +0 -122
  235. package/build/src/config.js.map +0 -1
  236. package/build/src/index.d.ts +0 -27
  237. package/build/src/index.js.map +0 -1
  238. package/build/src/servers/server.builder.d.ts +0 -508
  239. package/build/src/servers/server.builder.js.map +0 -1
  240. package/build/src/servers/server.js.map +0 -1
  241. package/build/src/types/api-response.js.map +0 -1
  242. package/build/src/types/index.js.map +0 -1
  243. package/build/src/types/server.js.map +0 -1
  244. package/build/src/utils/array.utils.js.map +0 -1
  245. package/build/src/utils/async.utils.js.map +0 -1
  246. package/build/src/utils/cache.utils.d.ts +0 -153
  247. package/build/src/utils/cache.utils.js.map +0 -1
  248. package/build/src/utils/context-store.utils.d.ts +0 -189
  249. package/build/src/utils/context-store.utils.js.map +0 -1
  250. package/build/src/utils/crypto.utils.d.ts +0 -160
  251. package/build/src/utils/crypto.utils.js.map +0 -1
  252. package/build/src/utils/date.utils.js.map +0 -1
  253. package/build/src/utils/decorators.utils.js.map +0 -1
  254. package/build/src/utils/dir.utils.d.ts +0 -196
  255. package/build/src/utils/dir.utils.js.map +0 -1
  256. package/build/src/utils/env.utils.d.ts +0 -377
  257. package/build/src/utils/env.utils.js.map +0 -1
  258. package/build/src/utils/exception.utils.js.map +0 -1
  259. package/build/src/utils/fs.utils.js.map +0 -1
  260. package/build/src/utils/http-status-codes.d.ts +0 -266
  261. package/build/src/utils/http-status-codes.js.map +0 -1
  262. package/build/src/utils/id.utils.d.ts +0 -36
  263. package/build/src/utils/id.utils.js.map +0 -1
  264. package/build/src/utils/logger.utils.js.map +0 -1
  265. package/build/src/utils/middleware.utils.d.ts +0 -100
  266. package/build/src/utils/middleware.utils.js.map +0 -1
  267. package/build/src/utils/obj.utils.d.ts +0 -124
  268. package/build/src/utils/obj.utils.js.map +0 -1
  269. package/build/src/utils/performance.utils.js.map +0 -1
  270. package/build/src/utils/request.utils.d.ts +0 -86
  271. package/build/src/utils/request.utils.js.map +0 -1
  272. package/build/src/utils/response.utils.d.ts +0 -163
  273. package/build/src/utils/response.utils.js.map +0 -1
  274. package/build/src/utils/stream.utils.d.ts +0 -88
  275. package/build/src/utils/stream.utils.js.map +0 -1
  276. package/build/src/utils/string.utils.d.ts +0 -93
  277. package/build/src/utils/string.utils.js.map +0 -1
  278. package/build/src/utils/type.utils.js.map +0 -1
  279. package/build/src/utils/url.utils.js.map +0 -1
  280. package/build/src/utils/validate.utils.js.map +0 -1
@@ -119,4 +119,3 @@ export declare function setConfig(value: Partial<typeof config>): void;
119
119
  * @returns The current configuration object.
120
120
  */
121
121
  export declare function getConfig(): typeof config;
122
- //# sourceMappingURL=config.d.ts.map
@@ -135,4 +135,3 @@ function setConfig(value) {
135
135
  function getConfig() {
136
136
  return exports.config;
137
137
  }
138
- //# sourceMappingURL=config.js.map
@@ -24,4 +24,3 @@ export * from './types/server';
24
24
  export * from './types/api-response';
25
25
  export * from './servers/server';
26
26
  export * from './servers/server.builder';
27
- //# sourceMappingURL=index.d.ts.map
@@ -66,4 +66,3 @@ __exportStar(require("./types/server"), exports);
66
66
  __exportStar(require("./types/api-response"), exports);
67
67
  __exportStar(require("./servers/server"), exports);
68
68
  __exportStar(require("./servers/server.builder"), exports);
69
- //# sourceMappingURL=index.js.map
@@ -505,4 +505,3 @@ export declare class ServerConfigBuilder {
505
505
  private mergeConfig;
506
506
  private setEnabled;
507
507
  }
508
- //# sourceMappingURL=server.builder.d.ts.map
@@ -45,9 +45,7 @@ const validate_utils_1 = require("../utils/validate.utils");
45
45
  */
46
46
  exports.BUILD_MARKER = Symbol.for('catbee.express.server.build');
47
47
  class ServerConfigBuilder {
48
- constructor() {
49
- this.config = {};
50
- }
48
+ config = {};
51
49
  /**
52
50
  * Validates that a port number is valid and usable.
53
51
  *
@@ -368,7 +366,7 @@ class ServerConfigBuilder {
368
366
  * @returns The builder instance for chaining
369
367
  */
370
368
  enableOpenApi(filePath, opts = {}) {
371
- this.setEnabled('openApi', true, Object.assign({ filePath }, opts));
369
+ this.setEnabled('openApi', true, { filePath, ...opts });
372
370
  return this;
373
371
  }
374
372
  /**
@@ -498,8 +496,7 @@ class ServerConfigBuilder {
498
496
  * ```
499
497
  */
500
498
  withBodyParser(opts) {
501
- var _a;
502
- this.config.bodyParser = (0, obj_utils_1.deepObjMerge)({}, (_a = this.config.bodyParser) !== null && _a !== void 0 ? _a : {}, opts);
499
+ this.config.bodyParser = (0, obj_utils_1.deepObjMerge)({}, this.config.bodyParser ?? {}, opts);
503
500
  return this;
504
501
  }
505
502
  /**
@@ -541,10 +538,9 @@ class ServerConfigBuilder {
541
538
  * ```
542
539
  */
543
540
  withStaticFolder(folder) {
544
- var _a;
545
541
  if (!folder.path)
546
542
  throw new Error('Static folder requires a path');
547
- const folders = [...((_a = this.config.staticFolders) !== null && _a !== void 0 ? _a : []), folder];
543
+ const folders = [...(this.config.staticFolders ?? []), folder];
548
544
  this.config.staticFolders = Array.from(new Map(folders.map(f => [f.path, f])).values());
549
545
  return this;
550
546
  }
@@ -638,13 +634,15 @@ class ServerConfigBuilder {
638
634
  * ```
639
635
  */
640
636
  build() {
641
- var _a;
642
637
  const config = (0, obj_utils_1.deepObjMerge)({}, config_1.defaultServerConfig, this.config);
643
638
  // Common validation
644
- if (((_a = config.openApi) === null || _a === void 0 ? void 0 : _a.enable) && !config.openApi.filePath) {
639
+ if (config.openApi?.enable && !config.openApi.filePath) {
645
640
  throw new Error('OpenAPI is enabled but no filePath is specified');
646
641
  }
647
- return Object.freeze(Object.assign(Object.assign({}, config), { [exports.BUILD_MARKER]: true }));
642
+ return Object.freeze({
643
+ ...config,
644
+ [exports.BUILD_MARKER]: true
645
+ });
648
646
  }
649
647
  mergeConfig(key, value) {
650
648
  const current = typeof this.config[key] === 'object' && this.config[key] !== null
@@ -653,9 +651,8 @@ class ServerConfigBuilder {
653
651
  this.config[key] = (0, obj_utils_1.deepObjMerge)({}, current, value);
654
652
  }
655
653
  setEnabled(key, enable, overrides = {}) {
656
- this.mergeConfig(key, Object.assign(Object.assign({}, overrides), { enable }));
654
+ this.mergeConfig(key, { ...overrides, enable });
657
655
  return this;
658
656
  }
659
657
  }
660
658
  exports.ServerConfigBuilder = ServerConfigBuilder;
661
- //# sourceMappingURL=server.builder.js.map
@@ -253,4 +253,3 @@ export declare class ExpressServer {
253
253
  private static isBuiltServerConfig;
254
254
  private static optionalRequire;
255
255
  }
256
- //# sourceMappingURL=server.d.ts.map
@@ -57,6 +57,38 @@ const validate_utils_1 = require("../utils/validate.utils");
57
57
  * Includes K8s readiness probes and zero-downtime support.
58
58
  */
59
59
  class ExpressServer {
60
+ /** Prometheus client registry for metrics collection */
61
+ register = null;
62
+ /** HTTP server instance (null when not running) */
63
+ server = null;
64
+ /** Merged configuration with defaults applied */
65
+ config;
66
+ /** User-defined lifecycle hooks */
67
+ hooks;
68
+ /** Global API prefix (from config) */
69
+ globalPrefix;
70
+ /** Internal fallback router */
71
+ rootRouter;
72
+ /** User-supplied router */
73
+ externalRouter;
74
+ /** Internal Express app instance */
75
+ app;
76
+ /** Set of active WebSocket connections */
77
+ connections = new Set();
78
+ /** Flag indicating if the server is shutting down */
79
+ isShuttingDown = false;
80
+ /**
81
+ * Collection of registered health check functions.
82
+ * These are executed when the health check endpoint is accessed.
83
+ */
84
+ healthChecks = [];
85
+ /** Prometheus metrics for monitoring */
86
+ requestCounter;
87
+ routeTimings;
88
+ requestSizes;
89
+ clientIPs;
90
+ /** Promise that resolves when initialization (middleware + routes) is complete */
91
+ initPromise;
60
92
  /**
61
93
  * Initializes server with intelligent defaults and security best practices.
62
94
  * All settings can be customized via config and hooks.
@@ -75,20 +107,6 @@ class ExpressServer {
75
107
  * - Request tracing
76
108
  */
77
109
  constructor(config, hooks = {}) {
78
- var _a, _b, _c;
79
- /** Prometheus client registry for metrics collection */
80
- this.register = null;
81
- /** HTTP server instance (null when not running) */
82
- this.server = null;
83
- /** Set of active WebSocket connections */
84
- this.connections = new Set();
85
- /** Flag indicating if the server is shutting down */
86
- this.isShuttingDown = false;
87
- /**
88
- * Collection of registered health check functions.
89
- * These are executed when the health check endpoint is accessed.
90
- */
91
- this.healthChecks = [];
92
110
  if (ExpressServer.isBuiltServerConfig(config)) {
93
111
  this.config = config;
94
112
  }
@@ -102,7 +120,7 @@ class ExpressServer {
102
120
  }
103
121
  // Sanitize app name for metrics (replace invalid characters with underscore)
104
122
  const safeAppName = (this.config.appName || 'express_app').toLowerCase().replace(/[^a-z0-9_]/g, '_');
105
- if ((_a = this.config.metrics) === null || _a === void 0 ? void 0 : _a.enable) {
123
+ if (this.config.metrics?.enable) {
106
124
  const client = ExpressServer.optionalRequire('prom-client');
107
125
  if (!client) {
108
126
  (0, logger_utils_1.getLogger)().error({ command: 'npm install prom-client' }, 'prom-client is required for metrics but not installed. Please add it to your dependencies');
@@ -143,11 +161,11 @@ class ExpressServer {
143
161
  });
144
162
  }
145
163
  // Health checks
146
- if ((_b = config.healthCheck) === null || _b === void 0 ? void 0 : _b.checks) {
164
+ if (config.healthCheck?.checks) {
147
165
  this.healthChecks.push(...config.healthCheck.checks);
148
166
  }
149
167
  // Set global prefix (normalize to empty string or "/prefix" without trailing slash)
150
- this.globalPrefix = this.normalizePath((_c = this.config.globalPrefix) !== null && _c !== void 0 ? _c : '', false);
168
+ this.globalPrefix = this.normalizePath(this.config.globalPrefix ?? '', false);
151
169
  this.hooks = hooks;
152
170
  this.app = (0, express_1.default)();
153
171
  this.rootRouter = express_1.default.Router();
@@ -202,7 +220,6 @@ class ExpressServer {
202
220
  * 14. Custom response hooks
203
221
  */
204
222
  async setupMiddleware() {
205
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
206
223
  if (this.config.https) {
207
224
  await this.validateHttpsFiles();
208
225
  }
@@ -213,13 +230,13 @@ class ExpressServer {
213
230
  }
214
231
  // Request ID generation - must be first for proper tracing
215
232
  this.app.use((0, middleware_utils_1.requestId)({
216
- headerName: (_a = this.config.requestId) === null || _a === void 0 ? void 0 : _a.headerName,
217
- exposeHeader: (_b = this.config.requestId) === null || _b === void 0 ? void 0 : _b.exposeHeader,
218
- generator: (_c = this.config.requestId) === null || _c === void 0 ? void 0 : _c.generator
233
+ headerName: this.config.requestId?.headerName,
234
+ exposeHeader: this.config.requestId?.exposeHeader,
235
+ generator: this.config.requestId?.generator
219
236
  }));
220
237
  // Request context setup for logging correlation
221
238
  this.app.use((0, middleware_utils_1.setupRequestContext)({
222
- headerName: (_d = this.config.requestId) === null || _d === void 0 ? void 0 : _d.headerName,
239
+ headerName: this.config.requestId?.headerName,
223
240
  autoLog: false
224
241
  }));
225
242
  // Early shutdown-awareness middleware (lets load balancers drain connections gracefully)
@@ -258,7 +275,6 @@ class ExpressServer {
258
275
  }
259
276
  // Global headers
260
277
  this.app.use((_req, res, next) => {
261
- var _a, _b, _c, _d;
262
278
  if (this.config.globalHeaders) {
263
279
  for (const key in this.config.globalHeaders) {
264
280
  const value = this.config.globalHeaders[key];
@@ -268,11 +284,11 @@ class ExpressServer {
268
284
  if (this.config.isMicroservice) {
269
285
  res.setHeader('X-Microservice', this.config.appName || 'express_app');
270
286
  }
271
- if ((_a = this.config.serviceVersion) === null || _a === void 0 ? void 0 : _a.enable) {
272
- const version = typeof ((_b = this.config.serviceVersion) === null || _b === void 0 ? void 0 : _b.version) === 'function'
287
+ if (this.config.serviceVersion?.enable) {
288
+ const version = typeof this.config.serviceVersion?.version === 'function'
273
289
  ? this.config.serviceVersion.version()
274
- : (_c = this.config.serviceVersion) === null || _c === void 0 ? void 0 : _c.version;
275
- res.setHeader(((_d = this.config.serviceVersion) === null || _d === void 0 ? void 0 : _d.headerName) || 'x-service-version', version || '0.0.0');
290
+ : this.config.serviceVersion?.version;
291
+ res.setHeader(this.config.serviceVersion?.headerName || 'x-service-version', version || '0.0.0');
276
292
  }
277
293
  next();
278
294
  });
@@ -281,43 +297,41 @@ class ExpressServer {
281
297
  this.app.use((0, middleware_utils_1.timeout)(this.config.requestTimeout));
282
298
  }
283
299
  // Response time tracking for performance monitoring
284
- if ((_e = this.config.responseTime) === null || _e === void 0 ? void 0 : _e.enable) {
300
+ if (this.config.responseTime?.enable) {
285
301
  this.app.use((0, middleware_utils_1.responseTime)({
286
302
  addHeader: this.config.responseTime.addHeader,
287
303
  logOnComplete: this.config.responseTime.logOnComplete
288
304
  }));
289
305
  }
290
306
  // Rate limiting should be early to prevent unnecessary processing
291
- if ((_f = this.config.rateLimit) === null || _f === void 0 ? void 0 : _f.enable) {
307
+ if (this.config.rateLimit?.enable) {
292
308
  const rateLimit = ExpressServer.optionalRequire('express-rate-limit');
293
309
  if (!rateLimit) {
294
310
  (0, logger_utils_1.getLogger)().error({ command: 'npm install express-rate-limit' }, 'express-rate-limit is required but not installed. Please add it to your dependencies');
295
311
  process.exit(1);
296
312
  }
297
313
  this.app.use(rateLimit({
298
- windowMs: (_g = this.config.rateLimit.windowMs) !== null && _g !== void 0 ? _g : 15 * 60 * 1000,
299
- max: (_h = this.config.rateLimit.max) !== null && _h !== void 0 ? _h : 100,
314
+ windowMs: this.config.rateLimit.windowMs ?? 15 * 60 * 1000,
315
+ max: this.config.rateLimit.max ?? 100,
300
316
  handler: (req, res) => {
301
- var _a;
302
317
  const status = http_status_codes_1.HttpStatusCodes.TOO_MANY_REQUESTS;
303
- const response = (0, response_utils_1.createFinalErrorResponse)(req, status, ((_a = this.config.rateLimit) === null || _a === void 0 ? void 0 : _a.message) || 'Too many requests');
318
+ const response = (0, response_utils_1.createFinalErrorResponse)(req, status, this.config.rateLimit?.message || 'Too many requests');
304
319
  res.status(status).json(response);
305
320
  },
306
- standardHeaders: (_j = this.config.rateLimit.standardHeaders) !== null && _j !== void 0 ? _j : true,
307
- legacyHeaders: (_k = this.config.rateLimit.legacyHeaders) !== null && _k !== void 0 ? _k : false
321
+ standardHeaders: this.config.rateLimit.standardHeaders ?? true,
322
+ legacyHeaders: this.config.rateLimit.legacyHeaders ?? false
308
323
  }));
309
324
  }
310
325
  // Request logging with filtering
311
- if ((_l = this.config.requestLogging) === null || _l === void 0 ? void 0 : _l.enable) {
326
+ if (this.config.requestLogging?.enable) {
312
327
  this.app.use((req, res, next) => {
313
- var _a, _b, _c, _d, _e, _f;
314
- if (typeof ((_a = this.config.requestLogging) === null || _a === void 0 ? void 0 : _a.ignorePaths) === 'function') {
315
- const skip = (_c = (_b = this.config.requestLogging) === null || _b === void 0 ? void 0 : _b.ignorePaths) === null || _c === void 0 ? void 0 : _c.call(_b, req, res);
328
+ if (typeof this.config.requestLogging?.ignorePaths === 'function') {
329
+ const skip = this.config.requestLogging?.ignorePaths?.(req, res);
316
330
  if (skip)
317
331
  return next();
318
332
  }
319
- else if (Array.isArray((_d = this.config.requestLogging) === null || _d === void 0 ? void 0 : _d.ignorePaths)) {
320
- const skip = (_f = (_e = this.config.requestLogging) === null || _e === void 0 ? void 0 : _e.ignorePaths) === null || _f === void 0 ? void 0 : _f.includes(req.path);
333
+ else if (Array.isArray(this.config.requestLogging?.ignorePaths)) {
334
+ const skip = this.config.requestLogging?.ignorePaths?.includes(req.path);
321
335
  if (skip)
322
336
  return next();
323
337
  }
@@ -353,8 +367,7 @@ class ExpressServer {
353
367
  // Static file serving (do NOT normalize filesystem path; only normalize route)
354
368
  if (this.config.staticFolders) {
355
369
  this.config.staticFolders.forEach(folder => {
356
- var _a;
357
- this.app.use(this.normalizePath((_a = folder.path) !== null && _a !== void 0 ? _a : '/'), express_1.default.static(folder.directory, {
370
+ this.app.use(this.normalizePath(folder.path ?? '/'), express_1.default.static(folder.directory, {
358
371
  maxAge: folder.maxAge || 0,
359
372
  etag: folder.etag !== false,
360
373
  immutable: folder.immutable === true,
@@ -388,9 +401,9 @@ class ExpressServer {
388
401
  }
389
402
  }
390
403
  // OpenAPI docs via @scalar/express-api-reference
391
- if ((_m = this.config.openApi) === null || _m === void 0 ? void 0 : _m.enable) {
404
+ if (this.config.openApi?.enable) {
392
405
  try {
393
- const openApiMountPath = this.normalizePath((_o = this.config.openApi.mountPath) !== null && _o !== void 0 ? _o : '/docs', this.config.openApi.withGlobalPrefix);
406
+ const openApiMountPath = this.normalizePath(this.config.openApi.mountPath ?? '/docs', this.config.openApi.withGlobalPrefix);
394
407
  const openApiFilePath = this.config.openApi.filePath;
395
408
  if (!openApiFilePath) {
396
409
  (0, logger_utils_1.getLogger)().error('OpenAPI file path is required');
@@ -401,7 +414,7 @@ class ExpressServer {
401
414
  (0, logger_utils_1.getLogger)().error(`OpenAPI spec file not found at ${openApiFilePath}`);
402
415
  process.exit(1);
403
416
  }
404
- if ((_p = this.config.openApi) === null || _p === void 0 ? void 0 : _p.verbose) {
417
+ if (this.config.openApi?.verbose) {
405
418
  (0, logger_utils_1.getLogger)().info(`Mounting OpenAPI docs at ${openApiMountPath}`);
406
419
  (0, logger_utils_1.getLogger)().info(`Using OpenAPI spec file at ${openApiFilePath}`);
407
420
  }
@@ -415,7 +428,7 @@ class ExpressServer {
415
428
  content: await fs_1.default.promises.readFile(openApiFilePath, 'utf8')
416
429
  }
417
430
  }));
418
- if ((_q = this.config.openApi) === null || _q === void 0 ? void 0 : _q.verbose) {
431
+ if (this.config.openApi?.verbose) {
419
432
  (0, logger_utils_1.getLogger)().info(`Mounted OpenAPI docs at ${openApiMountPath}`);
420
433
  }
421
434
  }
@@ -427,32 +440,30 @@ class ExpressServer {
427
440
  if (this.hooks.onResponse) {
428
441
  this.app.use(this.globalPrefix, this.hooks.onResponse);
429
442
  }
430
- if ((_r = this.config.metrics) === null || _r === void 0 ? void 0 : _r.enable) {
443
+ if (this.config.metrics?.enable) {
431
444
  // Add metrics tracking middleware
432
445
  this.app.use((req, res, next) => {
433
- var _a, _b;
434
446
  const start = process.hrtime();
435
447
  // Track client IPs
436
- (_a = this.clientIPs) === null || _a === void 0 ? void 0 : _a.inc({ ip: req.ip, method: req.method });
448
+ this.clientIPs?.inc({ ip: req.ip, method: req.method });
437
449
  // Track request sizes (parse safely)
438
450
  const cl = req.headers['content-length'];
439
451
  if (cl) {
440
452
  const size = Number(cl);
441
453
  if (!Number.isNaN(size) && size >= 0) {
442
454
  const route = this.normalizeRouteForMetrics(req, res);
443
- (_b = this.requestSizes) === null || _b === void 0 ? void 0 : _b.observe({ method: req.method, route }, size);
455
+ this.requestSizes?.observe({ method: req.method, route }, size);
444
456
  }
445
457
  }
446
458
  res.once('finish', () => {
447
- var _a, _b;
448
459
  const [seconds, nanoseconds] = process.hrtime(start);
449
460
  const finalRoute = this.normalizeRouteForMetrics(req, res);
450
- (_a = this.requestCounter) === null || _a === void 0 ? void 0 : _a.inc({
461
+ this.requestCounter?.inc({
451
462
  method: req.method,
452
463
  route: finalRoute,
453
464
  status: res.statusCode.toString()
454
465
  });
455
- (_b = this.routeTimings) === null || _b === void 0 ? void 0 : _b.observe({
466
+ this.routeTimings?.observe({
456
467
  method: req.method,
457
468
  route: finalRoute,
458
469
  status: res.statusCode.toString()
@@ -472,11 +483,9 @@ class ExpressServer {
472
483
  * 4. Error handler
473
484
  */
474
485
  async setupRoutes() {
475
- var _a, _b, _c, _d, _e;
476
486
  // Health check endpoint
477
- const healthCheckPath = this.normalizePath(((_a = this.config.healthCheck) === null || _a === void 0 ? void 0 : _a.path) || '/healthz', (_b = this.config.healthCheck) === null || _b === void 0 ? void 0 : _b.withGlobalPrefix);
487
+ const healthCheckPath = this.normalizePath(this.config.healthCheck?.path || '/healthz', this.config.healthCheck?.withGlobalPrefix);
478
488
  this.app.get(healthCheckPath, async (_req, res) => {
479
- var _a;
480
489
  try {
481
490
  if (!this.healthChecks.length) {
482
491
  return res.status(http_status_codes_1.HttpStatusCodes.OK).json(new response_utils_1.SuccessResponse('OK'));
@@ -500,19 +509,19 @@ class ExpressServer {
500
509
  const response = new response_utils_1.SuccessResponse(allOk ? 'OK' : 'Service unavailable');
501
510
  if (!allOk)
502
511
  response.error = true;
503
- if ((_a = this.config.healthCheck) === null || _a === void 0 ? void 0 : _a.detailed)
512
+ if (this.config.healthCheck?.detailed)
504
513
  response.data = { checks: results };
505
514
  return res.status(status).json(response);
506
515
  }
507
- catch (_b) {
516
+ catch {
508
517
  return res
509
518
  .status(http_status_codes_1.HttpStatusCodes.INTERNAL_SERVER_ERROR)
510
519
  .json(new exception_utils_1.InternalServerErrorException('Health check failed'));
511
520
  }
512
521
  });
513
522
  // Metrics endpoint
514
- if ((_c = this.config.metrics) === null || _c === void 0 ? void 0 : _c.enable) {
515
- const metricsPath = this.normalizePath((_d = this.config.metrics.path) !== null && _d !== void 0 ? _d : '/metrics', (_e = this.config.metrics) === null || _e === void 0 ? void 0 : _e.withGlobalPrefix);
523
+ if (this.config.metrics?.enable) {
524
+ const metricsPath = this.normalizePath(this.config.metrics.path ?? '/metrics', this.config.metrics?.withGlobalPrefix);
516
525
  this.app.get(metricsPath, async (_req, res) => {
517
526
  res.set('Content-Type', this.register.contentType);
518
527
  res.end(await this.register.metrics());
@@ -529,12 +538,11 @@ class ExpressServer {
529
538
  });
530
539
  // Global error handler (must be the last middleware)
531
540
  this.app.use((err, req, res, next) => {
532
- var _a;
533
541
  // Check if this is a 404 error that should be handled with special logging rules
534
542
  const isNotFoundError = err instanceof exception_utils_2.NotFoundException;
535
543
  const shouldSkipLogging = !this.hooks.onError &&
536
544
  isNotFoundError &&
537
- ((_a = this.config.requestLogging) === null || _a === void 0 ? void 0 : _a.enable) &&
545
+ this.config.requestLogging?.enable &&
538
546
  this.config.requestLogging.skipNotFoundRoutes === true;
539
547
  if (this.hooks.onError) {
540
548
  // Use custom error handler if provided
@@ -612,17 +620,16 @@ class ExpressServer {
612
620
  this.config.port,
613
621
  this.config.host,
614
622
  async () => {
615
- var _a, _b, _c;
616
623
  const protocol = this.config.https ? 'https' : 'http';
617
624
  const url = `${protocol}://${this.config.host}:${this.config.port}`;
618
625
  (0, logger_utils_1.getLogger)().info(`Server running on ${url}`);
619
- if ((_a = this.config.healthCheck) === null || _a === void 0 ? void 0 : _a.path) {
626
+ if (this.config.healthCheck?.path) {
620
627
  (0, logger_utils_1.getLogger)().info(`Health check available at ${url}${this.normalizePath(this.config.healthCheck.path, this.config.healthCheck.withGlobalPrefix)}`);
621
628
  }
622
- if (((_b = this.config.metrics) === null || _b === void 0 ? void 0 : _b.enable) && this.config.metrics.path) {
629
+ if (this.config.metrics?.enable && this.config.metrics.path) {
623
630
  (0, logger_utils_1.getLogger)().info(`Metrics available at ${url}${this.normalizePath(this.config.metrics.path, this.config.metrics.withGlobalPrefix)}`);
624
631
  }
625
- if ((_c = this.config.openApi) === null || _c === void 0 ? void 0 : _c.enable) {
632
+ if (this.config.openApi?.enable) {
626
633
  (0, logger_utils_1.getLogger)().info(`API docs available at ${url}${this.normalizePath(this.config.openApi.mountPath, this.config.openApi.withGlobalPrefix)}`);
627
634
  }
628
635
  if (this.server)
@@ -631,7 +638,11 @@ class ExpressServer {
631
638
  }
632
639
  ];
633
640
  if (this.config.https) {
634
- const httpsOptions = Object.assign(Object.assign({}, this.config.https), { key: fs_1.default.readFileSync(this.config.https.key), cert: fs_1.default.readFileSync(this.config.https.cert) });
641
+ const httpsOptions = {
642
+ ...this.config.https,
643
+ key: fs_1.default.readFileSync(this.config.https.key),
644
+ cert: fs_1.default.readFileSync(this.config.https.cert)
645
+ };
635
646
  if (this.config.https.ca) {
636
647
  httpsOptions.ca = fs_1.default.readFileSync(this.config.https.ca);
637
648
  }
@@ -687,7 +698,7 @@ class ExpressServer {
687
698
  }
688
699
  this.isShuttingDown = true;
689
700
  await this.runHook('beforeStop', this.server);
690
- const shutdownTimeout = 10000; // 10s max wait
701
+ const shutdownTimeout = 10_000; // 10s max wait
691
702
  const serverClosePromise = new Promise((resolve, reject) => {
692
703
  this.server.close(async (err) => {
693
704
  if (err) {
@@ -847,8 +858,7 @@ class ExpressServer {
847
858
  * @return {*} {client.Registry}
848
859
  */
849
860
  getMetricsRegistry() {
850
- var _a;
851
- if (!((_a = this.config.metrics) === null || _a === void 0 ? void 0 : _a.enable)) {
861
+ if (!this.config.metrics?.enable) {
852
862
  throw new Error('Metrics are not enabled in the server configuration');
853
863
  }
854
864
  return this.register;
@@ -886,9 +896,8 @@ class ExpressServer {
886
896
  return sanitize(prefix + '/' + path);
887
897
  }
888
898
  normalizeRouteForMetrics(req, res) {
889
- var _a;
890
899
  // Prevent high cardinality metrics by normalizing routes
891
- if ((_a = req === null || req === void 0 ? void 0 : req.route) === null || _a === void 0 ? void 0 : _a.path) {
900
+ if (req?.route?.path) {
892
901
  // Use Express route pattern instead of actual URL
893
902
  return req.route.path;
894
903
  }
@@ -953,10 +962,9 @@ class ExpressServer {
953
962
  try {
954
963
  return require(name);
955
964
  }
956
- catch (_a) {
965
+ catch {
957
966
  return null;
958
967
  }
959
968
  }
960
969
  }
961
970
  exports.ExpressServer = ExpressServer;
962
- //# sourceMappingURL=server.js.map
@@ -149,4 +149,3 @@ export interface PaginationParams {
149
149
  * Type that combines pagination parameters with additional data.
150
150
  */
151
151
  export type WithPagination<T = {}> = PaginationParams & T;
152
- //# sourceMappingURL=api-response.d.ts.map
@@ -34,4 +34,3 @@ var SortDirection;
34
34
  /** Descending sort order */
35
35
  SortDirection["DESC"] = "desc";
36
36
  })(SortDirection || (exports.SortDirection = SortDirection = {}));
37
- //# sourceMappingURL=api-response.js.map
@@ -122,4 +122,3 @@ export type Optional2<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
122
122
  export type Without<T, U> = {
123
123
  [P in keyof T as T[P] extends U ? never : P]: T[P];
124
124
  };
125
- //# sourceMappingURL=index.d.ts.map
@@ -23,4 +23,3 @@
23
23
  * SOFTWARE.
24
24
  */
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- //# sourceMappingURL=index.js.map
@@ -265,4 +265,3 @@ export interface ServerHooks {
265
265
  /** Called before response is sent - good for response modification */
266
266
  onResponse?: (req: Request, res: Response, next: NextFunction) => void;
267
267
  }
268
- //# sourceMappingURL=server.d.ts.map
@@ -23,4 +23,3 @@
23
23
  * SOFTWARE.
24
24
  */
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- //# sourceMappingURL=server.js.map
@@ -165,4 +165,3 @@ export declare function compact<T>(array: T[]): NonNullable<T>[];
165
165
  * @returns {Record<string, number>} Object with counts by key.
166
166
  */
167
167
  export declare function countBy<T>(array: T[], keyFn: (item: T) => string | number | symbol): Record<string, number>;
168
- //# sourceMappingURL=array.utils.d.ts.map
@@ -361,4 +361,3 @@ function countBy(array, keyFn) {
361
361
  return acc;
362
362
  }, {});
363
363
  }
364
- //# sourceMappingURL=array.utils.js.map
@@ -262,4 +262,3 @@ export declare function runWithConcurrency<T>(tasks: Array<() => Promise<T>>, op
262
262
  /** Abort signal to cancel execution */
263
263
  signal?: AbortSignal;
264
264
  }): Promise<T[]>;
265
- //# sourceMappingURL=async.utils.d.ts.map
@@ -580,7 +580,7 @@ async function runWithConcurrency(tasks, options = {}) {
580
580
  if (totalTasks === 0)
581
581
  return results;
582
582
  // Check if execution is already aborted
583
- if (signal === null || signal === void 0 ? void 0 : signal.aborted) {
583
+ if (signal?.aborted) {
584
584
  throw new Error('Aborted');
585
585
  }
586
586
  return new Promise((resolve, reject) => {
@@ -596,7 +596,7 @@ async function runWithConcurrency(tasks, options = {}) {
596
596
  // Run the task
597
597
  const result = await tasks[currentTaskIndex]();
598
598
  // Check if aborted during task execution
599
- if (signal === null || signal === void 0 ? void 0 : signal.aborted) {
599
+ if (signal?.aborted) {
600
600
  reject(new Error('Aborted'));
601
601
  return;
602
602
  }
@@ -638,4 +638,3 @@ async function runWithConcurrency(tasks, options = {}) {
638
638
  }
639
639
  });
640
640
  }
641
- //# sourceMappingURL=async.utils.js.map
@@ -150,4 +150,3 @@ export declare class TTLCache<K, V> {
150
150
  */
151
151
  private evictLRU;
152
152
  }
153
- //# sourceMappingURL=cache.utils.d.ts.map
@@ -37,13 +37,15 @@ const config_1 = require("../config");
37
37
  * const value = cache.get("x"); // 123
38
38
  */
39
39
  class TTLCache {
40
+ cache = new Map();
41
+ ttlMs;
42
+ maxSize;
43
+ cleanupInterval;
40
44
  /**
41
45
  * @param options - Configuration options for the cache
42
46
  */
43
47
  constructor(options = {}) {
44
- var _a;
45
- this.cache = new Map();
46
- this.ttlMs = (_a = options.ttlMs) !== null && _a !== void 0 ? _a : config_1.config.cache.defaultTtl;
48
+ this.ttlMs = options.ttlMs ?? config_1.config.cache.defaultTtl;
47
49
  this.maxSize = options.maxSize;
48
50
  // Setup auto-cleanup if enabled
49
51
  const autoCleanupMs = options.autoCleanupMs;
@@ -115,7 +117,7 @@ class TTLCache {
115
117
  if (value !== undefined)
116
118
  return value;
117
119
  const newValue = await producer();
118
- this.setWithTTL(key, newValue, ttlMs !== null && ttlMs !== void 0 ? ttlMs : this.ttlMs);
120
+ this.setWithTTL(key, newValue, ttlMs ?? this.ttlMs);
119
121
  return newValue;
120
122
  }
121
123
  /**
@@ -237,7 +239,7 @@ class TTLCache {
237
239
  this.cache.delete(key);
238
240
  return false;
239
241
  }
240
- entry.expiresAt = now + (ttlMs !== null && ttlMs !== void 0 ? ttlMs : this.ttlMs);
242
+ entry.expiresAt = now + (ttlMs ?? this.ttlMs);
241
243
  entry.lastAccessed = now;
242
244
  return true;
243
245
  }
@@ -294,4 +296,3 @@ class TTLCache {
294
296
  }
295
297
  }
296
298
  exports.TTLCache = TTLCache;
297
- //# sourceMappingURL=cache.utils.js.map
@@ -144,7 +144,7 @@ export declare class ContextStore {
144
144
  * @param {(req: any) => Partial<Record<symbol, unknown>>} initialValuesFactory - Function that returns initial context values.
145
145
  * @returns Express middleware function.
146
146
  */
147
- static createExpressMiddleware(initialValuesFactory?: (req: any) => Partial<Record<symbol, unknown>>): (req: any, res: any, next: any) => void;
147
+ static createExpressMiddleware(initialValuesFactory?: (req: any) => Partial<Record<symbol, unknown>>): (req: any, _res: any, next: any) => void;
148
148
  }
149
149
  /**
150
150
  * Type-safe wrapper for accessing and modifying context values with specific types.
@@ -186,4 +186,3 @@ export declare class TypedContextKey<T> {
186
186
  */
187
187
  delete(): boolean;
188
188
  }
189
- //# sourceMappingURL=context-store.utils.d.ts.map