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

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/esm/config.d.ts +0 -1
  2. package/build/esm/config.js +6 -7
  3. package/build/esm/index.d.ts +0 -1
  4. package/build/esm/index.js +0 -1
  5. package/build/esm/servers/server.builder.d.ts +0 -1
  6. package/build/esm/servers/server.builder.js +99 -147
  7. package/build/esm/servers/server.d.ts +0 -1
  8. package/build/esm/servers/server.js +591 -876
  9. package/build/esm/types/api-response.d.ts +0 -1
  10. package/build/esm/types/api-response.js +0 -1
  11. package/build/esm/types/index.d.ts +0 -1
  12. package/build/esm/types/index.js +0 -1
  13. package/build/esm/types/server.d.ts +0 -1
  14. package/build/esm/types/server.js +0 -1
  15. package/build/esm/utils/array.utils.d.ts +0 -1
  16. package/build/esm/utils/array.utils.js +48 -86
  17. package/build/esm/utils/async.utils.d.ts +0 -1
  18. package/build/esm/utils/async.utils.js +247 -524
  19. package/build/esm/utils/cache.utils.d.ts +0 -1
  20. package/build/esm/utils/cache.utils.js +96 -301
  21. package/build/esm/utils/context-store.utils.d.ts +0 -1
  22. package/build/esm/utils/context-store.utils.js +62 -79
  23. package/build/esm/utils/crypto.utils.d.ts +0 -1
  24. package/build/esm/utils/crypto.utils.js +78 -175
  25. package/build/esm/utils/date.utils.d.ts +0 -1
  26. package/build/esm/utils/date.utils.js +47 -53
  27. package/build/esm/utils/decorators.utils.d.ts +30 -27
  28. package/build/esm/utils/decorators.utils.js +417 -461
  29. package/build/esm/utils/dir.utils.d.ts +0 -1
  30. package/build/esm/utils/dir.utils.js +264 -786
  31. package/build/esm/utils/env.utils.d.ts +0 -1
  32. package/build/esm/utils/env.utils.js +180 -271
  33. package/build/esm/utils/exception.utils.d.ts +0 -1
  34. package/build/esm/utils/exception.utils.js +112 -289
  35. package/build/esm/utils/fs.utils.d.ts +0 -1
  36. package/build/esm/utils/fs.utils.js +169 -401
  37. package/build/esm/utils/http-status-codes.d.ts +0 -1
  38. package/build/esm/utils/http-status-codes.js +0 -1
  39. package/build/esm/utils/id.utils.d.ts +0 -1
  40. package/build/esm/utils/id.utils.js +5 -9
  41. package/build/esm/utils/logger.utils.d.ts +0 -1
  42. package/build/esm/utils/logger.utils.js +34 -71
  43. package/build/esm/utils/middleware.utils.d.ts +0 -1
  44. package/build/esm/utils/middleware.utils.js +65 -155
  45. package/build/esm/utils/obj.utils.d.ts +0 -1
  46. package/build/esm/utils/obj.utils.js +69 -176
  47. package/build/esm/utils/performance.utils.d.ts +0 -1
  48. package/build/esm/utils/performance.utils.js +92 -195
  49. package/build/esm/utils/request.utils.d.ts +0 -1
  50. package/build/esm/utils/request.utils.js +41 -74
  51. package/build/esm/utils/response.utils.d.ts +0 -1
  52. package/build/esm/utils/response.utils.js +84 -107
  53. package/build/esm/utils/stream.utils.d.ts +0 -1
  54. package/build/esm/utils/stream.utils.js +38 -113
  55. package/build/esm/utils/string.utils.d.ts +0 -1
  56. package/build/esm/utils/string.utils.js +6 -11
  57. package/build/esm/utils/type.utils.d.ts +0 -1
  58. package/build/esm/utils/type.utils.js +8 -12
  59. package/build/esm/utils/url.utils.d.ts +0 -1
  60. package/build/esm/utils/url.utils.js +49 -127
  61. package/build/esm/utils/validate.utils.d.ts +0 -1
  62. package/build/esm/utils/validate.utils.js +23 -40
  63. package/package.json +3 -33
  64. package/build/esm/config.js.map +0 -1
  65. package/build/esm/index.js.map +0 -1
  66. package/build/esm/servers/server.builder.js.map +0 -1
  67. package/build/esm/servers/server.js.map +0 -1
  68. package/build/esm/types/api-response.js.map +0 -1
  69. package/build/esm/types/index.js.map +0 -1
  70. package/build/esm/types/server.js.map +0 -1
  71. package/build/esm/utils/array.utils.js.map +0 -1
  72. package/build/esm/utils/async.utils.js.map +0 -1
  73. package/build/esm/utils/cache.utils.js.map +0 -1
  74. package/build/esm/utils/context-store.utils.js.map +0 -1
  75. package/build/esm/utils/crypto.utils.js.map +0 -1
  76. package/build/esm/utils/date.utils.js.map +0 -1
  77. package/build/esm/utils/decorators.utils.js.map +0 -1
  78. package/build/esm/utils/dir.utils.js.map +0 -1
  79. package/build/esm/utils/env.utils.js.map +0 -1
  80. package/build/esm/utils/exception.utils.js.map +0 -1
  81. package/build/esm/utils/fs.utils.js.map +0 -1
  82. package/build/esm/utils/http-status-codes.js.map +0 -1
  83. package/build/esm/utils/id.utils.js.map +0 -1
  84. package/build/esm/utils/logger.utils.js.map +0 -1
  85. package/build/esm/utils/middleware.utils.js.map +0 -1
  86. package/build/esm/utils/obj.utils.js.map +0 -1
  87. package/build/esm/utils/performance.utils.js.map +0 -1
  88. package/build/esm/utils/request.utils.js.map +0 -1
  89. package/build/esm/utils/response.utils.js.map +0 -1
  90. package/build/esm/utils/stream.utils.js.map +0 -1
  91. package/build/esm/utils/string.utils.js.map +0 -1
  92. package/build/esm/utils/type.utils.js.map +0 -1
  93. package/build/esm/utils/url.utils.js.map +0 -1
  94. package/build/esm/utils/validate.utils.js.map +0 -1
  95. package/build/esnext/config.d.ts +0 -122
  96. package/build/esnext/config.js +0 -133
  97. package/build/esnext/config.js.map +0 -1
  98. package/build/esnext/index.d.ts +0 -27
  99. package/build/esnext/index.js +0 -50
  100. package/build/esnext/index.js.map +0 -1
  101. package/build/esnext/servers/server.builder.d.ts +0 -508
  102. package/build/esnext/servers/server.builder.js +0 -657
  103. package/build/esnext/servers/server.builder.js.map +0 -1
  104. package/build/esnext/servers/server.d.ts +0 -256
  105. package/build/esnext/servers/server.js +0 -955
  106. package/build/esnext/servers/server.js.map +0 -1
  107. package/build/esnext/types/api-response.d.ts +0 -152
  108. package/build/esnext/types/api-response.js +0 -34
  109. package/build/esnext/types/api-response.js.map +0 -1
  110. package/build/esnext/types/index.d.ts +0 -125
  111. package/build/esnext/types/index.js +0 -25
  112. package/build/esnext/types/index.js.map +0 -1
  113. package/build/esnext/types/server.d.ts +0 -268
  114. package/build/esnext/types/server.js +0 -25
  115. package/build/esnext/types/server.js.map +0 -1
  116. package/build/esnext/utils/array.utils.d.ts +0 -168
  117. package/build/esnext/utils/array.utils.js +0 -345
  118. package/build/esnext/utils/array.utils.js.map +0 -1
  119. package/build/esnext/utils/async.utils.d.ts +0 -265
  120. package/build/esnext/utils/async.utils.js +0 -620
  121. package/build/esnext/utils/async.utils.js.map +0 -1
  122. package/build/esnext/utils/cache.utils.d.ts +0 -153
  123. package/build/esnext/utils/cache.utils.js +0 -293
  124. package/build/esnext/utils/cache.utils.js.map +0 -1
  125. package/build/esnext/utils/context-store.utils.d.ts +0 -189
  126. package/build/esnext/utils/context-store.utils.js +0 -289
  127. package/build/esnext/utils/context-store.utils.js.map +0 -1
  128. package/build/esnext/utils/crypto.utils.d.ts +0 -160
  129. package/build/esnext/utils/crypto.utils.js +0 -276
  130. package/build/esnext/utils/crypto.utils.js.map +0 -1
  131. package/build/esnext/utils/date.utils.d.ts +0 -159
  132. package/build/esnext/utils/date.utils.js +0 -384
  133. package/build/esnext/utils/date.utils.js.map +0 -1
  134. package/build/esnext/utils/decorators.utils.d.ts +0 -508
  135. package/build/esnext/utils/decorators.utils.js +0 -877
  136. package/build/esnext/utils/decorators.utils.js.map +0 -1
  137. package/build/esnext/utils/dir.utils.d.ts +0 -196
  138. package/build/esnext/utils/dir.utils.js +0 -477
  139. package/build/esnext/utils/dir.utils.js.map +0 -1
  140. package/build/esnext/utils/env.utils.d.ts +0 -377
  141. package/build/esnext/utils/env.utils.js +0 -785
  142. package/build/esnext/utils/env.utils.js.map +0 -1
  143. package/build/esnext/utils/exception.utils.d.ts +0 -230
  144. package/build/esnext/utils/exception.utils.js +0 -381
  145. package/build/esnext/utils/exception.utils.js.map +0 -1
  146. package/build/esnext/utils/fs.utils.d.ts +0 -164
  147. package/build/esnext/utils/fs.utils.js +0 -349
  148. package/build/esnext/utils/fs.utils.js.map +0 -1
  149. package/build/esnext/utils/http-status-codes.d.ts +0 -266
  150. package/build/esnext/utils/http-status-codes.js +0 -295
  151. package/build/esnext/utils/http-status-codes.js.map +0 -1
  152. package/build/esnext/utils/id.utils.d.ts +0 -36
  153. package/build/esnext/utils/id.utils.js +0 -84
  154. package/build/esnext/utils/id.utils.js.map +0 -1
  155. package/build/esnext/utils/logger.utils.d.ts +0 -160
  156. package/build/esnext/utils/logger.utils.js +0 -300
  157. package/build/esnext/utils/logger.utils.js.map +0 -1
  158. package/build/esnext/utils/middleware.utils.d.ts +0 -100
  159. package/build/esnext/utils/middleware.utils.js +0 -236
  160. package/build/esnext/utils/middleware.utils.js.map +0 -1
  161. package/build/esnext/utils/obj.utils.d.ts +0 -124
  162. package/build/esnext/utils/obj.utils.js +0 -413
  163. package/build/esnext/utils/obj.utils.js.map +0 -1
  164. package/build/esnext/utils/performance.utils.d.ts +0 -136
  165. package/build/esnext/utils/performance.utils.js +0 -271
  166. package/build/esnext/utils/performance.utils.js.map +0 -1
  167. package/build/esnext/utils/request.utils.d.ts +0 -86
  168. package/build/esnext/utils/request.utils.js +0 -186
  169. package/build/esnext/utils/request.utils.js.map +0 -1
  170. package/build/esnext/utils/response.utils.d.ts +0 -163
  171. package/build/esnext/utils/response.utils.js +0 -247
  172. package/build/esnext/utils/response.utils.js.map +0 -1
  173. package/build/esnext/utils/stream.utils.d.ts +0 -88
  174. package/build/esnext/utils/stream.utils.js +0 -210
  175. package/build/esnext/utils/stream.utils.js.map +0 -1
  176. package/build/esnext/utils/string.utils.d.ts +0 -93
  177. package/build/esnext/utils/string.utils.js +0 -165
  178. package/build/esnext/utils/string.utils.js.map +0 -1
  179. package/build/esnext/utils/type.utils.d.ts +0 -90
  180. package/build/esnext/utils/type.utils.js +0 -187
  181. package/build/esnext/utils/type.utils.js.map +0 -1
  182. package/build/esnext/utils/url.utils.d.ts +0 -141
  183. package/build/esnext/utils/url.utils.js +0 -304
  184. package/build/esnext/utils/url.utils.js.map +0 -1
  185. package/build/esnext/utils/validate.utils.d.ts +0 -177
  186. package/build/esnext/utils/validate.utils.js +0 -320
  187. package/build/esnext/utils/validate.utils.js.map +0 -1
  188. package/build/src/config.d.ts +0 -122
  189. package/build/src/config.js +0 -138
  190. package/build/src/config.js.map +0 -1
  191. package/build/src/index.d.ts +0 -27
  192. package/build/src/index.js +0 -69
  193. package/build/src/index.js.map +0 -1
  194. package/build/src/servers/server.builder.d.ts +0 -508
  195. package/build/src/servers/server.builder.js +0 -661
  196. package/build/src/servers/server.builder.js.map +0 -1
  197. package/build/src/servers/server.d.ts +0 -256
  198. package/build/src/servers/server.js +0 -962
  199. package/build/src/servers/server.js.map +0 -1
  200. package/build/src/types/api-response.d.ts +0 -152
  201. package/build/src/types/api-response.js +0 -37
  202. package/build/src/types/api-response.js.map +0 -1
  203. package/build/src/types/index.d.ts +0 -125
  204. package/build/src/types/index.js +0 -26
  205. package/build/src/types/index.js.map +0 -1
  206. package/build/src/types/server.d.ts +0 -268
  207. package/build/src/types/server.js +0 -26
  208. package/build/src/types/server.js.map +0 -1
  209. package/build/src/utils/array.utils.d.ts +0 -168
  210. package/build/src/utils/array.utils.js +0 -364
  211. package/build/src/utils/array.utils.js.map +0 -1
  212. package/build/src/utils/async.utils.d.ts +0 -265
  213. package/build/src/utils/async.utils.js +0 -641
  214. package/build/src/utils/async.utils.js.map +0 -1
  215. package/build/src/utils/cache.utils.d.ts +0 -153
  216. package/build/src/utils/cache.utils.js +0 -297
  217. package/build/src/utils/cache.utils.js.map +0 -1
  218. package/build/src/utils/context-store.utils.d.ts +0 -189
  219. package/build/src/utils/context-store.utils.js +0 -296
  220. package/build/src/utils/context-store.utils.js.map +0 -1
  221. package/build/src/utils/crypto.utils.d.ts +0 -160
  222. package/build/src/utils/crypto.utils.js +0 -293
  223. package/build/src/utils/crypto.utils.js.map +0 -1
  224. package/build/src/utils/date.utils.d.ts +0 -159
  225. package/build/src/utils/date.utils.js +0 -396
  226. package/build/src/utils/date.utils.js.map +0 -1
  227. package/build/src/utils/decorators.utils.d.ts +0 -508
  228. package/build/src/utils/decorators.utils.js +0 -896
  229. package/build/src/utils/decorators.utils.js.map +0 -1
  230. package/build/src/utils/dir.utils.d.ts +0 -196
  231. package/build/src/utils/dir.utils.js +0 -501
  232. package/build/src/utils/dir.utils.js.map +0 -1
  233. package/build/src/utils/env.utils.d.ts +0 -377
  234. package/build/src/utils/env.utils.js +0 -789
  235. package/build/src/utils/env.utils.js.map +0 -1
  236. package/build/src/utils/exception.utils.d.ts +0 -230
  237. package/build/src/utils/exception.utils.js +0 -407
  238. package/build/src/utils/exception.utils.js.map +0 -1
  239. package/build/src/utils/fs.utils.d.ts +0 -164
  240. package/build/src/utils/fs.utils.js +0 -372
  241. package/build/src/utils/fs.utils.js.map +0 -1
  242. package/build/src/utils/http-status-codes.d.ts +0 -266
  243. package/build/src/utils/http-status-codes.js +0 -298
  244. package/build/src/utils/http-status-codes.js.map +0 -1
  245. package/build/src/utils/id.utils.d.ts +0 -36
  246. package/build/src/utils/id.utils.js +0 -91
  247. package/build/src/utils/id.utils.js.map +0 -1
  248. package/build/src/utils/logger.utils.d.ts +0 -160
  249. package/build/src/utils/logger.utils.js +0 -346
  250. package/build/src/utils/logger.utils.js.map +0 -1
  251. package/build/src/utils/middleware.utils.d.ts +0 -100
  252. package/build/src/utils/middleware.utils.js +0 -244
  253. package/build/src/utils/middleware.utils.js.map +0 -1
  254. package/build/src/utils/obj.utils.d.ts +0 -124
  255. package/build/src/utils/obj.utils.js +0 -429
  256. package/build/src/utils/obj.utils.js.map +0 -1
  257. package/build/src/utils/performance.utils.d.ts +0 -136
  258. package/build/src/utils/performance.utils.js +0 -278
  259. package/build/src/utils/performance.utils.js.map +0 -1
  260. package/build/src/utils/request.utils.d.ts +0 -86
  261. package/build/src/utils/request.utils.js +0 -195
  262. package/build/src/utils/request.utils.js.map +0 -1
  263. package/build/src/utils/response.utils.d.ts +0 -163
  264. package/build/src/utils/response.utils.js +0 -260
  265. package/build/src/utils/response.utils.js.map +0 -1
  266. package/build/src/utils/stream.utils.d.ts +0 -88
  267. package/build/src/utils/stream.utils.js +0 -218
  268. package/build/src/utils/stream.utils.js.map +0 -1
  269. package/build/src/utils/string.utils.d.ts +0 -93
  270. package/build/src/utils/string.utils.js +0 -179
  271. package/build/src/utils/string.utils.js.map +0 -1
  272. package/build/src/utils/type.utils.d.ts +0 -90
  273. package/build/src/utils/type.utils.js +0 -196
  274. package/build/src/utils/type.utils.js.map +0 -1
  275. package/build/src/utils/url.utils.d.ts +0 -141
  276. package/build/src/utils/url.utils.js +0 -317
  277. package/build/src/utils/url.utils.js.map +0 -1
  278. package/build/src/utils/validate.utils.d.ts +0 -177
  279. package/build/src/utils/validate.utils.js +0 -345
  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
@@ -27,7 +27,7 @@ import { deepObjMerge } from './utils/obj.utils';
27
27
  /**
28
28
  * Application runtime configuration loaded from environment variables.
29
29
  */
30
- export var config = {
30
+ export let config = {
31
31
  logger: {
32
32
  /**
33
33
  * Logging level (e.g., 'info', 'debug', 'warn', 'error').
@@ -54,7 +54,7 @@ export var config = {
54
54
  defaultTtl: Env.getNumber('CACHE_DEFAULT_TTL_SECONDS', 3600) * 1000
55
55
  }
56
56
  };
57
- export var defaultServerConfig = {
57
+ export const defaultServerConfig = {
58
58
  port: 3000,
59
59
  host: '0.0.0.0',
60
60
  cors: false,
@@ -78,9 +78,9 @@ export var defaultServerConfig = {
78
78
  },
79
79
  requestLogging: {
80
80
  enable: Env.isDev(),
81
- ignorePaths: function (req, _res) {
82
- var skipPaths = ['/healthz', '/favicon.ico', '/metrics', '/docs', '/.well-known'];
83
- return skipPaths.some(function (path) { return req.path.startsWith(path); });
81
+ ignorePaths: (req, _res) => {
82
+ const skipPaths = ['/healthz', '/favicon.ico', '/metrics', '/docs', '/.well-known'];
83
+ return skipPaths.some(path => req.path.startsWith(path));
84
84
  },
85
85
  skipNotFoundRoutes: false
86
86
  },
@@ -103,7 +103,7 @@ export var defaultServerConfig = {
103
103
  requestId: {
104
104
  headerName: 'x-request-id',
105
105
  exposeHeader: true,
106
- generator: function () { return uuid(); }
106
+ generator: () => uuid()
107
107
  },
108
108
  metrics: {
109
109
  enable: false,
@@ -130,4 +130,3 @@ export function setConfig(value) {
130
130
  export function getConfig() {
131
131
  return config;
132
132
  }
133
- //# 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
@@ -47,4 +47,3 @@ export * from './types/server';
47
47
  export * from './types/api-response';
48
48
  export * from './servers/server';
49
49
  export * from './servers/server.builder';
50
- //# 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
@@ -21,42 +21,6 @@
21
21
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
22
  * SOFTWARE.
23
23
  */
24
- var __assign = (this && this.__assign) || function () {
25
- __assign = Object.assign || function(t) {
26
- for (var s, i = 1, n = arguments.length; i < n; i++) {
27
- s = arguments[i];
28
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
29
- t[p] = s[p];
30
- }
31
- return t;
32
- };
33
- return __assign.apply(this, arguments);
34
- };
35
- var __read = (this && this.__read) || function (o, n) {
36
- var m = typeof Symbol === "function" && o[Symbol.iterator];
37
- if (!m) return o;
38
- var i = m.call(o), r, ar = [], e;
39
- try {
40
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
41
- }
42
- catch (error) { e = { error: error }; }
43
- finally {
44
- try {
45
- if (r && !r.done && (m = i["return"])) m.call(i);
46
- }
47
- finally { if (e) throw e.error; }
48
- }
49
- return ar;
50
- };
51
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
52
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
53
- if (ar || !(i in from)) {
54
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
55
- ar[i] = from[i];
56
- }
57
- }
58
- return to.concat(ar || Array.prototype.slice.call(from));
59
- };
60
24
  import { deepObjMerge } from '../utils/obj.utils';
61
25
  import { defaultServerConfig } from '../config';
62
26
  import { isPort } from '../utils/validate.utils';
@@ -76,11 +40,9 @@ import { isPort } from '../utils/validate.utils';
76
40
  * .build();
77
41
  * ```
78
42
  */
79
- export var BUILD_MARKER = Symbol.for('catbee.express.server.build');
80
- var ServerConfigBuilder = /** @class */ (function () {
81
- function ServerConfigBuilder() {
82
- this.config = {};
83
- }
43
+ export const BUILD_MARKER = Symbol.for('catbee.express.server.build');
44
+ export class ServerConfigBuilder {
45
+ config = {};
84
46
  /**
85
47
  * Validates that a port number is valid and usable.
86
48
  *
@@ -88,11 +50,11 @@ var ServerConfigBuilder = /** @class */ (function () {
88
50
  * @param port - The port number to validate
89
51
  * @throws {Error} If port is not an integer or is outside the valid range (1-65535)
90
52
  */
91
- ServerConfigBuilder.prototype.validatePort = function (port) {
53
+ validatePort(port) {
92
54
  if (!isPort(port)) {
93
- throw new Error("Port must be a valid number between 1 and 65535, got: ".concat(port));
55
+ throw new Error(`Port must be a valid number between 1 and 65535, got: ${port}`);
94
56
  }
95
- };
57
+ }
96
58
  /**
97
59
  * Sets the port the server will listen on.
98
60
  *
@@ -106,11 +68,11 @@ var ServerConfigBuilder = /** @class */ (function () {
106
68
  * builder.withPort(3000)
107
69
  * ```
108
70
  */
109
- ServerConfigBuilder.prototype.withPort = function (port) {
71
+ withPort(port) {
110
72
  this.validatePort(port);
111
73
  this.config.port = port;
112
74
  return this;
113
- };
75
+ }
114
76
  /**
115
77
  * Sets the hostname the server will bind to.
116
78
  *
@@ -123,10 +85,10 @@ var ServerConfigBuilder = /** @class */ (function () {
123
85
  * builder.withHost('0.0.0.0') // Listen on all interfaces
124
86
  * ```
125
87
  */
126
- ServerConfigBuilder.prototype.withHost = function (host) {
88
+ withHost(host) {
127
89
  this.config.host = host;
128
90
  return this;
129
- };
91
+ }
130
92
  /**
131
93
  * Configures Cross-Origin Resource Sharing (CORS) for the server.
132
94
  *
@@ -146,26 +108,26 @@ var ServerConfigBuilder = /** @class */ (function () {
146
108
  * })
147
109
  * ```
148
110
  */
149
- ServerConfigBuilder.prototype.withCors = function (opts) {
111
+ withCors(opts) {
150
112
  this.config.cors = opts;
151
113
  return this;
152
- };
114
+ }
153
115
  /**
154
116
  * Enables CORS with default settings
155
117
  *
156
118
  * @returns The builder instance for chaining
157
119
  */
158
- ServerConfigBuilder.prototype.enableCors = function () {
120
+ enableCors() {
159
121
  return this.withCors(true);
160
- };
122
+ }
161
123
  /**
162
124
  * Disables CORS
163
125
  *
164
126
  * @returns The builder instance for chaining
165
127
  */
166
- ServerConfigBuilder.prototype.disableCors = function () {
128
+ disableCors() {
167
129
  return this.withCors(false);
168
- };
130
+ }
169
131
  /**
170
132
  * Configures the Helmet middleware for setting HTTP security headers.
171
133
  *
@@ -185,26 +147,26 @@ var ServerConfigBuilder = /** @class */ (function () {
185
147
  * })
186
148
  * ```
187
149
  */
188
- ServerConfigBuilder.prototype.withHelmet = function (opts) {
150
+ withHelmet(opts) {
189
151
  this.config.helmet = opts;
190
152
  return this;
191
- };
153
+ }
192
154
  /**
193
155
  * Enables Helmet with default settings
194
156
  *
195
157
  * @returns The builder instance for chaining
196
158
  */
197
- ServerConfigBuilder.prototype.enableHelmet = function () {
159
+ enableHelmet() {
198
160
  return this.withHelmet(true);
199
- };
161
+ }
200
162
  /**
201
163
  * Disables Helmet
202
164
  *
203
165
  * @returns The builder instance for chaining
204
166
  */
205
- ServerConfigBuilder.prototype.disableHelmet = function () {
167
+ disableHelmet() {
206
168
  return this.withHelmet(false);
207
- };
169
+ }
208
170
  /**
209
171
  * Configures response compression middleware.
210
172
  *
@@ -224,26 +186,26 @@ var ServerConfigBuilder = /** @class */ (function () {
224
186
  * })
225
187
  * ```
226
188
  */
227
- ServerConfigBuilder.prototype.withCompression = function (opts) {
189
+ withCompression(opts) {
228
190
  this.config.compression = opts;
229
191
  return this;
230
- };
192
+ }
231
193
  /**
232
194
  * Enables compression with default settings
233
195
  *
234
196
  * @returns The builder instance for chaining
235
197
  */
236
- ServerConfigBuilder.prototype.enableCompression = function () {
198
+ enableCompression() {
237
199
  return this.withCompression(true);
238
- };
200
+ }
239
201
  /**
240
202
  * Disables compression
241
203
  *
242
204
  * @returns The builder instance for chaining
243
205
  */
244
- ServerConfigBuilder.prototype.disableCompression = function () {
206
+ disableCompression() {
245
207
  return this.withCompression(false);
246
- };
208
+ }
247
209
  /**
248
210
  * Configures rate limiting to protect against brute-force attacks.
249
211
  *
@@ -260,28 +222,27 @@ var ServerConfigBuilder = /** @class */ (function () {
260
222
  * })
261
223
  * ```
262
224
  */
263
- ServerConfigBuilder.prototype.withRateLimit = function (opts) {
225
+ withRateLimit(opts) {
264
226
  this.mergeConfig('rateLimit', opts);
265
227
  return this;
266
- };
228
+ }
267
229
  /**
268
230
  * Enables rate limiting with default or custom settings
269
231
  *
270
232
  * @param opts - Optional rate limit configuration (max requests, window, etc.)
271
233
  * @returns The builder instance for chaining
272
234
  */
273
- ServerConfigBuilder.prototype.enableRateLimit = function (opts) {
274
- if (opts === void 0) { opts = {}; }
235
+ enableRateLimit(opts = {}) {
275
236
  return this.setEnabled('rateLimit', true, opts);
276
- };
237
+ }
277
238
  /**
278
239
  * Disables rate limiting
279
240
  *
280
241
  * @returns The builder instance for chaining
281
242
  */
282
- ServerConfigBuilder.prototype.disableRateLimit = function () {
243
+ disableRateLimit() {
283
244
  return this.setEnabled('rateLimit', false);
284
- };
245
+ }
285
246
  /**
286
247
  * Configures HTTP request logging middleware.
287
248
  *
@@ -298,28 +259,27 @@ var ServerConfigBuilder = /** @class */ (function () {
298
259
  * })
299
260
  * ```
300
261
  */
301
- ServerConfigBuilder.prototype.withRequestLogging = function (opts) {
262
+ withRequestLogging(opts) {
302
263
  this.mergeConfig('requestLogging', opts);
303
264
  return this;
304
- };
265
+ }
305
266
  /**
306
267
  * Enables request logging with default or custom settings
307
268
  *
308
269
  * @param opts - Optional request logging configuration
309
270
  * @returns The builder instance for chaining
310
271
  */
311
- ServerConfigBuilder.prototype.enableRequestLogging = function (opts) {
312
- if (opts === void 0) { opts = {}; }
272
+ enableRequestLogging(opts = {}) {
313
273
  return this.setEnabled('requestLogging', true, opts);
314
- };
274
+ }
315
275
  /**
316
276
  * Disables request logging
317
277
  *
318
278
  * @returns The builder instance for chaining
319
279
  */
320
- ServerConfigBuilder.prototype.disableRequestLogging = function () {
280
+ disableRequestLogging() {
321
281
  return this.setEnabled('requestLogging', false);
322
- };
282
+ }
323
283
  /**
324
284
  * Configures server metrics collection and endpoints.
325
285
  *
@@ -335,28 +295,27 @@ var ServerConfigBuilder = /** @class */ (function () {
335
295
  * })
336
296
  * ```
337
297
  */
338
- ServerConfigBuilder.prototype.withMetrics = function (opts) {
298
+ withMetrics(opts) {
339
299
  this.mergeConfig('metrics', opts);
340
300
  return this;
341
- };
301
+ }
342
302
  /**
343
303
  * Enables Prometheus metrics collection and endpoint
344
304
  *
345
305
  * @param opts - Optional metrics configuration
346
306
  * @returns The builder instance for chaining
347
307
  */
348
- ServerConfigBuilder.prototype.enableMetrics = function (opts) {
349
- if (opts === void 0) { opts = {}; }
308
+ enableMetrics(opts = {}) {
350
309
  return this.setEnabled('metrics', true, opts);
351
- };
310
+ }
352
311
  /**
353
312
  * Disables Prometheus metrics
354
313
  *
355
314
  * @returns The builder instance for chaining
356
315
  */
357
- ServerConfigBuilder.prototype.disableMetrics = function () {
316
+ disableMetrics() {
358
317
  return this.setEnabled('metrics', false);
359
- };
318
+ }
360
319
  /**
361
320
  * Configures server health check endpoint.
362
321
  *
@@ -372,10 +331,10 @@ var ServerConfigBuilder = /** @class */ (function () {
372
331
  * })
373
332
  * ```
374
333
  */
375
- ServerConfigBuilder.prototype.withHealthCheck = function (opts) {
334
+ withHealthCheck(opts) {
376
335
  this.mergeConfig('healthCheck', opts);
377
336
  return this;
378
- };
337
+ }
379
338
  /**
380
339
  * Configures OpenAPI/Swagger documentation for the API.
381
340
  *
@@ -392,10 +351,10 @@ var ServerConfigBuilder = /** @class */ (function () {
392
351
  * })
393
352
  * ```
394
353
  */
395
- ServerConfigBuilder.prototype.withOpenApi = function (opts) {
354
+ withOpenApi(opts) {
396
355
  this.mergeConfig('openApi', opts);
397
356
  return this;
398
- };
357
+ }
399
358
  /**
400
359
  * Enables OpenAPI documentation with required file path
401
360
  *
@@ -403,19 +362,18 @@ var ServerConfigBuilder = /** @class */ (function () {
403
362
  * @param opts - Optional OpenAPI configuration
404
363
  * @returns The builder instance for chaining
405
364
  */
406
- ServerConfigBuilder.prototype.enableOpenApi = function (filePath, opts) {
407
- if (opts === void 0) { opts = {}; }
408
- this.setEnabled('openApi', true, __assign({ filePath: filePath }, opts));
365
+ enableOpenApi(filePath, opts = {}) {
366
+ this.setEnabled('openApi', true, { filePath, ...opts });
409
367
  return this;
410
- };
368
+ }
411
369
  /**
412
370
  * Disables OpenAPI documentation
413
371
  *
414
372
  * @returns The builder instance for chaining
415
373
  */
416
- ServerConfigBuilder.prototype.disableOpenApi = function () {
374
+ disableOpenApi() {
417
375
  return this.setEnabled('openApi', false);
418
- };
376
+ }
419
377
  /**
420
378
  * Configures the server as a microservice with versioning.
421
379
  *
@@ -434,12 +392,12 @@ var ServerConfigBuilder = /** @class */ (function () {
434
392
  * })
435
393
  * ```
436
394
  */
437
- ServerConfigBuilder.prototype.withMicroService = function (opts) {
395
+ withMicroService(opts) {
438
396
  this.config.isMicroservice = true;
439
397
  this.config.appName = opts.appName;
440
398
  this.mergeConfig('serviceVersion', opts.serviceVersion);
441
399
  return this;
442
- };
400
+ }
443
401
  /**
444
402
  * Configures the trust proxy settings to determine if X-Forwarded-* headers should be trusted.
445
403
  *
@@ -453,10 +411,10 @@ var ServerConfigBuilder = /** @class */ (function () {
453
411
  * builder.withTrustProxy(true)
454
412
  * ```
455
413
  */
456
- ServerConfigBuilder.prototype.withTrustProxy = function (opts) {
414
+ withTrustProxy(opts) {
457
415
  this.config.trustProxy = opts;
458
416
  return this;
459
- };
417
+ }
460
418
  /**
461
419
  * Configures the request ID middleware for tracing requests across services.
462
420
  *
@@ -472,10 +430,10 @@ var ServerConfigBuilder = /** @class */ (function () {
472
430
  * })
473
431
  * ```
474
432
  */
475
- ServerConfigBuilder.prototype.withRequestId = function (opts) {
433
+ withRequestId(opts) {
476
434
  this.mergeConfig('requestId', opts);
477
435
  return this;
478
- };
436
+ }
479
437
  /**
480
438
  * Configures the response time middleware for measuring request processing times.
481
439
  *
@@ -492,29 +450,28 @@ var ServerConfigBuilder = /** @class */ (function () {
492
450
  * })
493
451
  * ```
494
452
  */
495
- ServerConfigBuilder.prototype.withResponseTime = function (opts) {
453
+ withResponseTime(opts) {
496
454
  this.mergeConfig('responseTime', opts);
497
455
  return this;
498
- };
456
+ }
499
457
  /**
500
458
  * Enables response time tracking with default or custom settings
501
459
  *
502
460
  * @param opts - Optional response time configuration
503
461
  * @returns The builder instance for chaining
504
462
  */
505
- ServerConfigBuilder.prototype.enableResponseTime = function (opts) {
506
- if (opts === void 0) { opts = {}; }
463
+ enableResponseTime(opts = {}) {
507
464
  this.setEnabled('responseTime', true, opts);
508
465
  return this;
509
- };
466
+ }
510
467
  /**
511
468
  * Disables response time tracking
512
469
  *
513
470
  * @returns The builder instance for chaining
514
471
  */
515
- ServerConfigBuilder.prototype.disableResponseTime = function () {
472
+ disableResponseTime() {
516
473
  return this.setEnabled('responseTime', false);
517
- };
474
+ }
518
475
  /**
519
476
  * Configures the body parser middleware options for parsing request bodies.
520
477
  *
@@ -535,11 +492,10 @@ var ServerConfigBuilder = /** @class */ (function () {
535
492
  * })
536
493
  * ```
537
494
  */
538
- ServerConfigBuilder.prototype.withBodyParser = function (opts) {
539
- var _a;
540
- this.config.bodyParser = deepObjMerge({}, (_a = this.config.bodyParser) !== null && _a !== void 0 ? _a : {}, opts);
495
+ withBodyParser(opts) {
496
+ this.config.bodyParser = deepObjMerge({}, this.config.bodyParser ?? {}, opts);
541
497
  return this;
542
- };
498
+ }
543
499
  /**
544
500
  * Configures cookie parsing middleware.
545
501
  *
@@ -559,10 +515,10 @@ var ServerConfigBuilder = /** @class */ (function () {
559
515
  * })
560
516
  * ```
561
517
  */
562
- ServerConfigBuilder.prototype.withCookies = function (opts) {
518
+ withCookies(opts) {
563
519
  this.config.cookieParser = opts;
564
520
  return this;
565
- };
521
+ }
566
522
  /**
567
523
  * Adds a static folder to serve files from.
568
524
  *
@@ -578,14 +534,13 @@ var ServerConfigBuilder = /** @class */ (function () {
578
534
  * })
579
535
  * ```
580
536
  */
581
- ServerConfigBuilder.prototype.withStaticFolder = function (folder) {
582
- var _a;
537
+ withStaticFolder(folder) {
583
538
  if (!folder.path)
584
539
  throw new Error('Static folder requires a path');
585
- var folders = __spreadArray(__spreadArray([], __read(((_a = this.config.staticFolders) !== null && _a !== void 0 ? _a : [])), false), [folder], false);
586
- this.config.staticFolders = Array.from(new Map(folders.map(function (f) { return [f.path, f]; })).values());
540
+ const folders = [...(this.config.staticFolders ?? []), folder];
541
+ this.config.staticFolders = Array.from(new Map(folders.map(f => [f.path, f])).values());
587
542
  return this;
588
- };
543
+ }
589
544
  /**
590
545
  * Sets global headers to be included in all responses.
591
546
  *
@@ -601,10 +556,10 @@ var ServerConfigBuilder = /** @class */ (function () {
601
556
  * })
602
557
  * ```
603
558
  */
604
- ServerConfigBuilder.prototype.withGlobalHeaders = function (headers) {
559
+ withGlobalHeaders(headers) {
605
560
  this.mergeConfig('globalHeaders', headers);
606
561
  return this;
607
- };
562
+ }
608
563
  /**
609
564
  * Sets a global prefix for all routes.
610
565
  *
@@ -617,10 +572,10 @@ var ServerConfigBuilder = /** @class */ (function () {
617
572
  * builder.withGlobalPrefix('/api/v1')
618
573
  * ```
619
574
  */
620
- ServerConfigBuilder.prototype.withGlobalPrefix = function (prefix) {
575
+ withGlobalPrefix(prefix) {
621
576
  this.config.globalPrefix = prefix;
622
577
  return this;
623
- };
578
+ }
624
579
  /**
625
580
  * Applies custom configuration overrides directly.
626
581
  *
@@ -635,10 +590,10 @@ var ServerConfigBuilder = /** @class */ (function () {
635
590
  * })
636
591
  * ```
637
592
  */
638
- ServerConfigBuilder.prototype.withCustom = function (overrides) {
593
+ withCustom(overrides) {
639
594
  this.config = deepObjMerge({}, this.config, overrides);
640
595
  return this;
641
- };
596
+ }
642
597
  /**
643
598
  * Configures HTTPS server options.
644
599
  *
@@ -653,10 +608,10 @@ var ServerConfigBuilder = /** @class */ (function () {
653
608
  * })
654
609
  * ```
655
610
  */
656
- ServerConfigBuilder.prototype.withHttps = function (opts) {
611
+ withHttps(opts) {
657
612
  this.config.https = opts;
658
613
  return this;
659
- };
614
+ }
660
615
  /**
661
616
  * Builds and returns the final server configuration.
662
617
  *
@@ -675,28 +630,25 @@ var ServerConfigBuilder = /** @class */ (function () {
675
630
  * .build();
676
631
  * ```
677
632
  */
678
- ServerConfigBuilder.prototype.build = function () {
679
- var _a;
680
- var _b;
681
- var config = deepObjMerge({}, defaultServerConfig, this.config);
633
+ build() {
634
+ const config = deepObjMerge({}, defaultServerConfig, this.config);
682
635
  // Common validation
683
- if (((_b = config.openApi) === null || _b === void 0 ? void 0 : _b.enable) && !config.openApi.filePath) {
636
+ if (config.openApi?.enable && !config.openApi.filePath) {
684
637
  throw new Error('OpenAPI is enabled but no filePath is specified');
685
638
  }
686
- return Object.freeze(__assign(__assign({}, config), (_a = {}, _a[BUILD_MARKER] = true, _a)));
687
- };
688
- ServerConfigBuilder.prototype.mergeConfig = function (key, value) {
689
- var current = typeof this.config[key] === 'object' && this.config[key] !== null
639
+ return Object.freeze({
640
+ ...config,
641
+ [BUILD_MARKER]: true
642
+ });
643
+ }
644
+ mergeConfig(key, value) {
645
+ const current = typeof this.config[key] === 'object' && this.config[key] !== null
690
646
  ? this.config[key]
691
647
  : {};
692
648
  this.config[key] = deepObjMerge({}, current, value);
693
- };
694
- ServerConfigBuilder.prototype.setEnabled = function (key, enable, overrides) {
695
- if (overrides === void 0) { overrides = {}; }
696
- this.mergeConfig(key, __assign(__assign({}, overrides), { enable: enable }));
649
+ }
650
+ setEnabled(key, enable, overrides = {}) {
651
+ this.mergeConfig(key, { ...overrides, enable });
697
652
  return this;
698
- };
699
- return ServerConfigBuilder;
700
- }());
701
- export { ServerConfigBuilder };
702
- //# sourceMappingURL=server.builder.js.map
653
+ }
654
+ }
@@ -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