@catbee/utils 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (201) hide show
  1. package/LICENSE +21 -201
  2. package/README.md +222 -4
  3. package/build/esm/config.d.ts +88 -3
  4. package/build/esm/config.js +97 -1
  5. package/build/esm/config.js.map +1 -1
  6. package/build/esm/index.d.ts +4 -0
  7. package/build/esm/index.js +27 -0
  8. package/build/esm/index.js.map +1 -1
  9. package/build/esm/servers/server.builder.d.ts +625 -0
  10. package/build/esm/servers/server.builder.js +722 -0
  11. package/build/esm/servers/server.builder.js.map +1 -0
  12. package/build/esm/servers/server.d.ts +256 -0
  13. package/build/esm/servers/server.js +1211 -0
  14. package/build/esm/servers/server.js.map +1 -0
  15. package/build/esm/types/api-response.d.ts +5 -7
  16. package/build/esm/types/api-response.js +23 -0
  17. package/build/esm/types/api-response.js.map +1 -1
  18. package/build/esm/types/index.d.ts +125 -0
  19. package/build/esm/types/index.js +25 -0
  20. package/build/esm/types/index.js.map +1 -0
  21. package/build/esm/types/server.d.ts +285 -0
  22. package/build/esm/types/server.js +25 -0
  23. package/build/esm/types/server.js.map +1 -0
  24. package/build/esm/utils/array.utils.js +23 -0
  25. package/build/esm/utils/array.utils.js.map +1 -1
  26. package/build/esm/utils/async.utils.js +23 -0
  27. package/build/esm/utils/async.utils.js.map +1 -1
  28. package/build/esm/utils/cache.utils.js +23 -0
  29. package/build/esm/utils/cache.utils.js.map +1 -1
  30. package/build/esm/utils/context-store.utils.js +23 -0
  31. package/build/esm/utils/context-store.utils.js.map +1 -1
  32. package/build/esm/utils/crypto.utils.js +23 -0
  33. package/build/esm/utils/crypto.utils.js.map +1 -1
  34. package/build/esm/utils/decorators.utils.js +23 -1
  35. package/build/esm/utils/decorators.utils.js.map +1 -1
  36. package/build/esm/utils/dir.utils.js +23 -0
  37. package/build/esm/utils/dir.utils.js.map +1 -1
  38. package/build/esm/utils/env.utils.js +23 -0
  39. package/build/esm/utils/env.utils.js.map +1 -1
  40. package/build/esm/utils/exception.utils.js +31 -8
  41. package/build/esm/utils/exception.utils.js.map +1 -1
  42. package/build/esm/utils/fs.utils.js +23 -0
  43. package/build/esm/utils/fs.utils.js.map +1 -1
  44. package/build/esm/utils/http-status-codes.js +23 -0
  45. package/build/esm/utils/http-status-codes.js.map +1 -1
  46. package/build/esm/utils/id.utils.js +23 -0
  47. package/build/esm/utils/id.utils.js.map +1 -1
  48. package/build/esm/utils/logger.utils.d.ts +11 -0
  49. package/build/esm/utils/logger.utils.js +46 -3
  50. package/build/esm/utils/logger.utils.js.map +1 -1
  51. package/build/esm/utils/middleware.utils.d.ts +2 -0
  52. package/build/esm/utils/middleware.utils.js +59 -49
  53. package/build/esm/utils/middleware.utils.js.map +1 -1
  54. package/build/esm/utils/obj.utils.d.ts +10 -3
  55. package/build/esm/utils/obj.utils.js +225 -15
  56. package/build/esm/utils/obj.utils.js.map +1 -1
  57. package/build/esm/utils/request.utils.js +23 -0
  58. package/build/esm/utils/request.utils.js.map +1 -1
  59. package/build/esm/utils/response.utils.d.ts +15 -1
  60. package/build/esm/utils/response.utils.js +51 -0
  61. package/build/esm/utils/response.utils.js.map +1 -1
  62. package/build/esm/utils/string.utils.js +23 -0
  63. package/build/esm/utils/string.utils.js.map +1 -1
  64. package/build/esm/utils/url.utils.js +23 -0
  65. package/build/esm/utils/url.utils.js.map +1 -1
  66. package/build/esm/utils/validate.utils.d.ts +7 -0
  67. package/build/esm/utils/validate.utils.js +35 -2
  68. package/build/esm/utils/validate.utils.js.map +1 -1
  69. package/build/esnext/config.d.ts +88 -3
  70. package/build/esnext/config.js +97 -1
  71. package/build/esnext/config.js.map +1 -1
  72. package/build/esnext/index.d.ts +4 -0
  73. package/build/esnext/index.js +27 -0
  74. package/build/esnext/index.js.map +1 -1
  75. package/build/esnext/servers/server.builder.d.ts +625 -0
  76. package/build/esnext/servers/server.builder.js +677 -0
  77. package/build/esnext/servers/server.builder.js.map +1 -0
  78. package/build/esnext/servers/server.d.ts +256 -0
  79. package/build/esnext/servers/server.js +918 -0
  80. package/build/esnext/servers/server.js.map +1 -0
  81. package/build/esnext/types/api-response.d.ts +5 -7
  82. package/build/esnext/types/api-response.js +23 -0
  83. package/build/esnext/types/api-response.js.map +1 -1
  84. package/build/esnext/types/index.d.ts +125 -0
  85. package/build/esnext/types/index.js +25 -0
  86. package/build/esnext/types/index.js.map +1 -0
  87. package/build/esnext/types/server.d.ts +285 -0
  88. package/build/esnext/types/server.js +25 -0
  89. package/build/esnext/types/server.js.map +1 -0
  90. package/build/esnext/utils/array.utils.js +23 -0
  91. package/build/esnext/utils/array.utils.js.map +1 -1
  92. package/build/esnext/utils/async.utils.js +23 -0
  93. package/build/esnext/utils/async.utils.js.map +1 -1
  94. package/build/esnext/utils/cache.utils.js +23 -0
  95. package/build/esnext/utils/cache.utils.js.map +1 -1
  96. package/build/esnext/utils/context-store.utils.js +23 -0
  97. package/build/esnext/utils/context-store.utils.js.map +1 -1
  98. package/build/esnext/utils/crypto.utils.js +23 -0
  99. package/build/esnext/utils/crypto.utils.js.map +1 -1
  100. package/build/esnext/utils/decorators.utils.js +23 -1
  101. package/build/esnext/utils/decorators.utils.js.map +1 -1
  102. package/build/esnext/utils/dir.utils.js +23 -0
  103. package/build/esnext/utils/dir.utils.js.map +1 -1
  104. package/build/esnext/utils/env.utils.js +23 -0
  105. package/build/esnext/utils/env.utils.js.map +1 -1
  106. package/build/esnext/utils/exception.utils.js +30 -7
  107. package/build/esnext/utils/exception.utils.js.map +1 -1
  108. package/build/esnext/utils/fs.utils.js +23 -0
  109. package/build/esnext/utils/fs.utils.js.map +1 -1
  110. package/build/esnext/utils/http-status-codes.js +23 -0
  111. package/build/esnext/utils/http-status-codes.js.map +1 -1
  112. package/build/esnext/utils/id.utils.js +23 -0
  113. package/build/esnext/utils/id.utils.js.map +1 -1
  114. package/build/esnext/utils/logger.utils.d.ts +11 -0
  115. package/build/esnext/utils/logger.utils.js +46 -3
  116. package/build/esnext/utils/logger.utils.js.map +1 -1
  117. package/build/esnext/utils/middleware.utils.d.ts +2 -0
  118. package/build/esnext/utils/middleware.utils.js +55 -49
  119. package/build/esnext/utils/middleware.utils.js.map +1 -1
  120. package/build/esnext/utils/obj.utils.d.ts +10 -3
  121. package/build/esnext/utils/obj.utils.js +176 -12
  122. package/build/esnext/utils/obj.utils.js.map +1 -1
  123. package/build/esnext/utils/request.utils.js +23 -0
  124. package/build/esnext/utils/request.utils.js.map +1 -1
  125. package/build/esnext/utils/response.utils.d.ts +15 -1
  126. package/build/esnext/utils/response.utils.js +51 -0
  127. package/build/esnext/utils/response.utils.js.map +1 -1
  128. package/build/esnext/utils/string.utils.js +23 -0
  129. package/build/esnext/utils/string.utils.js.map +1 -1
  130. package/build/esnext/utils/url.utils.js +23 -0
  131. package/build/esnext/utils/url.utils.js.map +1 -1
  132. package/build/esnext/utils/validate.utils.d.ts +7 -0
  133. package/build/esnext/utils/validate.utils.js +33 -0
  134. package/build/esnext/utils/validate.utils.js.map +1 -1
  135. package/build/src/config.d.ts +88 -3
  136. package/build/src/config.js +98 -2
  137. package/build/src/config.js.map +1 -1
  138. package/build/src/index.d.ts +4 -0
  139. package/build/src/index.js +27 -0
  140. package/build/src/index.js.map +1 -1
  141. package/build/src/servers/server.builder.d.ts +625 -0
  142. package/build/src/servers/server.builder.js +681 -0
  143. package/build/src/servers/server.builder.js.map +1 -0
  144. package/build/src/servers/server.d.ts +256 -0
  145. package/build/src/servers/server.js +958 -0
  146. package/build/src/servers/server.js.map +1 -0
  147. package/build/src/types/api-response.d.ts +5 -7
  148. package/build/src/types/api-response.js +23 -0
  149. package/build/src/types/api-response.js.map +1 -1
  150. package/build/src/types/index.d.ts +125 -0
  151. package/build/src/types/index.js +26 -0
  152. package/build/src/types/index.js.map +1 -0
  153. package/build/src/types/server.d.ts +285 -0
  154. package/build/src/types/server.js +26 -0
  155. package/build/src/types/server.js.map +1 -0
  156. package/build/src/utils/array.utils.js +23 -0
  157. package/build/src/utils/array.utils.js.map +1 -1
  158. package/build/src/utils/async.utils.js +23 -0
  159. package/build/src/utils/async.utils.js.map +1 -1
  160. package/build/src/utils/cache.utils.js +23 -0
  161. package/build/src/utils/cache.utils.js.map +1 -1
  162. package/build/src/utils/context-store.utils.js +23 -0
  163. package/build/src/utils/context-store.utils.js.map +1 -1
  164. package/build/src/utils/crypto.utils.js +23 -0
  165. package/build/src/utils/crypto.utils.js.map +1 -1
  166. package/build/src/utils/decorators.utils.js +23 -1
  167. package/build/src/utils/decorators.utils.js.map +1 -1
  168. package/build/src/utils/dir.utils.js +23 -0
  169. package/build/src/utils/dir.utils.js.map +1 -1
  170. package/build/src/utils/env.utils.js +23 -0
  171. package/build/src/utils/env.utils.js.map +1 -1
  172. package/build/src/utils/exception.utils.js +30 -7
  173. package/build/src/utils/exception.utils.js.map +1 -1
  174. package/build/src/utils/fs.utils.js +23 -0
  175. package/build/src/utils/fs.utils.js.map +1 -1
  176. package/build/src/utils/http-status-codes.js +23 -0
  177. package/build/src/utils/http-status-codes.js.map +1 -1
  178. package/build/src/utils/id.utils.js +23 -0
  179. package/build/src/utils/id.utils.js.map +1 -1
  180. package/build/src/utils/logger.utils.d.ts +11 -0
  181. package/build/src/utils/logger.utils.js +47 -4
  182. package/build/src/utils/logger.utils.js.map +1 -1
  183. package/build/src/utils/middleware.utils.d.ts +2 -0
  184. package/build/src/utils/middleware.utils.js +54 -48
  185. package/build/src/utils/middleware.utils.js.map +1 -1
  186. package/build/src/utils/obj.utils.d.ts +10 -3
  187. package/build/src/utils/obj.utils.js +177 -12
  188. package/build/src/utils/obj.utils.js.map +1 -1
  189. package/build/src/utils/request.utils.js +23 -0
  190. package/build/src/utils/request.utils.js.map +1 -1
  191. package/build/src/utils/response.utils.d.ts +15 -1
  192. package/build/src/utils/response.utils.js +52 -0
  193. package/build/src/utils/response.utils.js.map +1 -1
  194. package/build/src/utils/string.utils.js +23 -0
  195. package/build/src/utils/string.utils.js.map +1 -1
  196. package/build/src/utils/url.utils.js +23 -0
  197. package/build/src/utils/url.utils.js.map +1 -1
  198. package/build/src/utils/validate.utils.d.ts +7 -0
  199. package/build/src/utils/validate.utils.js +36 -2
  200. package/build/src/utils/validate.utils.js.map +1 -1
  201. package/package.json +35 -9
@@ -1,4 +1,28 @@
1
+ /*
2
+ * The MIT License
3
+ *
4
+ * Copyright (c) 2025 Catbee Technologies
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
1
24
  import { Env } from './utils/env.utils';
25
+ import { uuid } from './utils/id.utils';
2
26
  import { deepObjMerge } from './utils/obj.utils';
3
27
  /**
4
28
  * Application runtime configuration loaded from environment variables.
@@ -17,7 +41,11 @@ export let config = {
17
41
  * Enables pretty-print logging in development.
18
42
  * Has no effect in production.
19
43
  */
20
- pretty: Env.getBoolean('LOGGER_PRETTY', true)
44
+ pretty: Env.getBoolean('LOGGER_PRETTY', true),
45
+ /**
46
+ * Single line output for pretty-print (default: false)
47
+ */
48
+ singleLine: Env.getBoolean('LOGGER_PRETTY_SINGLE_LINE', false)
21
49
  },
22
50
  http: {
23
51
  /**
@@ -32,6 +60,74 @@ export let config = {
32
60
  defaultTtl: Env.getNumber('CACHE_DEFAULT_TTL_SECONDS', 3600) * 1000
33
61
  }
34
62
  };
63
+ export const defaultServerConfig = {
64
+ port: 3000,
65
+ host: '0.0.0.0',
66
+ cors: false,
67
+ helmet: false,
68
+ compression: false,
69
+ bodyParser: {
70
+ json: { limit: '1mb' },
71
+ urlencoded: { extended: true, limit: '1mb' }
72
+ },
73
+ cookieParser: false,
74
+ isMicroservice: false,
75
+ appName: 'express_app',
76
+ globalHeaders: {},
77
+ rateLimit: {
78
+ enable: false,
79
+ windowMs: 15 * 60 * 1000,
80
+ max: 100,
81
+ message: 'Too many requests',
82
+ standardHeaders: true,
83
+ legacyHeaders: false
84
+ },
85
+ requestLogging: {
86
+ enable: Env.isDev(),
87
+ ignorePaths: (req, _res) => {
88
+ const skipPaths = ['/healthz', '/favicon.ico', '/metrics', '/docs', '/.well-known'];
89
+ return skipPaths.some(path => req.path.startsWith(path));
90
+ },
91
+ skipNotFoundRoutes: false
92
+ },
93
+ openApi: {
94
+ enable: false,
95
+ mountPath: '/docs',
96
+ verbose: false,
97
+ withGlobalPrefix: false
98
+ },
99
+ healthCheck: {
100
+ path: '/healthz',
101
+ detailed: true
102
+ },
103
+ requestTimeout: 30000,
104
+ responseTime: {
105
+ enable: false,
106
+ addHeader: true,
107
+ logOnComplete: false
108
+ },
109
+ requestId: {
110
+ headerName: 'x-request-id',
111
+ exposeHeader: true,
112
+ generator: () => uuid()
113
+ },
114
+ logger: {
115
+ name: 'express_app',
116
+ level: 'info',
117
+ prettyPrint: false,
118
+ singleLine: false
119
+ },
120
+ metrics: {
121
+ enable: false,
122
+ path: '/metrics',
123
+ withGlobalPrefix: false
124
+ },
125
+ serviceVersion: {
126
+ enable: false,
127
+ headerName: 'x-service-version',
128
+ version: '0.0.0'
129
+ }
130
+ };
35
131
  /**
36
132
  * Update the @catbee/utils configuration.
37
133
  * @param value Partial configuration object.
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAIjD;;GAEG;AACH,MAAM,CAAC,IAAI,MAAM,GAAG;IAClB,MAAM,EAAE;QACN;;WAEG;QACH,KAAK,EAAE,GAAG,CAAC,GAAG,CAAC,cAAc,EAAE,MAAM,CAAa;QAElD;;WAEG;QACH,IAAI,EAAE,GAAG,CAAC,GAAG,CAAC,aAAa,EAAE,GAAG,CAAC,GAAG,CAAC,kBAAkB,EAAE,eAAe,CAAC,CAAC;QAE1E;;;WAGG;QACH,MAAM,EAAE,GAAG,CAAC,UAAU,CAAC,eAAe,EAAE,IAAI,CAAC;KAC9C;IAED,IAAI,EAAE;QACJ;;WAEG;QACH,OAAO,EAAE,GAAG,CAAC,SAAS,CAAC,cAAc,EAAE,KAAK,CAAC;KAC9C;IAED,KAAK,EAAE;QACL;;WAEG;QACH,UAAU,EAAE,GAAG,CAAC,SAAS,CAAC,2BAA2B,EAAE,IAAI,CAAC,GAAG,IAAI;KACpE;CACF,CAAC;AAEF;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAC,KAA6B;IACrD,YAAY,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AAC9B,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,SAAS;IACvB,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { Env } from './utils/env.utils';\nimport { deepObjMerge } from './utils/obj.utils';\n\ntype LogLevel = 'fatal' | 'error' | 'warn' | 'info' | 'debug' | 'trace' | 'silent';\n\n/**\n * Application runtime configuration loaded from environment variables.\n */\nexport let config = {\n logger: {\n /**\n * Logging level (e.g., 'info', 'debug', 'warn', 'error').\n */\n level: Env.get('LOGGER_LEVEL', 'info') as LogLevel,\n\n /**\n * Name of the logger instance (defaults to npm package name).\n */\n name: Env.get('LOGGER_NAME', Env.get('npm_package_name', '@catbee/utils')),\n\n /**\n * Enables pretty-print logging in development.\n * Has no effect in production.\n */\n pretty: Env.getBoolean('LOGGER_PRETTY', true)\n },\n\n http: {\n /**\n * Timeout for HTTP requests in milliseconds\n */\n timeout: Env.getNumber('HTTP_TIMEOUT', 30000)\n },\n\n cache: {\n /**\n * Default TTL (time to live) for cache entries in seconds\n */\n defaultTtl: Env.getNumber('CACHE_DEFAULT_TTL_SECONDS', 3600) * 1000\n }\n};\n\n/**\n * Update the @catbee/utils configuration.\n * @param value Partial configuration object.\n */\nexport function setConfig(value: Partial<typeof config>): void {\n deepObjMerge(config, value);\n}\n\n/**\n * Get the current @catbee/utils configuration.\n * @returns The current configuration object.\n */\nexport function getConfig(): typeof config {\n return config;\n}\n"]}
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"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","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\nimport { ServerConfig } from './types/server';\nimport { Env } from './utils/env.utils';\nimport { uuid } from './utils/id.utils';\nimport { LoggerLevels } from './utils/logger.utils';\nimport { deepObjMerge } from './utils/obj.utils';\n\n/**\n * Extends Express Request interface to add request ID tracking.\n * Added by requestId middleware during request processing.\n */\ndeclare global {\n namespace Express {\n interface Request {\n /** Unique request identifier (set by middleware) */\n id?: string;\n }\n }\n}\n\n/**\n * Application runtime configuration loaded from environment variables.\n */\nexport let config = {\n logger: {\n /**\n * Logging level (e.g., 'info', 'debug', 'warn', 'error').\n */\n level: Env.get('LOGGER_LEVEL', 'info') as LoggerLevels,\n\n /**\n * Name of the logger instance (defaults to npm package name).\n */\n name: Env.get('LOGGER_NAME', Env.get('npm_package_name', '@catbee/utils')),\n\n /**\n * Enables pretty-print logging in development.\n * Has no effect in production.\n */\n pretty: Env.getBoolean('LOGGER_PRETTY', true),\n /**\n * Single line output for pretty-print (default: false)\n */\n singleLine: Env.getBoolean('LOGGER_PRETTY_SINGLE_LINE', false)\n },\n\n http: {\n /**\n * Timeout for HTTP requests in milliseconds\n */\n timeout: Env.getNumber('HTTP_TIMEOUT', 30000)\n },\n\n cache: {\n /**\n * Default TTL (time to live) for cache entries in seconds\n */\n defaultTtl: Env.getNumber('CACHE_DEFAULT_TTL_SECONDS', 3600) * 1000\n }\n};\n\nexport const defaultServerConfig = {\n port: 3000,\n host: '0.0.0.0',\n cors: false,\n helmet: false,\n compression: false,\n bodyParser: {\n json: { limit: '1mb' },\n urlencoded: { extended: true, limit: '1mb' }\n },\n cookieParser: false,\n isMicroservice: false,\n appName: 'express_app',\n globalHeaders: {},\n rateLimit: {\n enable: false,\n windowMs: 15 * 60 * 1000,\n max: 100,\n message: 'Too many requests',\n standardHeaders: true,\n legacyHeaders: false\n },\n requestLogging: {\n enable: Env.isDev(),\n ignorePaths: (req, _res) => {\n const skipPaths = ['/healthz', '/favicon.ico', '/metrics', '/docs', '/.well-known'];\n return skipPaths.some(path => req.path.startsWith(path));\n },\n skipNotFoundRoutes: false\n },\n openApi: {\n enable: false,\n mountPath: '/docs',\n verbose: false,\n withGlobalPrefix: false\n },\n healthCheck: {\n path: '/healthz',\n detailed: true\n },\n requestTimeout: 30000,\n responseTime: {\n enable: false,\n addHeader: true,\n logOnComplete: false\n },\n requestId: {\n headerName: 'x-request-id',\n exposeHeader: true,\n generator: () => uuid()\n },\n logger: {\n name: 'express_app',\n level: 'info' as LoggerLevels,\n prettyPrint: false,\n singleLine: false\n },\n metrics: {\n enable: false,\n path: '/metrics',\n withGlobalPrefix: false\n },\n serviceVersion: {\n enable: false,\n headerName: 'x-service-version',\n version: '0.0.0'\n }\n} satisfies ServerConfig;\n\n/**\n * Update the @catbee/utils configuration.\n * @param value Partial configuration object.\n */\nexport function setConfig(value: Partial<typeof config>): void {\n deepObjMerge(config, value);\n}\n\n/**\n * Get the current @catbee/utils configuration.\n * @returns The current configuration object.\n */\nexport function getConfig(): typeof config {\n return config;\n}\n"]}
@@ -19,5 +19,9 @@ export * from './utils/response.utils';
19
19
  export * from './utils/string.utils';
20
20
  export * from './utils/url.utils';
21
21
  export * from './utils/validate.utils';
22
+ export * from './types/index';
23
+ export * from './types/server';
22
24
  export * from './types/api-response';
25
+ export * from './servers/server';
26
+ export * from './servers/server.builder';
23
27
  //# sourceMappingURL=index.d.ts.map
@@ -1,3 +1,26 @@
1
+ /*
2
+ * The MIT License
3
+ *
4
+ * Copyright (c) 2025 Catbee Technologies
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
1
24
  export { setConfig, getConfig } from './config';
2
25
  export * from './utils/array.utils';
3
26
  export * from './utils/async.utils';
@@ -19,5 +42,9 @@ export * from './utils/response.utils';
19
42
  export * from './utils/string.utils';
20
43
  export * from './utils/url.utils';
21
44
  export * from './utils/validate.utils';
45
+ export * from './types/index';
46
+ export * from './types/server';
22
47
  export * from './types/api-response';
48
+ export * from './servers/server';
49
+ export * from './servers/server.builder';
23
50
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAEhD,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,kBAAkB,CAAC;AACjC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AAEvC,cAAc,sBAAsB,CAAC","sourcesContent":["export { 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/api-response';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAEhD,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,kBAAkB,CAAC;AACjC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AAEvC,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AAErC,cAAc,kBAAkB,CAAC;AACjC,cAAc,0BAA0B,CAAC","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"]}