@zintrust/core 0.1.22 → 0.1.24

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 (234) hide show
  1. package/bin/z.d.ts +1 -1
  2. package/bin/z.js +1 -1
  3. package/bin/zin.d.ts +1 -1
  4. package/bin/zin.js +1 -1
  5. package/bin/zintrust-main.d.ts +1 -1
  6. package/bin/zintrust-main.js +2 -2
  7. package/bin/zintrust-microservices.d.ts +1 -1
  8. package/bin/zintrust-microservices.js +1 -1
  9. package/bin/zintrust.d.ts +1 -1
  10. package/bin/zintrust.js +1 -1
  11. package/bin/zt.d.ts +1 -1
  12. package/bin/zt.js +1 -1
  13. package/package.json +2 -3
  14. package/public/index.html +3 -3
  15. package/routes/api.js +1 -1
  16. package/routes/health.d.ts +3 -4
  17. package/routes/health.d.ts.map +1 -1
  18. package/routes/health.js +3 -125
  19. package/src/boot/Application.d.ts.map +1 -1
  20. package/src/boot/Application.js +11 -22
  21. package/src/boot/bootstrap.d.ts +1 -1
  22. package/src/boot/bootstrap.js +48 -7
  23. package/src/builder/BundleOptimizer.d.ts +1 -1
  24. package/src/builder/BundleOptimizer.js +1 -1
  25. package/src/cache/drivers/KVRemoteDriver.d.ts +1 -1
  26. package/src/cache/drivers/KVRemoteDriver.js +1 -1
  27. package/src/cli/CLI.d.ts.map +1 -1
  28. package/src/cli/CLI.js +15 -1
  29. package/src/cli/ErrorHandler.js +3 -3
  30. package/src/cli/commands/AddCommand.d.ts +1 -1
  31. package/src/cli/commands/AddCommand.d.ts.map +1 -1
  32. package/src/cli/commands/AddCommand.js +1 -1
  33. package/src/cli/commands/DbSeedCommand.d.ts.map +1 -1
  34. package/src/cli/commands/DbSeedCommand.js +7 -39
  35. package/src/cli/commands/MakeMailTemplateCommand.js +2 -1
  36. package/src/cli/commands/MakeNotificationTemplateCommand.js +2 -1
  37. package/src/cli/commands/MigrateCommand.d.ts.map +1 -1
  38. package/src/cli/commands/MigrateCommand.js +12 -55
  39. package/src/cli/commands/MigrateWorkerCommand.d.ts +9 -0
  40. package/src/cli/commands/MigrateWorkerCommand.d.ts.map +1 -0
  41. package/src/cli/commands/MigrateWorkerCommand.js +136 -0
  42. package/src/cli/commands/NewCommand.d.ts +1 -1
  43. package/src/cli/commands/NewCommand.d.ts.map +1 -1
  44. package/src/cli/commands/NewCommand.js +9 -7
  45. package/src/cli/commands/PublishCommand.d.ts +5 -0
  46. package/src/cli/commands/PublishCommand.d.ts.map +1 -0
  47. package/src/cli/commands/PublishCommand.js +54 -0
  48. package/src/cli/commands/QACommand.js +4 -4
  49. package/src/cli/commands/ResourceControlCommand.d.ts +6 -0
  50. package/src/cli/commands/ResourceControlCommand.d.ts.map +1 -0
  51. package/src/cli/commands/ResourceControlCommand.js +43 -0
  52. package/src/cli/commands/SimulateCommand.d.ts +1 -1
  53. package/src/cli/commands/SimulateCommand.js +4 -4
  54. package/src/cli/commands/StartCommand.js +7 -7
  55. package/src/cli/commands/UpgradeCommand.d.ts +1 -1
  56. package/src/cli/commands/UpgradeCommand.js +2 -2
  57. package/src/cli/commands/WorkerCommands.d.ts +17 -0
  58. package/src/cli/commands/WorkerCommands.d.ts.map +1 -0
  59. package/src/cli/commands/WorkerCommands.js +264 -0
  60. package/src/cli/commands/index.d.ts +2 -0
  61. package/src/cli/commands/index.d.ts.map +1 -1
  62. package/src/cli/commands/index.js +2 -0
  63. package/src/cli/config/ConfigSchema.d.ts +1 -1
  64. package/src/cli/config/ConfigSchema.d.ts.map +1 -1
  65. package/src/cli/config/ConfigSchema.js +4 -3
  66. package/src/cli/scaffolding/ProjectScaffolder.js +5 -5
  67. package/src/cli/scaffolding/RouteGenerator.d.ts.map +1 -1
  68. package/src/cli/scaffolding/RouteGenerator.js +21 -2
  69. package/src/cli/scaffolding/TemplateEngine.js +1 -1
  70. package/src/cli/utils/DatabaseCliUtils.d.ts +20 -0
  71. package/src/cli/utils/DatabaseCliUtils.d.ts.map +1 -0
  72. package/src/cli/utils/DatabaseCliUtils.js +54 -0
  73. package/src/cli/utils/EnvFileLoader.d.ts.map +1 -1
  74. package/src/common/ExternalServiceUtils.d.ts +63 -0
  75. package/src/common/ExternalServiceUtils.d.ts.map +1 -0
  76. package/src/common/ExternalServiceUtils.js +116 -0
  77. package/src/common/HealthRoutes.d.ts +10 -0
  78. package/src/common/HealthRoutes.d.ts.map +1 -0
  79. package/src/common/HealthRoutes.js +114 -0
  80. package/src/config/SecretsManager.d.ts.map +1 -1
  81. package/src/config/SecretsManager.js +2 -1
  82. package/src/config/app.d.ts +2 -1
  83. package/src/config/app.d.ts.map +1 -1
  84. package/src/config/app.js +98 -52
  85. package/src/config/broadcast.d.ts.map +1 -1
  86. package/src/config/broadcast.js +1 -1
  87. package/src/config/cache.d.ts.map +1 -1
  88. package/src/config/cache.js +2 -2
  89. package/src/config/database.d.ts.map +1 -1
  90. package/src/config/database.js +24 -5
  91. package/src/config/env.d.ts +43 -1
  92. package/src/config/env.d.ts.map +1 -1
  93. package/src/config/env.js +68 -21
  94. package/src/config/index.d.ts +10 -1
  95. package/src/config/index.d.ts.map +1 -1
  96. package/src/config/index.js +1 -0
  97. package/src/config/mail.d.ts.map +1 -1
  98. package/src/config/mail.js +3 -3
  99. package/src/config/middleware.d.ts.map +1 -1
  100. package/src/config/middleware.js +1 -1
  101. package/src/config/notification.d.ts.map +1 -1
  102. package/src/config/notification.js +2 -2
  103. package/src/config/queue.d.ts +14 -0
  104. package/src/config/queue.d.ts.map +1 -1
  105. package/src/config/queue.js +61 -36
  106. package/src/config/security.js +2 -2
  107. package/src/config/storage.d.ts.map +1 -1
  108. package/src/config/storage.js +1 -1
  109. package/src/config/type.d.ts +111 -0
  110. package/src/config/type.d.ts.map +1 -1
  111. package/src/config/workers.d.ts +13 -0
  112. package/src/config/workers.d.ts.map +1 -0
  113. package/src/config/workers.js +173 -0
  114. package/src/database/Paginator.d.ts +37 -0
  115. package/src/database/Paginator.d.ts.map +1 -0
  116. package/src/database/Paginator.js +81 -0
  117. package/src/exceptions/ZintrustError.d.ts +5 -2
  118. package/src/exceptions/ZintrustError.d.ts.map +1 -1
  119. package/src/exceptions/ZintrustError.js +6 -2
  120. package/src/features/Auth.d.ts +1 -1
  121. package/src/features/Auth.d.ts.map +1 -1
  122. package/src/features/Auth.js +3 -2
  123. package/src/features/Queue.d.ts.map +1 -1
  124. package/src/features/Queue.js +0 -2
  125. package/src/index.d.ts +15 -5
  126. package/src/index.d.ts.map +1 -1
  127. package/src/index.js +24 -3
  128. package/src/microservices/MicroserviceBootstrap.d.ts.map +1 -1
  129. package/src/microservices/MicroserviceBootstrap.js +3 -1
  130. package/src/microservices/MicroserviceGenerator.js +4 -4
  131. package/src/microservices/MicroserviceManager.d.ts +1 -1
  132. package/src/microservices/MicroserviceManager.js +1 -1
  133. package/src/middleware/RateLimiter.d.ts.map +1 -1
  134. package/src/middleware/RateLimiter.js +4 -3
  135. package/src/node-singletons/crypto.d.ts +1 -1
  136. package/src/node-singletons/crypto.d.ts.map +1 -1
  137. package/src/node-singletons/crypto.js +1 -1
  138. package/src/node-singletons/os.d.ts +10 -1
  139. package/src/node-singletons/os.d.ts.map +1 -1
  140. package/src/node-singletons/os.js +10 -1
  141. package/src/openapi/OpenApiGenerator.js +2 -2
  142. package/src/orm/ConnectionManager.d.ts +1 -1
  143. package/src/orm/ConnectionManager.d.ts.map +1 -1
  144. package/src/orm/ConnectionManager.js +37 -19
  145. package/src/orm/Model.d.ts +8 -1
  146. package/src/orm/Model.d.ts.map +1 -1
  147. package/src/orm/Model.js +85 -24
  148. package/src/orm/QueryBuilder.d.ts +12 -2
  149. package/src/orm/QueryBuilder.d.ts.map +1 -1
  150. package/src/orm/QueryBuilder.js +438 -38
  151. package/src/orm/Relationships.d.ts +61 -1
  152. package/src/orm/Relationships.d.ts.map +1 -1
  153. package/src/orm/Relationships.js +190 -0
  154. package/src/orm/adapters/D1RemoteAdapter.d.ts +1 -1
  155. package/src/orm/adapters/D1RemoteAdapter.js +1 -1
  156. package/src/performance/Optimizer.d.ts.map +1 -1
  157. package/src/performance/Optimizer.js +2 -4
  158. package/src/routing/CoreRoutes.d.ts +1 -1
  159. package/src/routing/CoreRoutes.d.ts.map +1 -1
  160. package/src/routing/CoreRoutes.js +2 -116
  161. package/src/routing/error.d.ts.map +1 -1
  162. package/src/routing/error.js +3 -2
  163. package/src/routing/publicRoot.d.ts.map +1 -1
  164. package/src/routing/publicRoot.js +4 -2
  165. package/src/runtime/PluginAutoImports.d.ts.map +1 -1
  166. package/src/runtime/PluginAutoImports.js +8 -4
  167. package/src/runtime/PluginManager.d.ts.map +1 -1
  168. package/src/runtime/PluginManager.js +11 -6
  169. package/src/runtime/RuntimeAdapter.d.ts +3 -3
  170. package/src/runtime/RuntimeAdapter.d.ts.map +1 -1
  171. package/src/runtime/StartupConfigFileRegistry.d.ts +2 -1
  172. package/src/runtime/StartupConfigFileRegistry.d.ts.map +1 -1
  173. package/src/runtime/StartupConfigFileRegistry.js +2 -1
  174. package/src/runtime/adapters/CloudflareAdapter.d.ts.map +1 -1
  175. package/src/runtime/adapters/CloudflareAdapter.js +1 -1
  176. package/src/runtime/adapters/DenoAdapter.d.ts.map +1 -1
  177. package/src/runtime/adapters/DenoAdapter.js +1 -1
  178. package/src/runtime/adapters/FargateAdapter.d.ts +2 -2
  179. package/src/runtime/adapters/FargateAdapter.d.ts.map +1 -1
  180. package/src/runtime/adapters/FargateAdapter.js +1 -1
  181. package/src/runtime/adapters/LambdaAdapter.d.ts +1 -1
  182. package/src/runtime/adapters/LambdaAdapter.d.ts.map +1 -1
  183. package/src/runtime/adapters/LambdaAdapter.js +6 -4
  184. package/src/runtime/adapters/NodeServerAdapter.js +1 -1
  185. package/src/scripts/GenerateEnvArtifacts.js +1 -1
  186. package/src/security/SignedRequest.js +1 -1
  187. package/src/security/StartupSecretValidation.d.ts.map +1 -1
  188. package/src/security/StartupSecretValidation.js +7 -1
  189. package/src/start.d.ts.map +1 -1
  190. package/src/start.js +0 -2
  191. package/src/templates/features/Auth.ts.tpl +4 -4
  192. package/src/templates/project/basic/README.md.tpl +1 -1
  193. package/src/templates/project/basic/app/Middleware/index.ts.tpl +1 -1
  194. package/src/templates/project/basic/config/notification.ts.tpl +1 -1
  195. package/src/templates/project/basic/routes/api.ts.tpl +1 -3
  196. package/src/templates/project/basic/src/index.ts.tpl +1 -1
  197. package/src/templates/project/basic/src/zintrust.plugins.ts.tpl +1 -1
  198. package/src/templates/project/basic/template.json +1 -1
  199. package/src/toolkit/Secrets/index.d.ts.map +1 -1
  200. package/src/toolkit/Secrets/index.js +13 -9
  201. package/src/toolkit/Secrets/providers/AwsSecretsManager.d.ts.map +1 -1
  202. package/src/toolkit/Secrets/providers/AwsSecretsManager.js +8 -7
  203. package/src/toolkit/Secrets/providers/CloudflareKv.d.ts.map +1 -1
  204. package/src/toolkit/Secrets/providers/CloudflareKv.js +7 -6
  205. package/src/tools/http/Http.js +1 -1
  206. package/src/tools/mail/drivers/Ses.d.ts.map +1 -1
  207. package/src/tools/mail/drivers/Ses.js +5 -4
  208. package/src/tools/mail/templates/index.js +2 -2
  209. package/src/tools/notification/drivers/Termii.d.ts.map +1 -1
  210. package/src/tools/notification/drivers/Termii.js +6 -17
  211. package/src/tools/notification/testingHelpers.d.ts.map +1 -1
  212. package/src/tools/queue/Queue.d.ts.map +1 -1
  213. package/src/tools/queue/Queue.js +3 -5
  214. package/src/tools/queue/drivers/Redis.d.ts.map +1 -1
  215. package/src/tools/queue/drivers/Redis.js +7 -1
  216. package/src/tools/storage/drivers/S3.d.ts.map +1 -1
  217. package/src/tools/storage/drivers/S3.js +4 -3
  218. package/src/routes/health.d.ts +0 -2
  219. package/src/routes/health.d.ts.map +0 -1
  220. package/src/routes/health.js +0 -1
  221. package/src/runtime/RuntimeDetector.d.ts +0 -15
  222. package/src/runtime/RuntimeDetector.d.ts.map +0 -1
  223. package/src/runtime/RuntimeDetector.js +0 -271
  224. package/src/templates/project/basic/routes/health.ts.tpl +0 -143
  225. package/src/templates/project/basic/routes/metrics.ts.tpl +0 -22
  226. package/src/workers/BroadcastWorker.d.ts +0 -22
  227. package/src/workers/BroadcastWorker.d.ts.map +0 -1
  228. package/src/workers/BroadcastWorker.js +0 -24
  229. package/src/workers/NotificationWorker.d.ts +0 -22
  230. package/src/workers/NotificationWorker.d.ts.map +0 -1
  231. package/src/workers/NotificationWorker.js +0 -23
  232. package/src/workers/createQueueWorker.d.ts +0 -24
  233. package/src/workers/createQueueWorker.d.ts.map +0 -1
  234. package/src/workers/createQueueWorker.js +0 -114
package/src/config/app.js CHANGED
@@ -4,60 +4,113 @@
4
4
  * Sealed namespace for immutability
5
5
  */
6
6
  import { Env } from './env.js';
7
- const getProcessLike = () => {
8
- return typeof process === 'undefined' ? undefined : process;
9
- };
7
+ // Cache getSafeEnv result at module load time to avoid repeated object creation
8
+ const anyEnv = Env;
10
9
  const readEnvString = (key, defaultValue = '') => {
11
- const anyEnv = Env;
12
10
  if (typeof anyEnv.get === 'function') {
13
- return anyEnv.get(key, defaultValue);
11
+ return anyEnv.get(key, defaultValue) ?? '';
12
+ }
13
+ if (typeof process !== 'undefined') {
14
+ const raw = process.env?.[key];
15
+ if (typeof raw === 'string' && raw !== '')
16
+ return raw;
14
17
  }
15
- const proc = getProcessLike();
16
- const raw = proc?.env?.[key];
17
- return raw ?? defaultValue;
18
+ return defaultValue;
18
19
  };
19
- const readEnvInt = (key, defaultValue) => {
20
- const anyEnv = Env;
20
+ const readEnvInt = (key, defaultValue = 0) => {
21
21
  if (typeof anyEnv.getInt === 'function') {
22
22
  return anyEnv.getInt(key, defaultValue);
23
23
  }
24
24
  const raw = readEnvString(key, String(defaultValue));
25
25
  const parsed = Number.parseInt(raw, 10);
26
- return Number.isNaN(parsed) ? defaultValue : parsed;
26
+ return Number.isFinite(parsed) ? parsed : defaultValue;
27
27
  };
28
- const readEnvBool = (key, defaultValue) => {
29
- const anyEnv = Env;
28
+ const readEnvBool = (key, defaultValue = false) => {
30
29
  if (typeof anyEnv.getBool === 'function') {
31
30
  return anyEnv.getBool(key, defaultValue);
32
31
  }
33
- const raw = readEnvString(key, defaultValue ? 'true' : 'false');
32
+ const raw = readEnvString(key, '');
33
+ if (raw === '')
34
+ return defaultValue;
34
35
  return raw.toLowerCase() === 'true' || raw === '1';
35
36
  };
36
- const getSafeEnv = () => {
37
- const baseEnv = typeof process === 'undefined' ? {} : process.env;
38
- return {
39
- ...baseEnv,
40
- // Ensure required keys exist (env.d.ts augments ProcessEnv with required fields)
41
- NODE_ENV: baseEnv.NODE_ENV ??
42
- readEnvString('NODE_ENV', 'development'),
43
- USE_RAW_QRY: baseEnv.USE_RAW_QRY ?? (readEnvString('USE_RAW_QRY', '') || undefined),
44
- SERVICE_API_KEY: baseEnv.SERVICE_API_KEY ?? readEnvString('SERVICE_API_KEY', ''),
45
- SERVICE_JWT_SECRET: baseEnv.SERVICE_JWT_SECRET ??
46
- readEnvString('SERVICE_JWT_SECRET', '') ??
47
- readEnvString('APP_KEY', ''),
48
- BASE_URL: baseEnv['BASE_URL'] ?? readEnvString('BASE_URL', ''),
49
- MODE: baseEnv['MODE'] ?? readEnvString('MODE', ''),
50
- // Hardening for child-process usage
51
- PATH: typeof Env.SAFE_PATH === 'string'
52
- ? Env.SAFE_PATH
53
- : (baseEnv['PATH'] ?? ''),
54
- npm_config_scripts_prepend_node_path: 'true',
55
- };
37
+ const readAppPort = () => {
38
+ if (typeof anyEnv.getInt === 'function') {
39
+ return anyEnv.getInt('PORT', anyEnv.getInt('APP_PORT', 3000));
40
+ }
41
+ if (typeof Env.PORT === 'number' && Number.isFinite(Env.PORT) && Env.PORT > 0) {
42
+ return Env.PORT;
43
+ }
44
+ const portRaw = readEnvString('PORT', readEnvString('APP_PORT', '3000'));
45
+ const parsed = Number.parseInt(portRaw, 10);
46
+ return Number.isFinite(parsed) ? parsed : 3000;
47
+ };
48
+ /**
49
+ * Check if running on AWS Lambda
50
+ */
51
+ function isLambda() {
52
+ return (Env.getBool('LAMBDA_TASK_ROOT') === true ||
53
+ Env.getBool('AWS_LAMBDA_FUNCTION_NAME') === true ||
54
+ Env.getBool('AWS_EXECUTION_ENV') === true);
55
+ }
56
+ /**
57
+ * Check if running on Cloudflare Workers
58
+ */
59
+ function isCloudflare() {
60
+ return globalThis.CF !== undefined;
61
+ }
62
+ /**
63
+ * Check if running on Deno
64
+ */
65
+ function isDeno() {
66
+ return globalThis.Deno !== undefined;
67
+ }
68
+ /**
69
+ * Detect current runtime environment
70
+ */
71
+ const detectRuntime = () => {
72
+ const explicit = Env.get('RUNTIME').trim();
73
+ if (explicit !== '' && explicit !== 'auto')
74
+ return explicit;
75
+ // Auto-detection logic
76
+ if (isLambda() === true) {
77
+ return 'lambda';
78
+ }
79
+ if (isCloudflare() === true) {
80
+ return 'cloudflare';
81
+ }
82
+ if (isDeno() === true) {
83
+ return 'deno';
84
+ }
85
+ // Default to nodejs for containers (Fargate, Docker, Cloud Run)
86
+ return 'nodejs';
87
+ };
88
+ const resolvedNodeEnv = readEnvString('NODE_ENV', 'development');
89
+ // Cache getSafeEnv result at module load time to avoid repeated object creation
90
+ const cachedSafeEnv = {
91
+ ...(typeof process === 'undefined' ? {} : process.env),
92
+ NODE_ENV: resolvedNodeEnv,
93
+ MODE: resolvedNodeEnv,
94
+ npm_config_scripts_prepend_node_path: 'true',
56
95
  };
96
+ const useRawQry = readEnvString('USE_RAW_QRY');
97
+ if (useRawQry !== '')
98
+ cachedSafeEnv.USE_RAW_QRY = useRawQry;
99
+ const serviceApiKey = readEnvString('SERVICE_API_KEY');
100
+ if (serviceApiKey !== '')
101
+ cachedSafeEnv.SERVICE_API_KEY = serviceApiKey;
102
+ const serviceJwtSecret = readEnvString('SERVICE_JWT_SECRET') || readEnvString('APP_KEY');
103
+ if (serviceJwtSecret !== '')
104
+ cachedSafeEnv.SERVICE_JWT_SECRET = serviceJwtSecret;
105
+ const baseUrl = readEnvString('BASE_URL');
106
+ if (baseUrl !== '')
107
+ cachedSafeEnv['BASE_URL'] = baseUrl;
108
+ if (typeof Env.SAFE_PATH === 'string' && Env.SAFE_PATH !== '') {
109
+ cachedSafeEnv['PATH'] = Env.SAFE_PATH;
110
+ }
111
+ const getSafeEnv = () => cachedSafeEnv;
57
112
  const normalizeMode = () => {
58
- const value = (typeof Env.NODE_ENV === 'string'
59
- ? Env.NODE_ENV
60
- : readEnvString('NODE_ENV', 'development'));
113
+ const value = readEnvString('NODE_ENV', Env.NODE_ENV ?? 'development');
61
114
  if (value === 'production' || value === 'pro' || value === 'prod')
62
115
  return 'production';
63
116
  if (value === 'testing' || value === 'test')
@@ -68,9 +121,7 @@ const appConfigObj = {
68
121
  /**
69
122
  * Application name
70
123
  */
71
- name: typeof Env.APP_NAME === 'string'
72
- ? Env.APP_NAME
73
- : readEnvString('APP_NAME', 'ZinTrust'),
124
+ name: readEnvString('APP_NAME', Env.APP_NAME),
74
125
  /**
75
126
  * Application environment
76
127
  */
@@ -78,15 +129,11 @@ const appConfigObj = {
78
129
  /**
79
130
  * Application port
80
131
  */
81
- port: typeof Env.PORT === 'number'
82
- ? Env.PORT
83
- : readEnvInt('APP_PORT', 3000),
132
+ port: readAppPort(),
84
133
  /**
85
134
  * Application host
86
135
  */
87
- host: typeof Env.HOST === 'string'
88
- ? Env.HOST
89
- : readEnvString('HOST', 'localhost'),
136
+ host: readEnvString('HOST', Env.HOST),
90
137
  /**
91
138
  * Is development environment
92
139
  */
@@ -108,22 +155,21 @@ const appConfigObj = {
108
155
  /**
109
156
  * Application debug mode
110
157
  */
111
- debug: typeof Env.DEBUG === 'boolean'
112
- ? Env.DEBUG
113
- : readEnvBool('DEBUG', false),
158
+ debug: readEnvBool('DEBUG', Env.DEBUG),
114
159
  /**
115
160
  * Application timezone
116
161
  */
117
- timezone: readEnvString('APP_TIMEZONE', 'UTC'),
162
+ timezone: readEnvString('APP_TIMEZONE', Env.APP_TIMEZONE),
118
163
  /**
119
164
  * Request timeout (milliseconds)
120
165
  */
121
- requestTimeout: readEnvInt('REQUEST_TIMEOUT', 30000),
166
+ requestTimeout: readEnvInt('REQUEST_TIMEOUT', Env.REQUEST_TIMEOUT),
122
167
  /**
123
168
  * Max request body size
124
169
  */
125
- maxBodySize: readEnvString('MAX_BODY_SIZE', '10mb'),
170
+ maxBodySize: readEnvInt('MAX_BODY_SIZE', Env.MAX_BODY_SIZE),
126
171
  getSafeEnv,
172
+ detectRuntime,
127
173
  };
128
174
  export const appConfig = Object.freeze(appConfigObj);
129
175
  export { getSafeEnv };
@@ -1 +1 @@
1
- {"version":3,"file":"broadcast.d.ts","sourceRoot":"","sources":["../../../src/config/broadcast.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAEV,gBAAgB,EAEhB,0BAA0B,EAI3B,MAAM,cAAc,CAAC;AAGtB,MAAM,MAAM,wBAAwB,GAAG,OAAO,CAAC;IAC7C,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,0BAA0B,CAAC,CAAC;CACrD,CAAC,CAAC;AAEH,KAAK,sBAAsB,GAAG;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,gBAAgB,CAAC;IAC1B,aAAa,EAAE,MAAM,MAAM,CAAC;IAC5B,eAAe,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,KAAK,0BAA0B,CAAC;CAChE,CAAC;AA0EF,QAAA,MAAM,qBAAqB,QAAO,sBAoDjC,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAqBvE,QAAA,MAAM,eAAe,EAAE,eAYrB,CAAC;AAEH,eAAe,eAAe,CAAC"}
1
+ {"version":3,"file":"broadcast.d.ts","sourceRoot":"","sources":["../../../src/config/broadcast.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAEV,gBAAgB,EAEhB,0BAA0B,EAI3B,MAAM,cAAc,CAAC;AAItB,MAAM,MAAM,wBAAwB,GAAG,OAAO,CAAC;IAC7C,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,0BAA0B,CAAC,CAAC;CACrD,CAAC,CAAC;AAEH,KAAK,sBAAsB,GAAG;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,gBAAgB,CAAC;IAC1B,aAAa,EAAE,MAAM,MAAM,CAAC;IAC5B,eAAe,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,KAAK,0BAA0B,CAAC;CAChE,CAAC;AA0EF,QAAA,MAAM,qBAAqB,QAAO,sBAoDjC,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAqBvE,QAAA,MAAM,eAAe,EAAE,eAYrB,CAAC;AAEH,eAAe,eAAe,CAAC"}
@@ -4,9 +4,9 @@
4
4
  * Centralizes broadcast driver selection and provider env mappings.
5
5
  * Driver selection must be dynamic (tests may mutate process.env).
6
6
  */
7
- import { StartupConfigFile, StartupConfigFileRegistry } from '../runtime/StartupConfigFileRegistry.js';
8
7
  import { Env } from './env.js';
9
8
  import { ErrorFactory } from '../exceptions/ZintrustError.js';
9
+ import { StartupConfigFile, StartupConfigFileRegistry } from '../runtime/StartupConfigFileRegistry.js';
10
10
  const normalizeDriverName = (value) => value.trim().toLowerCase();
11
11
  const hasOwn = (obj, key) => {
12
12
  return Object.hasOwn(obj, key);
@@ -1 +1 @@
1
- {"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../../src/config/cache.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAGxE,MAAM,MAAM,oBAAoB,GAAG,OAAO,CAAC;IACzC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,gBAAgB,CAAC,SAAS,CAAC,CAAC;IACrC,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,MAAM,CAAC;CACb,CAAC,CAAC;AA0BH,QAAA,MAAM,iBAAiB,QAAO;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,gBAAgB,CAAC,SAAS,CAAC,CAAC;IACrC,SAAS,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,KAAK,iBAAiB,CAAC;IAChD,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,MAAM,CAAC;CA4Fb,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAqB/D,eAAO,MAAM,WAAW,EAAE,WAYxB,CAAC"}
1
+ {"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../../src/config/cache.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAIxE,MAAM,MAAM,oBAAoB,GAAG,OAAO,CAAC;IACzC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,gBAAgB,CAAC,SAAS,CAAC,CAAC;IACrC,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,MAAM,CAAC;CACb,CAAC,CAAC;AA0BH,QAAA,MAAM,iBAAiB,QAAO;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,gBAAgB,CAAC,SAAS,CAAC,CAAC;IACrC,SAAS,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,KAAK,iBAAiB,CAAC;IAChD,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,MAAM,CAAC;CA4Fb,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAqB/D,eAAO,MAAM,WAAW,EAAE,WAYxB,CAAC"}
@@ -3,9 +3,9 @@
3
3
  * Caching drivers and settings
4
4
  * Sealed namespace for immutability
5
5
  */
6
- import { StartupConfigFile, StartupConfigFileRegistry } from '../runtime/StartupConfigFileRegistry.js';
7
6
  import { Env } from './env.js';
8
7
  import { ErrorFactory } from '../exceptions/ZintrustError.js';
8
+ import { StartupConfigFile, StartupConfigFileRegistry } from '../runtime/StartupConfigFileRegistry.js';
9
9
  const getCacheDriver = (config, name) => {
10
10
  const selected = String(name ?? config.default).trim();
11
11
  const storeName = selected === 'default' ? String(config.default).trim() : selected;
@@ -61,7 +61,7 @@ const createCacheConfig = () => {
61
61
  const overrides = StartupConfigFileRegistry.get(StartupConfigFile.Cache) ?? {};
62
62
  const mergedDrivers = {
63
63
  ...baseDrivers,
64
- ...(overrides.drivers ?? {}),
64
+ ...overrides.drivers,
65
65
  };
66
66
  const mergedDefault = typeof overrides.default === 'string' && overrides.default.trim() !== ''
67
67
  ? overrides.default.trim().toLowerCase()
@@ -1 +1 @@
1
- {"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../../../src/config/database.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EACV,mBAAmB,EACnB,wBAAwB,EACxB,mBAAmB,EACpB,MAAM,cAAc,CAAC;AAGtB,MAAM,MAAM,uBAAuB,GAAG,OAAO,CAAC;IAC5C,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,mBAAmB,CAAC;IACjC,OAAO,EAAE;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAC7C,UAAU,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;IACrD,OAAO,EAAE;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;CAChC,CAAC,CAAC;AA0LH,QAAA,MAAM,oBAAoB,QAAO;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,mBAAmB,CAAC;IACjC,aAAa,EAAE,CAAC,IAAI,EAAE,mBAAmB,KAAK,wBAAwB,CAAC;IACvE,OAAO,EAAE;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAC7C,UAAU,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;IACrD,OAAO,EAAE;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;CAyEhC,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAqBrE,eAAO,MAAM,cAAc,EAAE,cAY3B,CAAC"}
1
+ {"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../../../src/config/database.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EACV,mBAAmB,EACnB,wBAAwB,EACxB,mBAAmB,EACpB,MAAM,cAAc,CAAC;AAItB,MAAM,MAAM,uBAAuB,GAAG,OAAO,CAAC;IAC5C,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,mBAAmB,CAAC;IACjC,OAAO,EAAE;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAC7C,UAAU,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;IACrD,OAAO,EAAE;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;CAChC,CAAC,CAAC;AAgNH,QAAA,MAAM,oBAAoB,QAAO;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,mBAAmB,CAAC;IACjC,aAAa,EAAE,CAAC,IAAI,EAAE,mBAAmB,KAAK,wBAAwB,CAAC;IACvE,OAAO,EAAE;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAC7C,UAAU,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;IACrD,OAAO,EAAE;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;CAyEhC,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAqBrE,eAAO,MAAM,cAAc,EAAE,cAY3B,CAAC"}
@@ -3,20 +3,35 @@
3
3
  * Database connections and pooling settings
4
4
  * Sealed namespace for immutability
5
5
  */
6
- import { StartupConfigFile, StartupConfigFileRegistry } from '../runtime/StartupConfigFileRegistry.js';
7
6
  import { Env } from './env.js';
8
7
  import { ErrorFactory } from '../exceptions/ZintrustError.js';
8
+ import { StartupConfigFile, StartupConfigFileRegistry } from '../runtime/StartupConfigFileRegistry.js';
9
9
  const isNodeProcess = () => {
10
10
  return typeof process !== 'undefined' && typeof process.cwd === 'function';
11
11
  };
12
+ const readEnvString = (key, fallback = '') => {
13
+ const anyEnv = Env;
14
+ const fromEnv = typeof anyEnv.get === 'function' ? anyEnv.get(key, fallback) : fallback;
15
+ if (typeof fromEnv === 'string' && fromEnv.trim() !== '')
16
+ return fromEnv;
17
+ if (typeof process !== 'undefined') {
18
+ const raw = process.env?.[key];
19
+ if (typeof raw === 'string' && raw.trim() !== '')
20
+ return raw;
21
+ }
22
+ return fromEnv ?? '';
23
+ };
12
24
  const isExplicitEnvValue = (key) => {
13
25
  if (!isNodeProcess())
14
26
  return false;
15
- const raw = process.env[key];
27
+ const direct = Env[key];
28
+ if (typeof direct === 'string' && direct.trim() !== '')
29
+ return true;
30
+ const raw = process.env[key] ?? Env.get(key, '');
16
31
  return typeof raw === 'string' && raw.trim() !== '';
17
32
  };
18
33
  const looksLikeSqliteFilePath = (value) => {
19
- const v = value.trim();
34
+ const v = String(value ?? '').trim();
20
35
  if (v === '')
21
36
  return false;
22
37
  if (v === ':memory:')
@@ -67,10 +82,14 @@ const toSafeDbBasename = (raw) => {
67
82
  return result === '' ? 'zintrust' : result;
68
83
  };
69
84
  const resolveSqliteDefaultBasename = () => {
70
- const service = typeof process.env['SERVICE_NAME'] === 'string' ? process.env['SERVICE_NAME'] : '';
85
+ const service = typeof Env.SERVICE_NAME === 'string' && Env.SERVICE_NAME.trim() !== ''
86
+ ? Env.SERVICE_NAME
87
+ : readEnvString('SERVICE_NAME', '');
71
88
  if (service.trim() !== '')
72
89
  return toSafeDbBasename(service);
73
- const app = typeof process.env['APP_NAME'] === 'string' ? process.env['APP_NAME'] : '';
90
+ const app = typeof Env.APP_NAME === 'string' && Env.APP_NAME.trim() !== ''
91
+ ? Env.APP_NAME
92
+ : readEnvString('APP_NAME', '');
74
93
  if (app.trim() !== '')
75
94
  return toSafeDbBasename(app);
76
95
  return 'zintrust';
@@ -5,11 +5,20 @@
5
5
  * Sealed namespace pattern - all exports through Env namespace
6
6
  * Safe for both Node.js and serverless runtimes (Cloudflare Workers, Deno, Lambda)
7
7
  */
8
+ import type { ProcessLike } from './type';
9
+ export declare const getProcessLike: () => ProcessLike | undefined;
10
+ export declare const dirnameFromExecPath: (execPath: string, platform?: string) => string;
11
+ export declare const get: (key: string, defaultValue?: string) => string;
12
+ export declare const getInt: (key: string, defaultValue?: number) => number;
13
+ export declare const getFloat: (key: string, defaultValue?: number) => number;
14
+ export declare const getBool: (key: string, defaultValue?: boolean) => boolean;
15
+ export declare const getDefaultLogLevel: () => "debug" | "info" | "warn" | "error";
8
16
  export declare const Env: Readonly<{
9
17
  get: (key: string, defaultValue?: string) => string;
10
18
  getInt: (key: string, defaultValue?: number) => number;
11
19
  getBool: (key: string, defaultValue?: boolean) => boolean;
12
- NODE_ENV: string;
20
+ getFloat: (key: string, defaultValue?: number) => number;
21
+ NODE_ENV: NodeJS.ProcessEnv["NODE_ENV"];
13
22
  PORT: number;
14
23
  HOST: string;
15
24
  BASE_URL: string;
@@ -50,8 +59,17 @@ export declare const Env: Readonly<{
50
59
  REDIS_HOST: string;
51
60
  REDIS_PORT: number;
52
61
  REDIS_PASSWORD: string;
62
+ REDIS_URL: string;
53
63
  MONGO_URI: string;
54
64
  MONGO_DB: string;
65
+ QUEUE_CONNECTION: string;
66
+ QUEUE_DRIVER: string;
67
+ RATE_LIMIT_STORE: string;
68
+ RATE_LIMIT_DRIVER: string;
69
+ RATE_LIMIT_KEY_PREFIX: string;
70
+ NOTIFICATION_DRIVER: string;
71
+ TERMII_API_KEY: string;
72
+ TERMII_SENDER: string;
55
73
  AWS_REGION: string;
56
74
  AWS_LAMBDA_FUNCTION_NAME: string;
57
75
  AWS_LAMBDA_FUNCTION_VERSION: string;
@@ -71,15 +89,39 @@ export declare const Env: Readonly<{
71
89
  ENCRYPTION_CIPHER: string;
72
90
  ENVIRONMENT: string;
73
91
  REQUEST_TIMEOUT: number;
92
+ APP_TIMEZONE: string;
74
93
  MAX_BODY_SIZE: number;
75
94
  SHUTDOWN_TIMEOUT: number;
76
95
  LOG_LEVEL: "debug" | "info" | "warn" | "error";
77
96
  LOG_FORMAT: string;
97
+ LOG_CHANNEL: string;
78
98
  DISABLE_LOGGING: boolean;
79
99
  LOG_HTTP_REQUEST: boolean;
80
100
  LOG_TO_FILE: boolean;
81
101
  LOG_ROTATION_SIZE: number;
82
102
  LOG_ROTATION_DAYS: number;
103
+ ZINTRUST_PROJECT_ROOT: string;
104
+ ZINTRUST_ALLOW_POSTINSTALL: string;
105
+ ZINTRUST_ENV_FILE: string;
106
+ ZINTRUST_SECRETS_MANIFEST: string;
107
+ ZINTRUST_ENV_IN_FILE: string;
108
+ ZINTRUST_SECRETS_PROVIDER: string;
109
+ ZINTRUST_ALLOW_AUTO_INSTALL: string;
110
+ CLOUDFLARE_ACCOUNT_ID: string;
111
+ CLOUDFLARE_API_TOKEN: string;
112
+ CLOUDFLARE_KV_NAMESPACE_ID: string;
113
+ AWS_DEFAULT_REGION: string;
114
+ AWS_ACCESS_KEY_ID: string;
115
+ AWS_SECRET_ACCESS_KEY: string;
116
+ AWS_SESSION_TOKEN: string;
117
+ CI: string;
118
+ HOME: string;
119
+ USERPROFILE: string;
120
+ TEMPLATE_COPYRIGHT: string;
121
+ SERVICE_NAME: string;
122
+ APP_MODE: string;
123
+ APP_PORT: number;
124
+ RUNTIME: string;
83
125
  NODE_BIN_DIR: string;
84
126
  SAFE_PATH: string;
85
127
  }>;
@@ -1 +1 @@
1
- {"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../../src/config/env.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AA+CH,eAAO,MAAM,GAAG;eA/BE,MAAM,iBAAiB,MAAM,KAAG,MAAM;kBAMnC,MAAM,iBAAiB,MAAM,KAAG,MAAM;mBASrC,MAAM,iBAAiB,OAAO,KAAG,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eAoHP,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO;;;;;;;;;EAkCxF,CAAC"}
1
+ {"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../../src/config/env.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAMhD,eAAO,MAAM,cAAc,QAAO,WAAW,GAAG,SAAwB,CAAC;AAEzE,eAAO,MAAM,mBAAmB,GAAI,UAAU,MAAM,EAAE,WAAW,MAAM,KAAG,MAKzE,CAAC;AAGF,eAAO,MAAM,GAAG,GAAI,KAAK,MAAM,EAAE,eAAe,MAAM,KAAG,MAGxD,CAAC;AAEF,eAAO,MAAM,MAAM,GAAI,KAAK,MAAM,EAAE,eAAe,MAAM,KAAG,MAM3D,CAAC;AAEF,eAAO,MAAM,QAAQ,GAAI,KAAK,MAAM,EAAE,eAAe,MAAM,KAAG,MAM7D,CAAC;AAEF,eAAO,MAAM,OAAO,GAAI,KAAK,MAAM,EAAE,eAAe,OAAO,KAAG,OAK7D,CAAC;AAEF,eAAO,MAAM,kBAAkB,QAAO,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAKjE,CAAC;AAGF,eAAO,MAAM,GAAG;eApCS,MAAM,iBAAiB,MAAM,KAAG,MAAM;kBAKnC,MAAM,iBAAiB,MAAM,KAAG,MAAM;mBAgBrC,MAAM,iBAAiB,OAAO,KAAG,OAAO;oBARvC,MAAM,iBAAiB,MAAM,KAAG,MAAM;cA+BtB,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eA6GpB,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmExF,CAAC"}
package/src/config/env.js CHANGED
@@ -5,10 +5,10 @@
5
5
  * Sealed namespace pattern - all exports through Env namespace
6
6
  * Safe for both Node.js and serverless runtimes (Cloudflare Workers, Deno, Lambda)
7
7
  */
8
- const getProcessLike = () => {
9
- return typeof process === 'undefined' ? undefined : process;
10
- };
11
- const dirnameFromExecPath = (execPath, platform) => {
8
+ // Cache process check once at module load time
9
+ const processLike = typeof process === 'undefined' ? undefined : process;
10
+ export const getProcessLike = () => processLike;
11
+ export const dirnameFromExecPath = (execPath, platform) => {
12
12
  const separator = platform === 'win32' ? '\\' : '/';
13
13
  const lastSep = execPath.lastIndexOf(separator);
14
14
  if (lastSep <= 0)
@@ -16,14 +16,12 @@ const dirnameFromExecPath = (execPath, platform) => {
16
16
  return execPath.slice(0, lastSep);
17
17
  };
18
18
  // Private helper functions
19
- const get = (key, defaultValue) => {
20
- const proc = getProcessLike();
21
- const env = proc?.env ?? {};
19
+ export const get = (key, defaultValue) => {
20
+ const env = processLike?.env ?? {};
22
21
  return env[key] ?? defaultValue ?? '';
23
22
  };
24
- const getInt = (key, defaultValue) => {
25
- const proc = getProcessLike();
26
- const env = proc?.env ?? {};
23
+ export const getInt = (key, defaultValue) => {
24
+ const env = processLike?.env ?? {};
27
25
  const value = env[key];
28
26
  if (value === undefined || value === null)
29
27
  return defaultValue ?? 0;
@@ -31,15 +29,23 @@ const getInt = (key, defaultValue) => {
31
29
  return defaultValue ?? 0;
32
30
  return Number.parseInt(value, 10);
33
31
  };
34
- const getBool = (key, defaultValue) => {
35
- const proc = getProcessLike();
36
- const env = proc?.env ?? {};
32
+ export const getFloat = (key, defaultValue) => {
33
+ const env = processLike?.env ?? {};
34
+ const value = env[key];
35
+ if (value === undefined || value === null)
36
+ return defaultValue ?? 0;
37
+ if (typeof value === 'string' && value.trim() === '')
38
+ return defaultValue ?? 0;
39
+ return Number.parseFloat(value);
40
+ };
41
+ export const getBool = (key, defaultValue) => {
42
+ const env = processLike?.env ?? {};
37
43
  const value = env[key];
38
44
  if (value === undefined || value === null)
39
45
  return defaultValue ?? false;
40
46
  return value.toLowerCase() === 'true' || value === '1';
41
47
  };
42
- const getDefaultLogLevel = () => {
48
+ export const getDefaultLogLevel = () => {
43
49
  const NODE_ENV_VALUE = get('NODE_ENV', 'development');
44
50
  if (NODE_ENV_VALUE === 'production')
45
51
  return 'info';
@@ -53,6 +59,7 @@ export const Env = Object.freeze({
53
59
  get,
54
60
  getInt,
55
61
  getBool,
62
+ getFloat,
56
63
  // Core
57
64
  NODE_ENV: get('NODE_ENV', 'development'),
58
65
  // Prefer PORT, fallback to APP_PORT for compatibility
@@ -105,8 +112,20 @@ export const Env = Object.freeze({
105
112
  REDIS_HOST: get('REDIS_HOST', 'localhost'),
106
113
  REDIS_PORT: getInt('REDIS_PORT', 6379),
107
114
  REDIS_PASSWORD: get('REDIS_PASSWORD', ''),
115
+ REDIS_URL: get('REDIS_URL', ''),
108
116
  MONGO_URI: get('MONGO_URI'),
109
117
  MONGO_DB: get('MONGO_DB', 'zintrust_cache'),
118
+ // Queue
119
+ QUEUE_CONNECTION: get('QUEUE_CONNECTION', ''),
120
+ QUEUE_DRIVER: get('QUEUE_DRIVER', ''),
121
+ // Rate Limiting
122
+ RATE_LIMIT_STORE: get('RATE_LIMIT_STORE', ''),
123
+ RATE_LIMIT_DRIVER: get('RATE_LIMIT_DRIVER', ''),
124
+ RATE_LIMIT_KEY_PREFIX: get('RATE_LIMIT_KEY_PREFIX', 'zintrust:ratelimit:'),
125
+ // Notifications
126
+ NOTIFICATION_DRIVER: get('NOTIFICATION_DRIVER', ''),
127
+ TERMII_API_KEY: get('TERMII_API_KEY', ''),
128
+ TERMII_SENDER: get('TERMII_SENDER', 'ZinTrust'),
110
129
  // AWS
111
130
  AWS_REGION: get('AWS_REGION', 'us-east-1'),
112
131
  AWS_LAMBDA_FUNCTION_NAME: get('AWS_LAMBDA_FUNCTION_NAME'),
@@ -131,23 +150,52 @@ export const Env = Object.freeze({
131
150
  // Deployment
132
151
  ENVIRONMENT: get('ENVIRONMENT', 'development'),
133
152
  REQUEST_TIMEOUT: getInt('REQUEST_TIMEOUT', 30000),
153
+ APP_TIMEZONE: get('APP_TIMEZONE', 'UTC'),
134
154
  MAX_BODY_SIZE: getInt('MAX_BODY_SIZE', 10485760),
135
155
  SHUTDOWN_TIMEOUT: getInt('SHUTDOWN_TIMEOUT', 10000),
136
156
  // Logging
137
157
  LOG_LEVEL: get('LOG_LEVEL', getDefaultLogLevel()),
138
158
  LOG_FORMAT: get('LOG_FORMAT', 'text'),
159
+ LOG_CHANNEL: get('LOG_CHANNEL', ''),
139
160
  DISABLE_LOGGING: getBool('DISABLE_LOGGING', false),
140
161
  LOG_HTTP_REQUEST: getBool('LOG_HTTP_REQUEST', false),
141
162
  LOG_TO_FILE: getBool('LOG_TO_FILE', false),
142
163
  LOG_ROTATION_SIZE: getInt('LOG_ROTATION_SIZE', 10485760),
143
164
  LOG_ROTATION_DAYS: getInt('LOG_ROTATION_DAYS', 7),
165
+ // zintrust-specific
166
+ ZINTRUST_PROJECT_ROOT: get('ZINTRUST_PROJECT_ROOT', ''),
167
+ ZINTRUST_ALLOW_POSTINSTALL: get('ZINTRUST_ALLOW_POSTINSTALL', ''),
168
+ ZINTRUST_ENV_FILE: get('ZINTRUST_ENV_FILE', '.env.pull'),
169
+ ZINTRUST_SECRETS_MANIFEST: get('ZINTRUST_SECRETS_MANIFEST', 'secrets.manifest.json'),
170
+ ZINTRUST_ENV_IN_FILE: get('ZINTRUST_ENV_IN_FILE', '.env'),
171
+ ZINTRUST_SECRETS_PROVIDER: get('ZINTRUST_SECRETS_PROVIDER', ''),
172
+ ZINTRUST_ALLOW_AUTO_INSTALL: get('ZINTRUST_ALLOW_AUTO_INSTALL', ''),
173
+ // Cloudflare Credentials
174
+ CLOUDFLARE_ACCOUNT_ID: get('CLOUDFLARE_ACCOUNT_ID', ''),
175
+ CLOUDFLARE_API_TOKEN: get('CLOUDFLARE_API_TOKEN', ''),
176
+ CLOUDFLARE_KV_NAMESPACE_ID: get('CLOUDFLARE_KV_NAMESPACE_ID', ''),
177
+ // AWS Credentials (additional)
178
+ AWS_DEFAULT_REGION: get('AWS_DEFAULT_REGION', ''),
179
+ AWS_ACCESS_KEY_ID: get('AWS_ACCESS_KEY_ID', ''),
180
+ AWS_SECRET_ACCESS_KEY: get('AWS_SECRET_ACCESS_KEY', ''),
181
+ AWS_SESSION_TOKEN: get('AWS_SESSION_TOKEN', ''),
182
+ // CI/CD
183
+ CI: get('CI', ''),
184
+ // System paths
185
+ HOME: get('HOME', ''),
186
+ USERPROFILE: get('USERPROFILE', ''),
187
+ // Template/Misc
188
+ TEMPLATE_COPYRIGHT: get('TEMPLATE_COPYRIGHT', '© 2025 ZinTrust Framework. All rights reserved.'),
189
+ SERVICE_NAME: get('SERVICE_NAME', ''),
190
+ APP_MODE: get('APP_MODE', ''),
191
+ APP_PORT: getInt('APP_PORT', 3000),
192
+ RUNTIME: get('RUNTIME', ''),
144
193
  // Paths (safely constructed for Node.js environments)
145
194
  NODE_BIN_DIR: (() => {
146
195
  try {
147
- const proc = getProcessLike();
148
- if (proc?.execPath === null || proc?.execPath === undefined)
196
+ if (processLike?.execPath === null || processLike?.execPath === undefined)
149
197
  return '';
150
- return dirnameFromExecPath(proc.execPath, proc.platform);
198
+ return dirnameFromExecPath(processLike.execPath, processLike.platform);
151
199
  }
152
200
  catch {
153
201
  // Fallback for non-Node environments
@@ -156,11 +204,10 @@ export const Env = Object.freeze({
156
204
  })(),
157
205
  SAFE_PATH: (() => {
158
206
  try {
159
- const proc = getProcessLike();
160
- if (proc?.execPath === null || proc?.execPath === undefined)
207
+ if (processLike?.execPath === null || processLike?.execPath === undefined)
161
208
  return '';
162
- const binDir = dirnameFromExecPath(proc.execPath, proc.platform);
163
- if (proc.platform === 'win32') {
209
+ const binDir = dirnameFromExecPath(processLike.execPath, processLike.platform);
210
+ if (processLike.platform === 'win32') {
164
211
  return [String.raw `C:\Windows\System32`, String.raw `C:\Windows`, binDir].join(';');
165
212
  }
166
213
  return ['/usr/bin', '/bin', '/usr/sbin', '/sbin', binDir].join(':');
@@ -12,6 +12,7 @@ export { notificationConfig, type NotificationConfig } from './notification';
12
12
  export { queueConfig, type QueueConfig } from './queue';
13
13
  export { securityConfig } from './security';
14
14
  export { storageConfig, type StorageConfig } from './storage';
15
+ export { createRedisConnection } from './workers';
15
16
  /**
16
17
  * Combined configuration object
17
18
  * Sealed namespace for immutability
@@ -28,8 +29,9 @@ export declare const config: Readonly<{
28
29
  readonly debug: boolean;
29
30
  readonly timezone: string;
30
31
  readonly requestTimeout: number;
31
- readonly maxBodySize: string;
32
+ readonly maxBodySize: number;
32
33
  readonly getSafeEnv: () => NodeJS.ProcessEnv;
34
+ readonly detectRuntime: () => string;
33
35
  }>;
34
36
  readonly broadcast: {
35
37
  default: string;
@@ -225,6 +227,13 @@ export declare const config: Readonly<{
225
227
  backoff: number;
226
228
  workers: number;
227
229
  };
230
+ monitor: {
231
+ enabled: boolean;
232
+ basePath: string;
233
+ middleware: ReadonlyArray<string>;
234
+ autoRefresh: boolean;
235
+ refreshIntervalMs: number;
236
+ };
228
237
  };
229
238
  }>;
230
239
  export type Config = typeof config;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/config/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAaH,OAAO,EAAE,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,KAAK,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAE,KAAK,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACtF,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,KAAK,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AACnF,OAAO,EAAE,WAAW,EAAE,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEpE;;;GAGG;AACH,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;8BAXgB,CAAA;;;;;;;;;;;;;;;;;;;;2EAAA,CAAC;;;;;;;;;;;;;;;;;;;;8BAD2B,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAoBxD,CAAC;;;;;;;;;;;;;;;;;;;EAGE,CAAC;AAEZ,MAAM,MAAM,MAAM,GAAG,OAAO,MAAM,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/config/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAaH,OAAO,EAAE,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,KAAK,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAE,KAAK,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACtF,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,KAAK,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AACnF,OAAO,EAAE,WAAW,EAAE,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAExD;;;GAGG;AACH,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;8BAZc,CAAC;;;;;;;;;;;;;;;;;;;;2EAAC,CAAA;;;;;;;;;;;;;;;;;;;;8BAD2B,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAmBrD,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;EAKA,CAAC;AAEZ,MAAM,MAAM,MAAM,GAAG,OAAO,MAAM,CAAC"}
@@ -22,6 +22,7 @@ export { notificationConfig } from './notification.js';
22
22
  export { queueConfig } from './queue.js';
23
23
  export { securityConfig } from './security.js';
24
24
  export { storageConfig } from './storage.js';
25
+ export { createRedisConnection } from './workers.js';
25
26
  /**
26
27
  * Combined configuration object
27
28
  * Sealed namespace for immutability
@@ -1 +1 @@
1
- {"version":3,"file":"mail.d.ts","sourceRoot":"","sources":["../../../src/config/mail.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAGtE,MAAM,MAAM,mBAAmB,GAAG,OAAO,CAAC;IACxC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IACxC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;CAC3C,CAAC,CAAC;AAmCH,QAAA,MAAM,gBAAgB,QAAO;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IACxC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IAC1C,SAAS,EAAE,CAAC,IAAI,EAAE,eAAe,EAAE,IAAI,CAAC,EAAE,MAAM,KAAK,gBAAgB,CAAC;CAgGvE,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAqB7D,eAAO,MAAM,UAAU,EAAE,UAYvB,CAAC"}
1
+ {"version":3,"file":"mail.d.ts","sourceRoot":"","sources":["../../../src/config/mail.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAItE,MAAM,MAAM,mBAAmB,GAAG,OAAO,CAAC;IACxC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IACxC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;CAC3C,CAAC,CAAC;AAmCH,QAAA,MAAM,gBAAgB,QAAO;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IACxC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IAC1C,SAAS,EAAE,CAAC,IAAI,EAAE,eAAe,EAAE,IAAI,CAAC,EAAE,MAAM,KAAK,gBAAgB,CAAC;CAgGvE,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAqB7D,eAAO,MAAM,UAAU,EAAE,UAYvB,CAAC"}
@@ -3,9 +3,9 @@
3
3
  * Runtime mail drivers and settings
4
4
  * Sealed namespace for immutability
5
5
  */
6
- import { StartupConfigFile, StartupConfigFileRegistry } from '../runtime/StartupConfigFileRegistry.js';
7
6
  import { Env } from './env.js';
8
7
  import { ErrorFactory } from '../exceptions/ZintrustError.js';
8
+ import { StartupConfigFile, StartupConfigFileRegistry } from '../runtime/StartupConfigFileRegistry.js';
9
9
  const isMailDriverConfig = (value) => {
10
10
  if (typeof value !== 'object' || value === null)
11
11
  return false;
@@ -107,14 +107,14 @@ const createMailConfig = () => {
107
107
  */
108
108
  from: {
109
109
  ...baseFrom,
110
- ...(overrides.from ?? {}),
110
+ ...overrides.from,
111
111
  },
112
112
  /**
113
113
  * Driver configs
114
114
  */
115
115
  drivers: {
116
116
  ...baseDrivers,
117
- ...(overrides.drivers ?? {}),
117
+ ...overrides.drivers,
118
118
  },
119
119
  /**
120
120
  * Get selected driver config