@zintrust/core 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/bin/zintrust.d.ts.map +1 -1
- package/bin/zintrust.js +18 -1
- package/package.json +1 -1
- package/src/boot/Application.d.ts.map +1 -1
- package/src/boot/Application.js +46 -3
- package/src/boot/Server.d.ts.map +1 -1
- package/src/boot/Server.js +3 -4
- package/src/boot/bootstrap.js +77 -6
- package/src/builder/BundleOptimizer.d.ts.map +1 -1
- package/src/builder/BundleOptimizer.js +6 -4
- package/src/cache/drivers/KVDriver.d.ts.map +1 -1
- package/src/cache/drivers/KVDriver.js +6 -6
- package/src/cache/drivers/RedisDriver.js +1 -1
- package/src/cli/BaseCommand.d.ts +2 -2
- package/src/cli/BaseCommand.d.ts.map +1 -1
- package/src/cli/BaseCommand.js +2 -1
- package/src/cli/CLI.d.ts.map +1 -1
- package/src/cli/CLI.js +11 -4
- package/src/cli/commands/AddCommand.js +1 -1
- package/src/cli/commands/ConfigCommand.d.ts.map +1 -1
- package/src/cli/commands/ConfigCommand.js +34 -4
- package/src/cli/commands/D1MigrateCommand.d.ts +4 -0
- package/src/cli/commands/D1MigrateCommand.d.ts.map +1 -1
- package/src/cli/commands/D1MigrateCommand.js +4 -3
- package/src/cli/commands/FixCommand.d.ts.map +1 -1
- package/src/cli/commands/FixCommand.js +3 -16
- package/src/cli/commands/LogsCleanupCommand.d.ts +6 -0
- package/src/cli/commands/LogsCleanupCommand.d.ts.map +1 -0
- package/src/cli/commands/LogsCleanupCommand.js +20 -0
- package/src/cli/commands/LogsCommand.d.ts.map +1 -1
- package/src/cli/commands/LogsCommand.js +1 -1
- package/src/cli/commands/MakeMailTemplateCommand.d.ts +10 -0
- package/src/cli/commands/MakeMailTemplateCommand.d.ts.map +1 -0
- package/src/cli/commands/MakeMailTemplateCommand.js +74 -0
- package/src/cli/commands/MakeNotificationTemplateCommand.d.ts +10 -0
- package/src/cli/commands/MakeNotificationTemplateCommand.d.ts.map +1 -0
- package/src/cli/commands/MakeNotificationTemplateCommand.js +113 -0
- package/src/cli/commands/NewCommand.d.ts +4 -0
- package/src/cli/commands/NewCommand.d.ts.map +1 -1
- package/src/cli/commands/NewCommand.js +33 -20
- package/src/cli/commands/PluginCommand.d.ts.map +1 -1
- package/src/cli/commands/PluginCommand.js +8 -4
- package/src/cli/commands/PrepareCommand.d.ts.map +1 -1
- package/src/cli/commands/PrepareCommand.js +1 -1
- package/src/cli/commands/QACommand.d.ts.map +1 -1
- package/src/cli/commands/QACommand.js +11 -20
- package/src/cli/commands/SecretsCommand.d.ts +16 -0
- package/src/cli/commands/SecretsCommand.d.ts.map +1 -0
- package/src/cli/commands/SecretsCommand.js +91 -0
- package/src/cli/commands/StartCommand.d.ts.map +1 -1
- package/src/cli/commands/StartCommand.js +2 -2
- package/src/cli/commands/TemplatesCommand.d.ts +3 -0
- package/src/cli/commands/TemplatesCommand.d.ts.map +1 -0
- package/src/cli/commands/TemplatesCommand.js +65 -0
- package/src/cli/commands/index.d.ts +5 -0
- package/src/cli/commands/index.d.ts.map +1 -1
- package/src/cli/commands/index.js +5 -0
- package/src/cli/config/ConfigManager.js +1 -1
- package/src/cli/index.d.ts +2 -1
- package/src/cli/index.d.ts.map +1 -1
- package/src/cli/index.js +2 -1
- package/src/cli/scaffolding/ControllerGenerator.js +1 -1
- package/src/cli/scaffolding/FeatureScaffolder.js +4 -4
- package/src/cli/scaffolding/FileGenerator.js +1 -1
- package/src/cli/scaffolding/ModelGenerator.js +1 -1
- package/src/cli/scaffolding/ProjectScaffolder.d.ts.map +1 -1
- package/src/cli/scaffolding/ProjectScaffolder.js +61 -11
- package/src/cli/scaffolding/ResponseFactoryGenerator.d.ts.map +1 -1
- package/src/cli/scaffolding/ResponseFactoryGenerator.js +3 -2
- package/src/cli/scaffolding/RouteGenerator.js +1 -1
- package/src/cli/scaffolding/ServiceIntegrationTestGenerator.js +1 -1
- package/src/cli/scaffolding/ServiceScaffolder.js +2 -2
- package/src/cli/scaffolding/TemplateGenerator.d.ts +40 -0
- package/src/cli/scaffolding/TemplateGenerator.d.ts.map +1 -0
- package/src/cli/scaffolding/TemplateGenerator.js +172 -0
- package/src/cli/scaffolding/index.d.ts +1 -0
- package/src/cli/scaffolding/index.d.ts.map +1 -1
- package/src/cli/scaffolding/index.js +1 -0
- package/src/cli/utils/spawn.js +1 -1
- package/src/common/AwsSigV4.d.ts +41 -0
- package/src/common/AwsSigV4.d.ts.map +1 -0
- package/src/common/AwsSigV4.js +69 -0
- package/src/common/index.d.ts +39 -0
- package/src/common/index.d.ts.map +1 -1
- package/src/common/index.js +101 -8
- package/src/common/uuid.d.ts +3 -0
- package/src/common/uuid.d.ts.map +1 -0
- package/src/common/uuid.js +30 -0
- package/src/config/FileLogWriter.d.ts +22 -0
- package/src/config/FileLogWriter.d.ts.map +1 -0
- package/src/config/FileLogWriter.js +192 -0
- package/src/config/SecretsManager.d.ts.map +1 -1
- package/src/config/SecretsManager.js +37 -11
- package/src/config/StartupConfigValidator.d.ts +15 -0
- package/src/config/StartupConfigValidator.d.ts.map +1 -0
- package/src/config/StartupConfigValidator.js +86 -0
- package/src/config/app.d.ts +2 -1
- package/src/config/app.d.ts.map +1 -1
- package/src/config/app.js +65 -15
- package/src/config/broadcast.d.ts +47 -0
- package/src/config/broadcast.d.ts.map +1 -0
- package/src/config/broadcast.js +54 -0
- package/src/config/cache.d.ts +13 -17
- package/src/config/cache.d.ts.map +1 -1
- package/src/config/cache.js +9 -11
- package/src/config/cloudflare.d.ts +26 -0
- package/src/config/cloudflare.d.ts.map +1 -0
- package/src/config/cloudflare.js +38 -0
- package/src/config/env.d.ts +6 -0
- package/src/config/env.d.ts.map +1 -1
- package/src/config/env.js +6 -0
- package/src/config/index.d.ts +52 -28
- package/src/config/index.d.ts.map +1 -1
- package/src/config/index.js +3 -0
- package/src/config/logger.d.ts +2 -0
- package/src/config/logger.d.ts.map +1 -1
- package/src/config/logger.js +270 -11
- package/src/config/logging/HttpLogger.d.ts +23 -0
- package/src/config/logging/HttpLogger.d.ts.map +1 -0
- package/src/config/logging/HttpLogger.js +93 -0
- package/src/config/logging/KvLogger.d.ts +22 -0
- package/src/config/logging/KvLogger.d.ts.map +1 -0
- package/src/config/logging/KvLogger.js +143 -0
- package/src/config/logging/SlackLogger.d.ts +23 -0
- package/src/config/logging/SlackLogger.d.ts.map +1 -0
- package/src/config/logging/SlackLogger.js +119 -0
- package/src/config/mail.d.ts +81 -0
- package/src/config/mail.d.ts.map +1 -0
- package/src/config/mail.js +73 -0
- package/src/config/middleware.d.ts +8 -0
- package/src/config/middleware.d.ts.map +1 -0
- package/src/config/middleware.js +18 -0
- package/src/config/notification.d.ts +62 -0
- package/src/config/notification.d.ts.map +1 -0
- package/src/config/notification.js +43 -0
- package/src/config/security.d.ts.map +1 -1
- package/src/config/security.js +2 -2
- package/src/config/startup.d.ts +23 -0
- package/src/config/startup.d.ts.map +1 -0
- package/src/config/startup.js +15 -0
- package/src/config/storage.d.ts +21 -35
- package/src/config/storage.d.ts.map +1 -1
- package/src/config/storage.js +57 -37
- package/src/database/migrations/index.d.ts +1 -1
- package/src/database/migrations/index.d.ts.map +1 -1
- package/src/database/migrations/index.js +2 -1
- package/src/features/Queue.js +1 -25
- package/src/health/RuntimeHealthProbes.d.ts +13 -0
- package/src/health/RuntimeHealthProbes.d.ts.map +1 -0
- package/src/health/RuntimeHealthProbes.js +62 -0
- package/src/health/StartupHealthChecks.d.ts +26 -0
- package/src/health/StartupHealthChecks.d.ts.map +1 -0
- package/src/health/StartupHealthChecks.js +124 -0
- package/src/http/ErrorResponse.d.ts +28 -0
- package/src/http/ErrorResponse.d.ts.map +1 -0
- package/src/http/ErrorResponse.js +42 -0
- package/src/http/Kernel.d.ts +5 -0
- package/src/http/Kernel.d.ts.map +1 -1
- package/src/http/Kernel.js +96 -30
- package/src/http/RequestContext.d.ts +20 -0
- package/src/http/RequestContext.d.ts.map +1 -0
- package/src/http/RequestContext.js +77 -0
- package/src/index.d.ts +9 -1
- package/src/index.d.ts.map +1 -1
- package/src/index.js +8 -2
- package/src/microservices/MicroserviceManager.d.ts.map +1 -1
- package/src/microservices/MicroserviceManager.js +9 -6
- package/src/microservices/PostgresAdapter.d.ts.map +1 -1
- package/src/microservices/PostgresAdapter.js +3 -1
- package/src/microservices/ServiceBundler.d.ts.map +1 -1
- package/src/microservices/ServiceBundler.js +6 -4
- package/src/microservices/ServiceHealthMonitor.js +2 -2
- package/src/middleware/CsrfMiddleware.d.ts.map +1 -1
- package/src/middleware/CsrfMiddleware.js +2 -19
- package/src/middleware/ErrorHandlerMiddleware.d.ts +6 -0
- package/src/middleware/ErrorHandlerMiddleware.d.ts.map +1 -0
- package/src/middleware/ErrorHandlerMiddleware.js +33 -0
- package/src/middleware/LoggingMiddleware.d.ts +9 -0
- package/src/middleware/LoggingMiddleware.d.ts.map +1 -0
- package/src/middleware/LoggingMiddleware.js +36 -0
- package/src/middleware/index.d.ts +2 -0
- package/src/middleware/index.d.ts.map +1 -1
- package/src/middleware/index.js +2 -0
- package/src/node-singletons/async_hooks.d.ts +9 -0
- package/src/node-singletons/async_hooks.d.ts.map +1 -0
- package/src/node-singletons/async_hooks.js +8 -0
- package/src/node-singletons/fs.d.ts +2 -2
- package/src/node-singletons/fs.d.ts.map +1 -1
- package/src/node-singletons/fs.js +2 -2
- package/src/node-singletons/http.d.ts +1 -1
- package/src/node-singletons/http.d.ts.map +1 -1
- package/src/node-singletons/http.js +1 -1
- package/src/node-singletons/index.d.ts +4 -0
- package/src/node-singletons/index.d.ts.map +1 -1
- package/src/node-singletons/index.js +4 -0
- package/src/node-singletons/net.d.ts +9 -0
- package/src/node-singletons/net.d.ts.map +1 -0
- package/src/node-singletons/net.js +8 -0
- package/src/node-singletons/os.d.ts +3 -3
- package/src/node-singletons/os.d.ts.map +1 -1
- package/src/node-singletons/os.js +3 -4
- package/src/node-singletons/path.d.ts +3 -1
- package/src/node-singletons/path.d.ts.map +1 -1
- package/src/node-singletons/path.js +3 -1
- package/src/node-singletons/perf-hooks.d.ts +3 -1
- package/src/node-singletons/perf-hooks.d.ts.map +1 -1
- package/src/node-singletons/perf-hooks.js +3 -1
- package/src/node-singletons/process.d.ts +23 -0
- package/src/node-singletons/process.d.ts.map +1 -0
- package/src/node-singletons/process.js +8 -0
- package/src/node-singletons/readline.d.ts +3 -3
- package/src/node-singletons/readline.d.ts.map +1 -1
- package/src/node-singletons/readline.js +3 -4
- package/src/node-singletons/tls.d.ts +9 -0
- package/src/node-singletons/tls.d.ts.map +1 -0
- package/src/node-singletons/tls.js +8 -0
- package/src/node-singletons/url.d.ts +3 -1
- package/src/node-singletons/url.d.ts.map +1 -1
- package/src/node-singletons/url.js +3 -1
- package/src/orm/ConnectionManager.d.ts +6 -1
- package/src/orm/ConnectionManager.d.ts.map +1 -1
- package/src/orm/ConnectionManager.js +14 -0
- package/src/orm/DatabaseAdapter.d.ts +6 -0
- package/src/orm/DatabaseAdapter.d.ts.map +1 -1
- package/src/orm/QueryBuilder.d.ts +8 -1
- package/src/orm/QueryBuilder.d.ts.map +1 -1
- package/src/orm/QueryBuilder.js +188 -28
- package/src/orm/adapters/D1Adapter.d.ts.map +1 -1
- package/src/orm/adapters/D1Adapter.js +18 -12
- package/src/orm/adapters/MySQLAdapter.d.ts.map +1 -1
- package/src/orm/adapters/MySQLAdapter.js +4 -0
- package/src/orm/adapters/PostgreSQLAdapter.d.ts.map +1 -1
- package/src/orm/adapters/PostgreSQLAdapter.js +4 -0
- package/src/orm/adapters/SQLServerAdapter.d.ts.map +1 -1
- package/src/orm/adapters/SQLServerAdapter.js +4 -0
- package/src/orm/adapters/SQLiteAdapter.d.ts.map +1 -1
- package/src/orm/adapters/SQLiteAdapter.js +4 -0
- package/src/performance/CodeGenerationBenchmark.js +3 -3
- package/src/performance/Optimizer.d.ts +1 -1
- package/src/performance/Optimizer.d.ts.map +1 -1
- package/src/performance/Optimizer.js +150 -75
- package/src/performance/establish-baseline.js +3 -3
- package/src/runtime/PluginManager.d.ts +3 -1
- package/src/runtime/PluginManager.d.ts.map +1 -1
- package/src/runtime/PluginManager.js +124 -28
- package/src/runtime/RuntimeDetector.d.ts.map +1 -1
- package/src/runtime/RuntimeDetector.js +47 -6
- package/src/runtime/adapters/CloudflareAdapter.js +2 -2
- package/src/runtime/adapters/FargateAdapter.d.ts.map +1 -1
- package/src/runtime/adapters/FargateAdapter.js +2 -1
- package/src/runtime/adapters/LambdaAdapter.d.ts.map +1 -1
- package/src/runtime/adapters/LambdaAdapter.js +4 -2
- package/src/runtime/adapters/NodeServerAdapter.d.ts.map +1 -1
- package/src/runtime/adapters/NodeServerAdapter.js +2 -1
- package/src/scheduler/ScheduleRunner.d.ts +18 -0
- package/src/scheduler/ScheduleRunner.d.ts.map +1 -0
- package/src/scheduler/ScheduleRunner.js +155 -0
- package/src/scheduler/index.d.ts +3 -0
- package/src/scheduler/index.d.ts.map +1 -0
- package/src/scheduler/index.js +1 -0
- package/src/scheduler/types.d.ts +16 -0
- package/src/scheduler/types.d.ts.map +1 -0
- package/src/scheduler/types.js +4 -0
- package/src/schedules/index.d.ts +2 -0
- package/src/schedules/index.d.ts.map +1 -0
- package/src/schedules/index.js +1 -0
- package/src/schedules/log-cleanup.d.ts +4 -0
- package/src/schedules/log-cleanup.d.ts.map +1 -0
- package/src/schedules/log-cleanup.js +18 -0
- package/src/scripts/GenerateEnvArtifacts.d.ts +13 -0
- package/src/scripts/GenerateEnvArtifacts.d.ts.map +1 -0
- package/src/scripts/GenerateEnvArtifacts.js +171 -0
- package/src/scripts/TemplateSync.js +109 -70
- package/src/security/CsrfTokenManager.js +1 -1
- package/src/security/Encryptor.js +1 -1
- package/src/security/Hash.d.ts +14 -0
- package/src/security/Hash.d.ts.map +1 -0
- package/src/security/Hash.js +81 -0
- package/src/security/StartupSecretValidation.d.ts +20 -0
- package/src/security/StartupSecretValidation.d.ts.map +1 -0
- package/src/security/StartupSecretValidation.js +61 -0
- package/src/security/UrlValidator.d.ts +0 -1
- package/src/security/UrlValidator.d.ts.map +1 -1
- package/src/security/UrlValidator.js +1 -2
- package/src/security/Xss.d.ts +14 -0
- package/src/security/Xss.d.ts.map +1 -0
- package/src/security/Xss.js +57 -0
- package/src/security/XssProtection.d.ts.map +1 -1
- package/src/security/XssProtection.js +150 -16
- package/src/templates/adapters/MySQLAdapter.ts.tpl +5 -0
- package/src/templates/adapters/PostgreSQLAdapter.ts.tpl +5 -0
- package/src/templates/adapters/SQLServerAdapter.ts.tpl +5 -0
- package/src/templates/adapters/SQLiteAdapter.ts.tpl +5 -0
- package/src/templates/features/Queue.ts.tpl +1 -29
- package/src/templates/project/basic/.env.example.tpl +48 -0
- package/src/templates/project/basic/.env.tpl +89 -94
- package/src/templates/project/basic/app/Toolkit/Broadcast/sendBroadcast.ts.tpl +7 -0
- package/src/templates/project/basic/app/Toolkit/Mail/sendWelcomeEmail.ts.tpl +30 -0
- package/src/templates/project/basic/app/Toolkit/Notification/sendSlackNotification.ts.tpl +10 -0
- package/src/templates/project/basic/app/Toolkit/Notification/sendSms.ts.tpl +13 -0
- package/src/templates/project/basic/config/FileLogWriter.ts.tpl +240 -0
- package/src/templates/project/basic/config/SecretsManager.ts.tpl +44 -21
- package/src/templates/project/basic/config/StartupConfigValidator.ts.tpl +151 -0
- package/src/templates/project/basic/config/app.ts.tpl +84 -15
- package/src/templates/project/basic/config/broadcast.ts.tpl +97 -0
- package/src/templates/project/basic/config/cache.ts.tpl +19 -23
- package/src/templates/project/basic/config/cloudflare.ts.tpl +57 -0
- package/src/templates/project/basic/config/env.ts.tpl +7 -1
- package/src/templates/project/basic/config/index.ts.tpl +3 -0
- package/src/templates/project/basic/config/logger.ts.tpl +301 -11
- package/src/templates/project/basic/config/logging/HttpLogger.ts.tpl +121 -0
- package/src/templates/project/basic/config/logging/KvLogger.ts.tpl +181 -0
- package/src/templates/project/basic/config/logging/SlackLogger.ts.tpl +156 -0
- package/src/templates/project/basic/config/mail.ts.tpl +141 -0
- package/src/templates/project/basic/config/middleware.ts.tpl +27 -0
- package/src/templates/project/basic/config/notification.ts.tpl +86 -0
- package/src/templates/project/basic/config/security.ts.tpl +4 -5
- package/src/templates/project/basic/config/startup.ts.tpl +27 -0
- package/src/templates/project/basic/config/storage.ts.tpl +77 -42
- package/src/templates/project/basic/database/migrations/index.ts.tpl +1 -1
- package/src/templates/project/basic/package.json.tpl +1 -1
- package/src/templates/project/basic/routes/api.ts.tpl +9 -37
- package/src/templates/project/basic/routes/broadcast.ts.tpl +32 -0
- package/src/templates/project/basic/routes/health.ts.tpl +134 -0
- package/src/templates/project/basic/src/index.ts.tpl +38 -11
- package/src/templates/project/basic/template.json +3 -0
- package/src/toolkit/Secrets/EnvFile.d.ts +15 -0
- package/src/toolkit/Secrets/EnvFile.d.ts.map +1 -0
- package/src/toolkit/Secrets/EnvFile.js +63 -0
- package/src/toolkit/Secrets/Manifest.d.ts +24 -0
- package/src/toolkit/Secrets/Manifest.d.ts.map +1 -0
- package/src/toolkit/Secrets/Manifest.js +71 -0
- package/src/toolkit/Secrets/index.d.ts +42 -0
- package/src/toolkit/Secrets/index.d.ts.map +1 -0
- package/src/toolkit/Secrets/index.js +119 -0
- package/src/toolkit/Secrets/providers/AwsSecretsManager.d.ts +14 -0
- package/src/toolkit/Secrets/providers/AwsSecretsManager.d.ts.map +1 -0
- package/src/toolkit/Secrets/providers/AwsSecretsManager.js +131 -0
- package/src/toolkit/Secrets/providers/CloudflareKv.d.ts +9 -0
- package/src/toolkit/Secrets/providers/CloudflareKv.d.ts.map +1 -0
- package/src/toolkit/Secrets/providers/CloudflareKv.js +73 -0
- package/src/tools/broadcast/Broadcast.d.ts +7 -0
- package/src/tools/broadcast/Broadcast.d.ts.map +1 -0
- package/src/tools/broadcast/Broadcast.js +37 -0
- package/src/tools/broadcast/drivers/BaseDriver.d.ts +5 -0
- package/src/tools/broadcast/drivers/BaseDriver.d.ts.map +1 -0
- package/src/tools/broadcast/drivers/BaseDriver.js +8 -0
- package/src/tools/broadcast/drivers/InMemory.d.ts +18 -0
- package/src/tools/broadcast/drivers/InMemory.d.ts.map +1 -0
- package/src/tools/broadcast/drivers/InMemory.js +16 -0
- package/src/tools/broadcast/drivers/Pusher.d.ts +8 -0
- package/src/tools/broadcast/drivers/Pusher.d.ts.map +1 -0
- package/src/tools/broadcast/drivers/Pusher.js +75 -0
- package/src/tools/broadcast/drivers/Redis.d.ts +19 -0
- package/src/tools/broadcast/drivers/Redis.d.ts.map +1 -0
- package/src/tools/broadcast/drivers/Redis.js +73 -0
- package/src/tools/broadcast/drivers/RedisHttps.d.ts +14 -0
- package/src/tools/broadcast/drivers/RedisHttps.d.ts.map +1 -0
- package/src/tools/broadcast/drivers/RedisHttps.js +50 -0
- package/src/tools/broadcast/index.d.ts +7 -0
- package/src/tools/broadcast/index.d.ts.map +1 -0
- package/src/tools/broadcast/index.js +6 -0
- package/src/tools/http/Http.d.ts +51 -0
- package/src/tools/http/Http.d.ts.map +1 -0
- package/src/tools/http/Http.js +171 -0
- package/src/tools/http/HttpResponse.d.ts +32 -0
- package/src/tools/http/HttpResponse.d.ts.map +1 -0
- package/src/tools/http/HttpResponse.js +80 -0
- package/src/tools/http/index.d.ts +15 -0
- package/src/tools/http/index.d.ts.map +1 -0
- package/src/tools/http/index.js +9 -0
- package/src/tools/mail/Mail.d.ts +22 -0
- package/src/tools/mail/Mail.d.ts.map +1 -0
- package/src/tools/mail/Mail.js +105 -0
- package/src/tools/mail/attachments.d.ts +23 -0
- package/src/tools/mail/attachments.d.ts.map +1 -0
- package/src/tools/mail/attachments.js +26 -0
- package/src/tools/mail/drivers/BaseDriver.d.ts +5 -0
- package/src/tools/mail/drivers/BaseDriver.d.ts.map +1 -0
- package/src/tools/mail/drivers/BaseDriver.js +8 -0
- package/src/tools/mail/drivers/Mailgun.d.ts +31 -0
- package/src/tools/mail/drivers/Mailgun.d.ts.map +1 -0
- package/src/tools/mail/drivers/Mailgun.js +81 -0
- package/src/tools/mail/drivers/SendGrid.d.ts +29 -0
- package/src/tools/mail/drivers/SendGrid.d.ts.map +1 -0
- package/src/tools/mail/drivers/SendGrid.js +57 -0
- package/src/tools/mail/drivers/Ses.d.ts +24 -0
- package/src/tools/mail/drivers/Ses.d.ts.map +1 -0
- package/src/tools/mail/drivers/Ses.js +116 -0
- package/src/tools/mail/drivers/Smtp.d.ts +38 -0
- package/src/tools/mail/drivers/Smtp.d.ts.map +1 -0
- package/src/tools/mail/drivers/Smtp.js +327 -0
- package/src/tools/mail/templates/index.d.ts +27 -0
- package/src/tools/mail/templates/index.d.ts.map +1 -0
- package/src/tools/mail/templates/index.js +35 -0
- package/src/tools/mail/templates/markdown/index.d.ts +17 -0
- package/src/tools/mail/templates/markdown/index.d.ts.map +1 -0
- package/src/tools/mail/templates/markdown/index.js +49 -0
- package/src/tools/mail/templates/markdown/registry.d.ts +15 -0
- package/src/tools/mail/templates/markdown/registry.d.ts.map +1 -0
- package/src/tools/mail/templates/markdown/registry.js +34 -0
- package/src/tools/mail/templates/markdown/validator.d.ts +16 -0
- package/src/tools/mail/templates/markdown/validator.d.ts.map +1 -0
- package/src/tools/mail/templates/markdown/validator.js +24 -0
- package/src/tools/mail/testing.d.ts +41 -0
- package/src/tools/mail/testing.d.ts.map +1 -0
- package/src/tools/mail/testing.js +34 -0
- package/src/tools/notification/Driver.d.ts +11 -0
- package/src/tools/notification/Driver.d.ts.map +1 -0
- package/src/tools/notification/Driver.js +1 -0
- package/src/tools/notification/Notification.d.ts +11 -0
- package/src/tools/notification/Notification.d.ts.map +1 -0
- package/src/tools/notification/Notification.js +11 -0
- package/src/tools/notification/Registry.d.ts +10 -0
- package/src/tools/notification/Registry.d.ts.map +1 -0
- package/src/tools/notification/Registry.js +22 -0
- package/src/tools/notification/Service.d.ts +6 -0
- package/src/tools/notification/Service.d.ts.map +1 -0
- package/src/tools/notification/Service.js +18 -0
- package/src/tools/notification/config.d.ts +5 -0
- package/src/tools/notification/config.d.ts.map +1 -0
- package/src/tools/notification/config.js +5 -0
- package/src/tools/notification/drivers/BaseDriver.d.ts +5 -0
- package/src/tools/notification/drivers/BaseDriver.d.ts.map +1 -0
- package/src/tools/notification/drivers/BaseDriver.js +8 -0
- package/src/tools/notification/drivers/Console.d.ts +7 -0
- package/src/tools/notification/drivers/Console.d.ts.map +1 -0
- package/src/tools/notification/drivers/Console.js +13 -0
- package/src/tools/notification/drivers/Slack.d.ts +16 -0
- package/src/tools/notification/drivers/Slack.d.ts.map +1 -0
- package/src/tools/notification/drivers/Slack.js +24 -0
- package/src/tools/notification/drivers/Termii.d.ts +10 -0
- package/src/tools/notification/drivers/Termii.d.ts.map +1 -0
- package/src/tools/notification/drivers/Termii.js +47 -0
- package/src/tools/notification/drivers/Twilio.d.ts +21 -0
- package/src/tools/notification/drivers/Twilio.d.ts.map +1 -0
- package/src/tools/notification/drivers/Twilio.js +48 -0
- package/src/tools/notification/templates/markdown/index.d.ts +15 -0
- package/src/tools/notification/templates/markdown/index.d.ts.map +1 -0
- package/src/tools/notification/templates/markdown/index.js +38 -0
- package/src/tools/notification/templates/markdown/registry.d.ts +15 -0
- package/src/tools/notification/templates/markdown/registry.d.ts.map +1 -0
- package/src/tools/notification/templates/markdown/registry.js +36 -0
- package/src/tools/notification/testing.d.ts +19 -0
- package/src/tools/notification/testing.d.ts.map +1 -0
- package/src/tools/notification/testing.js +35 -0
- package/src/tools/notification/testingHelpers.d.ts +12 -0
- package/src/tools/notification/testingHelpers.d.ts.map +1 -0
- package/src/tools/notification/testingHelpers.js +32 -0
- package/src/tools/queue/Queue.d.ts +23 -0
- package/src/tools/queue/Queue.d.ts.map +1 -0
- package/src/tools/queue/Queue.js +38 -0
- package/src/tools/queue/drivers/InMemory.d.ts +10 -0
- package/src/tools/queue/drivers/InMemory.d.ts.map +1 -0
- package/src/tools/queue/drivers/InMemory.js +55 -0
- package/src/tools/queue/drivers/Redis.d.ts +10 -0
- package/src/tools/queue/drivers/Redis.d.ts.map +1 -0
- package/src/tools/queue/drivers/Redis.js +91 -0
- package/src/tools/storage/drivers/Gcs.d.ts +20 -0
- package/src/tools/storage/drivers/Gcs.d.ts.map +1 -0
- package/src/tools/storage/drivers/Gcs.js +152 -0
- package/src/tools/storage/drivers/Local.d.ts +17 -0
- package/src/tools/storage/drivers/Local.d.ts.map +1 -0
- package/src/tools/storage/drivers/Local.js +63 -0
- package/src/tools/storage/drivers/R2.d.ts +20 -0
- package/src/tools/storage/drivers/R2.d.ts.map +1 -0
- package/src/tools/storage/drivers/R2.js +73 -0
- package/src/tools/storage/drivers/S3.d.ts +26 -0
- package/src/tools/storage/drivers/S3.d.ts.map +1 -0
- package/src/tools/storage/drivers/S3.js +258 -0
- package/src/tools/storage/index.d.ts +24 -0
- package/src/tools/storage/index.d.ts.map +1 -0
- package/src/tools/storage/index.js +112 -0
- package/src/tools/storage/testing.d.ts +23 -0
- package/src/tools/storage/testing.d.ts.map +1 -0
- package/src/tools/storage/testing.js +52 -0
- package/src/tools/templates/MarkdownRenderer.d.ts +14 -0
- package/src/tools/templates/MarkdownRenderer.d.ts.map +1 -0
- package/src/tools/templates/MarkdownRenderer.js +300 -0
- package/src/tools/templates/index.d.ts +5 -0
- package/src/tools/templates/index.d.ts.map +1 -0
- package/src/tools/templates/index.js +4 -0
|
@@ -6,6 +6,47 @@
|
|
|
6
6
|
|
|
7
7
|
import { Env } from '@config/env';
|
|
8
8
|
|
|
9
|
+
type ProcessLike = { env?: Record<string, string | undefined> };
|
|
10
|
+
|
|
11
|
+
type Environment = 'development' | 'dev' | 'production' | 'prod' | 'pro' | 'testing' | 'test';
|
|
12
|
+
type StartMode = 'development' | 'production' | 'testing';
|
|
13
|
+
|
|
14
|
+
const getProcessLike = (): ProcessLike | undefined => {
|
|
15
|
+
return typeof process === 'undefined' ? undefined : (process as unknown as ProcessLike);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const readEnvString = (key: string, defaultValue: string = ''): string => {
|
|
19
|
+
const anyEnv = Env as unknown as { get?: unknown };
|
|
20
|
+
if (typeof anyEnv.get === 'function') {
|
|
21
|
+
return (anyEnv.get as (k: string, d?: string) => string)(key, defaultValue);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const proc = getProcessLike();
|
|
25
|
+
const raw = proc?.env?.[key];
|
|
26
|
+
return raw ?? defaultValue;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const readEnvInt = (key: string, defaultValue: number): number => {
|
|
30
|
+
const anyEnv = Env as unknown as { getInt?: unknown };
|
|
31
|
+
if (typeof anyEnv.getInt === 'function') {
|
|
32
|
+
return (anyEnv.getInt as (k: string, d?: number) => number)(key, defaultValue);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const raw = readEnvString(key, String(defaultValue));
|
|
36
|
+
const parsed = Number.parseInt(raw, 10);
|
|
37
|
+
return Number.isNaN(parsed) ? defaultValue : parsed;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const readEnvBool = (key: string, defaultValue: boolean): boolean => {
|
|
41
|
+
const anyEnv = Env as unknown as { getBool?: unknown };
|
|
42
|
+
if (typeof anyEnv.getBool === 'function') {
|
|
43
|
+
return (anyEnv.getBool as (k: string, d?: boolean) => boolean)(key, defaultValue);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const raw = readEnvString(key, defaultValue ? 'true' : 'false');
|
|
47
|
+
return raw.toLowerCase() === 'true' || raw === '1';
|
|
48
|
+
};
|
|
49
|
+
|
|
9
50
|
const getSafeEnv = (): NodeJS.ProcessEnv => {
|
|
10
51
|
const baseEnv: Partial<NodeJS.ProcessEnv> = typeof process === 'undefined' ? {} : process.env;
|
|
11
52
|
|
|
@@ -13,39 +54,64 @@ const getSafeEnv = (): NodeJS.ProcessEnv => {
|
|
|
13
54
|
...(baseEnv as NodeJS.ProcessEnv),
|
|
14
55
|
|
|
15
56
|
// Ensure required keys exist (env.d.ts augments ProcessEnv with required fields)
|
|
16
|
-
NODE_ENV:
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
57
|
+
NODE_ENV:
|
|
58
|
+
baseEnv.NODE_ENV ??
|
|
59
|
+
(readEnvString('NODE_ENV', 'development') as NodeJS.ProcessEnv['NODE_ENV']),
|
|
60
|
+
USE_RAW_QRY: baseEnv.USE_RAW_QRY ?? (readEnvString('USE_RAW_QRY', '') || undefined),
|
|
61
|
+
SERVICE_API_KEY: baseEnv.SERVICE_API_KEY ?? readEnvString('SERVICE_API_KEY', ''),
|
|
62
|
+
SERVICE_JWT_SECRET: baseEnv.SERVICE_JWT_SECRET ?? readEnvString('SERVICE_JWT_SECRET', ''),
|
|
63
|
+
BASE_URL: baseEnv['BASE_URL'] ?? readEnvString('BASE_URL', ''),
|
|
64
|
+
MODE: baseEnv['MODE'] ?? readEnvString('MODE', ''),
|
|
22
65
|
|
|
23
66
|
// Hardening for child-process usage
|
|
24
|
-
PATH:
|
|
67
|
+
PATH:
|
|
68
|
+
typeof (Env as unknown as { SAFE_PATH?: unknown }).SAFE_PATH === 'string'
|
|
69
|
+
? (Env as unknown as { SAFE_PATH: string }).SAFE_PATH
|
|
70
|
+
: (baseEnv['PATH'] ?? ''),
|
|
25
71
|
npm_config_scripts_prepend_node_path: 'true',
|
|
26
72
|
};
|
|
27
73
|
};
|
|
28
74
|
|
|
75
|
+
const normalizeMode = (): StartMode => {
|
|
76
|
+
const value = (
|
|
77
|
+
typeof (Env as unknown as { NODE_ENV?: unknown }).NODE_ENV === 'string'
|
|
78
|
+
? (Env as unknown as { NODE_ENV: string }).NODE_ENV
|
|
79
|
+
: readEnvString('NODE_ENV', 'development')
|
|
80
|
+
) as Environment;
|
|
81
|
+
if (value === 'production' || value === 'pro' || value === 'prod') return 'production';
|
|
82
|
+
if (value === 'testing' || value === 'test') return 'testing';
|
|
83
|
+
return 'development';
|
|
84
|
+
};
|
|
85
|
+
|
|
29
86
|
const appConfigObj = {
|
|
30
87
|
/**
|
|
31
88
|
* Application name
|
|
32
89
|
*/
|
|
33
|
-
name:
|
|
90
|
+
name:
|
|
91
|
+
typeof (Env as unknown as { APP_NAME?: unknown }).APP_NAME === 'string'
|
|
92
|
+
? (Env as unknown as { APP_NAME: string }).APP_NAME
|
|
93
|
+
: readEnvString('APP_NAME', 'ZinTrust'),
|
|
34
94
|
|
|
35
95
|
/**
|
|
36
96
|
* Application environment
|
|
37
97
|
*/
|
|
38
|
-
environment:
|
|
98
|
+
environment: normalizeMode(),
|
|
39
99
|
|
|
40
100
|
/**
|
|
41
101
|
* Application port
|
|
42
102
|
*/
|
|
43
|
-
port:
|
|
103
|
+
port:
|
|
104
|
+
typeof (Env as unknown as { PORT?: unknown }).PORT === 'number'
|
|
105
|
+
? (Env as unknown as { PORT: number }).PORT
|
|
106
|
+
: readEnvInt('APP_PORT', 3000),
|
|
44
107
|
|
|
45
108
|
/**
|
|
46
109
|
* Application host
|
|
47
110
|
*/
|
|
48
|
-
host:
|
|
111
|
+
host:
|
|
112
|
+
typeof (Env as unknown as { HOST?: unknown }).HOST === 'string'
|
|
113
|
+
? (Env as unknown as { HOST: string }).HOST
|
|
114
|
+
: readEnvString('HOST', 'localhost'),
|
|
49
115
|
|
|
50
116
|
/**
|
|
51
117
|
* Is development environment
|
|
@@ -71,22 +137,25 @@ const appConfigObj = {
|
|
|
71
137
|
/**
|
|
72
138
|
* Application debug mode
|
|
73
139
|
*/
|
|
74
|
-
debug:
|
|
140
|
+
debug:
|
|
141
|
+
typeof (Env as unknown as { DEBUG?: unknown }).DEBUG === 'boolean'
|
|
142
|
+
? (Env as unknown as { DEBUG: boolean }).DEBUG
|
|
143
|
+
: readEnvBool('DEBUG', false),
|
|
75
144
|
|
|
76
145
|
/**
|
|
77
146
|
* Application timezone
|
|
78
147
|
*/
|
|
79
|
-
timezone:
|
|
148
|
+
timezone: readEnvString('APP_TIMEZONE', 'UTC'),
|
|
80
149
|
|
|
81
150
|
/**
|
|
82
151
|
* Request timeout (milliseconds)
|
|
83
152
|
*/
|
|
84
|
-
requestTimeout:
|
|
153
|
+
requestTimeout: readEnvInt('REQUEST_TIMEOUT', 30000),
|
|
85
154
|
|
|
86
155
|
/**
|
|
87
156
|
* Max request body size
|
|
88
157
|
*/
|
|
89
|
-
maxBodySize:
|
|
158
|
+
maxBodySize: readEnvString('MAX_BODY_SIZE', '10mb'),
|
|
90
159
|
|
|
91
160
|
getSafeEnv,
|
|
92
161
|
} as const;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Broadcast Configuration
|
|
3
|
+
*
|
|
4
|
+
* Centralizes broadcast driver selection and provider env mappings.
|
|
5
|
+
* Driver selection must be dynamic (tests may mutate process.env).
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { Env } from '@config/env';
|
|
9
|
+
|
|
10
|
+
export type KnownBroadcastDriverName = 'inmemory' | 'pusher' | 'redis' | 'redishttps';
|
|
11
|
+
|
|
12
|
+
export type InMemoryBroadcastDriverConfig = {
|
|
13
|
+
driver: 'inmemory';
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type PusherBroadcastDriverConfig = {
|
|
17
|
+
driver: 'pusher';
|
|
18
|
+
appId: string;
|
|
19
|
+
key: string;
|
|
20
|
+
secret: string;
|
|
21
|
+
cluster: string;
|
|
22
|
+
useTLS: boolean;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export type RedisBroadcastDriverConfig = {
|
|
26
|
+
driver: 'redis';
|
|
27
|
+
host: string;
|
|
28
|
+
port: number;
|
|
29
|
+
password: string;
|
|
30
|
+
channelPrefix: string;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export type RedisHttpsBroadcastDriverConfig = {
|
|
34
|
+
driver: 'redishttps';
|
|
35
|
+
endpoint: string;
|
|
36
|
+
token: string;
|
|
37
|
+
channelPrefix: string;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export type KnownBroadcastDriverConfig =
|
|
41
|
+
| InMemoryBroadcastDriverConfig
|
|
42
|
+
| PusherBroadcastDriverConfig
|
|
43
|
+
| RedisBroadcastDriverConfig
|
|
44
|
+
| RedisHttpsBroadcastDriverConfig;
|
|
45
|
+
|
|
46
|
+
const normalizeDriverName = (value: string): string => value.trim().toLowerCase();
|
|
47
|
+
|
|
48
|
+
const getPusherConfig = (): PusherBroadcastDriverConfig => ({
|
|
49
|
+
driver: 'pusher',
|
|
50
|
+
appId: Env.get('PUSHER_APP_ID', ''),
|
|
51
|
+
key: Env.get('PUSHER_APP_KEY', ''),
|
|
52
|
+
secret: Env.get('PUSHER_APP_SECRET', ''),
|
|
53
|
+
cluster: Env.get('PUSHER_APP_CLUSTER', ''),
|
|
54
|
+
useTLS: Env.getBool('PUSHER_USE_TLS', true),
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
const getRedisConfig = (): RedisBroadcastDriverConfig => ({
|
|
58
|
+
driver: 'redis',
|
|
59
|
+
host: Env.get('BROADCAST_REDIS_HOST', Env.get('REDIS_HOST', 'localhost')),
|
|
60
|
+
port: Env.getInt('BROADCAST_REDIS_PORT', Env.getInt('REDIS_PORT', 6379)),
|
|
61
|
+
password: Env.get('BROADCAST_REDIS_PASSWORD', Env.get('REDIS_PASSWORD', '')),
|
|
62
|
+
channelPrefix: Env.get('BROADCAST_CHANNEL_PREFIX', 'broadcast:'),
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
const getRedisHttpsConfig = (): RedisHttpsBroadcastDriverConfig => ({
|
|
66
|
+
driver: 'redishttps',
|
|
67
|
+
endpoint: Env.get('REDIS_HTTPS_ENDPOINT', ''),
|
|
68
|
+
token: Env.get('REDIS_HTTPS_TOKEN', ''),
|
|
69
|
+
channelPrefix: Env.get('BROADCAST_CHANNEL_PREFIX', 'broadcast:'),
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
const broadcastConfigObj = {
|
|
73
|
+
/**
|
|
74
|
+
* Normalized broadcast driver name.
|
|
75
|
+
*
|
|
76
|
+
* NOTE: Allows custom driver names (project-specific drivers), so returns string.
|
|
77
|
+
*/
|
|
78
|
+
getDriverName(): string {
|
|
79
|
+
return normalizeDriverName(Env.get('BROADCAST_DRIVER', 'inmemory'));
|
|
80
|
+
},
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Get a config object for the currently selected driver.
|
|
84
|
+
* Defaults to inmemory for unknown/unsupported names.
|
|
85
|
+
*/
|
|
86
|
+
getDriverConfig(): KnownBroadcastDriverConfig {
|
|
87
|
+
const driver = this.getDriverName();
|
|
88
|
+
|
|
89
|
+
if (driver === 'pusher') return getPusherConfig();
|
|
90
|
+
if (driver === 'redis') return getRedisConfig();
|
|
91
|
+
if (driver === 'redishttps') return getRedisHttpsConfig();
|
|
92
|
+
|
|
93
|
+
return { driver: 'inmemory' };
|
|
94
|
+
},
|
|
95
|
+
} as const;
|
|
96
|
+
|
|
97
|
+
export default Object.freeze(broadcastConfigObj);
|
|
@@ -15,34 +15,32 @@ type RedisCacheDriverConfig = {
|
|
|
15
15
|
driver: 'redis';
|
|
16
16
|
host: string;
|
|
17
17
|
port: number;
|
|
18
|
-
password: string | undefined;
|
|
19
|
-
database: number;
|
|
20
18
|
ttl: number;
|
|
21
19
|
};
|
|
22
20
|
|
|
23
|
-
type
|
|
24
|
-
driver: '
|
|
25
|
-
|
|
21
|
+
type MongoCacheDriverConfig = {
|
|
22
|
+
driver: 'mongodb';
|
|
23
|
+
uri: string;
|
|
24
|
+
db: string;
|
|
26
25
|
ttl: number;
|
|
27
26
|
};
|
|
28
27
|
|
|
29
|
-
type
|
|
30
|
-
driver: '
|
|
31
|
-
path: string;
|
|
28
|
+
type KvCacheDriverConfig = {
|
|
29
|
+
driver: 'kv';
|
|
32
30
|
ttl: number;
|
|
33
31
|
};
|
|
34
32
|
|
|
35
33
|
type CacheDriverConfig =
|
|
36
34
|
| MemoryCacheDriverConfig
|
|
37
35
|
| RedisCacheDriverConfig
|
|
38
|
-
|
|
|
39
|
-
|
|
|
36
|
+
| MongoCacheDriverConfig
|
|
37
|
+
| KvCacheDriverConfig;
|
|
40
38
|
|
|
41
39
|
type CacheDrivers = {
|
|
42
40
|
memory: MemoryCacheDriverConfig;
|
|
43
41
|
redis: RedisCacheDriverConfig;
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
mongodb: MongoCacheDriverConfig;
|
|
43
|
+
kv: KvCacheDriverConfig;
|
|
46
44
|
};
|
|
47
45
|
|
|
48
46
|
type CacheConfigInput = {
|
|
@@ -53,7 +51,7 @@ type CacheConfigInput = {
|
|
|
53
51
|
const getCacheDriver = (config: CacheConfigInput): CacheDriverConfig => {
|
|
54
52
|
const defaultDriver = config.default;
|
|
55
53
|
|
|
56
|
-
if (Object.
|
|
54
|
+
if (Object.hasOwn(config.drivers, defaultDriver)) {
|
|
57
55
|
const driverName = defaultDriver as keyof CacheDrivers;
|
|
58
56
|
return config.drivers[driverName];
|
|
59
57
|
}
|
|
@@ -79,19 +77,17 @@ const cacheConfigObj = {
|
|
|
79
77
|
driver: 'redis' as const,
|
|
80
78
|
host: Env.get('REDIS_HOST', 'localhost'),
|
|
81
79
|
port: Env.getInt('REDIS_PORT', 6379),
|
|
82
|
-
password: Env.get('REDIS_PASSWORD'),
|
|
83
|
-
database: Env.getInt('REDIS_DB', 0),
|
|
84
80
|
ttl: Env.getInt('CACHE_REDIS_TTL', 3600),
|
|
85
81
|
},
|
|
86
|
-
|
|
87
|
-
driver: '
|
|
88
|
-
|
|
89
|
-
|
|
82
|
+
mongodb: {
|
|
83
|
+
driver: 'mongodb' as const,
|
|
84
|
+
uri: Env.get('MONGO_URI'),
|
|
85
|
+
db: Env.get('MONGO_DB', 'zintrust_cache'),
|
|
86
|
+
ttl: Env.getInt('CACHE_MONGO_TTL', 3600),
|
|
90
87
|
},
|
|
91
|
-
|
|
92
|
-
driver: '
|
|
93
|
-
|
|
94
|
-
ttl: Env.getInt('CACHE_FILE_TTL', 3600),
|
|
88
|
+
kv: {
|
|
89
|
+
driver: 'kv' as const,
|
|
90
|
+
ttl: Env.getInt('CACHE_KV_TTL', 3600),
|
|
95
91
|
},
|
|
96
92
|
},
|
|
97
93
|
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cloudflare Workers Environment Access
|
|
3
|
+
*
|
|
4
|
+
* Centralizes access to Workers bindings via globalThis.env.
|
|
5
|
+
* This keeps runtime-specific globals out of adapters/drivers.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { DatabaseConfig, ID1Database } from '@orm/DatabaseAdapter';
|
|
9
|
+
|
|
10
|
+
export type WorkersEnv = Record<string, unknown>;
|
|
11
|
+
|
|
12
|
+
type KVNamespace = {
|
|
13
|
+
get(
|
|
14
|
+
key: string,
|
|
15
|
+
options?: { type: 'text' | 'json' | 'arrayBuffer' | 'stream' }
|
|
16
|
+
): Promise<unknown>;
|
|
17
|
+
put(
|
|
18
|
+
key: string,
|
|
19
|
+
value: string | ReadableStream | ArrayBuffer | FormData,
|
|
20
|
+
options?: { expiration?: number; expirationTtl?: number; metadata?: unknown }
|
|
21
|
+
): Promise<void>;
|
|
22
|
+
delete(key: string): Promise<void>;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const getWorkersEnv = (): WorkersEnv | null => {
|
|
26
|
+
const env = (globalThis as unknown as { env?: unknown }).env;
|
|
27
|
+
if (env === undefined || env === null) return null;
|
|
28
|
+
if (typeof env !== 'object') return null;
|
|
29
|
+
return env as WorkersEnv;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const getD1Binding = (config: DatabaseConfig): ID1Database | null => {
|
|
33
|
+
if (config.d1 !== undefined && config.d1 !== null) return config.d1;
|
|
34
|
+
|
|
35
|
+
const env = getWorkersEnv();
|
|
36
|
+
const envDb = env === null ? undefined : (env['DB'] as ID1Database | undefined);
|
|
37
|
+
if (envDb !== undefined) return envDb;
|
|
38
|
+
|
|
39
|
+
const globalDb = (globalThis as unknown as { DB?: ID1Database }).DB;
|
|
40
|
+
if (globalDb !== undefined) return globalDb;
|
|
41
|
+
|
|
42
|
+
return null;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const getKVBinding = (bindingName = 'CACHE'): KVNamespace | null => {
|
|
46
|
+
const env = getWorkersEnv();
|
|
47
|
+
if (env === null) return null;
|
|
48
|
+
|
|
49
|
+
const kv = env[bindingName] as KVNamespace | undefined;
|
|
50
|
+
return kv ?? null;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export const Cloudflare = Object.freeze({
|
|
54
|
+
getWorkersEnv,
|
|
55
|
+
getD1Binding,
|
|
56
|
+
getKVBinding,
|
|
57
|
+
});
|
|
@@ -71,7 +71,7 @@ export const Env = Object.freeze({
|
|
|
71
71
|
DB_CONNECTION: get('DB_CONNECTION', 'sqlite'),
|
|
72
72
|
DB_HOST: get('DB_HOST', 'localhost'),
|
|
73
73
|
DB_PORT: getInt('DB_PORT', 5432),
|
|
74
|
-
DB_DATABASE: get('DB_DATABASE', '
|
|
74
|
+
DB_DATABASE: get('DB_DATABASE', 'zintrust'),
|
|
75
75
|
DB_USERNAME: get('DB_USERNAME', 'postgres'),
|
|
76
76
|
DB_PASSWORD: get('DB_PASSWORD', ''),
|
|
77
77
|
DB_READ_HOSTS: get('DB_READ_HOSTS', ''),
|
|
@@ -114,10 +114,16 @@ export const Env = Object.freeze({
|
|
|
114
114
|
ENVIRONMENT: get('ENVIRONMENT', 'development'),
|
|
115
115
|
REQUEST_TIMEOUT: getInt('REQUEST_TIMEOUT', 30000),
|
|
116
116
|
MAX_BODY_SIZE: getInt('MAX_BODY_SIZE', 10485760),
|
|
117
|
+
SHUTDOWN_TIMEOUT: getInt('SHUTDOWN_TIMEOUT', 10000),
|
|
117
118
|
|
|
118
119
|
// Logging
|
|
119
120
|
LOG_LEVEL: get('LOG_LEVEL', getDefaultLogLevel()) as 'debug' | 'info' | 'warn' | 'error',
|
|
121
|
+
LOG_FORMAT: get('LOG_FORMAT', 'text'),
|
|
120
122
|
DISABLE_LOGGING: getBool('DISABLE_LOGGING', false),
|
|
123
|
+
LOG_HTTP_REQUEST: getBool('LOG_HTTP_REQUEST', false),
|
|
124
|
+
LOG_TO_FILE: getBool('LOG_TO_FILE', false),
|
|
125
|
+
LOG_ROTATION_SIZE: getInt('LOG_ROTATION_SIZE', 10485760),
|
|
126
|
+
LOG_ROTATION_DAYS: getInt('LOG_ROTATION_DAYS', 7),
|
|
121
127
|
|
|
122
128
|
// Paths (safely constructed for Node.js environments)
|
|
123
129
|
NODE_BIN_DIR: (() => {
|
|
@@ -7,6 +7,7 @@ import { appConfig } from '@config/app';
|
|
|
7
7
|
import { cacheConfig } from '@config/cache';
|
|
8
8
|
import { databaseConfig } from '@config/database';
|
|
9
9
|
import { microservicesConfig } from '@config/microservices';
|
|
10
|
+
import { middlewareConfig } from '@config/middleware';
|
|
10
11
|
import { queueConfig } from '@config/queue';
|
|
11
12
|
import { securityConfig } from '@config/security';
|
|
12
13
|
import { storageConfig } from '@config/storage';
|
|
@@ -15,6 +16,7 @@ export { appConfig, type AppConfig } from '@config/app';
|
|
|
15
16
|
export { cacheConfig, type CacheConfig } from '@config/cache';
|
|
16
17
|
export { databaseConfig, type DatabaseConfig } from '@config/database';
|
|
17
18
|
export { microservicesConfig, type MicroservicesConfig } from '@config/microservices';
|
|
19
|
+
export { middlewareConfig, type MiddlewareConfig } from '@config/middleware';
|
|
18
20
|
export { queueConfig, type QueueConfig } from '@config/queue';
|
|
19
21
|
export { securityConfig } from '@config/security';
|
|
20
22
|
export { storageConfig, type StorageConfig } from '@config/storage';
|
|
@@ -28,6 +30,7 @@ export const config = Object.freeze({
|
|
|
28
30
|
database: databaseConfig,
|
|
29
31
|
storage: storageConfig,
|
|
30
32
|
security: securityConfig,
|
|
33
|
+
middleware: middlewareConfig,
|
|
31
34
|
microservices: microservicesConfig,
|
|
32
35
|
cache: cacheConfig,
|
|
33
36
|
queue: queueConfig,
|