@zintrust/core 0.1.1 → 0.1.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.
- package/README.md +3 -3
- package/bin/zintrust.d.ts.map +1 -1
- package/bin/zintrust.js +18 -1
- package/package.json +15 -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 +155 -17
- 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 +11 -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/routes/storage.ts.tpl +42 -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 +49 -0
- package/src/tools/http/Http.d.ts.map +1 -0
- package/src/tools/http/Http.js +169 -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/LocalSignedUrl.d.ts +12 -0
- package/src/tools/storage/LocalSignedUrl.d.ts.map +1 -0
- package/src/tools/storage/LocalSignedUrl.js +108 -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 +18 -0
- package/src/tools/storage/drivers/Local.d.ts.map +1 -0
- package/src/tools/storage/drivers/Local.js +89 -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 +111 -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
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Slack Notification Logger
|
|
3
|
+
* Sends warn/error/fatal log events to a Slack incoming webhook.
|
|
4
|
+
*
|
|
5
|
+
* Enabled via env:
|
|
6
|
+
* - SLACK_LOG_ENABLED (default: false)
|
|
7
|
+
* - SLACK_LOG_WEBHOOK_URL
|
|
8
|
+
* - SLACK_LOG_LEVELS (comma-separated; default: "warn,error,fatal")
|
|
9
|
+
* - SLACK_LOG_BATCH_WINDOW_MS (default: 5000)
|
|
10
|
+
*/
|
|
11
|
+
import { Env } from '../env';
|
|
12
|
+
import { ErrorFactory } from '../../exceptions/ZintrustError';
|
|
13
|
+
import { HttpClient } from '../../tools/http/Http';
|
|
14
|
+
const isEnabled = () => Env.getBool('SLACK_LOG_ENABLED', false);
|
|
15
|
+
const getLevels = () => {
|
|
16
|
+
const raw = Env.get('SLACK_LOG_LEVELS', 'warn,error,fatal');
|
|
17
|
+
return new Set(raw
|
|
18
|
+
.split(',')
|
|
19
|
+
.map((s) => s.trim().toLowerCase())
|
|
20
|
+
.filter((s) => s.length > 0));
|
|
21
|
+
};
|
|
22
|
+
const levelToColor = (level) => {
|
|
23
|
+
if (level === 'fatal' || level === 'error')
|
|
24
|
+
return '#D50200';
|
|
25
|
+
if (level === 'warn')
|
|
26
|
+
return '#D39E00';
|
|
27
|
+
return '#439FE0';
|
|
28
|
+
};
|
|
29
|
+
const formatEventText = (ev) => {
|
|
30
|
+
const header = `*${ev.level.toUpperCase()}* ${ev.message}`;
|
|
31
|
+
const metaParts = [];
|
|
32
|
+
if (ev.category !== undefined)
|
|
33
|
+
metaParts.push(`category=${ev.category}`);
|
|
34
|
+
metaParts.push(`ts=${ev.timestamp}`);
|
|
35
|
+
const meta = metaParts.length > 0 ? `\n_${metaParts.join(' ')}_` : '';
|
|
36
|
+
const err = ev.error === undefined ? '' : `\n*error:* ${String(ev.error)}`;
|
|
37
|
+
const data = ev.data === undefined ? '' : `\n*data:* \`${JSON.stringify(ev.data)}\``;
|
|
38
|
+
return `${header}${meta}${err}${data}`;
|
|
39
|
+
};
|
|
40
|
+
let buffer = [];
|
|
41
|
+
let flushPromise;
|
|
42
|
+
let dedupeKeys = new Set();
|
|
43
|
+
const dedupeKeyFor = (ev) => {
|
|
44
|
+
const base = `${ev.level}:${ev.message}:${ev.error ?? ''}`;
|
|
45
|
+
return base.length > 500 ? base.slice(0, 500) : base;
|
|
46
|
+
};
|
|
47
|
+
const sendBatch = async (events) => {
|
|
48
|
+
const webhookUrl = Env.get('SLACK_LOG_WEBHOOK_URL').trim();
|
|
49
|
+
if (webhookUrl.length === 0) {
|
|
50
|
+
throw ErrorFactory.createConfigError('SLACK_LOG_WEBHOOK_URL is required when Slack logging is enabled');
|
|
51
|
+
}
|
|
52
|
+
const lines = events.map((e) => formatEventText(e)).join('\n\n');
|
|
53
|
+
const payload = {
|
|
54
|
+
attachments: [
|
|
55
|
+
{
|
|
56
|
+
color: levelToColor(events[0]?.level ?? 'warn'),
|
|
57
|
+
text: lines,
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
};
|
|
61
|
+
await HttpClient.post(webhookUrl, payload).send();
|
|
62
|
+
};
|
|
63
|
+
const flushNow = async () => {
|
|
64
|
+
const toSend = buffer;
|
|
65
|
+
buffer = [];
|
|
66
|
+
dedupeKeys = new Set();
|
|
67
|
+
if (!isEnabled())
|
|
68
|
+
return;
|
|
69
|
+
if (toSend.length === 0)
|
|
70
|
+
return;
|
|
71
|
+
try {
|
|
72
|
+
await sendBatch(toSend);
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
// Best-effort: never throw from logging.
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
const scheduleFlush = async () => {
|
|
79
|
+
if (flushPromise !== undefined)
|
|
80
|
+
return flushPromise;
|
|
81
|
+
const windowMs = Math.max(0, Env.getInt('SLACK_LOG_BATCH_WINDOW_MS', 5000));
|
|
82
|
+
const promise = new Promise((resolve) => {
|
|
83
|
+
const run = async () => {
|
|
84
|
+
try {
|
|
85
|
+
await flushNow();
|
|
86
|
+
}
|
|
87
|
+
finally {
|
|
88
|
+
resolve(undefined);
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
if (windowMs === 0 || typeof globalThis.setTimeout !== 'function') {
|
|
92
|
+
void run();
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
globalThis.setTimeout(() => {
|
|
96
|
+
void run();
|
|
97
|
+
}, windowMs);
|
|
98
|
+
});
|
|
99
|
+
flushPromise = promise.finally(() => {
|
|
100
|
+
flushPromise = undefined;
|
|
101
|
+
});
|
|
102
|
+
return flushPromise;
|
|
103
|
+
};
|
|
104
|
+
export const SlackLogger = Object.freeze({
|
|
105
|
+
async enqueue(event) {
|
|
106
|
+
if (!isEnabled())
|
|
107
|
+
return Promise.resolve();
|
|
108
|
+
const levels = getLevels();
|
|
109
|
+
if (!levels.has(event.level))
|
|
110
|
+
return Promise.resolve();
|
|
111
|
+
const key = dedupeKeyFor(event);
|
|
112
|
+
if (dedupeKeys.has(key))
|
|
113
|
+
return scheduleFlush();
|
|
114
|
+
dedupeKeys.add(key);
|
|
115
|
+
buffer.push(event);
|
|
116
|
+
return scheduleFlush();
|
|
117
|
+
},
|
|
118
|
+
});
|
|
119
|
+
export default SlackLogger;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mail Configuration
|
|
3
|
+
* Runtime mail drivers and settings
|
|
4
|
+
* Sealed namespace for immutability
|
|
5
|
+
*/
|
|
6
|
+
export type MailDriverName = 'disabled' | 'sendgrid' | 'smtp' | 'ses' | 'mailgun';
|
|
7
|
+
export type DisabledMailDriverConfig = {
|
|
8
|
+
driver: 'disabled';
|
|
9
|
+
};
|
|
10
|
+
export type SendGridMailDriverConfig = {
|
|
11
|
+
driver: 'sendgrid';
|
|
12
|
+
apiKey: string;
|
|
13
|
+
};
|
|
14
|
+
export type MailgunMailDriverConfig = {
|
|
15
|
+
driver: 'mailgun';
|
|
16
|
+
apiKey: string;
|
|
17
|
+
domain: string;
|
|
18
|
+
baseUrl: string;
|
|
19
|
+
};
|
|
20
|
+
export type SmtpMailDriverConfig = {
|
|
21
|
+
driver: 'smtp';
|
|
22
|
+
host: string;
|
|
23
|
+
port: number;
|
|
24
|
+
username: string;
|
|
25
|
+
password: string;
|
|
26
|
+
secure: boolean | 'starttls';
|
|
27
|
+
};
|
|
28
|
+
export type SesMailDriverConfig = {
|
|
29
|
+
driver: 'ses';
|
|
30
|
+
region: string;
|
|
31
|
+
};
|
|
32
|
+
export type MailDriverConfig = DisabledMailDriverConfig | SendGridMailDriverConfig | MailgunMailDriverConfig | SmtpMailDriverConfig | SesMailDriverConfig;
|
|
33
|
+
export declare const mailConfig: Readonly<{
|
|
34
|
+
/**
|
|
35
|
+
* Default mail driver
|
|
36
|
+
*/
|
|
37
|
+
readonly default: MailDriverName;
|
|
38
|
+
/**
|
|
39
|
+
* Default "From" identity
|
|
40
|
+
*/
|
|
41
|
+
readonly from: {
|
|
42
|
+
readonly address: string;
|
|
43
|
+
readonly name: string;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Driver configs
|
|
47
|
+
*/
|
|
48
|
+
readonly drivers: {
|
|
49
|
+
readonly disabled: {
|
|
50
|
+
readonly driver: "disabled";
|
|
51
|
+
};
|
|
52
|
+
readonly sendgrid: {
|
|
53
|
+
readonly driver: "sendgrid";
|
|
54
|
+
readonly apiKey: string;
|
|
55
|
+
};
|
|
56
|
+
readonly mailgun: {
|
|
57
|
+
readonly driver: "mailgun";
|
|
58
|
+
readonly apiKey: string;
|
|
59
|
+
readonly domain: string;
|
|
60
|
+
readonly baseUrl: string;
|
|
61
|
+
};
|
|
62
|
+
readonly smtp: {
|
|
63
|
+
readonly driver: "smtp";
|
|
64
|
+
readonly host: string;
|
|
65
|
+
readonly port: number;
|
|
66
|
+
readonly username: string;
|
|
67
|
+
readonly password: string;
|
|
68
|
+
readonly secure: boolean | "starttls";
|
|
69
|
+
};
|
|
70
|
+
readonly ses: {
|
|
71
|
+
readonly driver: "ses";
|
|
72
|
+
readonly region: string;
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Get selected driver config
|
|
77
|
+
*/
|
|
78
|
+
readonly getDriver: () => MailDriverConfig;
|
|
79
|
+
}>;
|
|
80
|
+
export type MailConfig = typeof mailConfig;
|
|
81
|
+
//# sourceMappingURL=mail.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mail.d.ts","sourceRoot":"","sources":["../../../src/config/mail.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,MAAM,MAAM,cAAc,GAAG,UAAU,GAAG,UAAU,GAAG,MAAM,GAAG,KAAK,GAAG,SAAS,CAAC;AAElF,MAAM,MAAM,wBAAwB,GAAG;IACrC,MAAM,EAAE,UAAU,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACrC,MAAM,EAAE,UAAU,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,MAAM,EAAE,SAAS,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAGF,MAAM,MAAM,oBAAoB,GAAG;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,OAAO,GAAG,UAAU,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,MAAM,EAAE,KAAK,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GACxB,wBAAwB,GACxB,wBAAwB,GACxB,uBAAuB,GACvB,oBAAoB,GACpB,mBAAmB,CAAC;AA6FxB,eAAO,MAAM,UAAU;IA9DrB;;OAEG;;IAGH;;OAEG;;;;;IAMH;;OAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAuCH;;OAEG;8BACU,gBAAgB;EAKuB,CAAC;AACvD,MAAM,MAAM,UAAU,GAAG,OAAO,UAAU,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mail Configuration
|
|
3
|
+
* Runtime mail drivers and settings
|
|
4
|
+
* Sealed namespace for immutability
|
|
5
|
+
*/
|
|
6
|
+
import { Env } from './env';
|
|
7
|
+
const getMailDriver = (config) => {
|
|
8
|
+
const defaultDriver = config.default;
|
|
9
|
+
if (Object.hasOwn(config.drivers, defaultDriver)) {
|
|
10
|
+
const driverName = defaultDriver;
|
|
11
|
+
return config.drivers[driverName];
|
|
12
|
+
}
|
|
13
|
+
return config.drivers.disabled;
|
|
14
|
+
};
|
|
15
|
+
const mailConfigObj = {
|
|
16
|
+
/**
|
|
17
|
+
* Default mail driver
|
|
18
|
+
*/
|
|
19
|
+
default: Env.get('MAIL_DRIVER', 'disabled') ?? 'disabled',
|
|
20
|
+
/**
|
|
21
|
+
* Default "From" identity
|
|
22
|
+
*/
|
|
23
|
+
from: {
|
|
24
|
+
address: Env.get('MAIL_FROM_ADDRESS', ''),
|
|
25
|
+
name: Env.get('MAIL_FROM_NAME', ''),
|
|
26
|
+
},
|
|
27
|
+
/**
|
|
28
|
+
* Driver configs
|
|
29
|
+
*/
|
|
30
|
+
drivers: {
|
|
31
|
+
disabled: {
|
|
32
|
+
driver: 'disabled',
|
|
33
|
+
},
|
|
34
|
+
sendgrid: {
|
|
35
|
+
driver: 'sendgrid',
|
|
36
|
+
apiKey: Env.get('SENDGRID_API_KEY', ''),
|
|
37
|
+
},
|
|
38
|
+
mailgun: {
|
|
39
|
+
driver: 'mailgun',
|
|
40
|
+
apiKey: Env.get('MAILGUN_API_KEY', ''),
|
|
41
|
+
domain: Env.get('MAILGUN_DOMAIN', ''),
|
|
42
|
+
baseUrl: Env.get('MAILGUN_BASE_URL', 'https://api.mailgun.net').trim(),
|
|
43
|
+
},
|
|
44
|
+
smtp: {
|
|
45
|
+
driver: 'smtp',
|
|
46
|
+
host: Env.get('MAIL_HOST', ''),
|
|
47
|
+
port: Env.getInt('MAIL_PORT', 587),
|
|
48
|
+
username: Env.get('MAIL_USERNAME', ''),
|
|
49
|
+
password: Env.get('MAIL_PASSWORD', ''),
|
|
50
|
+
secure: (() => {
|
|
51
|
+
const raw = Env.get('MAIL_SECURE', '').trim().toLowerCase();
|
|
52
|
+
if (raw === 'starttls')
|
|
53
|
+
return 'starttls';
|
|
54
|
+
if (raw === 'tls' || raw === 'ssl' || raw === 'smtps' || raw === 'implicit')
|
|
55
|
+
return true;
|
|
56
|
+
if (raw === 'none' || raw === 'off' || raw === 'false' || raw === '0')
|
|
57
|
+
return false;
|
|
58
|
+
return Env.getBool('MAIL_SECURE', false);
|
|
59
|
+
})(),
|
|
60
|
+
},
|
|
61
|
+
ses: {
|
|
62
|
+
driver: 'ses',
|
|
63
|
+
region: Env.get('AWS_REGION', 'us-east-1'),
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
/**
|
|
67
|
+
* Get selected driver config
|
|
68
|
+
*/
|
|
69
|
+
getDriver() {
|
|
70
|
+
return getMailDriver(this);
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
export const mailConfig = Object.freeze(mailConfigObj);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Middleware } from '../middleware/MiddlewareStack';
|
|
2
|
+
export type MiddlewareConfig = {
|
|
3
|
+
global: Middleware[];
|
|
4
|
+
route: Record<string, Middleware>;
|
|
5
|
+
};
|
|
6
|
+
export declare const middlewareConfig: Readonly<MiddlewareConfig>;
|
|
7
|
+
export default middlewareConfig;
|
|
8
|
+
//# sourceMappingURL=middleware.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../../src/config/middleware.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAI9D,MAAM,MAAM,gBAAgB,GAAG;IAC7B,MAAM,EAAE,UAAU,EAAE,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;CACnC,CAAC;AAeF,eAAO,MAAM,gBAAgB,4BAAqC,CAAC;AACnE,eAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { CsrfMiddleware } from '../middleware/CsrfMiddleware';
|
|
2
|
+
import { ErrorHandlerMiddleware } from '../middleware/ErrorHandlerMiddleware';
|
|
3
|
+
import { LoggingMiddleware } from '../middleware/LoggingMiddleware';
|
|
4
|
+
import { RateLimiter } from '../middleware/RateLimiter';
|
|
5
|
+
import { SecurityMiddleware } from '../middleware/SecurityMiddleware';
|
|
6
|
+
const shared = Object.freeze({
|
|
7
|
+
log: LoggingMiddleware.create(),
|
|
8
|
+
error: ErrorHandlerMiddleware.create(),
|
|
9
|
+
security: SecurityMiddleware.create(),
|
|
10
|
+
rateLimit: RateLimiter.create(),
|
|
11
|
+
csrf: CsrfMiddleware.create(),
|
|
12
|
+
});
|
|
13
|
+
const middlewareConfigObj = {
|
|
14
|
+
global: [shared.log, shared.error, shared.security, shared.rateLimit, shared.csrf],
|
|
15
|
+
route: shared,
|
|
16
|
+
};
|
|
17
|
+
export const middlewareConfig = Object.freeze(middlewareConfigObj);
|
|
18
|
+
export default middlewareConfig;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Notification Configuration
|
|
3
|
+
*
|
|
4
|
+
* Config-first mapping of notification providers.
|
|
5
|
+
* Keeps runtime driver selection in one place and uses Env for safe access.
|
|
6
|
+
*/
|
|
7
|
+
export type KnownNotificationDriverName = 'console' | 'termii' | 'twilio' | 'slack';
|
|
8
|
+
export type ConsoleNotificationDriverConfig = {
|
|
9
|
+
driver: 'console';
|
|
10
|
+
};
|
|
11
|
+
export type TermiiNotificationDriverConfig = {
|
|
12
|
+
driver: 'termii';
|
|
13
|
+
apiKey: string;
|
|
14
|
+
sender: string;
|
|
15
|
+
endpoint: string;
|
|
16
|
+
};
|
|
17
|
+
export type TwilioNotificationDriverConfig = {
|
|
18
|
+
driver: 'twilio';
|
|
19
|
+
accountSid: string;
|
|
20
|
+
authToken: string;
|
|
21
|
+
fromNumber: string;
|
|
22
|
+
};
|
|
23
|
+
export type SlackNotificationDriverConfig = {
|
|
24
|
+
driver: 'slack';
|
|
25
|
+
webhookUrl: string;
|
|
26
|
+
};
|
|
27
|
+
export type KnownNotificationDriverConfig = ConsoleNotificationDriverConfig | TermiiNotificationDriverConfig | TwilioNotificationDriverConfig | SlackNotificationDriverConfig;
|
|
28
|
+
declare const _default: Readonly<{
|
|
29
|
+
/**
|
|
30
|
+
* Normalized notification driver name.
|
|
31
|
+
*
|
|
32
|
+
* NOTE: This intentionally supports custom driver names (e.g. project-specific drivers),
|
|
33
|
+
* so it returns a string rather than a strict union.
|
|
34
|
+
*/
|
|
35
|
+
readonly getDriverName: () => string;
|
|
36
|
+
/**
|
|
37
|
+
* Provider configs.
|
|
38
|
+
*/
|
|
39
|
+
readonly providers: {
|
|
40
|
+
console: {
|
|
41
|
+
driver: "console";
|
|
42
|
+
};
|
|
43
|
+
termii: {
|
|
44
|
+
driver: "termii";
|
|
45
|
+
apiKey: string;
|
|
46
|
+
sender: string;
|
|
47
|
+
endpoint: string;
|
|
48
|
+
};
|
|
49
|
+
twilio: {
|
|
50
|
+
driver: "twilio";
|
|
51
|
+
accountSid: string;
|
|
52
|
+
authToken: string;
|
|
53
|
+
fromNumber: string;
|
|
54
|
+
};
|
|
55
|
+
slack: {
|
|
56
|
+
driver: "slack";
|
|
57
|
+
webhookUrl: string;
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
}>;
|
|
61
|
+
export default _default;
|
|
62
|
+
//# sourceMappingURL=notification.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notification.d.ts","sourceRoot":"","sources":["../../../src/config/notification.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,MAAM,MAAM,2BAA2B,GAAG,SAAS,GAAG,QAAQ,GAAG,QAAQ,GAAG,OAAO,CAAC;AAEpF,MAAM,MAAM,+BAA+B,GAAG;IAAE,MAAM,EAAE,SAAS,CAAA;CAAE,CAAC;AAEpE,MAAM,MAAM,8BAA8B,GAAG;IAC3C,MAAM,EAAE,QAAQ,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,8BAA8B,GAAG;IAC3C,MAAM,EAAE,QAAQ,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,6BAA6B,GAAG;IAC1C,MAAM,EAAE,OAAO,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,6BAA6B,GACrC,+BAA+B,GAC/B,8BAA8B,GAC9B,8BAA8B,GAC9B,6BAA6B,CAAC;;IAUhC;;;;;OAKG;kCACc,MAAM;IAIvB;;OAEG;;;;;;;;;;;;;;;;;;;;;;;AA2BL,wBAAoD"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Notification Configuration
|
|
3
|
+
*
|
|
4
|
+
* Config-first mapping of notification providers.
|
|
5
|
+
* Keeps runtime driver selection in one place and uses Env for safe access.
|
|
6
|
+
*/
|
|
7
|
+
import { Env } from './env';
|
|
8
|
+
const notificationConfigObj = {
|
|
9
|
+
/**
|
|
10
|
+
* Normalized notification driver name.
|
|
11
|
+
*
|
|
12
|
+
* NOTE: This intentionally supports custom driver names (e.g. project-specific drivers),
|
|
13
|
+
* so it returns a string rather than a strict union.
|
|
14
|
+
*/
|
|
15
|
+
getDriverName() {
|
|
16
|
+
return Env.get('NOTIFICATION_DRIVER', 'console').trim().toLowerCase();
|
|
17
|
+
},
|
|
18
|
+
/**
|
|
19
|
+
* Provider configs.
|
|
20
|
+
*/
|
|
21
|
+
providers: {
|
|
22
|
+
console: {
|
|
23
|
+
driver: 'console',
|
|
24
|
+
},
|
|
25
|
+
termii: {
|
|
26
|
+
driver: 'termii',
|
|
27
|
+
apiKey: Env.get('TERMII_API_KEY', ''),
|
|
28
|
+
sender: Env.get('TERMII_SENDER', 'Zintrust'),
|
|
29
|
+
endpoint: Env.get('TERMII_ENDPOINT', 'https://api.termii.com/sms/send'),
|
|
30
|
+
},
|
|
31
|
+
twilio: {
|
|
32
|
+
driver: 'twilio',
|
|
33
|
+
accountSid: Env.get('TWILIO_ACCOUNT_SID', ''),
|
|
34
|
+
authToken: Env.get('TWILIO_AUTH_TOKEN', ''),
|
|
35
|
+
fromNumber: Env.get('TWILIO_FROM_NUMBER', ''),
|
|
36
|
+
},
|
|
37
|
+
slack: {
|
|
38
|
+
driver: 'slack',
|
|
39
|
+
webhookUrl: Env.get('SLACK_WEBHOOK_URL', ''),
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
export default Object.freeze(notificationConfigObj);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"security.d.ts","sourceRoot":"","sources":["../../../src/config/security.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"security.d.ts","sourceRoot":"","sources":["../../../src/config/security.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AA+IH,eAAO,MAAM,cAAc;IAtHzB;;OAEG;;;yBAGa,MAAM;4BAQ4B,OAAO,GAAG,OAAO,GAAG,OAAO;;;;;;IAO7E;;OAEG;;;;;;;;iCAQ6D,QAAQ,GAAG,KAAK,GAAG,MAAM;;IAGzF;;OAEG;;;;;IAMH;;OAEG;;;;;;IAOH;;OAEG;;;;;;;;;;IAWH;;OAEG;;;;;;;IAQH;;OAEG;;;;;IAMH;;OAEG;;;;;;;;;;IAWH;;OAEG;;;;;;;2BAOmD,QAAQ,GAAG,KAAK,GAAG,MAAM;;IAG/E;;OAEG;;;;;;;;EAUyD,CAAC"}
|
package/src/config/security.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* JWT, CSRF, encryption and other security settings
|
|
4
4
|
* Sealed namespace for immutability
|
|
5
5
|
*/
|
|
6
|
+
import { appConfig } from './app';
|
|
6
7
|
import { Env } from './env';
|
|
7
8
|
import { Logger } from './logger';
|
|
8
9
|
import { ErrorFactory } from '../exceptions/ZintrustError';
|
|
@@ -12,8 +13,7 @@ import { ErrorFactory } from '../exceptions/ZintrustError';
|
|
|
12
13
|
function warnMissingSecret(secretName) {
|
|
13
14
|
Logger.error(`❌ CRITICAL: ${secretName} environment variable is not set!`);
|
|
14
15
|
Logger.error('⚠️ Application may not function correctly. Set this in production immediately.');
|
|
15
|
-
|
|
16
|
-
if (nodeEnv === 'production') {
|
|
16
|
+
if (appConfig.isProduction()) {
|
|
17
17
|
throw ErrorFactory.createConfigError(`Missing required secret: ${secretName}`, { secretName });
|
|
18
18
|
}
|
|
19
19
|
// In non-production environments, allow the app/CLI to start while still warning loudly.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Startup Configuration
|
|
3
|
+
*
|
|
4
|
+
* Startup-only controls (evaluated during Application.boot()).
|
|
5
|
+
*/
|
|
6
|
+
export type StartupConfig = {
|
|
7
|
+
healthChecksEnabled: boolean;
|
|
8
|
+
validateSecrets: boolean;
|
|
9
|
+
checkDatabase: boolean;
|
|
10
|
+
checkCache: boolean;
|
|
11
|
+
timeoutMs: number;
|
|
12
|
+
continueOnFailure: boolean;
|
|
13
|
+
};
|
|
14
|
+
export declare const startupConfig: Readonly<{
|
|
15
|
+
healthChecksEnabled: boolean;
|
|
16
|
+
validateSecrets: boolean;
|
|
17
|
+
checkDatabase: boolean;
|
|
18
|
+
checkCache: boolean;
|
|
19
|
+
timeoutMs: number;
|
|
20
|
+
continueOnFailure: boolean;
|
|
21
|
+
}>;
|
|
22
|
+
export default startupConfig;
|
|
23
|
+
//# sourceMappingURL=startup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"startup.d.ts","sourceRoot":"","sources":["../../../src/config/startup.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,MAAM,MAAM,aAAa,GAAG;IAC1B,mBAAmB,EAAE,OAAO,CAAC;IAC7B,eAAe,EAAE,OAAO,CAAC;IACzB,aAAa,EAAE,OAAO,CAAC;IACvB,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,iBAAiB,EAAE,OAAO,CAAC;CAC5B,CAAC;AAEF,eAAO,MAAM,aAAa;;;;;;;EAOA,CAAC;AAE3B,eAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Startup Configuration
|
|
3
|
+
*
|
|
4
|
+
* Startup-only controls (evaluated during Application.boot()).
|
|
5
|
+
*/
|
|
6
|
+
import { Env } from './env';
|
|
7
|
+
export const startupConfig = Object.freeze({
|
|
8
|
+
healthChecksEnabled: Env.getBool('STARTUP_HEALTH_CHECKS', true),
|
|
9
|
+
validateSecrets: Env.getBool('STARTUP_VALIDATE_SECRETS', true),
|
|
10
|
+
checkDatabase: Env.getBool('STARTUP_CHECK_DB', false),
|
|
11
|
+
checkCache: Env.getBool('STARTUP_CHECK_CACHE', false),
|
|
12
|
+
timeoutMs: Env.getInt('STARTUP_HEALTH_TIMEOUT_MS', 2500),
|
|
13
|
+
continueOnFailure: Env.getBool('STARTUP_CONTINUE_ON_FAILURE', false),
|
|
14
|
+
});
|
|
15
|
+
export default startupConfig;
|
package/src/config/storage.d.ts
CHANGED
|
@@ -14,14 +14,23 @@ type LocalStorageDriverConfig = {
|
|
|
14
14
|
};
|
|
15
15
|
type S3StorageDriverConfig = {
|
|
16
16
|
driver: 's3';
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
accessKeyId: EnvGetValue;
|
|
18
|
+
secretAccessKey: EnvGetValue;
|
|
19
19
|
region: typeof Env.AWS_REGION;
|
|
20
20
|
bucket: EnvGetValue;
|
|
21
21
|
url: EnvGetValue;
|
|
22
22
|
endpoint: EnvGetValue;
|
|
23
23
|
usePathStyleUrl: EnvGetBoolValue;
|
|
24
24
|
};
|
|
25
|
+
type R2StorageDriverConfig = {
|
|
26
|
+
driver: 'r2';
|
|
27
|
+
accessKeyId: EnvGetValue;
|
|
28
|
+
secretAccessKey: EnvGetValue;
|
|
29
|
+
region: EnvGetValue;
|
|
30
|
+
bucket: EnvGetValue;
|
|
31
|
+
endpoint: EnvGetValue;
|
|
32
|
+
url: EnvGetValue;
|
|
33
|
+
};
|
|
25
34
|
type GcsStorageDriverConfig = {
|
|
26
35
|
driver: 'gcs';
|
|
27
36
|
projectId: EnvGetValue;
|
|
@@ -32,47 +41,24 @@ type GcsStorageDriverConfig = {
|
|
|
32
41
|
type StorageDrivers = {
|
|
33
42
|
local: LocalStorageDriverConfig;
|
|
34
43
|
s3: S3StorageDriverConfig;
|
|
44
|
+
r2: R2StorageDriverConfig;
|
|
35
45
|
gcs: GcsStorageDriverConfig;
|
|
36
46
|
};
|
|
37
47
|
type StorageDriverName = keyof StorageDrivers;
|
|
38
48
|
type StorageDriverConfig = StorageDrivers[StorageDriverName];
|
|
39
49
|
type StorageConfigRuntime = {
|
|
40
|
-
default: string;
|
|
41
|
-
drivers: StorageDrivers;
|
|
50
|
+
readonly default: string;
|
|
51
|
+
readonly drivers: StorageDrivers;
|
|
42
52
|
};
|
|
43
53
|
export declare const storageConfig: Readonly<{
|
|
44
54
|
/**
|
|
45
|
-
* Default storage driver
|
|
55
|
+
* Default storage driver (dynamic; tests may mutate process.env)
|
|
46
56
|
*/
|
|
47
|
-
default: string;
|
|
57
|
+
readonly default: string;
|
|
48
58
|
/**
|
|
49
|
-
* Storage drivers configuration
|
|
59
|
+
* Storage drivers configuration (dynamic; tests may mutate process.env)
|
|
50
60
|
*/
|
|
51
|
-
drivers:
|
|
52
|
-
local: {
|
|
53
|
-
driver: "local";
|
|
54
|
-
root: string;
|
|
55
|
-
url: string;
|
|
56
|
-
visibility: string;
|
|
57
|
-
};
|
|
58
|
-
s3: {
|
|
59
|
-
driver: "s3";
|
|
60
|
-
key: string;
|
|
61
|
-
secret: string;
|
|
62
|
-
region: string;
|
|
63
|
-
bucket: string;
|
|
64
|
-
url: string;
|
|
65
|
-
endpoint: string;
|
|
66
|
-
usePathStyleUrl: boolean;
|
|
67
|
-
};
|
|
68
|
-
gcs: {
|
|
69
|
-
driver: "gcs";
|
|
70
|
-
projectId: string;
|
|
71
|
-
keyFile: string;
|
|
72
|
-
bucket: string;
|
|
73
|
-
url: string;
|
|
74
|
-
};
|
|
75
|
-
};
|
|
61
|
+
readonly drivers: StorageDrivers;
|
|
76
62
|
/**
|
|
77
63
|
* Get storage driver config
|
|
78
64
|
*/
|
|
@@ -80,14 +66,14 @@ export declare const storageConfig: Readonly<{
|
|
|
80
66
|
/**
|
|
81
67
|
* Temporary file settings
|
|
82
68
|
*/
|
|
83
|
-
temp: {
|
|
69
|
+
readonly temp: {
|
|
84
70
|
path: string;
|
|
85
71
|
maxAge: number;
|
|
86
72
|
};
|
|
87
73
|
/**
|
|
88
74
|
* Uploads settings
|
|
89
75
|
*/
|
|
90
|
-
uploads: {
|
|
76
|
+
readonly uploads: {
|
|
91
77
|
maxSize: string;
|
|
92
78
|
allowedMimes: string;
|
|
93
79
|
path: string;
|
|
@@ -95,7 +81,7 @@ export declare const storageConfig: Readonly<{
|
|
|
95
81
|
/**
|
|
96
82
|
* Backups settings
|
|
97
83
|
*/
|
|
98
|
-
backups: {
|
|
84
|
+
readonly backups: {
|
|
99
85
|
path: string;
|
|
100
86
|
driver: string;
|
|
101
87
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../../src/config/storage.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAElC,KAAK,WAAW,GAAG,UAAU,CAAC,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC;AAC9C,KAAK,eAAe,GAAG,UAAU,CAAC,OAAO,GAAG,CAAC,OAAO,CAAC,CAAC;AAEtD,KAAK,wBAAwB,GAAG;IAC9B,MAAM,EAAE,OAAO,CAAC;IAChB,IAAI,EAAE,WAAW,CAAC;IAClB,GAAG,EAAE,WAAW,CAAC;IACjB,UAAU,EAAE,WAAW,CAAC;CACzB,CAAC;AAEF,KAAK,qBAAqB,GAAG;IAC3B,MAAM,EAAE,IAAI,CAAC;IACb,
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../../src/config/storage.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAElC,KAAK,WAAW,GAAG,UAAU,CAAC,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC;AAC9C,KAAK,eAAe,GAAG,UAAU,CAAC,OAAO,GAAG,CAAC,OAAO,CAAC,CAAC;AAEtD,KAAK,wBAAwB,GAAG;IAC9B,MAAM,EAAE,OAAO,CAAC;IAChB,IAAI,EAAE,WAAW,CAAC;IAClB,GAAG,EAAE,WAAW,CAAC;IACjB,UAAU,EAAE,WAAW,CAAC;CACzB,CAAC;AAEF,KAAK,qBAAqB,GAAG;IAC3B,MAAM,EAAE,IAAI,CAAC;IACb,WAAW,EAAE,WAAW,CAAC;IACzB,eAAe,EAAE,WAAW,CAAC;IAC7B,MAAM,EAAE,OAAO,GAAG,CAAC,UAAU,CAAC;IAC9B,MAAM,EAAE,WAAW,CAAC;IACpB,GAAG,EAAE,WAAW,CAAC;IACjB,QAAQ,EAAE,WAAW,CAAC;IACtB,eAAe,EAAE,eAAe,CAAC;CAClC,CAAC;AAEF,KAAK,qBAAqB,GAAG;IAC3B,MAAM,EAAE,IAAI,CAAC;IACb,WAAW,EAAE,WAAW,CAAC;IACzB,eAAe,EAAE,WAAW,CAAC;IAC7B,MAAM,EAAE,WAAW,CAAC;IACpB,MAAM,EAAE,WAAW,CAAC;IACpB,QAAQ,EAAE,WAAW,CAAC;IACtB,GAAG,EAAE,WAAW,CAAC;CAClB,CAAC;AAEF,KAAK,sBAAsB,GAAG;IAC5B,MAAM,EAAE,KAAK,CAAC;IACd,SAAS,EAAE,WAAW,CAAC;IACvB,OAAO,EAAE,WAAW,CAAC;IACrB,MAAM,EAAE,WAAW,CAAC;IACpB,GAAG,EAAE,WAAW,CAAC;CAClB,CAAC;AAEF,KAAK,cAAc,GAAG;IACpB,KAAK,EAAE,wBAAwB,CAAC;IAChC,EAAE,EAAE,qBAAqB,CAAC;IAC1B,EAAE,EAAE,qBAAqB,CAAC;IAC1B,GAAG,EAAE,sBAAsB,CAAC;CAC7B,CAAC;AAEF,KAAK,iBAAiB,GAAG,MAAM,cAAc,CAAC;AAC9C,KAAK,mBAAmB,GAAG,cAAc,CAAC,iBAAiB,CAAC,CAAC;AAE7D,KAAK,oBAAoB,GAAG;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC;CAClC,CAAC;AA4GF,eAAO,MAAM,aAAa;IArDxB;;OAEG;sBACY,MAAM;IAIrB;;OAEG;sBACY,cAAc;IAI7B;;OAEG;oBACa,oBAAoB,GAAG,mBAAmB;IAI1D;;OAEG;mBACS;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE;IAO5C;;OAEG;sBACY;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE;IAQtE;;OAEG;sBACY;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE;EAQW,CAAC;AAE7D,MAAM,MAAM,aAAa,GAAG,OAAO,aAAa,CAAC"}
|