@catbee/utils 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (169) hide show
  1. package/build/esm/config.d.ts +1 -1
  2. package/build/esm/config.js +7 -7
  3. package/build/esm/config.js.map +1 -1
  4. package/build/esm/index.d.ts +20 -19
  5. package/build/esm/index.js +20 -19
  6. package/build/esm/index.js.map +1 -1
  7. package/build/esm/types/api-response.d.ts +2 -2
  8. package/build/esm/types/api-response.js.map +1 -1
  9. package/build/esm/utils/array.utils.d.ts +1 -1
  10. package/build/esm/utils/array.utils.js +17 -27
  11. package/build/esm/utils/array.utils.js.map +1 -1
  12. package/build/esm/utils/async.utils.d.ts +1 -5
  13. package/build/esm/utils/async.utils.js +17 -20
  14. package/build/esm/utils/async.utils.js.map +1 -1
  15. package/build/esm/utils/cache.utils.js +2 -2
  16. package/build/esm/utils/cache.utils.js.map +1 -1
  17. package/build/esm/utils/context-store.utils.d.ts +1 -1
  18. package/build/esm/utils/context-store.utils.js +8 -8
  19. package/build/esm/utils/context-store.utils.js.map +1 -1
  20. package/build/esm/utils/crypto.utils.d.ts +2 -2
  21. package/build/esm/utils/crypto.utils.js +37 -45
  22. package/build/esm/utils/crypto.utils.js.map +1 -1
  23. package/build/esm/utils/decorators.utils.d.ts +7 -7
  24. package/build/esm/utils/decorators.utils.js +31 -31
  25. package/build/esm/utils/decorators.utils.js.map +1 -1
  26. package/build/esm/utils/dir.utils.d.ts +4 -4
  27. package/build/esm/utils/dir.utils.js +18 -20
  28. package/build/esm/utils/dir.utils.js.map +1 -1
  29. package/build/esm/utils/env.utils.js +22 -26
  30. package/build/esm/utils/env.utils.js.map +1 -1
  31. package/build/esm/utils/exception.utils.d.ts +1 -1
  32. package/build/esm/utils/exception.utils.js +26 -29
  33. package/build/esm/utils/exception.utils.js.map +1 -1
  34. package/build/esm/utils/fs.utils.d.ts +3 -3
  35. package/build/esm/utils/fs.utils.js +19 -23
  36. package/build/esm/utils/fs.utils.js.map +1 -1
  37. package/build/esm/utils/http-status-codes.js.map +1 -1
  38. package/build/esm/utils/id.utils.js +8 -8
  39. package/build/esm/utils/id.utils.js.map +1 -1
  40. package/build/esm/utils/logger.utils.d.ts +13 -4
  41. package/build/esm/utils/logger.utils.js +15 -15
  42. package/build/esm/utils/logger.utils.js.map +1 -1
  43. package/build/esm/utils/middleware.utils.d.ts +5 -4
  44. package/build/esm/utils/middleware.utils.js +19 -19
  45. package/build/esm/utils/middleware.utils.js.map +1 -1
  46. package/build/esm/utils/obj.utils.js +16 -27
  47. package/build/esm/utils/obj.utils.js.map +1 -1
  48. package/build/esm/utils/response.utils.d.ts +2 -2
  49. package/build/esm/utils/response.utils.js +11 -11
  50. package/build/esm/utils/response.utils.js.map +1 -1
  51. package/build/esm/utils/string.utils.js +17 -17
  52. package/build/esm/utils/string.utils.js.map +1 -1
  53. package/build/esm/utils/url.utils.js +20 -22
  54. package/build/esm/utils/url.utils.js.map +1 -1
  55. package/build/esm/utils/validate.utils.js +11 -15
  56. package/build/esm/utils/validate.utils.js.map +1 -1
  57. package/build/esnext/config.d.ts +1 -1
  58. package/build/esnext/config.js +7 -7
  59. package/build/esnext/config.js.map +1 -1
  60. package/build/esnext/index.d.ts +20 -19
  61. package/build/esnext/index.js +20 -19
  62. package/build/esnext/index.js.map +1 -1
  63. package/build/esnext/types/api-response.d.ts +2 -2
  64. package/build/esnext/types/api-response.js.map +1 -1
  65. package/build/esnext/utils/array.utils.d.ts +1 -1
  66. package/build/esnext/utils/array.utils.js +23 -31
  67. package/build/esnext/utils/array.utils.js.map +1 -1
  68. package/build/esnext/utils/async.utils.d.ts +1 -5
  69. package/build/esnext/utils/async.utils.js +22 -22
  70. package/build/esnext/utils/async.utils.js.map +1 -1
  71. package/build/esnext/utils/cache.utils.js +3 -3
  72. package/build/esnext/utils/cache.utils.js.map +1 -1
  73. package/build/esnext/utils/context-store.utils.d.ts +1 -1
  74. package/build/esnext/utils/context-store.utils.js +10 -10
  75. package/build/esnext/utils/context-store.utils.js.map +1 -1
  76. package/build/esnext/utils/crypto.utils.d.ts +2 -2
  77. package/build/esnext/utils/crypto.utils.js +37 -47
  78. package/build/esnext/utils/crypto.utils.js.map +1 -1
  79. package/build/esnext/utils/decorators.utils.d.ts +7 -7
  80. package/build/esnext/utils/decorators.utils.js +33 -33
  81. package/build/esnext/utils/decorators.utils.js.map +1 -1
  82. package/build/esnext/utils/dir.utils.d.ts +4 -4
  83. package/build/esnext/utils/dir.utils.js +22 -24
  84. package/build/esnext/utils/dir.utils.js.map +1 -1
  85. package/build/esnext/utils/env.utils.js +24 -26
  86. package/build/esnext/utils/env.utils.js.map +1 -1
  87. package/build/esnext/utils/exception.utils.d.ts +1 -1
  88. package/build/esnext/utils/exception.utils.js +26 -29
  89. package/build/esnext/utils/exception.utils.js.map +1 -1
  90. package/build/esnext/utils/fs.utils.d.ts +3 -3
  91. package/build/esnext/utils/fs.utils.js +21 -25
  92. package/build/esnext/utils/fs.utils.js.map +1 -1
  93. package/build/esnext/utils/http-status-codes.js.map +1 -1
  94. package/build/esnext/utils/id.utils.js +8 -8
  95. package/build/esnext/utils/id.utils.js.map +1 -1
  96. package/build/esnext/utils/logger.utils.d.ts +13 -4
  97. package/build/esnext/utils/logger.utils.js +15 -15
  98. package/build/esnext/utils/logger.utils.js.map +1 -1
  99. package/build/esnext/utils/middleware.utils.d.ts +5 -4
  100. package/build/esnext/utils/middleware.utils.js +19 -19
  101. package/build/esnext/utils/middleware.utils.js.map +1 -1
  102. package/build/esnext/utils/obj.utils.js +17 -26
  103. package/build/esnext/utils/obj.utils.js.map +1 -1
  104. package/build/esnext/utils/response.utils.d.ts +2 -2
  105. package/build/esnext/utils/response.utils.js +11 -11
  106. package/build/esnext/utils/response.utils.js.map +1 -1
  107. package/build/esnext/utils/string.utils.js +17 -17
  108. package/build/esnext/utils/string.utils.js.map +1 -1
  109. package/build/esnext/utils/url.utils.js +21 -23
  110. package/build/esnext/utils/url.utils.js.map +1 -1
  111. package/build/esnext/utils/validate.utils.js +14 -16
  112. package/build/esnext/utils/validate.utils.js.map +1 -1
  113. package/build/src/config.d.ts +1 -1
  114. package/build/src/config.js +6 -6
  115. package/build/src/config.js.map +1 -1
  116. package/build/src/index.d.ts +20 -19
  117. package/build/src/index.js +1 -0
  118. package/build/src/index.js.map +1 -1
  119. package/build/src/types/api-response.d.ts +2 -2
  120. package/build/src/types/api-response.js.map +1 -1
  121. package/build/src/utils/array.utils.d.ts +1 -1
  122. package/build/src/utils/array.utils.js +22 -30
  123. package/build/src/utils/array.utils.js.map +1 -1
  124. package/build/src/utils/async.utils.d.ts +1 -5
  125. package/build/src/utils/async.utils.js +22 -22
  126. package/build/src/utils/async.utils.js.map +1 -1
  127. package/build/src/utils/cache.utils.js +2 -2
  128. package/build/src/utils/cache.utils.js.map +1 -1
  129. package/build/src/utils/context-store.utils.d.ts +1 -1
  130. package/build/src/utils/context-store.utils.js +9 -9
  131. package/build/src/utils/context-store.utils.js.map +1 -1
  132. package/build/src/utils/crypto.utils.d.ts +2 -2
  133. package/build/src/utils/crypto.utils.js +35 -45
  134. package/build/src/utils/crypto.utils.js.map +1 -1
  135. package/build/src/utils/decorators.utils.d.ts +7 -7
  136. package/build/src/utils/decorators.utils.js +32 -32
  137. package/build/src/utils/decorators.utils.js.map +1 -1
  138. package/build/src/utils/dir.utils.d.ts +4 -4
  139. package/build/src/utils/dir.utils.js +16 -18
  140. package/build/src/utils/dir.utils.js.map +1 -1
  141. package/build/src/utils/env.utils.js +22 -24
  142. package/build/src/utils/env.utils.js.map +1 -1
  143. package/build/src/utils/exception.utils.d.ts +1 -1
  144. package/build/src/utils/exception.utils.js +23 -26
  145. package/build/src/utils/exception.utils.js.map +1 -1
  146. package/build/src/utils/fs.utils.d.ts +3 -3
  147. package/build/src/utils/fs.utils.js +15 -19
  148. package/build/src/utils/fs.utils.js.map +1 -1
  149. package/build/src/utils/http-status-codes.js.map +1 -1
  150. package/build/src/utils/id.utils.js +7 -7
  151. package/build/src/utils/id.utils.js.map +1 -1
  152. package/build/src/utils/logger.utils.d.ts +13 -4
  153. package/build/src/utils/logger.utils.js +12 -12
  154. package/build/src/utils/logger.utils.js.map +1 -1
  155. package/build/src/utils/middleware.utils.d.ts +5 -4
  156. package/build/src/utils/middleware.utils.js +12 -12
  157. package/build/src/utils/middleware.utils.js.map +1 -1
  158. package/build/src/utils/obj.utils.js +17 -26
  159. package/build/src/utils/obj.utils.js.map +1 -1
  160. package/build/src/utils/response.utils.d.ts +2 -2
  161. package/build/src/utils/response.utils.js +9 -9
  162. package/build/src/utils/response.utils.js.map +1 -1
  163. package/build/src/utils/string.utils.js +17 -17
  164. package/build/src/utils/string.utils.js.map +1 -1
  165. package/build/src/utils/url.utils.js +20 -22
  166. package/build/src/utils/url.utils.js.map +1 -1
  167. package/build/src/utils/validate.utils.js +14 -16
  168. package/build/src/utils/validate.utils.js.map +1 -1
  169. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"env.utils.js","sourceRoot":"","sources":["../../../src/utils/env.utils.ts"],"names":[],"mappings":";;;AAAA,qCAAqC;AACrC,2BAAgC;AAChC,+BAA2C;AAC3C;;GAEG;AACH,IAAY,WAKX;AALD,WAAY,WAAW;IACrB,wCAAyB,CAAA;IACzB,0CAA2B,CAAA;IAC3B,kCAAmB,CAAA;IACnB,kCAAmB,CAAA;AACrB,CAAC,EALW,WAAW,2BAAX,WAAW,QAKtB;AAED;;;GAGG;AACH,MAAa,GAAG;IACd;;;;OAIG;IACH,MAAM,CAAC,KAAK;QACV,OAAO,CACL,GAAG,CAAC,GAAG,CAAC,UAAU,EAAE,WAAW,CAAC,WAAW,CAAC,KAAK,WAAW,CAAC,WAAW,CACzE,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,MAAM;QACX,OAAO,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,WAAW,CAAC,UAAU,CAAC;IACxD,CAAC;IAED;;;;OAIG;IAC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YAAY,EAAE,EAAE,CACtD,GAAG,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,YAAY,CAAC,WAAW,EAAE,CAAC,CACvD,CAAC;YAEF,OAAO,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC;QAChD,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,GAAG,CAAC,GAAW;QACpB,OAAO,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,SAAS,CAAC;IACxC,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,MAAM,CAAC,GAAW;QACvB,OAAO,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC1B,CAAC;CACF;AAvbD,kBAubC","sourcesContent":["/* eslint-disable n/no-process-env */\nimport { existsSync } from \"fs\";\nimport { isAbsolute, resolve } from \"path\";\n/**\n * Enum representing valid application environments.\n */\nexport enum Environment {\n PRODUCTION = \"production\",\n DEVELOPMENT = \"development\",\n STAGING = \"staging\",\n TESTING = \"testing\",\n}\n\n/**\n * Utility class for accessing and managing environment variables.\n * Provides typed getters with fallback defaults and validation.\n */\nexport class Env {\n /**\n * Checks if the current NODE_ENV is 'development'.\n *\n * @returns {boolean} `true` if NODE_ENV is 'development', else `false`.\n */\n static isDev(): boolean {\n return (\n Env.get(\"NODE_ENV\", Environment.DEVELOPMENT) === Environment.DEVELOPMENT\n );\n }\n\n /**\n * Checks if the current NODE_ENV is 'production'.\n *\n * @returns {boolean} `true` if NODE_ENV is 'production', else `false`.\n */\n static isProd(): boolean {\n return Env.get(\"NODE_ENV\") === Environment.PRODUCTION;\n }\n\n /**\n * Checks if the current NODE_ENV is 'testing'.\n *\n * @returns {boolean} `true` if NODE_ENV is 'testing', else `false`.\n */\n static isTest(): boolean {\n return Env.get(\"NODE_ENV\") === Environment.TESTING;\n }\n\n /**\n * Checks if the current NODE_ENV is 'staging'.\n *\n * @returns {boolean} `true` if NODE_ENV is 'staging', else `false`.\n */\n static isStaging(): boolean {\n return Env.get(\"NODE_ENV\") === Environment.STAGING;\n }\n\n /**\n * Sets an environment variable (only affects runtime memory).\n *\n * @param {string} key - The environment variable key.\n * @param {string} value - The value to set.\n */\n static set(key: string, value: string): void {\n process.env[key] = value;\n }\n\n /**\n * Returns all environment variables as an object.\n *\n * @returns {object} The current `process.env` object.\n */\n static getAll(): object {\n return process.env;\n }\n\n /**\n * Retrieves a string environment variable with a fallback default.\n *\n * @param {string} key - The environment variable key.\n * @param {string} [defaultValue] - Value to return if the key is missing.\n * @returns {string | undefined} The env value or the fallback.\n */\n static get(key: string, defaultValue?: string): string | undefined {\n return process.env[key] ?? defaultValue;\n }\n\n /**\n * Retrieves a string environment variable and throws if it's missing.\n *\n * @param {string} key - The environment variable key.\n * @returns {string} The environment variable's value.\n * @throws {Error} If the variable is not defined.\n */\n static getRequired(key: string): string {\n const value = process.env[key];\n if (value === undefined) {\n throw new Error(`Required env ${key} is missing`);\n }\n return value;\n }\n\n /**\n * Retrieves an environment variable as a number, or returns a default.\n *\n * @param {string} key - The environment variable key.\n * @param {number} defaultValue - Fallback number if key is not present.\n * @returns {number} Parsed numeric value or default.\n * @throws {Error} If the value is not a valid number.\n */\n static getNumber(key: string, defaultValue: number): number {\n const value = process.env[key] ?? defaultValue;\n const numberValue = Number(value);\n if (isNaN(numberValue)) {\n throw new Error(`Env ${key} is not a number`);\n }\n return numberValue;\n }\n\n /**\n * Retrieves a required environment variable as a number.\n *\n * @param {string} key - The environment variable key.\n * @returns {number} Parsed number.\n * @throws {Error} If the value is missing or not a number.\n */\n static getNumberRequired(key: string): number {\n const value = process.env[key];\n if (value === undefined) {\n throw new Error(`Required env ${key} is missing`);\n }\n const numberValue = Number(value);\n if (isNaN(numberValue)) {\n throw new Error(`Required env ${key} is not a number`);\n }\n return numberValue;\n }\n\n /**\n * Retrieves an environment variable as a boolean.\n * Accepts `true`, `1`, `yes`, `on` as true; `false`, `0`, `no`, `off` as false.\n *\n * @param {string} key - The environment variable key.\n * @param {boolean} [defaultValue=false] - Optional fallback value if key is missing.\n * @returns {boolean} Parsed boolean.\n * @throws {Error} If the value is not a recognized boolean string.\n */\n static getBoolean(key: string, defaultValue = false): boolean {\n const value = (process.env[key] ?? defaultValue).toString().toLowerCase();\n if ([\"true\", \"1\", \"yes\", \"on\"].includes(value)) return true;\n if ([\"false\", \"0\", \"no\", \"off\"].includes(value)) return false;\n throw new Error(`Env variable ${key} is not a boolean`);\n }\n\n /**\n * Retrieves a required environment variable as a boolean.\n *\n * @param {string} key - The environment variable key.\n * @returns {boolean} Parsed boolean value.\n * @throws {Error} If missing or invalid.\n */\n static getBooleanRequired(key: string): boolean {\n const value = process.env[key];\n if (value === undefined) {\n throw new Error(`Required env ${key} is missing`);\n }\n return this.getBoolean(key); // reuse logic\n }\n\n /**\n * Parses a stringified JSON object from an environment variable.\n *\n * @typeParam T - The type to parse as (defaults to `object`).\n * @param {string} key - The environment variable key.\n * @param {T} defaultValue - Value to return if key is missing.\n * @returns {T} Parsed object or default.\n * @throws {Error} If the value is not valid JSON.\n */\n static getJSON<T extends object = object>(key: string, defaultValue: T): T {\n const v = process.env[key];\n if (v !== undefined) {\n try {\n return JSON.parse(v);\n } catch {\n throw new Error(`Env variable ${key} is not a valid JSON string`);\n }\n }\n return defaultValue;\n }\n\n /**\n * Parses a comma-separated string as an array.\n *\n * @typeParam T - The item type (optional, defaults to string).\n * @param {string} key - The environment variable key.\n * @param {T[]} [defaultValue=[]] - Array to return if value is empty or missing.\n * @param {string} [splitter=','] - Delimiter to split on.\n * @returns {string[] | T[]} An array of strings.\n */\n static getArray<T = string>(\n key: string,\n defaultValue: T[] = [],\n splitter = \",\",\n ): string[] | T[] {\n const value = process.env[key];\n if (!value || value.trim() === \"\") {\n return defaultValue;\n }\n return value\n .split(splitter)\n .map((item) => item.trim())\n .filter((item) => item.length > 0);\n }\n\n /**\n * Retrieves an enum-like environment variable value, validating against allowed values.\n *\n * @typeParam T - The allowed value type (string literal types).\n * @param {string} key - The environment variable key.\n * @param {T[]} allowedValues - Array of accepted string values.\n * @param {T} [defaultValue] - Optional fallback value.\n * @returns {T} The validated environment value.\n * @throws {Error} If missing or invalid.\n */\n static getEnum<T extends string>(\n key: string,\n allowedValues: T[],\n defaultValue?: T,\n ): T {\n const value = process.env[key] ?? defaultValue;\n if (!value || !allowedValues.includes(value as T)) {\n throw new Error(\n `Env ${key} must be one of ${allowedValues.join(\", \")}. Received: ${value}`,\n );\n }\n return value as T;\n }\n\n /**\n * Retrieves a URL environment variable and validates it.\n *\n * @param {string} key - The environment variable key.\n * @param {string} [defaultValue] - Optional fallback value.\n * @param {object} [options] - Validation options.\n * @param {string[]} [options.protocols] - Allowed protocols.\n * @param {boolean} [options.requireTld=true] - Whether TLD is required.\n * @returns {string} The validated URL.\n * @throws {Error} If URL is invalid.\n */\n static getUrl(\n key: string,\n defaultValue?: string,\n options: { protocols?: string[]; requireTld?: boolean } = {},\n ): string {\n const value = Env.get(key, defaultValue);\n if (!value) {\n throw new Error(`Env ${key} is missing or empty`);\n }\n\n let url: URL;\n try {\n url = new URL(value);\n } catch {\n throw new Error(`Env ${key} is not a valid URL`);\n }\n\n if (options.protocols && options.protocols.length > 0) {\n const protocol = url.protocol.replace(\":\", \"\");\n if (!options.protocols.includes(protocol)) {\n throw new Error(\n `Env ${key} must use one of the protocols: ${options.protocols.join(\", \")}`,\n );\n }\n }\n\n if (options.requireTld === true) {\n // Check if hostname has a TLD (contains at least one dot and doesn't end with a dot)\n // localhost, 127.0.0.1, etc. don't have TLDs\n const hostname = url.hostname;\n if (\n !hostname.includes(\".\") ||\n hostname === \"localhost\" ||\n /^[\\d.]+$/.test(hostname) || // IP address\n hostname.endsWith(\".\")\n ) {\n throw new Error(`Env ${key} must have a valid host with TLD`);\n }\n }\n\n return value;\n }\n\n /**\n * Retrieves an email environment variable and validates it.\n *\n * @param {string} key - The environment variable key.\n * @param {string} [defaultValue] - Optional fallback value.\n * @returns {string} The validated email address.\n * @throws {Error} If email is invalid.\n */\n static getEmail(key: string, defaultValue?: string): string {\n const value = Env.get(key, defaultValue);\n\n if (!value) {\n if (defaultValue === undefined) {\n throw new Error(`Email env ${key} is missing`);\n }\n return defaultValue;\n }\n\n // Simple email validation regex\n const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$/;\n if (!emailRegex.test(value)) {\n throw new Error(`Env ${key} is not a valid email address`);\n }\n\n return value;\n }\n\n /**\n * Retrieves a path environment variable and validates it exists.\n *\n * @param {string} key - The environment variable key.\n * @param {string} [defaultValue] - Optional fallback value.\n * @param {object} [options] - Validation options.\n * @param {boolean} [options.mustExist=false] - Whether path must exist.\n * @param {boolean} [options.makeAbsolute=true] - Convert relative paths to absolute.\n * @returns {string} The validated path.\n * @throws {Error} If path is invalid.\n */\n static getPath(\n key: string,\n defaultValue?: string,\n options: { mustExist?: boolean; makeAbsolute?: boolean } = {},\n ): string {\n const value = Env.get(key, defaultValue);\n\n if (!value) {\n if (defaultValue === undefined) {\n throw new Error(`Path env ${key} is missing`);\n }\n return defaultValue;\n }\n\n const path =\n options.makeAbsolute !== false && !isAbsolute(value)\n ? resolve(process.cwd(), value)\n : value;\n\n if (options.mustExist && !existsSync(path)) {\n throw new Error(`Path in env ${key} does not exist: ${path}`);\n }\n\n return path;\n }\n\n /**\n * Retrieves a port environment variable and validates it.\n *\n * @param {string} key - The environment variable key.\n * @param {number} [defaultValue=3000] - Optional fallback value.\n * @returns {number} The validated port number.\n * @throws {Error} If port is invalid.\n */\n static getPort(key: string, defaultValue: number = 3000): number {\n const port = Env.getNumber(key, defaultValue);\n\n if (port < 0 || port > 65535) {\n throw new Error(`Env ${key} must be a valid port number (0-65535)`);\n }\n\n return port;\n }\n\n /**\n * Retrieves a duration string and converts to milliseconds.\n * Supports formats like \"1d\", \"2h\", \"30m\", \"45s\", \"100ms\" or combinations like \"1h30m\".\n *\n * @param {string} key - The environment variable key.\n * @param {string|number} [defaultValue='0'] - Optional fallback value.\n * @returns {number} The duration in milliseconds.\n * @throws {Error} If duration format is invalid.\n */\n static getDuration(key: string, defaultValue: string | number = \"0\"): number {\n const value = Env.get(key, String(defaultValue));\n\n if (!value) return 0;\n\n // Handle plain number input (assume milliseconds)\n if (/^\\d+$/.test(value)) {\n return parseInt(value, 10);\n }\n\n // Parse duration string like \"1d2h30m15s\"\n const durationRegex = /(\\d+d)?(\\d+h)?(\\d+m)?(\\d+s)?(\\d+ms)?/;\n const matches = value.match(durationRegex);\n\n if (!matches || matches[0] === \"\") {\n throw new Error(\n `Env ${key} has invalid duration format. Use 1d, 2h, 30m, 45s, or 100ms.`,\n );\n }\n\n let ms = 0;\n\n if (matches[1]) ms += parseInt(matches[1], 10) * 86400000; // days\n if (matches[2]) ms += parseInt(matches[2], 10) * 3600000; // hours\n if (matches[3]) ms += parseInt(matches[3], 10) * 60000; // minutes\n if (matches[4]) ms += parseInt(matches[4], 10) * 1000; // seconds\n if (matches[5]) ms += parseInt(matches[5], 10); // milliseconds\n\n return ms;\n }\n\n /**\n * Gets all environment variables with sensitive values masked for safe logging.\n *\n * @param {string[]} [sensitiveKeys=['password', 'secret', 'key', 'token', 'auth']] - Keys to mask.\n * @returns {Record<string, string>} Environment variables with sensitive values masked.\n */\n static getSafeEnv(\n sensitiveKeys: string[] = [\"password\", \"secret\", \"key\", \"token\", \"auth\"],\n ): Record<string, string> {\n const safeEnv: Record<string, string> = {};\n\n for (const [key, value] of Object.entries(process.env)) {\n if (!value) continue;\n\n const isSensitive = sensitiveKeys.some((sensitiveKey) =>\n key.toLowerCase().includes(sensitiveKey.toLowerCase()),\n );\n\n safeEnv[key] = isSensitive ? \"******\" : value;\n }\n\n return safeEnv;\n }\n\n /**\n * Checks whether the specified environment variable exists.\n *\n * @param {string} key - The environment variable key.\n * @returns {boolean} `true` if the variable is defined, otherwise `false`.\n */\n static has(key: string): boolean {\n return process.env[key] !== undefined;\n }\n\n /**\n * Deletes the given environment variable (useful in tests).\n *\n * @param {string} key - The environment variable key to delete.\n * @returns {void}\n */\n static delete(key: string): void {\n delete process.env[key];\n }\n}\n"]}
1
+ {"version":3,"file":"env.utils.js","sourceRoot":"","sources":["../../../src/utils/env.utils.ts"],"names":[],"mappings":";;;AAAA,qCAAqC;AACrC,2BAAgC;AAChC,+BAA2C;AAC3C;;GAEG;AACH,IAAY,WAKX;AALD,WAAY,WAAW;IACrB,wCAAyB,CAAA;IACzB,0CAA2B,CAAA;IAC3B,kCAAmB,CAAA;IACnB,kCAAmB,CAAA;AACrB,CAAC,EALW,WAAW,2BAAX,WAAW,QAKtB;AAED;;;GAGG;AACH,MAAa,GAAG;IACd;;;;OAIG;IACH,MAAM,CAAC,KAAK;QACV,OAAO,GAAG,CAAC,GAAG,CAAC,UAAU,EAAE,WAAW,CAAC,WAAW,CAAC,KAAK,WAAW,CAAC,WAAW,CAAC;IAClF,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,MAAM;QACX,OAAO,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,WAAW,CAAC,UAAU,CAAC;IACxD,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,MAAM;QACX,OAAO,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,WAAW,CAAC,OAAO,CAAC;IACrD,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,SAAS;QACd,OAAO,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,WAAW,CAAC,OAAO,CAAC;IACrD,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,GAAG,CAAC,GAAW,EAAE,KAAa;QACnC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IAC3B,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,MAAM;QACX,OAAO,OAAO,CAAC,GAAG,CAAC;IACrB,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,GA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CACF;AAhaD,kBAgaC","sourcesContent":["/* eslint-disable n/no-process-env */\nimport { existsSync } from 'fs';\nimport { isAbsolute, resolve } from 'path';\n/**\n * Enum representing valid application environments.\n */\nexport enum Environment {\n PRODUCTION = 'production',\n DEVELOPMENT = 'development',\n STAGING = 'staging',\n TESTING = 'testing'\n}\n\n/**\n * Utility class for accessing and managing environment variables.\n * Provides typed getters with fallback defaults and validation.\n */\nexport class Env {\n /**\n * Checks if the current NODE_ENV is 'development'.\n *\n * @returns {boolean} `true` if NODE_ENV is 'development', else `false`.\n */\n static isDev(): boolean {\n return Env.get('NODE_ENV', Environment.DEVELOPMENT) === Environment.DEVELOPMENT;\n }\n\n /**\n * Checks if the current NODE_ENV is 'production'.\n *\n * @returns {boolean} `true` if NODE_ENV is 'production', else `false`.\n */\n static isProd(): boolean {\n return Env.get('NODE_ENV') === Environment.PRODUCTION;\n }\n\n /**\n * Checks if the current NODE_ENV is 'testing'.\n *\n * @returns {boolean} `true` if NODE_ENV is 'testing', else `false`.\n */\n static isTest(): boolean {\n return Env.get('NODE_ENV') === Environment.TESTING;\n }\n\n /**\n * Checks if the current NODE_ENV is 'staging'.\n *\n * @returns {boolean} `true` if NODE_ENV is 'staging', else `false`.\n */\n static isStaging(): boolean {\n return Env.get('NODE_ENV') === Environment.STAGING;\n }\n\n /**\n * Sets an environment variable (only affects runtime memory).\n *\n * @param {string} key - The environment variable key.\n * @param {string} value - The value to set.\n */\n static set(key: string, value: string): void {\n process.env[key] = value;\n }\n\n /**\n * Returns all environment variables as an object.\n *\n * @returns {object} The current `process.env` object.\n */\n static getAll(): object {\n return process.env;\n }\n\n /**\n * Retrieves a string environment variable with a fallback default.\n *\n * @param {string} key - The environment variable key.\n * @param {string} [defaultValue] - Value to return if the key is missing.\n * @returns {string | undefined} The env value or the fallback.\n */\n static get(key: string, defaultValue?: string): string | undefined {\n return process.env[key] ?? defaultValue;\n }\n\n /**\n * Retrieves a string environment variable and throws if it's missing.\n *\n * @param {string} key - The environment variable key.\n * @returns {string} The environment variable's value.\n * @throws {Error} If the variable is not defined.\n */\n static getRequired(key: string): string {\n const value = process.env[key];\n if (value === undefined) {\n throw new Error(`Required env ${key} is missing`);\n }\n return value;\n }\n\n /**\n * Retrieves an environment variable as a number, or returns a default.\n *\n * @param {string} key - The environment variable key.\n * @param {number} defaultValue - Fallback number if key is not present.\n * @returns {number} Parsed numeric value or default.\n * @throws {Error} If the value is not a valid number.\n */\n static getNumber(key: string, defaultValue: number): number {\n const value = process.env[key] ?? defaultValue;\n const numberValue = Number(value);\n if (isNaN(numberValue)) {\n throw new Error(`Env ${key} is not a number`);\n }\n return numberValue;\n }\n\n /**\n * Retrieves a required environment variable as a number.\n *\n * @param {string} key - The environment variable key.\n * @returns {number} Parsed number.\n * @throws {Error} If the value is missing or not a number.\n */\n static getNumberRequired(key: string): number {\n const value = process.env[key];\n if (value === undefined) {\n throw new Error(`Required env ${key} is missing`);\n }\n const numberValue = Number(value);\n if (isNaN(numberValue)) {\n throw new Error(`Required env ${key} is not a number`);\n }\n return numberValue;\n }\n\n /**\n * Retrieves an environment variable as a boolean.\n * Accepts `true`, `1`, `yes`, `on` as true; `false`, `0`, `no`, `off` as false.\n *\n * @param {string} key - The environment variable key.\n * @param {boolean} [defaultValue=false] - Optional fallback value if key is missing.\n * @returns {boolean} Parsed boolean.\n * @throws {Error} If the value is not a recognized boolean string.\n */\n static getBoolean(key: string, defaultValue = false): boolean {\n const value = (process.env[key] ?? defaultValue).toString().toLowerCase();\n if (['true', '1', 'yes', 'on'].includes(value)) return true;\n if (['false', '0', 'no', 'off'].includes(value)) return false;\n throw new Error(`Env variable ${key} is not a boolean`);\n }\n\n /**\n * Retrieves a required environment variable as a boolean.\n *\n * @param {string} key - The environment variable key.\n * @returns {boolean} Parsed boolean value.\n * @throws {Error} If missing or invalid.\n */\n static getBooleanRequired(key: string): boolean {\n const value = process.env[key];\n if (value === undefined) {\n throw new Error(`Required env ${key} is missing`);\n }\n return this.getBoolean(key); // reuse logic\n }\n\n /**\n * Parses a stringified JSON object from an environment variable.\n *\n * @typeParam T - The type to parse as (defaults to `object`).\n * @param {string} key - The environment variable key.\n * @param {T} defaultValue - Value to return if key is missing.\n * @returns {T} Parsed object or default.\n * @throws {Error} If the value is not valid JSON.\n */\n static getJSON<T extends object = object>(key: string, defaultValue: T): T {\n const v = process.env[key];\n if (v !== undefined) {\n try {\n return JSON.parse(v);\n } catch {\n throw new Error(`Env variable ${key} is not a valid JSON string`);\n }\n }\n return defaultValue;\n }\n\n /**\n * Parses a comma-separated string as an array.\n *\n * @typeParam T - The item type (optional, defaults to string).\n * @param {string} key - The environment variable key.\n * @param {T[]} [defaultValue=[]] - Array to return if value is empty or missing.\n * @param {string} [splitter=','] - Delimiter to split on.\n * @returns {string[] | T[]} An array of strings.\n */\n static getArray<T = string>(key: string, defaultValue: T[] = [], splitter = ','): string[] | T[] {\n const value = process.env[key];\n if (!value || value.trim() === '') {\n return defaultValue;\n }\n return value\n .split(splitter)\n .map(item => item.trim())\n .filter(item => item.length > 0);\n }\n\n /**\n * Retrieves an enum-like environment variable value, validating against allowed values.\n *\n * @typeParam T - The allowed value type (string literal types).\n * @param {string} key - The environment variable key.\n * @param {T[]} allowedValues - Array of accepted string values.\n * @param {T} [defaultValue] - Optional fallback value.\n * @returns {T} The validated environment value.\n * @throws {Error} If missing or invalid.\n */\n static getEnum<T extends string>(key: string, allowedValues: T[], defaultValue?: T): T {\n const value = process.env[key] ?? defaultValue;\n if (!value || !allowedValues.includes(value as T)) {\n throw new Error(`Env ${key} must be one of ${allowedValues.join(', ')}. Received: ${value}`);\n }\n return value as T;\n }\n\n /**\n * Retrieves a URL environment variable and validates it.\n *\n * @param {string} key - The environment variable key.\n * @param {string} [defaultValue] - Optional fallback value.\n * @param {object} [options] - Validation options.\n * @param {string[]} [options.protocols] - Allowed protocols.\n * @param {boolean} [options.requireTld=true] - Whether TLD is required.\n * @returns {string} The validated URL.\n * @throws {Error} If URL is invalid.\n */\n static getUrl(\n key: string,\n defaultValue?: string,\n options: { protocols?: string[]; requireTld?: boolean } = {}\n ): string {\n const value = Env.get(key, defaultValue);\n if (!value) {\n throw new Error(`Env ${key} is missing or empty`);\n }\n\n let url: URL;\n try {\n url = new URL(value);\n } catch {\n throw new Error(`Env ${key} is not a valid URL`);\n }\n\n if (options.protocols && options.protocols.length > 0) {\n const protocol = url.protocol.replace(':', '');\n if (!options.protocols.includes(protocol)) {\n throw new Error(`Env ${key} must use one of the protocols: ${options.protocols.join(', ')}`);\n }\n }\n\n if (options.requireTld === true) {\n // Check if hostname has a TLD (contains at least one dot and doesn't end with a dot)\n // localhost, 127.0.0.1, etc. don't have TLDs\n const hostname = url.hostname;\n if (\n !hostname.includes('.') ||\n hostname === 'localhost' ||\n /^[\\d.]+$/.test(hostname) || // IP address\n hostname.endsWith('.')\n ) {\n throw new Error(`Env ${key} must have a valid host with TLD`);\n }\n }\n\n return value;\n }\n\n /**\n * Retrieves an email environment variable and validates it.\n *\n * @param {string} key - The environment variable key.\n * @param {string} [defaultValue] - Optional fallback value.\n * @returns {string} The validated email address.\n * @throws {Error} If email is invalid.\n */\n static getEmail(key: string, defaultValue?: string): string {\n const value = Env.get(key, defaultValue);\n\n if (!value) {\n if (defaultValue === undefined) {\n throw new Error(`Email env ${key} is missing`);\n }\n return defaultValue;\n }\n\n // Simple email validation regex\n const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$/;\n if (!emailRegex.test(value)) {\n throw new Error(`Env ${key} is not a valid email address`);\n }\n\n return value;\n }\n\n /**\n * Retrieves a path environment variable and validates it exists.\n *\n * @param {string} key - The environment variable key.\n * @param {string} [defaultValue] - Optional fallback value.\n * @param {object} [options] - Validation options.\n * @param {boolean} [options.mustExist=false] - Whether path must exist.\n * @param {boolean} [options.makeAbsolute=true] - Convert relative paths to absolute.\n * @returns {string} The validated path.\n * @throws {Error} If path is invalid.\n */\n static getPath(\n key: string,\n defaultValue?: string,\n options: { mustExist?: boolean; makeAbsolute?: boolean } = {}\n ): string {\n const value = Env.get(key, defaultValue);\n\n if (!value) {\n if (defaultValue === undefined) {\n throw new Error(`Path env ${key} is missing`);\n }\n return defaultValue;\n }\n\n const path = options.makeAbsolute !== false && !isAbsolute(value) ? resolve(process.cwd(), value) : value;\n\n if (options.mustExist && !existsSync(path)) {\n throw new Error(`Path in env ${key} does not exist: ${path}`);\n }\n\n return path;\n }\n\n /**\n * Retrieves a port environment variable and validates it.\n *\n * @param {string} key - The environment variable key.\n * @param {number} [defaultValue=3000] - Optional fallback value.\n * @returns {number} The validated port number.\n * @throws {Error} If port is invalid.\n */\n static getPort(key: string, defaultValue: number = 3000): number {\n const port = Env.getNumber(key, defaultValue);\n\n if (port < 0 || port > 65535) {\n throw new Error(`Env ${key} must be a valid port number (0-65535)`);\n }\n\n return port;\n }\n\n /**\n * Retrieves a duration string and converts to milliseconds.\n * Supports formats like \"1d\", \"2h\", \"30m\", \"45s\", \"100ms\" or combinations like \"1h30m\".\n *\n * @param {string} key - The environment variable key.\n * @param {string|number} [defaultValue='0'] - Optional fallback value.\n * @returns {number} The duration in milliseconds.\n * @throws {Error} If duration format is invalid.\n */\n static getDuration(key: string, defaultValue: string | number = '0'): number {\n const value = Env.get(key, String(defaultValue));\n\n if (!value) return 0;\n\n // Handle plain number input (assume milliseconds)\n if (/^\\d+$/.test(value)) {\n return parseInt(value, 10);\n }\n\n // Parse duration string like \"1d2h30m15s\"\n const durationRegex = /(\\d+d)?(\\d+h)?(\\d+m)?(\\d+s)?(\\d+ms)?/;\n const matches = value.match(durationRegex);\n\n if (!matches || matches[0] === '') {\n throw new Error(`Env ${key} has invalid duration format. Use 1d, 2h, 30m, 45s, or 100ms.`);\n }\n\n let ms = 0;\n\n if (matches[1]) ms += parseInt(matches[1], 10) * 86400000; // days\n if (matches[2]) ms += parseInt(matches[2], 10) * 3600000; // hours\n if (matches[3]) ms += parseInt(matches[3], 10) * 60000; // minutes\n if (matches[4]) ms += parseInt(matches[4], 10) * 1000; // seconds\n if (matches[5]) ms += parseInt(matches[5], 10); // milliseconds\n\n return ms;\n }\n\n /**\n * Gets all environment variables with sensitive values masked for safe logging.\n *\n * @param {string[]} [sensitiveKeys=['password', 'secret', 'key', 'token', 'auth']] - Keys to mask.\n * @returns {Record<string, string>} Environment variables with sensitive values masked.\n */\n static getSafeEnv(sensitiveKeys: string[] = ['password', 'secret', 'key', 'token', 'auth']): Record<string, string> {\n const safeEnv: Record<string, string> = {};\n\n for (const [key, value] of Object.entries(process.env)) {\n if (!value) continue;\n\n const isSensitive = sensitiveKeys.some(sensitiveKey => key.toLowerCase().includes(sensitiveKey.toLowerCase()));\n\n safeEnv[key] = isSensitive ? '******' : value;\n }\n\n return safeEnv;\n }\n\n /**\n * Checks whether the specified environment variable exists.\n *\n * @param {string} key - The environment variable key.\n * @returns {boolean} `true` if the variable is defined, otherwise `false`.\n */\n static has(key: string): boolean {\n return process.env[key] !== undefined;\n }\n\n /**\n * Deletes the given environment variable (useful in tests).\n *\n * @param {string} key - The environment variable key to delete.\n * @returns {void}\n */\n static delete(key: string): void {\n delete process.env[key];\n }\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { ErrorResponse } from "./response.utils";
1
+ import { ErrorResponse } from './response.utils';
2
2
  /**
3
3
  * Generic HTTP error class used for custom exceptions with any status code.
4
4
  * Inherit this when you need to throw errors dynamically at runtime.
@@ -33,7 +33,7 @@ class InternalServerErrorException extends response_utils_1.ErrorResponse {
33
33
  /**
34
34
  * @param message - Optional custom message. Defaults to "Internal server error".
35
35
  */
36
- constructor(message = "Internal server error") {
36
+ constructor(message = 'Internal server error') {
37
37
  super(message);
38
38
  this.status = http_status_codes_1.HttpStatusCodes.INTERNAL_SERVER_ERROR;
39
39
  }
@@ -47,7 +47,7 @@ class UnauthorizedException extends response_utils_1.ErrorResponse {
47
47
  /**
48
48
  * @param message - Optional custom message. Defaults to "Unauthorized".
49
49
  */
50
- constructor(message = "Unauthorized") {
50
+ constructor(message = 'Unauthorized') {
51
51
  super(message);
52
52
  this.status = http_status_codes_1.HttpStatusCodes.UNAUTHORIZED;
53
53
  }
@@ -61,7 +61,7 @@ class BadRequestException extends response_utils_1.ErrorResponse {
61
61
  /**
62
62
  * @param message - Optional custom message. Defaults to "Bad request".
63
63
  */
64
- constructor(message = "Bad request") {
64
+ constructor(message = 'Bad request') {
65
65
  super(message);
66
66
  this.status = http_status_codes_1.HttpStatusCodes.BAD_REQUEST;
67
67
  }
@@ -75,7 +75,7 @@ class NotFoundException extends response_utils_1.ErrorResponse {
75
75
  /**
76
76
  * @param message - Optional custom message. Defaults to "Resource not found".
77
77
  */
78
- constructor(message = "Resource not found") {
78
+ constructor(message = 'Resource not found') {
79
79
  super(message);
80
80
  this.status = http_status_codes_1.HttpStatusCodes.NOT_FOUND;
81
81
  }
@@ -89,7 +89,7 @@ class ForbiddenException extends response_utils_1.ErrorResponse {
89
89
  /**
90
90
  * @param message - Optional custom message. Defaults to "Forbidden".
91
91
  */
92
- constructor(message = "Forbidden") {
92
+ constructor(message = 'Forbidden') {
93
93
  super(message);
94
94
  this.status = http_status_codes_1.HttpStatusCodes.FORBIDDEN;
95
95
  }
@@ -103,7 +103,7 @@ class ConflictException extends response_utils_1.ErrorResponse {
103
103
  /**
104
104
  * @param message - Optional custom message. Defaults to "Conflict".
105
105
  */
106
- constructor(message = "Conflict") {
106
+ constructor(message = 'Conflict') {
107
107
  super(message);
108
108
  this.status = http_status_codes_1.HttpStatusCodes.CONFLICT;
109
109
  }
@@ -117,7 +117,7 @@ class BadGatewayException extends response_utils_1.ErrorResponse {
117
117
  /**
118
118
  * @param message - Optional custom message. Defaults to "Bad Gateway".
119
119
  */
120
- constructor(message = "Bad Gateway") {
120
+ constructor(message = 'Bad Gateway') {
121
121
  super(message);
122
122
  this.status = http_status_codes_1.HttpStatusCodes.BAD_GATEWAY;
123
123
  }
@@ -131,7 +131,7 @@ class TooManyRequestsException extends response_utils_1.ErrorResponse {
131
131
  /**
132
132
  * @param message - Optional custom message. Defaults to "Too many requests".
133
133
  */
134
- constructor(message = "Too many requests") {
134
+ constructor(message = 'Too many requests') {
135
135
  super(message);
136
136
  this.status = http_status_codes_1.HttpStatusCodes.TOO_MANY_REQUESTS;
137
137
  }
@@ -145,7 +145,7 @@ class ServiceUnavailableException extends response_utils_1.ErrorResponse {
145
145
  /**
146
146
  * @param message - Optional custom message. Defaults to "Service Unavailable".
147
147
  */
148
- constructor(message = "Service Unavailable") {
148
+ constructor(message = 'Service Unavailable') {
149
149
  super(message);
150
150
  this.status = http_status_codes_1.HttpStatusCodes.SERVICE_UNAVAILABLE;
151
151
  }
@@ -159,7 +159,7 @@ class GatewayTimeoutException extends response_utils_1.ErrorResponse {
159
159
  /**
160
160
  * @param message - Optional custom message. Defaults to "Gateway Timeout".
161
161
  */
162
- constructor(message = "Gateway Timeout") {
162
+ constructor(message = 'Gateway Timeout') {
163
163
  super(message);
164
164
  this.status = http_status_codes_1.HttpStatusCodes.GATEWAY_TIMEOUT;
165
165
  }
@@ -174,7 +174,7 @@ class UnprocessableEntityException extends response_utils_1.ErrorResponse {
174
174
  * @param message - Optional custom message. Defaults to "Unprocessable Entity".
175
175
  * @param details - Optional validation details or additional error context.
176
176
  */
177
- constructor(message = "Unprocessable Entity", details) {
177
+ constructor(message = 'Unprocessable Entity', details) {
178
178
  super(message);
179
179
  this.details = details;
180
180
  this.status = http_status_codes_1.HttpStatusCodes.UNPROCESSABLE_ENTITY;
@@ -190,7 +190,7 @@ class MethodNotAllowedException extends response_utils_1.ErrorResponse {
190
190
  * @param message - Optional custom message. Defaults to "Method Not Allowed".
191
191
  * @param allowedMethods - Optional array of allowed HTTP methods.
192
192
  */
193
- constructor(message = "Method Not Allowed", allowedMethods) {
193
+ constructor(message = 'Method Not Allowed', allowedMethods) {
194
194
  super(message);
195
195
  this.allowedMethods = allowedMethods;
196
196
  this.status = http_status_codes_1.HttpStatusCodes.METHOD_NOT_ALLOWED;
@@ -205,7 +205,7 @@ class NotAcceptableException extends response_utils_1.ErrorResponse {
205
205
  /**
206
206
  * @param message - Optional custom message. Defaults to "Not Acceptable".
207
207
  */
208
- constructor(message = "Not Acceptable") {
208
+ constructor(message = 'Not Acceptable') {
209
209
  super(message);
210
210
  this.status = http_status_codes_1.HttpStatusCodes.NOT_ACCEPTABLE;
211
211
  }
@@ -219,7 +219,7 @@ class RequestTimeoutException extends response_utils_1.ErrorResponse {
219
219
  /**
220
220
  * @param message - Optional custom message. Defaults to "Request Timeout".
221
221
  */
222
- constructor(message = "Request Timeout") {
222
+ constructor(message = 'Request Timeout') {
223
223
  super(message);
224
224
  this.status = http_status_codes_1.HttpStatusCodes.REQUEST_TIMEOUT;
225
225
  }
@@ -233,7 +233,7 @@ class UnsupportedMediaTypeException extends response_utils_1.ErrorResponse {
233
233
  /**
234
234
  * @param message - Optional custom message. Defaults to "Unsupported Media Type".
235
235
  */
236
- constructor(message = "Unsupported Media Type") {
236
+ constructor(message = 'Unsupported Media Type') {
237
237
  super(message);
238
238
  this.status = http_status_codes_1.HttpStatusCodes.UNSUPPORTED_MEDIA_TYPE;
239
239
  }
@@ -247,7 +247,7 @@ class PayloadTooLargeException extends response_utils_1.ErrorResponse {
247
247
  /**
248
248
  * @param message - Optional custom message. Defaults to "Payload Too Large".
249
249
  */
250
- constructor(message = "Payload Too Large") {
250
+ constructor(message = 'Payload Too Large') {
251
251
  super(message);
252
252
  this.status = http_status_codes_1.HttpStatusCodes.PAYLOAD_TOO_LARGE;
253
253
  }
@@ -261,7 +261,7 @@ class InsufficientStorageException extends response_utils_1.ErrorResponse {
261
261
  /**
262
262
  * @param message - Optional custom message. Defaults to "Insufficient Storage".
263
263
  */
264
- constructor(message = "Insufficient Storage") {
264
+ constructor(message = 'Insufficient Storage') {
265
265
  super(message);
266
266
  this.status = http_status_codes_1.HttpStatusCodes.INSUFFICIENT_STORAGE;
267
267
  }
@@ -303,7 +303,7 @@ function createHttpError(status, message) {
303
303
  case http_status_codes_1.HttpStatusCodes.CONFLICT:
304
304
  return new ConflictException(message);
305
305
  case http_status_codes_1.HttpStatusCodes.GONE:
306
- return new HttpError(http_status_codes_1.HttpStatusCodes.GONE, message || "Gone");
306
+ return new HttpError(http_status_codes_1.HttpStatusCodes.GONE, message || 'Gone');
307
307
  case http_status_codes_1.HttpStatusCodes.PAYLOAD_TOO_LARGE:
308
308
  return new PayloadTooLargeException(message);
309
309
  case http_status_codes_1.HttpStatusCodes.UNSUPPORTED_MEDIA_TYPE:
@@ -333,10 +333,7 @@ function createHttpError(status, message) {
333
333
  * @returns True if object has error-like structure.
334
334
  */
335
335
  function hasErrorShape(error) {
336
- return (typeof error === "object" &&
337
- error !== null &&
338
- "message" in error &&
339
- typeof error.message === "string");
336
+ return (typeof error === 'object' && error !== null && 'message' in error && typeof error.message === 'string');
340
337
  }
341
338
  /**
342
339
  * Safely extracts message from any error type.
@@ -345,7 +342,7 @@ function hasErrorShape(error) {
345
342
  * @returns A string error message.
346
343
  */
347
344
  function getErrorMessage(error) {
348
- if (typeof error === "string") {
345
+ if (typeof error === 'string') {
349
346
  return error;
350
347
  }
351
348
  if (error instanceof Error) {
@@ -354,7 +351,7 @@ function getErrorMessage(error) {
354
351
  if (hasErrorShape(error)) {
355
352
  return error.message;
356
353
  }
357
- return "Unknown error occurred";
354
+ return 'Unknown error occurred';
358
355
  }
359
356
  /**
360
357
  * Wraps a function and transforms any errors into HTTP errors.
@@ -373,10 +370,10 @@ function withErrorHandling(handler) {
373
370
  throw error;
374
371
  }
375
372
  // Log the original error (consider using a proper logger)
376
- (0, logger_utils_1.getLogger)().error("Caught error in handler:", error);
373
+ (0, logger_utils_1.getLogger)().error('Caught error in handler:', error);
377
374
  // Extract status code if it exists, otherwise use 500
378
375
  let status = http_status_codes_1.HttpStatusCodes.INTERNAL_SERVER_ERROR;
379
- if (hasErrorShape(error) && typeof error.status === "number") {
376
+ if (hasErrorShape(error) && typeof error.status === 'number') {
380
377
  status = error.status;
381
378
  }
382
379
  // Create appropriate HTTP error
@@ -1 +1 @@
1
- {"version":3,"file":"exception.utils.js","sourceRoot":"","sources":["../../../src/utils/exception.utils.ts"],"names":[],"mappings":";;;AAgRA,kCAEC;AAUD,0CA4CC;AAQD,sCASC;AAQD,0CAcC;AASD,8CAwBC;AAhZD,2DAAsD;AACtD,iDAA2C;AAC3C,qDAAiD;AAEjD;;;GAGG;AACH,MAAa,SAAU,SAAQ,8BAAa;IAC1C;;;;OAIG;IACH,YAAY,MAAc,EAAE,OAAe;QACzC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF;AAVD,8BAUC;AAED;;;GAGG;AACH,MAAa,4BAA6B,SAAQ,8BAAa;IAC7D;;OAEG;IACH,YAAY,UAAkB,uBAAuB;QACnD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,MAAM,GAAG,mCAAe,CAAC,qBAAqB,CAAC;IACtD,CAAC;CACF;AARD,oEAQC;AAED;;;GAGG;AACH,MAAa,qBAAsB,SAAQ,8BAAa;IACtD;;OAEG;IACH,YAAY,UAAkB,cAAc;QAC1C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,MAAM,GAAG,mCAAe,CAAC,YAAY,CAAC;IAC7C,CAAC;CACF;AARD,sDAQC;AAED;;;GAGG;AACH,MAAa,mBAAoB,SAAQ,8BAAa;IACpD;;OAEG;IACH,YAAY,UAAkB,aAAa;QACzC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,MAAM,GAAG,mCAAe,CAAC,WAAW,CAAC;IAC5C,CAAC;CACF;AARD,kDAQC;AAED;;;GAGG;AACH,MAAa,iBAAkB,SAAQ,8BAAa;IAClD;;OAEG;IACH,YAAY,UAAkB,oBAAoB;QAChD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,MAAM,GAAG,mCAAe,CAAC,SAAS,CAAC;IAC1C,CAAC;CACF;AARD,8CAQC;AAED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Q,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC3B,OAAO,KAAK,CAAC,OAAO,CAAC;IACvB,CAAC;IAED,IAAI,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,KAAK,CAAC,OAAO,CAAC;IACvB,CAAC;IAED,OAAO,wBAAwB,CAAC;AAClC,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,iBAAiB,CAC/B,OAAU;IAEV,OAAO,KAAK,EAAE,GAAG,IAAmB,EAAE,EAAE;QACtC,IAAI,CAAC;YACH,OAAO,MAAM,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC;QAChC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC;gBACvB,MAAM,KAAK,CAAC;YACd,CAAC;YAED,0DAA0D;YAC1D,IAAA,wBAAS,GAAE,CAAC,KAAK,CAAC,0BAA0B,EAAE,KAAK,CAAC,CAAC;YAErD,sDAAsD;YACtD,IAAI,MAAM,GAAG,mCAAe,CAAC,qBAAqB,CAAC;YACnD,IAAI,aAAa,CAAC,KAAK,CAAC,IAAI,OAAO,KAAK,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;gBAC7D,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;YACxB,CAAC;YAED,gCAAgC;YAChC,MAAM,eAAe,CAAC,MAAM,EAAE,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC;QACxD,CAAC;IACH,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { HttpStatusCodes } from \"./http-status-codes\";\nimport { getLogger } from \"./logger.utils\";\nimport { ErrorResponse } from \"./response.utils\";\n\n/**\n * Generic HTTP error class used for custom exceptions with any status code.\n * Inherit this when you need to throw errors dynamically at runtime.\n */\nexport class HttpError extends ErrorResponse {\n /**\n * Creates a new HTTP error instance.\n * @param status - A valid HTTP status code (e.g., 400, 500).\n * @param message - The error message to return to the client.\n */\n constructor(status: number, message: string) {\n super(message);\n this.status = status;\n }\n}\n\n/**\n * Represents a 500 Internal Server Error.\n * Use this for unexpected backend errors that are not caused by the client.\n */\nexport class InternalServerErrorException extends ErrorResponse {\n /**\n * @param message - Optional custom message. Defaults to \"Internal server error\".\n */\n constructor(message: string = \"Internal server error\") {\n super(message);\n this.status = HttpStatusCodes.INTERNAL_SERVER_ERROR;\n }\n}\n\n/**\n * Represents a 401 Unauthorized Error.\n * Indicates that authentication is required and has failed or not been provided.\n */\nexport class UnauthorizedException extends ErrorResponse {\n /**\n * @param message - Optional custom message. Defaults to \"Unauthorized\".\n */\n constructor(message: string = \"Unauthorized\") {\n super(message);\n this.status = HttpStatusCodes.UNAUTHORIZED;\n }\n}\n\n/**\n * Represents a 400 Bad Request Error.\n * Indicates that the client has sent invalid data (e.g., malformed request body).\n */\nexport class BadRequestException extends ErrorResponse {\n /**\n * @param message - Optional custom message. Defaults to \"Bad request\".\n */\n constructor(message: string = \"Bad request\") {\n super(message);\n this.status = HttpStatusCodes.BAD_REQUEST;\n }\n}\n\n/**\n * Represents a 404 Not Found Error.\n * Used when a requested resource (e.g., user, file) could not be located.\n */\nexport class NotFoundException extends ErrorResponse {\n /**\n * @param message - Optional custom message. Defaults to \"Resource not found\".\n */\n constructor(message: string = \"Resource not found\") {\n super(message);\n this.status = HttpStatusCodes.NOT_FOUND;\n }\n}\n\n/**\n * Represents a 403 Forbidden Error.\n * Indicates that the client is authenticated but not allowed to access the resource.\n */\nexport class ForbiddenException extends ErrorResponse {\n /**\n * @param message - Optional custom message. Defaults to \"Forbidden\".\n */\n constructor(message: string = \"Forbidden\") {\n super(message);\n this.status = HttpStatusCodes.FORBIDDEN;\n }\n}\n\n/**\n * Represents a 409 Conflict Error.\n * Commonly used when a resource already exists or a versioning conflict occurs.\n */\nexport class ConflictException extends ErrorResponse {\n /**\n * @param message - Optional custom message. Defaults to \"Conflict\".\n */\n constructor(message: string = \"Conflict\") {\n super(message);\n this.status = HttpStatusCodes.CONFLICT;\n }\n}\n\n/**\n * Represents a 502 Bad Gateway Error.\n * Used when the server receives an invalid response from an upstream server.\n */\nexport class BadGatewayException extends ErrorResponse {\n /**\n * @param message - Optional custom message. Defaults to \"Bad Gateway\".\n */\n constructor(message: string = \"Bad Gateway\") {\n super(message);\n this.status = HttpStatusCodes.BAD_GATEWAY;\n }\n}\n\n/**\n * Represents a 429 Too Many Requests Error.\n * Returned when the client has hit a rate limit.\n */\nexport class TooManyRequestsException extends ErrorResponse {\n /**\n * @param message - Optional custom message. Defaults to \"Too many requests\".\n */\n constructor(message: string = \"Too many requests\") {\n super(message);\n this.status = HttpStatusCodes.TOO_MANY_REQUESTS;\n }\n}\n\n/**\n * Represents a 503 Service Unavailable Error.\n * Indicates that the server is temporarily unavailable (e.g., for maintenance).\n */\nexport class ServiceUnavailableException extends ErrorResponse {\n /**\n * @param message - Optional custom message. Defaults to \"Service Unavailable\".\n */\n constructor(message: string = \"Service Unavailable\") {\n super(message);\n this.status = HttpStatusCodes.SERVICE_UNAVAILABLE;\n }\n}\n\n/**\n * Represents a 504 Gateway Timeout Error.\n * Returned when the server acting as a gateway times out waiting for a response.\n */\nexport class GatewayTimeoutException extends ErrorResponse {\n /**\n * @param message - Optional custom message. Defaults to \"Gateway Timeout\".\n */\n constructor(message: string = \"Gateway Timeout\") {\n super(message);\n this.status = HttpStatusCodes.GATEWAY_TIMEOUT;\n }\n}\n\n/**\n * Represents a 422 Unprocessable Entity Error.\n * Used when the server understands the content type but cannot process the contained instructions.\n */\nexport class UnprocessableEntityException extends ErrorResponse {\n /**\n * @param message - Optional custom message. Defaults to \"Unprocessable Entity\".\n * @param details - Optional validation details or additional error context.\n */\n constructor(\n message: string = \"Unprocessable Entity\",\n public details?: Record<string, any>,\n ) {\n super(message);\n this.status = HttpStatusCodes.UNPROCESSABLE_ENTITY;\n }\n}\n\n/**\n * Represents a 405 Method Not Allowed Error.\n * Used when the request method is not supported for the requested resource.\n */\nexport class MethodNotAllowedException extends ErrorResponse {\n /**\n * @param message - Optional custom message. Defaults to \"Method Not Allowed\".\n * @param allowedMethods - Optional array of allowed HTTP methods.\n */\n constructor(\n message: string = \"Method Not Allowed\",\n public allowedMethods?: string[],\n ) {\n super(message);\n this.status = HttpStatusCodes.METHOD_NOT_ALLOWED;\n }\n}\n\n/**\n * Represents a 406 Not Acceptable Error.\n * Used when the server cannot produce a response matching the client's accepted content types.\n */\nexport class NotAcceptableException extends ErrorResponse {\n /**\n * @param message - Optional custom message. Defaults to \"Not Acceptable\".\n */\n constructor(message: string = \"Not Acceptable\") {\n super(message);\n this.status = HttpStatusCodes.NOT_ACCEPTABLE;\n }\n}\n\n/**\n * Represents a 408 Request Timeout Error.\n * Used when the server times out waiting for the client to send a request.\n */\nexport class RequestTimeoutException extends ErrorResponse {\n /**\n * @param message - Optional custom message. Defaults to \"Request Timeout\".\n */\n constructor(message: string = \"Request Timeout\") {\n super(message);\n this.status = HttpStatusCodes.REQUEST_TIMEOUT;\n }\n}\n\n/**\n * Represents a 415 Unsupported Media Type Error.\n * Used when the request's Content-Type is not supported.\n */\nexport class UnsupportedMediaTypeException extends ErrorResponse {\n /**\n * @param message - Optional custom message. Defaults to \"Unsupported Media Type\".\n */\n constructor(message: string = \"Unsupported Media Type\") {\n super(message);\n this.status = HttpStatusCodes.UNSUPPORTED_MEDIA_TYPE;\n }\n}\n\n/**\n * Represents a 413 Payload Too Large Error.\n * Used when the request body exceeds server limits.\n */\nexport class PayloadTooLargeException extends ErrorResponse {\n /**\n * @param message - Optional custom message. Defaults to \"Payload Too Large\".\n */\n constructor(message: string = \"Payload Too Large\") {\n super(message);\n this.status = HttpStatusCodes.PAYLOAD_TOO_LARGE;\n }\n}\n\n/**\n * Represents a 507 Insufficient Storage Error.\n * Used when the server has insufficient storage to complete the request.\n */\nexport class InsufficientStorageException extends ErrorResponse {\n /**\n * @param message - Optional custom message. Defaults to \"Insufficient Storage\".\n */\n constructor(message: string = \"Insufficient Storage\") {\n super(message);\n this.status = HttpStatusCodes.INSUFFICIENT_STORAGE;\n }\n}\n\n/**\n * Checks if an error is an instance of HttpError or its subclasses.\n *\n * @param error - The error to check.\n * @returns True if the error is an HttpError, false otherwise.\n */\nexport function isHttpError(error: unknown): error is ErrorResponse {\n return error instanceof ErrorResponse;\n}\n\n/**\n * Creates an HTTP error with the specified status code and message.\n * Factory function for creating appropriate HTTP error instances.\n *\n * @param status - HTTP status code.\n * @param message - Optional custom error message.\n * @returns An instance of the appropriate HTTP error class.\n */\nexport function createHttpError(\n status: number,\n message?: string,\n): ErrorResponse {\n switch (status) {\n case HttpStatusCodes.BAD_REQUEST:\n return new BadRequestException(message);\n case HttpStatusCodes.UNAUTHORIZED:\n return new UnauthorizedException(message);\n case HttpStatusCodes.FORBIDDEN:\n return new ForbiddenException(message);\n case HttpStatusCodes.NOT_FOUND:\n return new NotFoundException(message);\n case HttpStatusCodes.METHOD_NOT_ALLOWED:\n return new MethodNotAllowedException(message);\n case HttpStatusCodes.NOT_ACCEPTABLE:\n return new NotAcceptableException(message);\n case HttpStatusCodes.REQUEST_TIMEOUT:\n return new RequestTimeoutException(message);\n case HttpStatusCodes.CONFLICT:\n return new ConflictException(message);\n case HttpStatusCodes.GONE:\n return new HttpError(HttpStatusCodes.GONE, message || \"Gone\");\n case HttpStatusCodes.PAYLOAD_TOO_LARGE:\n return new PayloadTooLargeException(message);\n case HttpStatusCodes.UNSUPPORTED_MEDIA_TYPE:\n return new UnsupportedMediaTypeException(message);\n case HttpStatusCodes.UNPROCESSABLE_ENTITY:\n return new UnprocessableEntityException(message);\n case HttpStatusCodes.TOO_MANY_REQUESTS:\n return new TooManyRequestsException(message);\n case HttpStatusCodes.INTERNAL_SERVER_ERROR:\n return new InternalServerErrorException(message);\n case HttpStatusCodes.BAD_GATEWAY:\n return new BadGatewayException(message);\n case HttpStatusCodes.SERVICE_UNAVAILABLE:\n return new ServiceUnavailableException(message);\n case HttpStatusCodes.GATEWAY_TIMEOUT:\n return new GatewayTimeoutException(message);\n case HttpStatusCodes.INSUFFICIENT_STORAGE:\n return new InsufficientStorageException(message);\n default:\n return new HttpError(status, message || `HTTP Error ${status}`);\n }\n}\n\n/**\n * Type guard to check if an object has specific error properties.\n *\n * @param error - The object to check.\n * @returns True if object has error-like structure.\n */\nexport function hasErrorShape(\n error: unknown,\n): error is { message: string; status?: number; code?: string } {\n return (\n typeof error === \"object\" &&\n error !== null &&\n \"message\" in error &&\n typeof (error as any).message === \"string\"\n );\n}\n\n/**\n * Safely extracts message from any error type.\n *\n * @param error - Any error object or value.\n * @returns A string error message.\n */\nexport function getErrorMessage(error: unknown): string {\n if (typeof error === \"string\") {\n return error;\n }\n\n if (error instanceof Error) {\n return error.message;\n }\n\n if (hasErrorShape(error)) {\n return error.message;\n }\n\n return \"Unknown error occurred\";\n}\n\n/**\n * Wraps a function and transforms any errors into HTTP errors.\n * Useful for API handlers to ensure consistent error responses.\n *\n * @param handler - The async function to wrap.\n * @returns A function that always returns or throws an HTTP error.\n */\nexport function withErrorHandling<T extends (...args: any[]) => Promise<any>>(\n handler: T,\n): (...args: Parameters<T>) => Promise<Awaited<ReturnType<T>>> {\n return async (...args: Parameters<T>) => {\n try {\n return await handler(...args);\n } catch (error) {\n if (isHttpError(error)) {\n throw error;\n }\n\n // Log the original error (consider using a proper logger)\n getLogger().error(\"Caught error in handler:\", error);\n\n // Extract status code if it exists, otherwise use 500\n let status = HttpStatusCodes.INTERNAL_SERVER_ERROR;\n if (hasErrorShape(error) && typeof error.status === \"number\") {\n status = error.status;\n }\n\n // Create appropriate HTTP error\n throw createHttpError(status, getErrorMessage(error));\n }\n };\n}\n"]}
1
+ {"version":3,"file":"exception.utils.js","sourceRoot":"","sources":["../../../src/utils/exception.utils.ts"],"names":[],"mappings":";;;AAgRA,kCAEC;AAUD,0CAyCC;AAQD,sCAIC;AAQD,0CAcC;AASD,8CAwBC;AAxYD,2DAAsD;AACtD,iDAA2C;AAC3C,qDAAiD;AA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K,CAAC,OAAO,CAAC;IACvB,CAAC;IAED,OAAO,wBAAwB,CAAC;AAClC,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,iBAAiB,CAC/B,OAAU;IAEV,OAAO,KAAK,EAAE,GAAG,IAAmB,EAAE,EAAE;QACtC,IAAI,CAAC;YACH,OAAO,MAAM,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC;QAChC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC;gBACvB,MAAM,KAAK,CAAC;YACd,CAAC;YAED,0DAA0D;YAC1D,IAAA,wBAAS,GAAE,CAAC,KAAK,CAAC,0BAA0B,EAAE,KAAK,CAAC,CAAC;YAErD,sDAAsD;YACtD,IAAI,MAAM,GAAG,mCAAe,CAAC,qBAAqB,CAAC;YACnD,IAAI,aAAa,CAAC,KAAK,CAAC,IAAI,OAAO,KAAK,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;gBAC7D,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;YACxB,CAAC;YAED,gCAAgC;YAChC,MAAM,eAAe,CAAC,MAAM,EAAE,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC;QACxD,CAAC;IACH,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { HttpStatusCodes } from './http-status-codes';\nimport { getLogger } from './logger.utils';\nimport { ErrorResponse } from './response.utils';\n\n/**\n * Generic HTTP error class used for custom exceptions with any status code.\n * Inherit this when you need to throw errors dynamically at runtime.\n */\nexport class HttpError extends ErrorResponse {\n /**\n * Creates a new HTTP error instance.\n * @param status - A valid HTTP status code (e.g., 400, 500).\n * @param message - The error message to return to the client.\n */\n constructor(status: number, message: string) {\n super(message);\n this.status = status;\n }\n}\n\n/**\n * Represents a 500 Internal Server Error.\n * Use this for unexpected backend errors that are not caused by the client.\n */\nexport class InternalServerErrorException extends ErrorResponse {\n /**\n * @param message - Optional custom message. Defaults to \"Internal server error\".\n */\n constructor(message: string = 'Internal server error') {\n super(message);\n this.status = HttpStatusCodes.INTERNAL_SERVER_ERROR;\n }\n}\n\n/**\n * Represents a 401 Unauthorized Error.\n * Indicates that authentication is required and has failed or not been provided.\n */\nexport class UnauthorizedException extends ErrorResponse {\n /**\n * @param message - Optional custom message. Defaults to \"Unauthorized\".\n */\n constructor(message: string = 'Unauthorized') {\n super(message);\n this.status = HttpStatusCodes.UNAUTHORIZED;\n }\n}\n\n/**\n * Represents a 400 Bad Request Error.\n * Indicates that the client has sent invalid data (e.g., malformed request body).\n */\nexport class BadRequestException extends ErrorResponse {\n /**\n * @param message - Optional custom message. Defaults to \"Bad request\".\n */\n constructor(message: string = 'Bad request') {\n super(message);\n this.status = HttpStatusCodes.BAD_REQUEST;\n }\n}\n\n/**\n * Represents a 404 Not Found Error.\n * Used when a requested resource (e.g., user, file) could not be located.\n */\nexport class NotFoundException extends ErrorResponse {\n /**\n * @param message - Optional custom message. Defaults to \"Resource not found\".\n */\n constructor(message: string = 'Resource not found') {\n super(message);\n this.status = HttpStatusCodes.NOT_FOUND;\n }\n}\n\n/**\n * Represents a 403 Forbidden Error.\n * Indicates that the client is authenticated but not allowed to access the resource.\n */\nexport class ForbiddenException extends ErrorResponse {\n /**\n * @param message - Optional custom message. Defaults to \"Forbidden\".\n */\n constructor(message: string = 'Forbidden') {\n super(message);\n this.status = HttpStatusCodes.FORBIDDEN;\n }\n}\n\n/**\n * Represents a 409 Conflict Error.\n * Commonly used when a resource already exists or a versioning conflict occurs.\n */\nexport class ConflictException extends ErrorResponse {\n /**\n * @param message - Optional custom message. Defaults to \"Conflict\".\n */\n constructor(message: string = 'Conflict') {\n super(message);\n this.status = HttpStatusCodes.CONFLICT;\n }\n}\n\n/**\n * Represents a 502 Bad Gateway Error.\n * Used when the server receives an invalid response from an upstream server.\n */\nexport class BadGatewayException extends ErrorResponse {\n /**\n * @param message - Optional custom message. Defaults to \"Bad Gateway\".\n */\n constructor(message: string = 'Bad Gateway') {\n super(message);\n this.status = HttpStatusCodes.BAD_GATEWAY;\n }\n}\n\n/**\n * Represents a 429 Too Many Requests Error.\n * Returned when the client has hit a rate limit.\n */\nexport class TooManyRequestsException extends ErrorResponse {\n /**\n * @param message - Optional custom message. Defaults to \"Too many requests\".\n */\n constructor(message: string = 'Too many requests') {\n super(message);\n this.status = HttpStatusCodes.TOO_MANY_REQUESTS;\n }\n}\n\n/**\n * Represents a 503 Service Unavailable Error.\n * Indicates that the server is temporarily unavailable (e.g., for maintenance).\n */\nexport class ServiceUnavailableException extends ErrorResponse {\n /**\n * @param message - Optional custom message. Defaults to \"Service Unavailable\".\n */\n constructor(message: string = 'Service Unavailable') {\n super(message);\n this.status = HttpStatusCodes.SERVICE_UNAVAILABLE;\n }\n}\n\n/**\n * Represents a 504 Gateway Timeout Error.\n * Returned when the server acting as a gateway times out waiting for a response.\n */\nexport class GatewayTimeoutException extends ErrorResponse {\n /**\n * @param message - Optional custom message. Defaults to \"Gateway Timeout\".\n */\n constructor(message: string = 'Gateway Timeout') {\n super(message);\n this.status = HttpStatusCodes.GATEWAY_TIMEOUT;\n }\n}\n\n/**\n * Represents a 422 Unprocessable Entity Error.\n * Used when the server understands the content type but cannot process the contained instructions.\n */\nexport class UnprocessableEntityException extends ErrorResponse {\n /**\n * @param message - Optional custom message. Defaults to \"Unprocessable Entity\".\n * @param details - Optional validation details or additional error context.\n */\n constructor(\n message: string = 'Unprocessable Entity',\n public details?: Record<string, any>\n ) {\n super(message);\n this.status = HttpStatusCodes.UNPROCESSABLE_ENTITY;\n }\n}\n\n/**\n * Represents a 405 Method Not Allowed Error.\n * Used when the request method is not supported for the requested resource.\n */\nexport class MethodNotAllowedException extends ErrorResponse {\n /**\n * @param message - Optional custom message. Defaults to \"Method Not Allowed\".\n * @param allowedMethods - Optional array of allowed HTTP methods.\n */\n constructor(\n message: string = 'Method Not Allowed',\n public allowedMethods?: string[]\n ) {\n super(message);\n this.status = HttpStatusCodes.METHOD_NOT_ALLOWED;\n }\n}\n\n/**\n * Represents a 406 Not Acceptable Error.\n * Used when the server cannot produce a response matching the client's accepted content types.\n */\nexport class NotAcceptableException extends ErrorResponse {\n /**\n * @param message - Optional custom message. Defaults to \"Not Acceptable\".\n */\n constructor(message: string = 'Not Acceptable') {\n super(message);\n this.status = HttpStatusCodes.NOT_ACCEPTABLE;\n }\n}\n\n/**\n * Represents a 408 Request Timeout Error.\n * Used when the server times out waiting for the client to send a request.\n */\nexport class RequestTimeoutException extends ErrorResponse {\n /**\n * @param message - Optional custom message. Defaults to \"Request Timeout\".\n */\n constructor(message: string = 'Request Timeout') {\n super(message);\n this.status = HttpStatusCodes.REQUEST_TIMEOUT;\n }\n}\n\n/**\n * Represents a 415 Unsupported Media Type Error.\n * Used when the request's Content-Type is not supported.\n */\nexport class UnsupportedMediaTypeException extends ErrorResponse {\n /**\n * @param message - Optional custom message. Defaults to \"Unsupported Media Type\".\n */\n constructor(message: string = 'Unsupported Media Type') {\n super(message);\n this.status = HttpStatusCodes.UNSUPPORTED_MEDIA_TYPE;\n }\n}\n\n/**\n * Represents a 413 Payload Too Large Error.\n * Used when the request body exceeds server limits.\n */\nexport class PayloadTooLargeException extends ErrorResponse {\n /**\n * @param message - Optional custom message. Defaults to \"Payload Too Large\".\n */\n constructor(message: string = 'Payload Too Large') {\n super(message);\n this.status = HttpStatusCodes.PAYLOAD_TOO_LARGE;\n }\n}\n\n/**\n * Represents a 507 Insufficient Storage Error.\n * Used when the server has insufficient storage to complete the request.\n */\nexport class InsufficientStorageException extends ErrorResponse {\n /**\n * @param message - Optional custom message. Defaults to \"Insufficient Storage\".\n */\n constructor(message: string = 'Insufficient Storage') {\n super(message);\n this.status = HttpStatusCodes.INSUFFICIENT_STORAGE;\n }\n}\n\n/**\n * Checks if an error is an instance of HttpError or its subclasses.\n *\n * @param error - The error to check.\n * @returns True if the error is an HttpError, false otherwise.\n */\nexport function isHttpError(error: unknown): error is ErrorResponse {\n return error instanceof ErrorResponse;\n}\n\n/**\n * Creates an HTTP error with the specified status code and message.\n * Factory function for creating appropriate HTTP error instances.\n *\n * @param status - HTTP status code.\n * @param message - Optional custom error message.\n * @returns An instance of the appropriate HTTP error class.\n */\nexport function createHttpError(status: number, message?: string): ErrorResponse {\n switch (status) {\n case HttpStatusCodes.BAD_REQUEST:\n return new BadRequestException(message);\n case HttpStatusCodes.UNAUTHORIZED:\n return new UnauthorizedException(message);\n case HttpStatusCodes.FORBIDDEN:\n return new ForbiddenException(message);\n case HttpStatusCodes.NOT_FOUND:\n return new NotFoundException(message);\n case HttpStatusCodes.METHOD_NOT_ALLOWED:\n return new MethodNotAllowedException(message);\n case HttpStatusCodes.NOT_ACCEPTABLE:\n return new NotAcceptableException(message);\n case HttpStatusCodes.REQUEST_TIMEOUT:\n return new RequestTimeoutException(message);\n case HttpStatusCodes.CONFLICT:\n return new ConflictException(message);\n case HttpStatusCodes.GONE:\n return new HttpError(HttpStatusCodes.GONE, message || 'Gone');\n case HttpStatusCodes.PAYLOAD_TOO_LARGE:\n return new PayloadTooLargeException(message);\n case HttpStatusCodes.UNSUPPORTED_MEDIA_TYPE:\n return new UnsupportedMediaTypeException(message);\n case HttpStatusCodes.UNPROCESSABLE_ENTITY:\n return new UnprocessableEntityException(message);\n case HttpStatusCodes.TOO_MANY_REQUESTS:\n return new TooManyRequestsException(message);\n case HttpStatusCodes.INTERNAL_SERVER_ERROR:\n return new InternalServerErrorException(message);\n case HttpStatusCodes.BAD_GATEWAY:\n return new BadGatewayException(message);\n case HttpStatusCodes.SERVICE_UNAVAILABLE:\n return new ServiceUnavailableException(message);\n case HttpStatusCodes.GATEWAY_TIMEOUT:\n return new GatewayTimeoutException(message);\n case HttpStatusCodes.INSUFFICIENT_STORAGE:\n return new InsufficientStorageException(message);\n default:\n return new HttpError(status, message || `HTTP Error ${status}`);\n }\n}\n\n/**\n * Type guard to check if an object has specific error properties.\n *\n * @param error - The object to check.\n * @returns True if object has error-like structure.\n */\nexport function hasErrorShape(error: unknown): error is { message: string; status?: number; code?: string } {\n return (\n typeof error === 'object' && error !== null && 'message' in error && typeof (error as any).message === 'string'\n );\n}\n\n/**\n * Safely extracts message from any error type.\n *\n * @param error - Any error object or value.\n * @returns A string error message.\n */\nexport function getErrorMessage(error: unknown): string {\n if (typeof error === 'string') {\n return error;\n }\n\n if (error instanceof Error) {\n return error.message;\n }\n\n if (hasErrorShape(error)) {\n return error.message;\n }\n\n return 'Unknown error occurred';\n}\n\n/**\n * Wraps a function and transforms any errors into HTTP errors.\n * Useful for API handlers to ensure consistent error responses.\n *\n * @param handler - The async function to wrap.\n * @returns A function that always returns or throws an HTTP error.\n */\nexport function withErrorHandling<T extends (...args: any[]) => Promise<any>>(\n handler: T\n): (...args: Parameters<T>) => Promise<Awaited<ReturnType<T>>> {\n return async (...args: Parameters<T>) => {\n try {\n return await handler(...args);\n } catch (error) {\n if (isHttpError(error)) {\n throw error;\n }\n\n // Log the original error (consider using a proper logger)\n getLogger().error('Caught error in handler:', error);\n\n // Extract status code if it exists, otherwise use 500\n let status = HttpStatusCodes.INTERNAL_SERVER_ERROR;\n if (hasErrorShape(error) && typeof error.status === 'number') {\n status = error.status;\n }\n\n // Create appropriate HTTP error\n throw createHttpError(status, getErrorMessage(error));\n }\n };\n}\n"]}
@@ -1,5 +1,5 @@
1
- import { BufferEncoding } from "./crypto.utils";
2
- import { Stats } from "fs";
1
+ import { BufferEncoding } from './crypto.utils';
2
+ import { Stats } from 'fs';
3
3
  /**
4
4
  * Checks whether a file or directory exists at the given path.
5
5
  *
@@ -91,7 +91,7 @@ export declare function getFileStats(path: string): Promise<Stats | null>;
91
91
  * @param {string | Buffer} [options.content] - Optional content to write to the file.
92
92
  * @returns {Promise<string>} Path to the created temporary file.
93
93
  */
94
- export declare function createTempFile({ prefix, extension, dir, content, }?: {
94
+ export declare function createTempFile({ prefix, extension, dir, content }?: {
95
95
  prefix?: string;
96
96
  extension?: string;
97
97
  dir?: string;
@@ -51,7 +51,7 @@ async function fileExists(path) {
51
51
  */
52
52
  async function readJsonFile(path) {
53
53
  try {
54
- const data = await promises_1.default.readFile(path, "utf-8");
54
+ const data = await promises_1.default.readFile(path, 'utf-8');
55
55
  return JSON.parse(data);
56
56
  }
57
57
  catch (_a) {
@@ -68,7 +68,7 @@ async function readJsonFile(path) {
68
68
  */
69
69
  async function writeJsonFile(path, data, space = 2) {
70
70
  const json = JSON.stringify(data, null, space);
71
- await promises_1.default.writeFile(path, json, "utf-8");
71
+ await promises_1.default.writeFile(path, json, 'utf-8');
72
72
  }
73
73
  /**
74
74
  * Deletes a file if it exists.
@@ -82,7 +82,7 @@ async function deleteFileIfExists(path) {
82
82
  return true;
83
83
  }
84
84
  catch (err) {
85
- if (err.code === "ENOENT")
85
+ if (err.code === 'ENOENT')
86
86
  return true;
87
87
  return false;
88
88
  }
@@ -94,7 +94,7 @@ async function deleteFileIfExists(path) {
94
94
  * @param {BufferEncoding} [encoding="utf-8"] - The encoding to use.
95
95
  * @returns {Promise<string | null>} The file contents, or `null` if reading fails.
96
96
  */
97
- async function readTextFile(path, encoding = "utf-8") {
97
+ async function readTextFile(path, encoding = 'utf-8') {
98
98
  try {
99
99
  return await promises_1.default.readFile(path, encoding);
100
100
  }
@@ -110,7 +110,7 @@ async function readTextFile(path, encoding = "utf-8") {
110
110
  * @param {BufferEncoding} [encoding="utf-8"] - The encoding to use.
111
111
  * @returns {Promise<boolean>} Resolves to `true` if successful, `false` otherwise.
112
112
  */
113
- async function writeTextFile(path, content, encoding = "utf-8") {
113
+ async function writeTextFile(path, content, encoding = 'utf-8') {
114
114
  try {
115
115
  await promises_1.default.writeFile(path, content, encoding);
116
116
  return true;
@@ -127,7 +127,7 @@ async function writeTextFile(path, content, encoding = "utf-8") {
127
127
  * @param {BufferEncoding} [encoding="utf-8"] - The encoding to use.
128
128
  * @returns {Promise<boolean>} Resolves to `true` if successful, `false` otherwise.
129
129
  */
130
- async function appendTextFile(path, content, encoding = "utf-8") {
130
+ async function appendTextFile(path, content, encoding = 'utf-8') {
131
131
  try {
132
132
  await promises_1.default.appendFile(path, content, encoding);
133
133
  return true;
@@ -202,19 +202,15 @@ async function getFileStats(path) {
202
202
  * @param {string | Buffer} [options.content] - Optional content to write to the file.
203
203
  * @returns {Promise<string>} Path to the created temporary file.
204
204
  */
205
- async function createTempFile({ prefix = "tmp-", extension = "", dir = (0, os_1.tmpdir)(), content, } = {}) {
206
- const ext = extension
207
- ? extension.startsWith(".")
208
- ? extension
209
- : `.${extension}`
210
- : "";
205
+ async function createTempFile({ prefix = 'tmp-', extension = '', dir = (0, os_1.tmpdir)(), content } = {}) {
206
+ const ext = extension ? (extension.startsWith('.') ? extension : `.${extension}`) : '';
211
207
  const filename = `${prefix}${(0, crypto_1.randomUUID)()}${ext}`;
212
208
  const filepath = path_1.default.join(dir, filename);
213
209
  if (content) {
214
210
  await promises_1.default.writeFile(filepath, content);
215
211
  }
216
212
  else {
217
- await promises_1.default.writeFile(filepath, "");
213
+ await promises_1.default.writeFile(filepath, '');
218
214
  }
219
215
  return filepath;
220
216
  }
@@ -254,10 +250,10 @@ async function readDirectory(dirPath, options = {}) {
254
250
  const files = await promises_1.default.readdir(dirPath);
255
251
  let result = files;
256
252
  if (options.filter) {
257
- result = result.filter((file) => options.filter.test(file));
253
+ result = result.filter(file => options.filter.test(file));
258
254
  }
259
255
  if (options.fullPaths) {
260
- result = result.map((file) => path_1.default.join(dirPath, file));
256
+ result = result.map(file => path_1.default.join(dirPath, file));
261
257
  }
262
258
  return result;
263
259
  }
@@ -275,7 +271,7 @@ async function createDirectory(dirPath, recursive = true) {
275
271
  }
276
272
  catch (err) {
277
273
  // Consider it success if directory already exists
278
- return err.code === "EEXIST";
274
+ return err.code === 'EEXIST';
279
275
  }
280
276
  }
281
277
  /**
@@ -287,7 +283,7 @@ async function createDirectory(dirPath, recursive = true) {
287
283
  */
288
284
  async function safeReadJsonFile(path) {
289
285
  try {
290
- const content = await promises_1.default.readFile(path, "utf-8");
286
+ const content = await promises_1.default.readFile(path, 'utf-8');
291
287
  try {
292
288
  const data = JSON.parse(content);
293
289
  return { data, error: null };
@@ -295,14 +291,14 @@ async function safeReadJsonFile(path) {
295
291
  catch (error) {
296
292
  return {
297
293
  data: null,
298
- error: new Error(`Invalid JSON in file ${path}: ${error.message}`),
294
+ error: new Error(`Invalid JSON in file ${path}: ${error.message}`)
299
295
  };
300
296
  }
301
297
  }
302
298
  catch (error) {
303
299
  return {
304
300
  data: null,
305
- error: new Error(`Failed to read file ${path}: ${error.message}`),
301
+ error: new Error(`Failed to read file ${path}: ${error.message}`)
306
302
  };
307
303
  }
308
304
  }