@catbee/utils 0.0.6 → 0.0.8-next.0

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 (249) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +77 -1107
  3. package/build/index.cjs +6888 -0
  4. package/build/index.d.ts +5242 -0
  5. package/build/index.mjs +6615 -0
  6. package/package.json +26 -95
  7. package/build/esm/config.d.ts +0 -130
  8. package/build/esm/config.js +0 -145
  9. package/build/esm/config.js.map +0 -1
  10. package/build/esm/index.d.ts +0 -27
  11. package/build/esm/index.js +0 -50
  12. package/build/esm/index.js.map +0 -1
  13. package/build/esm/servers/server.builder.d.ts +0 -625
  14. package/build/esm/servers/server.builder.js +0 -722
  15. package/build/esm/servers/server.builder.js.map +0 -1
  16. package/build/esm/servers/server.d.ts +0 -256
  17. package/build/esm/servers/server.js +0 -1211
  18. package/build/esm/servers/server.js.map +0 -1
  19. package/build/esm/types/api-response.d.ts +0 -124
  20. package/build/esm/types/api-response.js +0 -25
  21. package/build/esm/types/api-response.js.map +0 -1
  22. package/build/esm/types/index.d.ts +0 -125
  23. package/build/esm/types/index.js +0 -25
  24. package/build/esm/types/index.js.map +0 -1
  25. package/build/esm/types/server.d.ts +0 -285
  26. package/build/esm/types/server.js +0 -25
  27. package/build/esm/types/server.js.map +0 -1
  28. package/build/esm/utils/array.utils.d.ts +0 -168
  29. package/build/esm/utils/array.utils.js +0 -382
  30. package/build/esm/utils/array.utils.js.map +0 -1
  31. package/build/esm/utils/async.utils.d.ts +0 -174
  32. package/build/esm/utils/async.utils.js +0 -652
  33. package/build/esm/utils/async.utils.js.map +0 -1
  34. package/build/esm/utils/cache.utils.d.ts +0 -153
  35. package/build/esm/utils/cache.utils.js +0 -499
  36. package/build/esm/utils/cache.utils.js.map +0 -1
  37. package/build/esm/utils/context-store.utils.d.ts +0 -186
  38. package/build/esm/utils/context-store.utils.js +0 -304
  39. package/build/esm/utils/context-store.utils.js.map +0 -1
  40. package/build/esm/utils/crypto.utils.d.ts +0 -160
  41. package/build/esm/utils/crypto.utils.js +0 -375
  42. package/build/esm/utils/crypto.utils.js.map +0 -1
  43. package/build/esm/utils/decorators.utils.d.ts +0 -315
  44. package/build/esm/utils/decorators.utils.js +0 -666
  45. package/build/esm/utils/decorators.utils.js.map +0 -1
  46. package/build/esm/utils/dir.utils.d.ts +0 -196
  47. package/build/esm/utils/dir.utils.js +0 -998
  48. package/build/esm/utils/dir.utils.js.map +0 -1
  49. package/build/esm/utils/env.utils.d.ts +0 -377
  50. package/build/esm/utils/env.utils.js +0 -873
  51. package/build/esm/utils/env.utils.js.map +0 -1
  52. package/build/esm/utils/exception.utils.d.ts +0 -230
  53. package/build/esm/utils/exception.utils.js +0 -559
  54. package/build/esm/utils/exception.utils.js.map +0 -1
  55. package/build/esm/utils/fs.utils.d.ts +0 -164
  56. package/build/esm/utils/fs.utils.js +0 -580
  57. package/build/esm/utils/fs.utils.js.map +0 -1
  58. package/build/esm/utils/http-status-codes.d.ts +0 -266
  59. package/build/esm/utils/http-status-codes.js +0 -295
  60. package/build/esm/utils/http-status-codes.js.map +0 -1
  61. package/build/esm/utils/id.utils.d.ts +0 -36
  62. package/build/esm/utils/id.utils.js +0 -87
  63. package/build/esm/utils/id.utils.js.map +0 -1
  64. package/build/esm/utils/logger.utils.d.ts +0 -166
  65. package/build/esm/utils/logger.utils.js +0 -347
  66. package/build/esm/utils/logger.utils.js.map +0 -1
  67. package/build/esm/utils/middleware.utils.d.ts +0 -83
  68. package/build/esm/utils/middleware.utils.js +0 -205
  69. package/build/esm/utils/middleware.utils.js.map +0 -1
  70. package/build/esm/utils/obj.utils.d.ts +0 -124
  71. package/build/esm/utils/obj.utils.js +0 -519
  72. package/build/esm/utils/obj.utils.js.map +0 -1
  73. package/build/esm/utils/request.utils.d.ts +0 -77
  74. package/build/esm/utils/request.utils.js +0 -196
  75. package/build/esm/utils/request.utils.js.map +0 -1
  76. package/build/esm/utils/response.utils.d.ts +0 -163
  77. package/build/esm/utils/response.utils.js +0 -284
  78. package/build/esm/utils/response.utils.js.map +0 -1
  79. package/build/esm/utils/string.utils.d.ts +0 -93
  80. package/build/esm/utils/string.utils.js +0 -169
  81. package/build/esm/utils/string.utils.js.map +0 -1
  82. package/build/esm/utils/url.utils.d.ts +0 -141
  83. package/build/esm/utils/url.utils.js +0 -381
  84. package/build/esm/utils/url.utils.js.map +0 -1
  85. package/build/esm/utils/validate.utils.d.ts +0 -177
  86. package/build/esm/utils/validate.utils.js +0 -336
  87. package/build/esm/utils/validate.utils.js.map +0 -1
  88. package/build/esnext/config.d.ts +0 -130
  89. package/build/esnext/config.js +0 -145
  90. package/build/esnext/config.js.map +0 -1
  91. package/build/esnext/index.d.ts +0 -27
  92. package/build/esnext/index.js +0 -50
  93. package/build/esnext/index.js.map +0 -1
  94. package/build/esnext/servers/server.builder.d.ts +0 -625
  95. package/build/esnext/servers/server.builder.js +0 -677
  96. package/build/esnext/servers/server.builder.js.map +0 -1
  97. package/build/esnext/servers/server.d.ts +0 -256
  98. package/build/esnext/servers/server.js +0 -918
  99. package/build/esnext/servers/server.js.map +0 -1
  100. package/build/esnext/types/api-response.d.ts +0 -124
  101. package/build/esnext/types/api-response.js +0 -25
  102. package/build/esnext/types/api-response.js.map +0 -1
  103. package/build/esnext/types/index.d.ts +0 -125
  104. package/build/esnext/types/index.js +0 -25
  105. package/build/esnext/types/index.js.map +0 -1
  106. package/build/esnext/types/server.d.ts +0 -285
  107. package/build/esnext/types/server.js +0 -25
  108. package/build/esnext/types/server.js.map +0 -1
  109. package/build/esnext/utils/array.utils.d.ts +0 -168
  110. package/build/esnext/utils/array.utils.js +0 -345
  111. package/build/esnext/utils/array.utils.js.map +0 -1
  112. package/build/esnext/utils/async.utils.d.ts +0 -174
  113. package/build/esnext/utils/async.utils.js +0 -430
  114. package/build/esnext/utils/async.utils.js.map +0 -1
  115. package/build/esnext/utils/cache.utils.d.ts +0 -153
  116. package/build/esnext/utils/cache.utils.js +0 -293
  117. package/build/esnext/utils/cache.utils.js.map +0 -1
  118. package/build/esnext/utils/context-store.utils.d.ts +0 -186
  119. package/build/esnext/utils/context-store.utils.js +0 -286
  120. package/build/esnext/utils/context-store.utils.js.map +0 -1
  121. package/build/esnext/utils/crypto.utils.d.ts +0 -160
  122. package/build/esnext/utils/crypto.utils.js +0 -276
  123. package/build/esnext/utils/crypto.utils.js.map +0 -1
  124. package/build/esnext/utils/decorators.utils.d.ts +0 -315
  125. package/build/esnext/utils/decorators.utils.js +0 -504
  126. package/build/esnext/utils/decorators.utils.js.map +0 -1
  127. package/build/esnext/utils/dir.utils.d.ts +0 -196
  128. package/build/esnext/utils/dir.utils.js +0 -477
  129. package/build/esnext/utils/dir.utils.js.map +0 -1
  130. package/build/esnext/utils/env.utils.d.ts +0 -377
  131. package/build/esnext/utils/env.utils.js +0 -785
  132. package/build/esnext/utils/env.utils.js.map +0 -1
  133. package/build/esnext/utils/exception.utils.d.ts +0 -230
  134. package/build/esnext/utils/exception.utils.js +0 -381
  135. package/build/esnext/utils/exception.utils.js.map +0 -1
  136. package/build/esnext/utils/fs.utils.d.ts +0 -164
  137. package/build/esnext/utils/fs.utils.js +0 -349
  138. package/build/esnext/utils/fs.utils.js.map +0 -1
  139. package/build/esnext/utils/http-status-codes.d.ts +0 -266
  140. package/build/esnext/utils/http-status-codes.js +0 -295
  141. package/build/esnext/utils/http-status-codes.js.map +0 -1
  142. package/build/esnext/utils/id.utils.d.ts +0 -36
  143. package/build/esnext/utils/id.utils.js +0 -84
  144. package/build/esnext/utils/id.utils.js.map +0 -1
  145. package/build/esnext/utils/logger.utils.d.ts +0 -166
  146. package/build/esnext/utils/logger.utils.js +0 -306
  147. package/build/esnext/utils/logger.utils.js.map +0 -1
  148. package/build/esnext/utils/middleware.utils.d.ts +0 -83
  149. package/build/esnext/utils/middleware.utils.js +0 -198
  150. package/build/esnext/utils/middleware.utils.js.map +0 -1
  151. package/build/esnext/utils/obj.utils.d.ts +0 -124
  152. package/build/esnext/utils/obj.utils.js +0 -413
  153. package/build/esnext/utils/obj.utils.js.map +0 -1
  154. package/build/esnext/utils/request.utils.d.ts +0 -77
  155. package/build/esnext/utils/request.utils.js +0 -168
  156. package/build/esnext/utils/request.utils.js.map +0 -1
  157. package/build/esnext/utils/response.utils.d.ts +0 -163
  158. package/build/esnext/utils/response.utils.js +0 -247
  159. package/build/esnext/utils/response.utils.js.map +0 -1
  160. package/build/esnext/utils/string.utils.d.ts +0 -93
  161. package/build/esnext/utils/string.utils.js +0 -165
  162. package/build/esnext/utils/string.utils.js.map +0 -1
  163. package/build/esnext/utils/url.utils.d.ts +0 -141
  164. package/build/esnext/utils/url.utils.js +0 -304
  165. package/build/esnext/utils/url.utils.js.map +0 -1
  166. package/build/esnext/utils/validate.utils.d.ts +0 -177
  167. package/build/esnext/utils/validate.utils.js +0 -320
  168. package/build/esnext/utils/validate.utils.js.map +0 -1
  169. package/build/src/config.d.ts +0 -130
  170. package/build/src/config.js +0 -150
  171. package/build/src/config.js.map +0 -1
  172. package/build/src/index.d.ts +0 -27
  173. package/build/src/index.js +0 -69
  174. package/build/src/index.js.map +0 -1
  175. package/build/src/servers/server.builder.d.ts +0 -625
  176. package/build/src/servers/server.builder.js +0 -681
  177. package/build/src/servers/server.builder.js.map +0 -1
  178. package/build/src/servers/server.d.ts +0 -256
  179. package/build/src/servers/server.js +0 -958
  180. package/build/src/servers/server.js.map +0 -1
  181. package/build/src/types/api-response.d.ts +0 -124
  182. package/build/src/types/api-response.js +0 -26
  183. package/build/src/types/api-response.js.map +0 -1
  184. package/build/src/types/index.d.ts +0 -125
  185. package/build/src/types/index.js +0 -26
  186. package/build/src/types/index.js.map +0 -1
  187. package/build/src/types/server.d.ts +0 -285
  188. package/build/src/types/server.js +0 -26
  189. package/build/src/types/server.js.map +0 -1
  190. package/build/src/utils/array.utils.d.ts +0 -168
  191. package/build/src/utils/array.utils.js +0 -364
  192. package/build/src/utils/array.utils.js.map +0 -1
  193. package/build/src/utils/async.utils.d.ts +0 -174
  194. package/build/src/utils/async.utils.js +0 -447
  195. package/build/src/utils/async.utils.js.map +0 -1
  196. package/build/src/utils/cache.utils.d.ts +0 -153
  197. package/build/src/utils/cache.utils.js +0 -297
  198. package/build/src/utils/cache.utils.js.map +0 -1
  199. package/build/src/utils/context-store.utils.d.ts +0 -186
  200. package/build/src/utils/context-store.utils.js +0 -293
  201. package/build/src/utils/context-store.utils.js.map +0 -1
  202. package/build/src/utils/crypto.utils.d.ts +0 -160
  203. package/build/src/utils/crypto.utils.js +0 -293
  204. package/build/src/utils/crypto.utils.js.map +0 -1
  205. package/build/src/utils/decorators.utils.d.ts +0 -315
  206. package/build/src/utils/decorators.utils.js +0 -516
  207. package/build/src/utils/decorators.utils.js.map +0 -1
  208. package/build/src/utils/dir.utils.d.ts +0 -196
  209. package/build/src/utils/dir.utils.js +0 -501
  210. package/build/src/utils/dir.utils.js.map +0 -1
  211. package/build/src/utils/env.utils.d.ts +0 -377
  212. package/build/src/utils/env.utils.js +0 -789
  213. package/build/src/utils/env.utils.js.map +0 -1
  214. package/build/src/utils/exception.utils.d.ts +0 -230
  215. package/build/src/utils/exception.utils.js +0 -407
  216. package/build/src/utils/exception.utils.js.map +0 -1
  217. package/build/src/utils/fs.utils.d.ts +0 -164
  218. package/build/src/utils/fs.utils.js +0 -372
  219. package/build/src/utils/fs.utils.js.map +0 -1
  220. package/build/src/utils/http-status-codes.d.ts +0 -266
  221. package/build/src/utils/http-status-codes.js +0 -298
  222. package/build/src/utils/http-status-codes.js.map +0 -1
  223. package/build/src/utils/id.utils.d.ts +0 -36
  224. package/build/src/utils/id.utils.js +0 -91
  225. package/build/src/utils/id.utils.js.map +0 -1
  226. package/build/src/utils/logger.utils.d.ts +0 -166
  227. package/build/src/utils/logger.utils.js +0 -352
  228. package/build/src/utils/logger.utils.js.map +0 -1
  229. package/build/src/utils/middleware.utils.d.ts +0 -83
  230. package/build/src/utils/middleware.utils.js +0 -205
  231. package/build/src/utils/middleware.utils.js.map +0 -1
  232. package/build/src/utils/obj.utils.d.ts +0 -124
  233. package/build/src/utils/obj.utils.js +0 -429
  234. package/build/src/utils/obj.utils.js.map +0 -1
  235. package/build/src/utils/request.utils.d.ts +0 -77
  236. package/build/src/utils/request.utils.js +0 -175
  237. package/build/src/utils/request.utils.js.map +0 -1
  238. package/build/src/utils/response.utils.d.ts +0 -163
  239. package/build/src/utils/response.utils.js +0 -260
  240. package/build/src/utils/response.utils.js.map +0 -1
  241. package/build/src/utils/string.utils.d.ts +0 -93
  242. package/build/src/utils/string.utils.js +0 -179
  243. package/build/src/utils/string.utils.js.map +0 -1
  244. package/build/src/utils/url.utils.d.ts +0 -141
  245. package/build/src/utils/url.utils.js +0 -317
  246. package/build/src/utils/url.utils.js.map +0 -1
  247. package/build/src/utils/validate.utils.d.ts +0 -177
  248. package/build/src/utils/validate.utils.js +0 -345
  249. package/build/src/utils/validate.utils.js.map +0 -1
@@ -1,69 +0,0 @@
1
- "use strict";
2
- /*
3
- * The MIT License
4
- *
5
- * Copyright (c) 2025 Catbee Technologies
6
- *
7
- * Permission is hereby granted, free of charge, to any person obtaining a copy
8
- * of this software and associated documentation files (the "Software"), to deal
9
- * in the Software without restriction, including without limitation the rights
10
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
- * copies of the Software, and to permit persons to whom the Software is
12
- * furnished to do so, subject to the following conditions:
13
- *
14
- * The above copyright notice and this permission notice shall be included in all
15
- * copies or substantial portions of the Software.
16
- *
17
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
- * SOFTWARE.
24
- */
25
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
26
- if (k2 === undefined) k2 = k;
27
- var desc = Object.getOwnPropertyDescriptor(m, k);
28
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
29
- desc = { enumerable: true, get: function() { return m[k]; } };
30
- }
31
- Object.defineProperty(o, k2, desc);
32
- }) : (function(o, m, k, k2) {
33
- if (k2 === undefined) k2 = k;
34
- o[k2] = m[k];
35
- }));
36
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
37
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
38
- };
39
- Object.defineProperty(exports, "__esModule", { value: true });
40
- exports.getConfig = exports.setConfig = void 0;
41
- var config_1 = require("./config");
42
- Object.defineProperty(exports, "setConfig", { enumerable: true, get: function () { return config_1.setConfig; } });
43
- Object.defineProperty(exports, "getConfig", { enumerable: true, get: function () { return config_1.getConfig; } });
44
- __exportStar(require("./utils/array.utils"), exports);
45
- __exportStar(require("./utils/async.utils"), exports);
46
- __exportStar(require("./utils/cache.utils"), exports);
47
- __exportStar(require("./utils/context-store.utils"), exports);
48
- __exportStar(require("./utils/crypto.utils"), exports);
49
- __exportStar(require("./utils/decorators.utils"), exports);
50
- __exportStar(require("./utils/dir.utils"), exports);
51
- __exportStar(require("./utils/env.utils"), exports);
52
- __exportStar(require("./utils/exception.utils"), exports);
53
- __exportStar(require("./utils/fs.utils"), exports);
54
- __exportStar(require("./utils/http-status-codes"), exports);
55
- __exportStar(require("./utils/id.utils"), exports);
56
- __exportStar(require("./utils/logger.utils"), exports);
57
- __exportStar(require("./utils/middleware.utils"), exports);
58
- __exportStar(require("./utils/obj.utils"), exports);
59
- __exportStar(require("./utils/request.utils"), exports);
60
- __exportStar(require("./utils/response.utils"), exports);
61
- __exportStar(require("./utils/string.utils"), exports);
62
- __exportStar(require("./utils/url.utils"), exports);
63
- __exportStar(require("./utils/validate.utils"), exports);
64
- __exportStar(require("./types/index"), exports);
65
- __exportStar(require("./types/server"), exports);
66
- __exportStar(require("./types/api-response"), exports);
67
- __exportStar(require("./servers/server"), exports);
68
- __exportStar(require("./servers/server.builder"), exports);
69
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;;;;;;;;;;;;;;;;AAEH,mCAAgD;AAAvC,mGAAA,SAAS,OAAA;AAAE,mGAAA,SAAS,OAAA;AAE7B,sDAAoC;AACpC,sDAAoC;AACpC,sDAAoC;AACpC,8DAA4C;AAC5C,uDAAqC;AACrC,2DAAyC;AACzC,oDAAkC;AAClC,oDAAkC;AAClC,0DAAwC;AACxC,mDAAiC;AACjC,4DAA0C;AAC1C,mDAAiC;AACjC,uDAAqC;AACrC,2DAAyC;AACzC,oDAAkC;AAClC,wDAAsC;AACtC,yDAAuC;AACvC,uDAAqC;AACrC,oDAAkC;AAClC,yDAAuC;AAEvC,gDAA8B;AAC9B,iDAA+B;AAC/B,uDAAqC;AAErC,mDAAiC;AACjC,2DAAyC","sourcesContent":["/*\n * The MIT License\n *\n * Copyright (c) 2025 Catbee Technologies\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nexport { setConfig, getConfig } from './config';\n\nexport * from './utils/array.utils';\nexport * from './utils/async.utils';\nexport * from './utils/cache.utils';\nexport * from './utils/context-store.utils';\nexport * from './utils/crypto.utils';\nexport * from './utils/decorators.utils';\nexport * from './utils/dir.utils';\nexport * from './utils/env.utils';\nexport * from './utils/exception.utils';\nexport * from './utils/fs.utils';\nexport * from './utils/http-status-codes';\nexport * from './utils/id.utils';\nexport * from './utils/logger.utils';\nexport * from './utils/middleware.utils';\nexport * from './utils/obj.utils';\nexport * from './utils/request.utils';\nexport * from './utils/response.utils';\nexport * from './utils/string.utils';\nexport * from './utils/url.utils';\nexport * from './utils/validate.utils';\n\nexport * from './types/index';\nexport * from './types/server';\nexport * from './types/api-response';\n\nexport * from './servers/server';\nexport * from './servers/server.builder';\n"]}
@@ -1,625 +0,0 @@
1
- import { ServerConfig } from '../types/server';
2
- /**
3
- * Builder class for creating and configuring an Express server configuration.
4
- *
5
- * This class provides a fluent interface to configure all aspects of the Express server
6
- * including security settings, middleware, routing, and more.
7
- *
8
- * @example
9
- * ```typescript
10
- * const serverConfig = new ServerConfigBuilder()
11
- * .withPort(3000)
12
- * .withHost('localhost')
13
- * .enableCors()
14
- * .enableHelmet()
15
- * .build();
16
- * ```
17
- */
18
- export declare const BUILD_MARKER: unique symbol;
19
- export declare class ServerConfigBuilder {
20
- private config;
21
- /**
22
- * Validates that a port number is valid and usable.
23
- *
24
- * @private
25
- * @param port - The port number to validate
26
- * @throws {Error} If port is not an integer or is outside the valid range (1-65535)
27
- */
28
- private validatePort;
29
- /**
30
- * Sets the port the server will listen on.
31
- *
32
- * @param port - The port number (1-65535)
33
- * @returns The builder instance for chaining
34
- * @throws {Error} If port is invalid
35
- * @default 3000 (can be overridden via PORT env variable)
36
- *
37
- * @example
38
- * ```typescript
39
- * builder.withPort(3000)
40
- * ```
41
- */
42
- withPort(port: number): this;
43
- /**
44
- * Sets the hostname the server will bind to.
45
- *
46
- * @param host - The hostname (e.g., 'localhost', '0.0.0.0', '127.0.0.1')
47
- * @returns The builder instance for chaining
48
- * @default '0.0.0.0' (can be overridden via HOST env variable)
49
- *
50
- * @example
51
- * ```typescript
52
- * builder.withHost('0.0.0.0') // Listen on all interfaces
53
- * ```
54
- */
55
- withHost(host: string): this;
56
- /**
57
- * Configures Cross-Origin Resource Sharing (CORS) for the server.
58
- *
59
- * @param opts - CORS options object or boolean (true to enable with defaults, false to disable)
60
- * @returns The builder instance for chaining
61
- * @default false (CORS is disabled by default)
62
- *
63
- * @example
64
- * ```typescript
65
- * // Enable CORS with default options
66
- * builder.withCors(true)
67
- *
68
- * // Configure CORS with specific options
69
- * builder.withCors({
70
- * origin: ['https://example.com'],
71
- * methods: ['GET', 'POST']
72
- * })
73
- * ```
74
- */
75
- withCors(opts: ServerConfig['cors']): this;
76
- /**
77
- * Enables CORS with default settings
78
- *
79
- * @returns The builder instance for chaining
80
- */
81
- enableCors(): this;
82
- /**
83
- * Disables CORS
84
- *
85
- * @returns The builder instance for chaining
86
- */
87
- disableCors(): this;
88
- /**
89
- * Configures the Helmet middleware for setting HTTP security headers.
90
- *
91
- * @param opts - Helmet options object or boolean (true to enable with defaults, false to disable)
92
- * @returns The builder instance for chaining
93
- * @default false (Helmet is disabled by default)
94
- *
95
- * @example
96
- * ```typescript
97
- * // Enable Helmet with default settings
98
- * builder.withHelmet(true)
99
- *
100
- * // Configure Helmet with specific options
101
- * builder.withHelmet({
102
- * contentSecurityPolicy: false,
103
- * xssFilter: true
104
- * })
105
- * ```
106
- */
107
- withHelmet(opts: ServerConfig['helmet']): this;
108
- /**
109
- * Enables Helmet with default settings
110
- *
111
- * @returns The builder instance for chaining
112
- */
113
- enableHelmet(): this;
114
- /**
115
- * Disables Helmet
116
- *
117
- * @returns The builder instance for chaining
118
- */
119
- disableHelmet(): this;
120
- /**
121
- * Configures response compression middleware.
122
- *
123
- * @param opts - Compression options object or boolean (true to enable with defaults, false to disable)
124
- * @returns The builder instance for chaining
125
- * @default false (Compression is disabled by default)
126
- *
127
- * @example
128
- * ```typescript
129
- * // Enable compression with default settings
130
- * builder.withCompression(true)
131
- *
132
- * // Configure compression with specific options
133
- * builder.withCompression({
134
- * level: 6,
135
- * threshold: 1024
136
- * })
137
- * ```
138
- */
139
- withCompression(opts: ServerConfig['compression']): this;
140
- /**
141
- * Enables compression with default settings
142
- *
143
- * @returns The builder instance for chaining
144
- */
145
- enableCompression(): this;
146
- /**
147
- * Disables compression
148
- *
149
- * @returns The builder instance for chaining
150
- */
151
- disableCompression(): this;
152
- /**
153
- * Configures rate limiting to protect against brute-force attacks.
154
- *
155
- * @param opts - Rate limit configuration options
156
- * @returns The builder instance for chaining
157
- * @default { enable: false, windowMs: 15 * 60 * 1000, max: 100, message: 'Too many requests', standardHeaders: true, legacyHeaders: false }
158
- *
159
- * @example
160
- * ```typescript
161
- * builder.withRateLimit({
162
- * enable: true,
163
- * windowMs: 15 * 60 * 1000, // 15 minutes
164
- * max: 100 // limit each IP to 100 requests per windowMs
165
- * })
166
- * ```
167
- */
168
- withRateLimit(opts: Partial<ServerConfig['rateLimit']>): this;
169
- /**
170
- * Enables rate limiting with default or custom settings
171
- *
172
- * @param opts - Optional rate limit configuration (max requests, window, etc.)
173
- * @returns The builder instance for chaining
174
- */
175
- enableRateLimit(opts?: Omit<Partial<NonNullable<ServerConfig['rateLimit']>>, 'enable'>): this;
176
- /**
177
- * Disables rate limiting
178
- *
179
- * @returns The builder instance for chaining
180
- */
181
- disableRateLimit(): this;
182
- /**
183
- * Configures HTTP request logging middleware.
184
- *
185
- * @param opts - Request logging configuration options
186
- * @returns The builder instance for chaining
187
- * @default { enable: true in dev/false in prod, ignorePaths: ['/healthz', '/favicon.ico', '/metrics', '/docs', '/.well-known'], skipNotFoundRoutes: false }
188
- *
189
- * @example
190
- * ```typescript
191
- * builder.withRequestLogging({
192
- * enable: true,
193
- * ignorePaths: ['/health', '/metrics'],
194
- * skipNotFoundRoutes: true
195
- * })
196
- * ```
197
- */
198
- withRequestLogging(opts: Partial<NonNullable<ServerConfig['requestLogging']>>): this;
199
- /**
200
- * Enables request logging with default or custom settings
201
- *
202
- * @param opts - Optional request logging configuration
203
- * @returns The builder instance for chaining
204
- */
205
- enableRequestLogging(opts?: Omit<Partial<NonNullable<ServerConfig['requestLogging']>>, 'enable'>): this;
206
- /**
207
- * Disables request logging
208
- *
209
- * @returns The builder instance for chaining
210
- */
211
- disableRequestLogging(): this;
212
- /**
213
- * Configures server metrics collection and endpoints.
214
- *
215
- * @param opts - Metrics configuration options
216
- * @returns The builder instance for chaining
217
- * @default { enable: false, path: '/metrics', withGlobalPrefix: false }
218
- *
219
- * @example
220
- * ```typescript
221
- * builder.withMetrics({
222
- * enable: true,
223
- * path: '/metrics'
224
- * })
225
- * ```
226
- */
227
- withMetrics(opts: Partial<NonNullable<ServerConfig['metrics']>>): this;
228
- /**
229
- * Enables Prometheus metrics collection and endpoint
230
- *
231
- * @param opts - Optional metrics configuration
232
- * @returns The builder instance for chaining
233
- */
234
- enableMetrics(opts?: Omit<Partial<NonNullable<ServerConfig['metrics']>>, 'enable'>): this;
235
- /**
236
- * Disables Prometheus metrics
237
- *
238
- * @returns The builder instance for chaining
239
- */
240
- disableMetrics(): this;
241
- /**
242
- * Configures server health check endpoint.
243
- *
244
- * @param opts - Health check configuration options
245
- * @returns The builder instance for chaining
246
- * @default { path: '/healthz', detailed: true, withGlobalPrefix: false }
247
- *
248
- * @example
249
- * ```typescript
250
- * builder.withHealthCheck({
251
- * path: '/health',
252
- * detailed: true
253
- * })
254
- * ```
255
- */
256
- withHealthCheck(opts: Partial<NonNullable<ServerConfig['healthCheck']>>): this;
257
- /**
258
- * Configures OpenAPI/Swagger documentation for the API.
259
- *
260
- * @param opts - OpenAPI configuration options
261
- * @returns The builder instance for chaining
262
- * @default { enable: false, mountPath: '/docs', verbose: false, withGlobalPrefix: false }
263
- *
264
- * @example
265
- * ```typescript
266
- * builder.withOpenApi({
267
- * enable: true,
268
- * path: '/api-docs',
269
- * filePath: './openapi.yaml'
270
- * })
271
- * ```
272
- */
273
- withOpenApi(opts: Partial<NonNullable<ServerConfig['openApi']>>): this;
274
- /**
275
- * Enables OpenAPI documentation with required file path
276
- *
277
- * @param filePath - Path to OpenAPI specification file (required)
278
- * @param opts - Optional OpenAPI configuration
279
- * @returns The builder instance for chaining
280
- */
281
- enableOpenApi(filePath: string, opts?: Omit<Partial<NonNullable<ServerConfig['openApi']>>, 'enable' | 'filePath'>): this;
282
- /**
283
- * Disables OpenAPI documentation
284
- *
285
- * @returns The builder instance for chaining
286
- */
287
- disableOpenApi(): this;
288
- /**
289
- * Configures the server as a microservice with versioning.
290
- *
291
- * @param opts - Microservice configuration options including app name and service version
292
- * @returns The builder instance for chaining
293
- * @default { isMicroservice: false, appName: 'express_app' }
294
- *
295
- * @example
296
- * ```typescript
297
- * builder.withMicroService({
298
- * appName: 'user-service',
299
- * serviceVersion: {
300
- * enable: true,
301
- * version: '1.2.3'
302
- * }
303
- * })
304
- * ```
305
- */
306
- withMicroService(opts: {
307
- appName: NonNullable<ServerConfig['appName']>;
308
- serviceVersion: Partial<NonNullable<ServerConfig['serviceVersion']>>;
309
- }): this;
310
- /**
311
- * Configures the trust proxy settings to determine if X-Forwarded-* headers should be trusted.
312
- *
313
- * @param opts - Trust proxy configuration options
314
- * @returns The builder instance for chaining
315
- * @default false
316
- *
317
- * @example
318
- * ```typescript
319
- * // Trust proxy headers (useful when behind a load balancer)
320
- * builder.withTrustProxy(true)
321
- * ```
322
- */
323
- withTrustProxy(opts: NonNullable<ServerConfig['trustProxy']>): this;
324
- /**
325
- * Configures the request ID middleware for tracing requests across services.
326
- *
327
- * @param opts - Request ID configuration options
328
- * @returns The builder instance for chaining
329
- * @default { headerName: 'x-request-id', exposeHeader: true }
330
- *
331
- * @example
332
- * ```typescript
333
- * builder.withRequestId({
334
- * headerName: 'X-Request-Id',
335
- * generator: () => crypto.randomUUID()
336
- * })
337
- * ```
338
- */
339
- withRequestId(opts: Partial<NonNullable<ServerConfig['requestId']>>): this;
340
- /**
341
- * Configures the response time middleware for measuring request processing times.
342
- *
343
- * @param opts - Response time configuration options
344
- * @returns The builder instance for chaining
345
- * @default { enable: false, addHeader: true, logOnComplete: false }
346
- *
347
- * @example
348
- * ```typescript
349
- * builder.withResponseTime({
350
- * enable: true,
351
- * addHeader: true,
352
- * logOnComplete: true
353
- * })
354
- * ```
355
- */
356
- withResponseTime(opts: Partial<NonNullable<ServerConfig['responseTime']>>): this;
357
- /**
358
- * Enables response time tracking with default or custom settings
359
- *
360
- * @param opts - Optional response time configuration
361
- * @returns The builder instance for chaining
362
- */
363
- enableResponseTime(opts?: Omit<Partial<NonNullable<ServerConfig['responseTime']>>, 'enable'>): this;
364
- /**
365
- * Disables response time tracking
366
- *
367
- * @returns The builder instance for chaining
368
- */
369
- disableResponseTime(): this;
370
- /**
371
- * Configures the body parser middleware options for parsing request bodies.
372
- *
373
- * @param opts - Body parser configuration options
374
- * @returns The builder instance for chaining
375
- * @default { json: { limit: '1mb' }, urlencoded: { extended: true, limit: '1mb' } }
376
- *
377
- * @example
378
- * ```typescript
379
- * builder.withBodyParser({
380
- * json: {
381
- * limit: '1mb'
382
- * },
383
- * urlencoded: {
384
- * extended: true,
385
- * limit: '1mb'
386
- * }
387
- * })
388
- * ```
389
- */
390
- withBodyParser(opts: NonNullable<ServerConfig['bodyParser']>): this;
391
- /**
392
- * Configures cookie parsing middleware.
393
- *
394
- * @param opts - Cookie parser options or boolean (true to enable with defaults, false to disable)
395
- * @returns The builder instance for chaining
396
- * @default false
397
- *
398
- * @example
399
- * ```typescript
400
- * // Enable cookie parsing with default options
401
- * builder.withCookies(true)
402
- *
403
- * // Enable cookie parsing with specific options
404
- * builder.withCookies({
405
- * secret: 'your-secret-key',
406
- * secure: true
407
- * })
408
- * ```
409
- */
410
- withCookies(opts: ServerConfig['cookieParser']): this;
411
- /**
412
- * Configures the logger used by the server.
413
- *
414
- * @param opts - Logger configuration options
415
- * @returns The builder instance for chaining
416
- * @default { name: 'express_app', level: 'info', prettyPrint: true in dev, singleLine: false }
417
- *
418
- * @example
419
- * ```typescript
420
- * builder.withLogger({
421
- * level: 'info',
422
- * prettyPrint: true,
423
- * singleLine: false
424
- * })
425
- * ```
426
- */
427
- withLogger(opts: Partial<NonNullable<ServerConfig['logger']>>): this;
428
- /**
429
- * Adds a static folder to serve files from.
430
- *
431
- * @param folder - Static folder configuration
432
- * @returns The builder instance for chaining
433
- *
434
- * @example
435
- * ```typescript
436
- * builder.withStaticFolder({
437
- * path: '/assets',
438
- * directory: './public',
439
- * options: { maxAge: '1d' }
440
- * })
441
- * ```
442
- */
443
- withStaticFolder(folder: NonNullable<ServerConfig['staticFolders']>[number]): this;
444
- /**
445
- * Sets global headers to be included in all responses.
446
- *
447
- * @param headers - Object containing header name/value pairs or functions that return values
448
- * @returns The builder instance for chaining
449
- * @default {}
450
- *
451
- * @example
452
- * ```typescript
453
- * builder.withGlobalHeaders({
454
- * 'X-Powered-By': 'Catbee',
455
- * 'Server-Time': () => new Date().toISOString()
456
- * })
457
- * ```
458
- */
459
- withGlobalHeaders(headers: NonNullable<ServerConfig['globalHeaders']>): this;
460
- /**
461
- * Sets a global prefix for all routes.
462
- *
463
- * @param prefix - The prefix to prepend to all routes (e.g., '/api/v1')
464
- * @returns The builder instance for chaining
465
- * @default '/'
466
- *
467
- * @example
468
- * ```typescript
469
- * builder.withGlobalPrefix('/api/v1')
470
- * ```
471
- */
472
- withGlobalPrefix(prefix: string): this;
473
- /**
474
- * Applies custom configuration overrides directly.
475
- *
476
- * @param overrides - Custom configuration options to merge
477
- * @returns The builder instance for chaining
478
- *
479
- * @example
480
- * ```typescript
481
- * builder.withCustom({
482
- * port: 8080,
483
- * customMiddleware: myMiddlewareFunction
484
- * })
485
- * ```
486
- */
487
- withCustom(overrides: Partial<ServerConfig>): this;
488
- /**
489
- * Configures HTTPS server options.
490
- *
491
- * @param opts - HTTPS configuration (key, cert, ca, passphrase, etc.)
492
- * @returns The builder instance for chaining
493
- *
494
- * @example
495
- * ```typescript
496
- * builder.withHttps({
497
- * key: './localhost-key.pem',
498
- * cert: './localhost-cert.pem'
499
- * })
500
- * ```
501
- */
502
- withHttps(opts: NonNullable<ServerConfig['https']>): this;
503
- /**
504
- * Builds and returns the final server configuration.
505
- *
506
- * This method merges the user-specified configuration with default values,
507
- * ensures all sections with 'enable' flags are properly structured, and
508
- * produces the final configuration to be used by the server.
509
- *
510
- * @returns The complete ServerConfig object
511
- *
512
- * @example
513
- * ```typescript
514
- * const config = new ServerConfigBuilder()
515
- * .withPort(3000)
516
- * .withHost('localhost')
517
- * .withCors(true)
518
- * .build();
519
- * ```
520
- */
521
- build(): Readonly<{
522
- [BUILD_MARKER]: boolean;
523
- port: number;
524
- host?: string;
525
- cors?: import("..").ToggleConfig<import("cors").CorsOptions>;
526
- helmet?: import("..").ToggleConfig<import("helmet").HelmetOptions>;
527
- compression?: import("..").ToggleConfig<import("compression").CompressionOptions>;
528
- bodyParser?: {
529
- json? /**
530
- * Sets the hostname the server will bind to.
531
- *
532
- * @param host - The hostname (e.g., 'localhost', '0.0.0.0', '127.0.0.1')
533
- * @returns The builder instance for chaining
534
- * @default '0.0.0.0' (can be overridden via HOST env variable)
535
- *
536
- * @example
537
- * ```typescript
538
- * builder.withHost('0.0.0.0') // Listen on all interfaces
539
- * ```
540
- */: Parameters<typeof import("express").json>[0];
541
- urlencoded?: Parameters<typeof import("express").urlencoded>[0];
542
- };
543
- cookieParser?: import("..").ToggleConfig<import("cookie-parser").CookieParseOptions>;
544
- trustProxy?: boolean;
545
- staticFolders?: Array<{
546
- path?: string;
547
- directory: string;
548
- maxAge?: string;
549
- etag?: boolean;
550
- immutable?: boolean;
551
- lastModified?: boolean;
552
- cacheControl?: boolean;
553
- }>;
554
- isMicroservice?: boolean;
555
- appName?: string;
556
- globalHeaders?: Record<string, string | (() => string)>;
557
- rateLimit?: {
558
- enable: boolean;
559
- windowMs?: number;
560
- max?: number;
561
- message?: string;
562
- standardHeaders?: boolean;
563
- legacyHeaders?: boolean;
564
- };
565
- requestLogging?: {
566
- enable: boolean;
567
- ignorePaths?: string[] | ((req: import("express").Request, res: import("express").Response) => boolean);
568
- skipNotFoundRoutes?: boolean;
569
- };
570
- healthCheck?: {
571
- path?: string;
572
- checks?: Array<{
573
- name: string;
574
- check: () => Promise<boolean> | boolean;
575
- }>;
576
- detailed?: boolean;
577
- withGlobalPrefix?: boolean;
578
- };
579
- requestTimeout?: number;
580
- responseTime?: {
581
- enable: boolean;
582
- addHeader?: boolean;
583
- logOnComplete?: boolean;
584
- };
585
- requestId?: {
586
- headerName?: string;
587
- exposeHeader?: boolean;
588
- generator?: () => string;
589
- };
590
- globalPrefix?: string;
591
- openApi?: {
592
- enable: boolean;
593
- mountPath?: string;
594
- filePath?: string;
595
- verbose?: boolean;
596
- withGlobalPrefix?: boolean;
597
- };
598
- logger?: {
599
- name?: string;
600
- level?: import("..").LoggerLevels;
601
- prettyPrint?: boolean;
602
- singleLine?: boolean;
603
- };
604
- metrics?: {
605
- enable: boolean;
606
- path?: string;
607
- withGlobalPrefix?: boolean;
608
- };
609
- serviceVersion?: {
610
- enable: boolean;
611
- headerName?: string;
612
- version?: string | (() => string);
613
- };
614
- https?: {
615
- key: string;
616
- cert: string;
617
- ca?: string;
618
- passphrase?: string;
619
- [key: string]: any;
620
- };
621
- }>;
622
- private mergeConfig;
623
- private setEnabled;
624
- }
625
- //# sourceMappingURL=server.builder.d.ts.map