@zintrust/core 0.1.18 → 0.1.20
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 +16 -10
- package/bin/zintrust-main.d.ts.map +1 -1
- package/bin/zintrust-main.js +9 -0
- package/package.json +11 -2
- package/public/error-pages/404.html +145 -0
- package/public/error-pages/500.html +266 -0
- package/public/error-pages/error.css +628 -0
- package/public/error-pages/error.js +428 -0
- package/public/index.html +1 -1
- package/public/zintrust.svg +30 -0
- package/routes/api.d.ts +7 -0
- package/routes/api.d.ts.map +1 -0
- package/routes/api.js +115 -0
- package/routes/broadcast.d.ts +9 -0
- package/routes/broadcast.d.ts.map +1 -0
- package/routes/broadcast.js +27 -0
- package/routes/health.d.ts +7 -0
- package/routes/health.d.ts.map +1 -0
- package/routes/health.js +127 -0
- package/routes/metrics.d.ts +9 -0
- package/routes/metrics.d.ts.map +1 -0
- package/routes/metrics.js +20 -0
- package/routes/openapi.d.ts +9 -0
- package/routes/openapi.d.ts.map +1 -0
- package/routes/openapi.js +76 -0
- package/routes/storage.d.ts +4 -0
- package/routes/storage.d.ts.map +1 -0
- package/routes/storage.js +35 -0
- package/src/boot/Application.d.ts +2 -2
- package/src/boot/Application.d.ts.map +1 -1
- package/src/boot/Application.js +18 -3
- package/src/boot/Server.d.ts +3 -2
- package/src/boot/Server.d.ts.map +1 -1
- package/src/boot/Server.js +39 -165
- package/src/boot/bootstrap.js +1 -1
- package/src/cache/Cache.d.ts +1 -1
- package/src/cache/Cache.d.ts.map +1 -1
- package/src/cache/CacheDriver.d.ts +4 -0
- package/src/cache/CacheDriver.d.ts.map +1 -1
- package/src/cache/drivers/KVDriver.d.ts +1 -1
- package/src/cache/drivers/KVDriver.d.ts.map +1 -1
- package/src/cache/drivers/MemoryDriver.d.ts +1 -1
- package/src/cache/drivers/MemoryDriver.d.ts.map +1 -1
- package/src/cache/drivers/MemoryDriver.js +16 -0
- package/src/cache/drivers/MongoDriver.d.ts +1 -1
- package/src/cache/drivers/MongoDriver.d.ts.map +1 -1
- package/src/cache/drivers/RedisDriver.d.ts +1 -1
- package/src/cache/drivers/RedisDriver.d.ts.map +1 -1
- package/src/cli/CLI.d.ts.map +1 -1
- package/src/cli/CLI.js +12 -4
- package/src/cli/PromptHelper.d.ts.map +1 -1
- package/src/cli/PromptHelper.js +4 -3
- package/src/cli/commands/AddCommand.d.ts +2 -2
- package/src/cli/commands/AddCommand.d.ts.map +1 -1
- package/src/cli/commands/AddCommand.js +135 -58
- package/src/cli/commands/ConfigCommand.d.ts +1 -1
- package/src/cli/commands/ConfigCommand.d.ts.map +1 -1
- package/src/cli/commands/CreateCommand.d.ts +15 -0
- package/src/cli/commands/CreateCommand.d.ts.map +1 -0
- package/src/cli/commands/CreateCommand.js +143 -0
- package/src/cli/commands/D1MigrateCommand.d.ts +1 -1
- package/src/cli/commands/D1MigrateCommand.d.ts.map +1 -1
- package/src/cli/commands/D1MigrateCommand.js +16 -20
- package/src/cli/commands/DbSeedCommand.d.ts +9 -0
- package/src/cli/commands/DbSeedCommand.d.ts.map +1 -0
- package/src/cli/commands/DbSeedCommand.js +171 -0
- package/src/cli/commands/DebugCommand.d.ts +1 -1
- package/src/cli/commands/DebugCommand.d.ts.map +1 -1
- package/src/cli/commands/FixCommand.d.ts +1 -1
- package/src/cli/commands/FixCommand.d.ts.map +1 -1
- package/src/cli/commands/JwtDevCommand.d.ts +8 -0
- package/src/cli/commands/JwtDevCommand.d.ts.map +1 -0
- package/src/cli/commands/JwtDevCommand.js +114 -0
- package/src/cli/commands/KeyGenerateCommand.d.ts +1 -1
- package/src/cli/commands/KeyGenerateCommand.d.ts.map +1 -1
- package/src/cli/commands/LogsCommand.d.ts +2 -2
- package/src/cli/commands/LogsCommand.d.ts.map +1 -1
- package/src/cli/commands/LogsCommand.js +36 -2
- package/src/cli/commands/MakeMailTemplateCommand.d.ts +1 -1
- package/src/cli/commands/MakeMailTemplateCommand.d.ts.map +1 -1
- package/src/cli/commands/MakeNotificationTemplateCommand.d.ts +1 -1
- package/src/cli/commands/MakeNotificationTemplateCommand.d.ts.map +1 -1
- package/src/cli/commands/MigrateCommand.d.ts +1 -1
- package/src/cli/commands/MigrateCommand.d.ts.map +1 -1
- package/src/cli/commands/MigrateCommand.js +291 -35
- package/src/cli/commands/NewCommand.d.ts +2 -2
- package/src/cli/commands/NewCommand.d.ts.map +1 -1
- package/src/cli/commands/NewCommand.js +38 -13
- package/src/cli/commands/PluginCommand.d.ts +1 -1
- package/src/cli/commands/PluginCommand.d.ts.map +1 -1
- package/src/cli/commands/PrepareCommand.d.ts +1 -1
- package/src/cli/commands/PrepareCommand.d.ts.map +1 -1
- package/src/cli/commands/QACommand.d.ts +2 -2
- package/src/cli/commands/QACommand.d.ts.map +1 -1
- package/src/cli/commands/RoutesCommand.d.ts +10 -0
- package/src/cli/commands/RoutesCommand.d.ts.map +1 -0
- package/src/cli/commands/RoutesCommand.js +242 -0
- package/src/cli/commands/SimulateCommand.d.ts +1 -1
- package/src/cli/commands/SimulateCommand.d.ts.map +1 -1
- package/src/cli/commands/SimulateCommand.js +1 -1
- package/src/cli/commands/StartCommand.d.ts.map +1 -1
- package/src/cli/commands/StartCommand.js +90 -3
- package/src/cli/commands/UpgradeCommand.d.ts +16 -0
- package/src/cli/commands/UpgradeCommand.d.ts.map +1 -0
- package/src/cli/commands/UpgradeCommand.js +107 -0
- package/src/cli/commands/index.d.ts +3 -0
- package/src/cli/commands/index.d.ts.map +1 -1
- package/src/cli/commands/index.js +3 -0
- package/src/cli/commands/runner/index.d.ts +3 -0
- package/src/cli/commands/runner/index.d.ts.map +1 -0
- package/src/cli/commands/runner/index.js +139 -0
- package/src/cli/config/ConfigManager.d.ts +1 -1
- package/src/cli/config/ConfigManager.d.ts.map +1 -1
- package/src/cli/config/ConfigValidator.d.ts +1 -1
- package/src/cli/config/ConfigValidator.d.ts.map +1 -1
- package/src/cli/config/ConfigValidator.js +1 -1
- package/src/cli/d1/D1SqlMigrations.d.ts +20 -0
- package/src/cli/d1/D1SqlMigrations.d.ts.map +1 -0
- package/src/cli/d1/D1SqlMigrations.js +224 -0
- package/src/cli/d1/WranglerConfig.d.ts +4 -0
- package/src/cli/d1/WranglerConfig.d.ts.map +1 -0
- package/src/cli/d1/WranglerConfig.js +122 -0
- package/src/cli/d1/WranglerD1.d.ts +11 -0
- package/src/cli/d1/WranglerD1.d.ts.map +1 -0
- package/src/cli/d1/WranglerD1.js +16 -0
- package/src/cli/env/EnvFileBackfill.d.ts +10 -0
- package/src/cli/env/EnvFileBackfill.d.ts.map +1 -0
- package/src/cli/env/EnvFileBackfill.js +64 -0
- package/src/cli/scaffolding/ControllerGenerator.d.ts.map +1 -1
- package/src/cli/scaffolding/ControllerGenerator.js +72 -22
- package/src/cli/scaffolding/FactoryGenerator.d.ts.map +1 -1
- package/src/cli/scaffolding/FactoryGenerator.js +3 -1
- package/src/cli/scaffolding/GovernanceScaffolder.d.ts +23 -0
- package/src/cli/scaffolding/GovernanceScaffolder.d.ts.map +1 -0
- package/src/cli/scaffolding/GovernanceScaffolder.js +327 -0
- package/src/cli/scaffolding/MigrationGenerator.d.ts +10 -0
- package/src/cli/scaffolding/MigrationGenerator.d.ts.map +1 -1
- package/src/cli/scaffolding/MigrationGenerator.js +137 -51
- package/src/cli/scaffolding/ProjectScaffolder.d.ts.map +1 -1
- package/src/cli/scaffolding/ProjectScaffolder.js +54 -59
- package/src/cli/scaffolding/RouteGenerator.d.ts.map +1 -1
- package/src/cli/scaffolding/RouteGenerator.js +79 -43
- package/src/cli/scaffolding/SeederGenerator.d.ts +5 -0
- package/src/cli/scaffolding/SeederGenerator.d.ts.map +1 -1
- package/src/cli/scaffolding/SeederGenerator.js +63 -15
- package/src/cli/scaffolding/ServiceScaffolder.d.ts.map +1 -1
- package/src/cli/scaffolding/ServiceScaffolder.js +24 -3
- package/src/cli/scaffolding/index.d.ts +2 -0
- package/src/cli/scaffolding/index.d.ts.map +1 -1
- package/src/cli/scaffolding/index.js +1 -0
- package/src/cli/utils/DistPackager.d.ts.map +1 -1
- package/src/cli/utils/DistPackager.js +8 -0
- package/src/common/index.d.ts +8 -0
- package/src/common/index.d.ts.map +1 -1
- package/src/common/index.js +28 -0
- package/src/common/utility.d.ts +38 -0
- package/src/common/utility.d.ts.map +1 -0
- package/src/common/utility.js +101 -0
- package/src/config/FileLogWriter.d.ts +2 -1
- package/src/config/FileLogWriter.d.ts.map +1 -1
- package/src/config/FileLogWriter.js +83 -2
- package/src/config/app.d.ts.map +1 -1
- package/src/config/app.js +3 -1
- package/src/config/broadcast.d.ts +1 -1
- package/src/config/broadcast.d.ts.map +1 -1
- package/src/config/broadcast.js +1 -1
- package/src/config/cache.d.ts +1 -1
- package/src/config/cache.d.ts.map +1 -1
- package/src/config/cloudflare.d.ts +1 -1
- package/src/config/cloudflare.d.ts.map +1 -1
- package/src/config/database.d.ts +7 -1
- package/src/config/database.d.ts.map +1 -1
- package/src/config/database.js +99 -7
- package/src/config/env.d.ts +6 -0
- package/src/config/env.d.ts.map +1 -1
- package/src/config/env.js +7 -0
- package/src/config/index.d.ts +8 -2
- package/src/config/index.d.ts.map +1 -1
- package/src/config/logging/KvLogger.js +1 -1
- package/src/config/logging/SlackLogger.js +2 -2
- package/src/config/middleware.d.ts +22 -2
- package/src/config/middleware.d.ts.map +1 -1
- package/src/config/middleware.js +179 -11
- package/src/config/notification.js +1 -1
- package/src/config/security.d.ts +1 -1
- package/src/config/security.js +1 -1
- package/src/config/storage.js +1 -1
- package/src/config/type.d.ts +8 -2
- package/src/config/type.d.ts.map +1 -1
- package/src/events/EventDispatcher.d.ts.map +1 -1
- package/src/events/EventDispatcher.js +6 -4
- package/src/exceptions/ZintrustError.d.ts +7 -0
- package/src/exceptions/ZintrustError.d.ts.map +1 -1
- package/src/exceptions/ZintrustError.js +56 -0
- package/src/features/Auth.d.ts +1 -1
- package/src/features/Auth.d.ts.map +1 -1
- package/src/features/Auth.js +3 -3
- package/src/features/Queue.js +1 -1
- package/src/functions/cloudflare.d.ts.map +1 -1
- package/src/functions/cloudflare.js +3 -14
- package/src/functions/deno.d.ts.map +1 -1
- package/src/functions/deno.js +3 -14
- package/src/functions/lambda.d.ts.map +1 -1
- package/src/functions/lambda.js +3 -14
- package/src/health/StartupHealthChecks.js +1 -1
- package/src/http/Controller.d.ts +2 -2
- package/src/http/Controller.d.ts.map +1 -1
- package/src/http/FileUpload.d.ts +68 -0
- package/src/http/FileUpload.d.ts.map +1 -0
- package/src/http/FileUpload.js +120 -0
- package/src/http/Kernel.d.ts +5 -5
- package/src/http/Kernel.d.ts.map +1 -1
- package/src/http/Kernel.js +139 -23
- package/src/http/Request.d.ts +20 -1
- package/src/http/Request.d.ts.map +1 -1
- package/src/http/Request.js +23 -0
- package/src/http/RequestContext.d.ts +6 -0
- package/src/http/RequestContext.d.ts.map +1 -1
- package/src/http/RequestContext.js +77 -1
- package/src/http/Response.d.ts +1 -1
- package/src/http/Response.d.ts.map +1 -1
- package/src/http/ValidationHelper.d.ts +78 -0
- package/src/http/ValidationHelper.d.ts.map +1 -0
- package/src/http/ValidationHelper.js +121 -0
- package/src/http/error-pages/ErrorPageRenderer.d.ts +17 -0
- package/src/http/error-pages/ErrorPageRenderer.d.ts.map +1 -0
- package/src/http/error-pages/ErrorPageRenderer.js +88 -0
- package/src/http/middleware/BodyParsingMiddleware.d.ts +12 -0
- package/src/http/middleware/BodyParsingMiddleware.d.ts.map +1 -0
- package/src/http/middleware/BodyParsingMiddleware.js +251 -0
- package/src/http/middleware/FileUploadMiddleware.d.ts +12 -0
- package/src/http/middleware/FileUploadMiddleware.d.ts.map +1 -0
- package/src/http/middleware/FileUploadMiddleware.js +74 -0
- package/src/http/parsers/BodyParsers.d.ts +32 -0
- package/src/http/parsers/BodyParsers.d.ts.map +1 -0
- package/src/http/parsers/BodyParsers.js +159 -0
- package/src/http/parsers/MultipartParser.d.ts +33 -0
- package/src/http/parsers/MultipartParser.d.ts.map +1 -0
- package/src/http/parsers/MultipartParser.js +129 -0
- package/src/http/parsers/MultipartParserRegistry.d.ts +34 -0
- package/src/http/parsers/MultipartParserRegistry.d.ts.map +1 -0
- package/src/http/parsers/MultipartParserRegistry.js +20 -0
- package/src/http/validated.d.ts +12 -0
- package/src/http/validated.d.ts.map +1 -0
- package/src/http/validated.js +41 -0
- package/src/index.d.ts +65 -7
- package/src/index.d.ts.map +1 -1
- package/src/index.js +59 -5
- package/src/microservices/RequestTracingMiddleware.d.ts +2 -2
- package/src/microservices/RequestTracingMiddleware.d.ts.map +1 -1
- package/src/microservices/RequestTracingMiddleware.js +3 -0
- package/src/microservices/ServiceAuthMiddleware.d.ts +2 -2
- package/src/microservices/ServiceAuthMiddleware.d.ts.map +1 -1
- package/src/middleware/AuthMiddleware.d.ts +10 -0
- package/src/middleware/AuthMiddleware.d.ts.map +1 -0
- package/src/middleware/AuthMiddleware.js +16 -0
- package/src/middleware/CsrfMiddleware.d.ts +11 -1
- package/src/middleware/CsrfMiddleware.d.ts.map +1 -1
- package/src/middleware/CsrfMiddleware.js +33 -0
- package/src/middleware/JwtAuthMiddleware.d.ts +11 -0
- package/src/middleware/JwtAuthMiddleware.d.ts.map +1 -0
- package/src/middleware/JwtAuthMiddleware.js +73 -0
- package/src/middleware/LoggingMiddleware.d.ts.map +1 -1
- package/src/middleware/LoggingMiddleware.js +8 -3
- package/src/middleware/MiddlewareStack.d.ts +2 -2
- package/src/middleware/MiddlewareStack.d.ts.map +1 -1
- package/src/middleware/RateLimiter.d.ts +2 -2
- package/src/middleware/RateLimiter.d.ts.map +1 -1
- package/src/middleware/RateLimiter.js +26 -1
- package/src/middleware/SanitizeBodyMiddleware.d.ts +12 -0
- package/src/middleware/SanitizeBodyMiddleware.d.ts.map +1 -0
- package/src/middleware/SanitizeBodyMiddleware.js +31 -0
- package/src/middleware/SecurityMiddleware.d.ts +1 -1
- package/src/middleware/SecurityMiddleware.d.ts.map +1 -1
- package/src/middleware/SessionMiddleware.d.ts +1 -1
- package/src/middleware/SessionMiddleware.d.ts.map +1 -1
- package/src/middleware/ValidationMiddleware.d.ts +25 -0
- package/src/middleware/ValidationMiddleware.d.ts.map +1 -0
- package/src/middleware/ValidationMiddleware.js +251 -0
- package/src/migrations/MigrationDiscovery.d.ts +5 -0
- package/src/migrations/MigrationDiscovery.d.ts.map +1 -0
- package/src/migrations/MigrationDiscovery.js +16 -0
- package/src/migrations/MigrationLoader.d.ts +5 -0
- package/src/migrations/MigrationLoader.d.ts.map +1 -0
- package/src/migrations/MigrationLoader.js +43 -0
- package/src/migrations/MigrationLock.d.ts +4 -0
- package/src/migrations/MigrationLock.d.ts.map +1 -0
- package/src/migrations/MigrationLock.js +33 -0
- package/src/migrations/Migrator.d.ts +23 -0
- package/src/migrations/Migrator.d.ts.map +1 -0
- package/src/migrations/Migrator.js +4 -0
- package/src/migrations/MigratorFactory.d.ts +25 -0
- package/src/migrations/MigratorFactory.d.ts.map +1 -0
- package/src/migrations/MigratorFactory.js +323 -0
- package/src/migrations/schema/Blueprint.d.ts +5 -0
- package/src/migrations/schema/Blueprint.d.ts.map +1 -0
- package/src/migrations/schema/Blueprint.js +189 -0
- package/src/migrations/schema/Schema.d.ts +8 -0
- package/src/migrations/schema/Schema.d.ts.map +1 -0
- package/src/migrations/schema/Schema.js +141 -0
- package/src/migrations/schema/SchemaCompiler.d.ts +20 -0
- package/src/migrations/schema/SchemaCompiler.d.ts.map +1 -0
- package/src/migrations/schema/SchemaCompiler.js +262 -0
- package/src/migrations/schema/index.d.ts +5 -0
- package/src/migrations/schema/index.d.ts.map +1 -0
- package/src/migrations/schema/index.js +3 -0
- package/src/migrations/schema/types.d.ts +86 -0
- package/src/migrations/schema/types.d.ts.map +1 -0
- package/src/migrations/schema/types.js +1 -0
- package/src/migrations/types.d.ts +45 -0
- package/src/migrations/types.d.ts.map +1 -0
- package/src/migrations/types.js +1 -0
- package/src/node-singletons/crypto.d.ts +1 -1
- package/src/node-singletons/crypto.d.ts.map +1 -1
- package/src/node-singletons/crypto.js +1 -1
- 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 +1 -1
- package/src/node-singletons/util.d.ts +6 -0
- package/src/node-singletons/util.d.ts.map +1 -0
- package/src/node-singletons/util.js +5 -0
- package/src/node.d.ts +2 -0
- package/src/node.d.ts.map +1 -1
- package/src/node.js +7 -0
- package/src/observability/OpenTelemetry.d.ts +62 -0
- package/src/observability/OpenTelemetry.d.ts.map +1 -0
- package/src/observability/OpenTelemetry.js +167 -0
- package/src/observability/PrometheusMetrics.d.ts +25 -0
- package/src/observability/PrometheusMetrics.d.ts.map +1 -0
- package/src/observability/PrometheusMetrics.js +114 -0
- package/src/openapi/OpenApiGenerator.d.ts +68 -0
- package/src/openapi/OpenApiGenerator.d.ts.map +1 -0
- package/src/openapi/OpenApiGenerator.js +287 -0
- package/src/orm/Database.d.ts +4 -2
- package/src/orm/Database.d.ts.map +1 -1
- package/src/orm/Database.js +142 -29
- package/src/orm/DatabaseAdapter.d.ts +13 -0
- package/src/orm/DatabaseAdapter.d.ts.map +1 -1
- package/src/orm/DatabaseAdapterRegistry.d.ts.map +1 -1
- package/src/orm/DatabaseAdapterRegistry.js +3 -1
- package/src/orm/DatabaseRuntimeRegistration.d.ts.map +1 -1
- package/src/orm/DatabaseRuntimeRegistration.js +4 -0
- package/src/orm/Model.d.ts +30 -2
- package/src/orm/Model.d.ts.map +1 -1
- package/src/orm/Model.js +255 -62
- package/src/orm/QueryBuilder.d.ts +22 -1
- package/src/orm/QueryBuilder.d.ts.map +1 -1
- package/src/orm/QueryBuilder.js +405 -95
- package/src/orm/Relationships.d.ts +7 -1
- package/src/orm/Relationships.d.ts.map +1 -1
- package/src/orm/Relationships.js +18 -0
- package/src/orm/SchemaCompiler.d.ts +9 -0
- package/src/orm/SchemaCompiler.d.ts.map +1 -0
- package/src/orm/SchemaCompiler.js +145 -0
- package/src/orm/adapters/D1Adapter.d.ts +1 -1
- package/src/orm/adapters/D1Adapter.d.ts.map +1 -1
- package/src/orm/adapters/MySQLAdapter.d.ts +1 -1
- package/src/orm/adapters/MySQLAdapter.d.ts.map +1 -1
- package/src/orm/adapters/MySQLAdapter.js +88 -69
- package/src/orm/adapters/PostgreSQLAdapter.d.ts +1 -1
- package/src/orm/adapters/PostgreSQLAdapter.d.ts.map +1 -1
- package/src/orm/adapters/PostgreSQLAdapter.js +88 -69
- package/src/orm/adapters/SQLServerAdapter.d.ts +1 -1
- package/src/orm/adapters/SQLServerAdapter.d.ts.map +1 -1
- package/src/orm/adapters/SQLiteAdapter.d.ts +1 -1
- package/src/orm/adapters/SQLiteAdapter.d.ts.map +1 -1
- package/src/orm/adapters/SQLiteAdapter.js +63 -3
- package/src/orm/maintenance/SqliteMaintenance.d.ts +5 -0
- package/src/orm/maintenance/SqliteMaintenance.d.ts.map +1 -0
- package/src/orm/maintenance/SqliteMaintenance.js +14 -0
- package/src/orm/migrations/MigrationStore.d.ts +38 -0
- package/src/orm/migrations/MigrationStore.d.ts.map +1 -0
- package/src/orm/migrations/MigrationStore.js +157 -0
- package/src/performance/CodeGenerationBenchmark.d.ts.map +1 -1
- package/src/performance/Optimizer.d.ts +1 -0
- package/src/performance/Optimizer.d.ts.map +1 -1
- package/src/performance/Optimizer.js +37 -3
- package/src/profiling/MemoryProfiler.d.ts +1 -1
- package/src/profiling/MemoryProfiler.d.ts.map +1 -1
- package/src/profiling/N1Detector.d.ts +1 -1
- package/src/profiling/N1Detector.d.ts.map +1 -1
- package/src/profiling/QueryLogger.d.ts +1 -1
- package/src/profiling/QueryLogger.d.ts.map +1 -1
- package/src/profiling/RequestProfiler.d.ts +3 -3
- package/src/profiling/RequestProfiler.d.ts.map +1 -1
- package/src/routes/api.d.ts +2 -0
- package/src/routes/api.d.ts.map +1 -0
- package/src/routes/api.js +1 -0
- package/src/routes/broadcast.d.ts +2 -0
- package/src/routes/broadcast.d.ts.map +1 -0
- package/src/routes/broadcast.js +1 -0
- package/src/routes/health.d.ts +2 -0
- package/src/routes/health.d.ts.map +1 -0
- package/src/routes/health.js +1 -0
- package/src/routes/metrics.d.ts +2 -0
- package/src/routes/metrics.d.ts.map +1 -0
- package/src/routes/metrics.js +1 -0
- package/src/routes/storage.d.ts +2 -0
- package/src/routes/storage.d.ts.map +1 -0
- package/src/routes/storage.js +1 -0
- package/src/routing/CoreRoutes.d.ts +12 -0
- package/src/routing/CoreRoutes.d.ts.map +1 -0
- package/src/routing/CoreRoutes.js +151 -0
- package/src/routing/RouteRegistry.d.ts +39 -0
- package/src/routing/RouteRegistry.d.ts.map +1 -0
- package/src/routing/RouteRegistry.js +44 -0
- package/src/routing/Router.d.ts +26 -9
- package/src/routing/Router.d.ts.map +1 -1
- package/src/routing/Router.js +79 -35
- package/src/routing/common.d.ts +15 -0
- package/src/routing/common.d.ts.map +1 -0
- package/src/routing/common.js +47 -0
- package/src/routing/doc.d.ts +28 -0
- package/src/routing/doc.d.ts.map +1 -0
- package/src/routing/doc.js +95 -0
- package/src/routing/error.d.ts +21 -0
- package/src/routing/error.d.ts.map +1 -0
- package/src/routing/error.js +126 -0
- package/src/routing/errorPages.d.ts +14 -0
- package/src/routing/errorPages.d.ts.map +1 -0
- package/src/routing/errorPages.js +103 -0
- package/src/routing/publicRoot.d.ts +18 -0
- package/src/routing/publicRoot.d.ts.map +1 -0
- package/src/routing/publicRoot.js +49 -0
- package/src/runtime/PluginAutoImports.d.ts +21 -0
- package/src/runtime/PluginAutoImports.d.ts.map +1 -0
- package/src/runtime/PluginAutoImports.js +59 -0
- package/src/runtime/PluginManager.d.ts +1 -5
- package/src/runtime/PluginManager.d.ts.map +1 -1
- package/src/runtime/PluginManager.js +25 -18
- package/src/runtime/RuntimeAdapter.d.ts.map +1 -1
- package/src/runtime/RuntimeAdapter.js +20 -1
- package/src/runtime/RuntimeDetector.d.ts +1 -1
- package/src/runtime/RuntimeDetector.d.ts.map +1 -1
- package/src/runtime/adapters/CloudflareAdapter.d.ts +1 -1
- package/src/runtime/adapters/CloudflareAdapter.d.ts.map +1 -1
- package/src/runtime/adapters/CloudflareAdapter.js +1 -1
- package/src/runtime/adapters/DenoAdapter.d.ts +1 -1
- package/src/runtime/adapters/DenoAdapter.d.ts.map +1 -1
- package/src/runtime/adapters/DenoAdapter.js +3 -3
- package/src/runtime/adapters/LambdaAdapter.d.ts +1 -1
- package/src/runtime/adapters/LambdaAdapter.d.ts.map +1 -1
- package/src/runtime/adapters/LambdaAdapter.js +1 -1
- package/src/runtime/adapters/NodeServerAdapter.d.ts +1 -1
- package/src/runtime/adapters/NodeServerAdapter.d.ts.map +1 -1
- package/src/runtime/getKernel.d.ts +9 -0
- package/src/runtime/getKernel.d.ts.map +1 -0
- package/src/runtime/getKernel.js +27 -0
- package/src/scripts/TemplateImportsCheck.js +47 -7
- package/src/scripts/TemplateSync.js +92 -20
- package/src/security/Encryptor.d.ts.map +1 -1
- package/src/security/Encryptor.js +64 -7
- package/src/security/JwtManager.d.ts +1 -0
- package/src/security/JwtManager.d.ts.map +1 -1
- package/src/security/JwtManager.js +33 -0
- package/src/security/Sanitizer.d.ts +76 -0
- package/src/security/Sanitizer.d.ts.map +1 -0
- package/src/security/Sanitizer.js +412 -0
- package/src/security/TokenRevocation.d.ts +7 -0
- package/src/security/TokenRevocation.d.ts.map +1 -0
- package/src/security/TokenRevocation.js +57 -0
- package/src/seeders/SeederDiscovery.d.ts +5 -0
- package/src/seeders/SeederDiscovery.d.ts.map +1 -0
- package/src/seeders/SeederDiscovery.js +21 -0
- package/src/seeders/SeederLoader.d.ts +5 -0
- package/src/seeders/SeederLoader.d.ts.map +1 -0
- package/src/seeders/SeederLoader.js +60 -0
- package/src/seeders/types.d.ts +18 -0
- package/src/seeders/types.d.ts.map +1 -0
- package/src/seeders/types.js +1 -0
- package/src/session/SessionManager.js +1 -1
- package/src/start.d.ts +21 -0
- package/src/start.d.ts.map +1 -0
- package/src/start.js +60 -0
- package/src/templates/adapters/MySQLAdapter.ts.tpl +109 -85
- package/src/templates/adapters/PostgreSQLAdapter.ts.tpl +129 -88
- package/src/templates/adapters/SQLServerAdapter.ts.tpl +5 -9
- package/src/templates/adapters/SQLiteAdapter.ts.tpl +78 -11
- package/src/templates/features/Queue.ts.tpl +2 -2
- package/src/templates/project/basic/app/Controllers/AuthController.ts.tpl +217 -0
- package/src/templates/project/basic/app/Controllers/UserController.ts.tpl +3 -16
- package/src/templates/project/basic/app/Middleware/ProfilerMiddleware.ts.tpl +1 -3
- package/src/templates/project/basic/app/Middleware/index.ts.tpl +3 -8
- package/src/templates/project/basic/app/Models/Post.ts.tpl +2 -3
- package/src/templates/project/basic/app/Models/User.ts.tpl +1 -1
- package/src/templates/project/basic/app/Types/controller.ts.tpl +46 -0
- package/src/templates/project/basic/config/FileLogWriter.ts.tpl +5 -236
- package/src/templates/project/basic/config/SecretsManager.ts.tpl +13 -450
- package/src/templates/project/basic/config/StartupConfigValidator.ts.tpl +9 -268
- package/src/templates/project/basic/config/app.ts.tpl +13 -153
- package/src/templates/project/basic/config/broadcast.ts.tpl +15 -129
- package/src/templates/project/basic/config/cache.ts.tpl +15 -92
- package/src/templates/project/basic/config/cloudflare.ts.tpl +4 -39
- package/src/templates/project/basic/config/constants.ts.tpl +9 -65
- package/src/templates/project/basic/config/database.ts.tpl +29 -116
- package/src/templates/project/basic/config/env.ts.tpl +5 -169
- package/src/templates/project/basic/config/features.ts.tpl +6 -54
- package/src/templates/project/basic/config/index.ts.tpl +27 -24
- package/src/templates/project/basic/config/logger.ts.tpl +5 -381
- package/src/templates/project/basic/config/logging/HttpLogger.ts.tpl +1 -1
- package/src/templates/project/basic/config/logging/KvLogger.ts.tpl +2 -2
- package/src/templates/project/basic/config/logging/SlackLogger.ts.tpl +1 -1
- package/src/templates/project/basic/config/mail.ts.tpl +15 -115
- package/src/templates/project/basic/config/microservices.ts.tpl +11 -97
- package/src/templates/project/basic/config/middleware.ts.tpl +27 -18
- package/src/templates/project/basic/config/notification.ts.tpl +14 -127
- package/src/templates/project/basic/config/queue.ts.tpl +16 -79
- package/src/templates/project/basic/config/security.ts.tpl +11 -163
- package/src/templates/project/basic/config/startup.ts.tpl +10 -21
- package/src/templates/project/basic/config/storage.ts.tpl +15 -133
- package/src/templates/project/basic/config/type.ts.tpl +33 -441
- package/src/templates/project/basic/database/factories/UserFactory.ts.tpl +80 -0
- package/src/templates/project/basic/database/migrations/create_tasks_table.ts.tpl +28 -0
- package/src/templates/project/basic/database/migrations/create_users_table.ts.tpl +29 -0
- package/src/templates/project/basic/database/seeders/DatabaseSeeder.ts.tpl +19 -0
- package/src/templates/project/basic/database/seeders/UserSeeder.ts.tpl +18 -0
- package/src/templates/project/basic/database/seeders/index.ts.tpl +2 -0
- package/src/templates/project/basic/package.json.tpl +1 -1
- package/src/templates/project/basic/routes/api.ts.tpl +74 -36
- package/src/templates/project/basic/routes/health.ts.tpl +1 -6
- package/src/templates/project/basic/routes/metrics.ts.tpl +22 -0
- package/src/templates/project/basic/src/index.ts.tpl +7 -80
- package/src/templates/project/basic/tsconfig.json.tpl +12 -13
- package/src/testing/TestEnvironment.d.ts +40 -0
- package/src/testing/TestEnvironment.d.ts.map +1 -0
- package/src/testing/TestEnvironment.js +141 -0
- package/src/testing/TestHttp.d.ts +29 -0
- package/src/testing/TestHttp.d.ts.map +1 -0
- package/src/testing/TestHttp.js +96 -0
- package/src/testing/index.d.ts +5 -0
- package/src/testing/index.d.ts.map +1 -0
- package/src/testing/index.js +2 -0
- package/src/time/DateTime.d.ts +181 -0
- package/src/time/DateTime.d.ts.map +1 -0
- package/src/time/DateTime.js +300 -0
- package/src/time/index.d.ts +7 -0
- package/src/time/index.d.ts.map +1 -0
- package/src/time/index.js +5 -0
- package/src/tools/http/Http.d.ts.map +1 -1
- package/src/tools/http/Http.js +4 -0
- package/src/tools/mail/drivers/Smtp.js +1 -1
- package/src/tools/queue/drivers/InMemory.d.ts +1 -1
- package/src/tools/queue/drivers/InMemory.d.ts.map +1 -1
- package/src/tools/queue/drivers/InMemory.js +1 -1
- package/src/tools/queue/drivers/Redis.d.ts +1 -1
- package/src/tools/queue/drivers/Redis.d.ts.map +1 -1
- package/src/tools/queue/drivers/Redis.js +1 -1
- package/src/validation/ValidationError.d.ts.map +1 -1
- package/src/validation/ValidationError.js +4 -2
- package/src/validation/Validator.d.ts +49 -16
- package/src/validation/Validator.d.ts.map +1 -1
- package/src/validation/Validator.js +307 -5
- package/src/common/uuid.d.ts +0 -3
- package/src/common/uuid.d.ts.map +0 -1
- package/src/common/uuid.js +0 -30
- package/src/templates/project/basic/.env.example.tpl +0 -74
- package/src/templates/project/basic/.env.tpl +0 -166
- package/src/templates/project/basic/database/migrations/index.ts.tpl +0 -2
|
@@ -1,104 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Microservices Configuration
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* Microservices Configuration (template)
|
|
3
|
+
*
|
|
4
|
+
* Keep this file declarative:
|
|
5
|
+
* - Core owns env parsing/default logic.
|
|
6
|
+
* - Projects can override values by editing `microservicesConfigObj`.
|
|
5
7
|
*/
|
|
6
8
|
|
|
7
|
-
import {
|
|
9
|
+
import { microservicesConfig as coreMicroservicesConfig } from '@zintrust/core';
|
|
8
10
|
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Enable microservices mode
|
|
12
|
-
*/
|
|
13
|
-
enabled: Env.getBool('MICROSERVICES', false),
|
|
11
|
+
type MicroservicesConfigShape = typeof coreMicroservicesConfig;
|
|
14
12
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
services: Env.get('SERVICES', '')
|
|
19
|
-
.split(',')
|
|
20
|
-
.filter((s) => s.trim()),
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Service discovery
|
|
24
|
-
*/
|
|
25
|
-
discovery: {
|
|
26
|
-
type: Env.get('SERVICE_DISCOVERY_TYPE', 'filesystem') as 'filesystem' | 'consul' | 'etcd',
|
|
27
|
-
servicesPath: Env.get('SERVICES_PATH', 'services'),
|
|
28
|
-
refreshInterval: Env.getInt('SERVICE_DISCOVERY_REFRESH_INTERVAL', 30000),
|
|
29
|
-
},
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Service Registry
|
|
33
|
-
*/
|
|
34
|
-
registry: {
|
|
35
|
-
host: Env.get('SERVICE_REGISTRY_HOST', 'localhost'),
|
|
36
|
-
port: Env.getInt('SERVICE_REGISTRY_PORT', 8500),
|
|
37
|
-
deregisterCriticalServiceAfter: Env.get('SERVICE_DEREGISTER_CRITICAL_AFTER', '30s'),
|
|
38
|
-
},
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Service Authentication
|
|
42
|
-
*/
|
|
43
|
-
auth: {
|
|
44
|
-
strategy: Env.get('SERVICE_AUTH_STRATEGY', 'none') as 'api-key' | 'jwt' | 'none' | 'custom',
|
|
45
|
-
apiKey: Env.get('SERVICE_API_KEY'),
|
|
46
|
-
jwtSecret: Env.get('SERVICE_JWT_SECRET'),
|
|
47
|
-
},
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Request Tracing
|
|
51
|
-
*/
|
|
52
|
-
tracing: {
|
|
53
|
-
enabled: Env.getBool('MICROSERVICES_TRACING', false),
|
|
54
|
-
samplingRate: Env.getInt('MICROSERVICES_TRACING_RATE', 100) / 100,
|
|
55
|
-
exportInterval: Env.getInt('TRACING_EXPORT_INTERVAL', 10000),
|
|
56
|
-
jaegerEndpoint: Env.get('JAEGER_AGENT_HOST', 'localhost'),
|
|
57
|
-
},
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Database Isolation
|
|
61
|
-
*/
|
|
62
|
-
database: {
|
|
63
|
-
isolation: Env.get('DATABASE_ISOLATION', 'shared') as 'shared' | 'isolated',
|
|
64
|
-
schema: Env.get('DATABASE_SCHEMA_PREFIX', 'microservice'),
|
|
65
|
-
},
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Service Health Check
|
|
69
|
-
*/
|
|
70
|
-
healthCheck: {
|
|
71
|
-
enabled: Env.getBool('SERVICE_HEALTH_CHECK_ENABLED', true),
|
|
72
|
-
interval: Env.getInt('SERVICE_HEALTH_CHECK_INTERVAL', 30000),
|
|
73
|
-
timeout: Env.getInt('SERVICE_HEALTH_CHECK_TIMEOUT', 5000),
|
|
74
|
-
unhealthyThreshold: Env.getInt('SERVICE_UNHEALTHY_THRESHOLD', 3),
|
|
75
|
-
healthyThreshold: Env.getInt('SERVICE_HEALTHY_THRESHOLD', 2),
|
|
76
|
-
},
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Service Communication
|
|
80
|
-
*/
|
|
81
|
-
communication: {
|
|
82
|
-
timeout: Env.getInt('SERVICE_CALL_TIMEOUT', 30000),
|
|
83
|
-
retries: Env.getInt('SERVICE_CALL_RETRIES', 3),
|
|
84
|
-
retryDelay: Env.getInt('SERVICE_CALL_RETRY_DELAY', 1000),
|
|
85
|
-
circuitBreaker: {
|
|
86
|
-
enabled: Env.getBool('CIRCUIT_BREAKER_ENABLED', true),
|
|
87
|
-
threshold: Env.getInt('CIRCUIT_BREAKER_THRESHOLD', 5),
|
|
88
|
-
timeout: Env.getInt('CIRCUIT_BREAKER_TIMEOUT', 60000),
|
|
89
|
-
},
|
|
90
|
-
},
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Service Mesh (Istio/Linkerd support)
|
|
94
|
-
*/
|
|
95
|
-
mesh: {
|
|
96
|
-
enabled: Env.getBool('SERVICE_MESH_ENABLED', false),
|
|
97
|
-
type: Env.get('SERVICE_MESH_TYPE', 'istio') as 'istio' | 'linkerd',
|
|
98
|
-
namespace: Env.get('SERVICE_MESH_NAMESPACE', 'default'),
|
|
99
|
-
},
|
|
100
|
-
} as const;
|
|
101
|
-
|
|
102
|
-
export const microservicesConfig = Object.freeze(microservicesConfigObj);
|
|
13
|
+
export const microservicesConfigObj = {
|
|
14
|
+
...coreMicroservicesConfig,
|
|
15
|
+
} satisfies MicroservicesConfigShape;
|
|
103
16
|
|
|
17
|
+
export const microservicesConfig = microservicesConfigObj;
|
|
104
18
|
export type MicroservicesConfig = typeof microservicesConfig;
|
|
@@ -1,23 +1,32 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Middleware Configuration (template)
|
|
3
|
+
*
|
|
4
|
+
* Keep this file declarative:
|
|
5
|
+
* - Core owns middleware construction / any runtime behavior.
|
|
6
|
+
* - Projects can override by editing `middlewareConfigObj`.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { middlewareConfig as coreMiddlewareConfig } from '@zintrust/core';
|
|
2
10
|
import { CsrfMiddleware } from '@zintrust/core';
|
|
3
|
-
import { ErrorHandlerMiddleware } from '@zintrust/core';
|
|
4
|
-
import { LoggingMiddleware } from '@zintrust/core';
|
|
5
|
-
import type { Middleware } from '@zintrust/core';
|
|
6
|
-
import { RateLimiter } from '@zintrust/core';
|
|
7
|
-
import { SecurityMiddleware } from '@zintrust/core';
|
|
8
11
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
type MiddlewareConfigShape = typeof coreMiddlewareConfig;
|
|
13
|
+
|
|
14
|
+
// Optional: if you're building a pure Bearer-token API (no cookie auth),
|
|
15
|
+
// you can bypass CSRF for API routes.
|
|
16
|
+
// Example: ['\/api\/*'] skips CSRF for all API endpoints.
|
|
17
|
+
const csrf = CsrfMiddleware.create({
|
|
18
|
+
skipPaths: [],
|
|
19
|
+
});
|
|
16
20
|
|
|
17
|
-
const middlewareConfigObj
|
|
18
|
-
|
|
19
|
-
route:
|
|
20
|
-
|
|
21
|
+
export const middlewareConfigObj = {
|
|
22
|
+
...coreMiddlewareConfig,
|
|
23
|
+
route: {
|
|
24
|
+
...coreMiddlewareConfig.route,
|
|
25
|
+
csrf,
|
|
26
|
+
},
|
|
27
|
+
// Keep global middleware order but swap in the overridden CSRF middleware.
|
|
28
|
+
global: coreMiddlewareConfig.global.map((mw) => (mw === coreMiddlewareConfig.route.csrf ? csrf : mw)),
|
|
29
|
+
} satisfies MiddlewareConfigShape;
|
|
21
30
|
|
|
22
|
-
export const middlewareConfig =
|
|
31
|
+
export const middlewareConfig = middlewareConfigObj;
|
|
23
32
|
export default middlewareConfig;
|
|
@@ -1,136 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Notification Configuration
|
|
2
|
+
* Notification Configuration (template)
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Keep this file declarative:
|
|
5
|
+
* - Core owns env parsing/default logic.
|
|
6
|
+
* - Projects can override values by editing `drivers` and `notificationConfigObj`.
|
|
6
7
|
*/
|
|
7
8
|
|
|
8
|
-
import {
|
|
9
|
-
import type {
|
|
10
|
-
KnownNotificationDriverConfig,
|
|
11
|
-
NotificationConfigInput,
|
|
12
|
-
NotificationDrivers,
|
|
13
|
-
NotificationProviders,
|
|
14
|
-
} from './type';
|
|
15
|
-
import { ErrorFactory } from '@zintrust/core';
|
|
9
|
+
import { notificationConfig as coreNotificationConfig } from '@zintrust/core';
|
|
16
10
|
|
|
17
|
-
|
|
11
|
+
type NotificationConfigShape = typeof coreNotificationConfig;
|
|
18
12
|
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
};
|
|
13
|
+
export const drivers = {
|
|
14
|
+
...coreNotificationConfig.drivers,
|
|
15
|
+
} satisfies NotificationConfigShape['drivers'];
|
|
22
16
|
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
);
|
|
28
|
-
const value = normalizeName(envSelectedRaw ?? 'console');
|
|
29
|
-
|
|
30
|
-
if (value.length > 0 && hasOwn(drivers, value)) return value;
|
|
31
|
-
|
|
32
|
-
if (envSelectedRaw.trim().length > 0) {
|
|
33
|
-
throw ErrorFactory.createConfigError(`Notification channel not configured: ${value}`);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return hasOwn(drivers, 'console') ? 'console' : (Object.keys(drivers)[0] ?? 'console');
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
const getNotificationDriver = (
|
|
40
|
-
config: NotificationConfigInput,
|
|
41
|
-
name?: string
|
|
42
|
-
): KnownNotificationDriverConfig => {
|
|
43
|
-
const selected = normalizeName(String(name ?? config.default));
|
|
44
|
-
const channelName = selected === 'default' ? normalizeName(config.default) : selected;
|
|
45
|
-
|
|
46
|
-
const isExplicitSelection =
|
|
47
|
-
name !== undefined &&
|
|
48
|
-
String(name).trim().length > 0 &&
|
|
49
|
-
normalizeName(String(name)) !== 'default';
|
|
50
|
-
|
|
51
|
-
if (channelName.length > 0 && hasOwn(config.drivers, channelName)) {
|
|
52
|
-
const resolved = config.drivers[channelName];
|
|
53
|
-
if (resolved !== undefined) return resolved;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
if (Object.keys(config.drivers ?? {}).length === 0) {
|
|
57
|
-
throw ErrorFactory.createConfigError('No notification channels are configured');
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
if (isExplicitSelection) {
|
|
61
|
-
throw ErrorFactory.createConfigError(`Notification channel not configured: ${channelName}`);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// Default selection is strict: if `default` points at an unconfigured channel, throw.
|
|
65
|
-
throw ErrorFactory.createConfigError(`Notification channel not configured: ${channelName}`);
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
const getBaseProviders = (): NotificationProviders => {
|
|
69
|
-
return {
|
|
70
|
-
console: { driver: 'console' as const },
|
|
71
|
-
termii: {
|
|
72
|
-
driver: 'termii' as const,
|
|
73
|
-
apiKey: Env.get('TERMII_API_KEY', ''),
|
|
74
|
-
sender: Env.get('TERMII_SENDER', 'Zintrust'),
|
|
75
|
-
endpoint: Env.get('TERMII_ENDPOINT', 'https://api.termii.com/sms/send'),
|
|
76
|
-
},
|
|
77
|
-
twilio: {
|
|
78
|
-
driver: 'twilio' as const,
|
|
79
|
-
accountSid: Env.get('TWILIO_ACCOUNT_SID', ''),
|
|
80
|
-
authToken: Env.get('TWILIO_AUTH_TOKEN', ''),
|
|
81
|
-
fromNumber: Env.get('TWILIO_FROM_NUMBER', ''),
|
|
82
|
-
},
|
|
83
|
-
slack: {
|
|
84
|
-
driver: 'slack' as const,
|
|
85
|
-
webhookUrl: Env.get('SLACK_WEBHOOK_URL', ''),
|
|
86
|
-
},
|
|
87
|
-
};
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
const notificationConfigObj = {
|
|
91
|
-
/**
|
|
92
|
-
* Default notification channel name (normalized).
|
|
93
|
-
*/
|
|
94
|
-
get default(): string {
|
|
95
|
-
return getDefaultChannel(this.drivers);
|
|
96
|
-
},
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Notification channels.
|
|
100
|
-
*
|
|
101
|
-
* You may add custom named channels (e.g. `opsSlack`, `smsMarketing`) that
|
|
102
|
-
* point to any known driver config.
|
|
103
|
-
*/
|
|
104
|
-
get drivers(): NotificationDrivers {
|
|
105
|
-
// Return a record of channels; can be extended by app-level config.
|
|
106
|
-
return getBaseProviders() as unknown as NotificationDrivers;
|
|
107
|
-
},
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Legacy provider configs (kept for backwards compatibility with wrappers).
|
|
111
|
-
*/
|
|
112
|
-
get providers(): NotificationProviders {
|
|
113
|
-
return getBaseProviders();
|
|
114
|
-
},
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Normalized notification channel name.
|
|
118
|
-
*/
|
|
119
|
-
getDriverName(): string {
|
|
120
|
-
return normalizeName(this.default);
|
|
121
|
-
},
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Resolve a channel config.
|
|
125
|
-
* - Unknown names throw when explicitly selected.
|
|
126
|
-
* - `default` is a reserved alias of the configured default.
|
|
127
|
-
*/
|
|
128
|
-
getDriverConfig(name?: string): KnownNotificationDriverConfig {
|
|
129
|
-
return getNotificationDriver(this, name);
|
|
130
|
-
},
|
|
131
|
-
} as const;
|
|
132
|
-
|
|
133
|
-
export const notificationConfig = Object.freeze(notificationConfigObj);
|
|
134
|
-
export type NotificationConfig = typeof notificationConfig;
|
|
17
|
+
export const notificationConfigObj = {
|
|
18
|
+
...coreNotificationConfig,
|
|
19
|
+
drivers,
|
|
20
|
+
} satisfies NotificationConfigShape;
|
|
135
21
|
|
|
22
|
+
const notificationConfig = notificationConfigObj;
|
|
136
23
|
export default notificationConfig;
|
|
@@ -1,86 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Queue Configuration
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* Queue Configuration (template)
|
|
3
|
+
*
|
|
4
|
+
* Keep this file declarative:
|
|
5
|
+
* - Core owns env parsing/default logic.
|
|
6
|
+
* - Projects can override values by editing `connections` and `queueConfigObj`.
|
|
5
7
|
*/
|
|
6
8
|
|
|
7
|
-
import {
|
|
9
|
+
import { queueConfig as coreQueueConfig } from '@zintrust/core';
|
|
8
10
|
|
|
9
|
-
|
|
11
|
+
type QueueConfigShape = typeof coreQueueConfig;
|
|
10
12
|
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
};
|
|
13
|
+
export const connections = {
|
|
14
|
+
...coreQueueConfig.connections,
|
|
15
|
+
} satisfies QueueConfigShape['connections'];
|
|
15
16
|
|
|
16
|
-
const queueConfigObj = {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
default: Env.get('QUEUE_DRIVER', 'sync') as QueueDriverName,
|
|
17
|
+
export const queueConfigObj = {
|
|
18
|
+
...coreQueueConfig,
|
|
19
|
+
connections,
|
|
20
|
+
} satisfies QueueConfigShape;
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
*/
|
|
25
|
-
drivers: {
|
|
26
|
-
sync: {
|
|
27
|
-
driver: 'sync' as const,
|
|
28
|
-
},
|
|
29
|
-
database: {
|
|
30
|
-
driver: 'database' as const,
|
|
31
|
-
table: Env.get('QUEUE_TABLE', 'jobs'),
|
|
32
|
-
connection: Env.get('QUEUE_DB_CONNECTION', 'default'),
|
|
33
|
-
},
|
|
34
|
-
redis: {
|
|
35
|
-
driver: 'redis' as const,
|
|
36
|
-
host: Env.get('REDIS_HOST', 'localhost'),
|
|
37
|
-
port: Env.getInt('REDIS_PORT', 6379),
|
|
38
|
-
password: Env.get('REDIS_PASSWORD'),
|
|
39
|
-
database: Env.getInt('REDIS_QUEUE_DB', 1),
|
|
40
|
-
},
|
|
41
|
-
rabbitmq: {
|
|
42
|
-
driver: 'rabbitmq' as const,
|
|
43
|
-
host: Env.get('RABBITMQ_HOST', 'localhost'),
|
|
44
|
-
port: Env.getInt('RABBITMQ_PORT', 5672),
|
|
45
|
-
username: Env.get('RABBITMQ_USER', 'guest'),
|
|
46
|
-
password: Env.get('RABBITMQ_PASSWORD', 'guest'),
|
|
47
|
-
vhost: Env.get('RABBITMQ_VHOST', '/'),
|
|
48
|
-
},
|
|
49
|
-
sqs: {
|
|
50
|
-
driver: 'sqs' as const,
|
|
51
|
-
key: Env.get('AWS_ACCESS_KEY_ID'),
|
|
52
|
-
secret: Env.get('AWS_SECRET_ACCESS_KEY'),
|
|
53
|
-
region: Env.AWS_REGION,
|
|
54
|
-
queueUrl: Env.get('AWS_SQS_QUEUE_URL'),
|
|
55
|
-
},
|
|
56
|
-
} satisfies QueueDriversConfig,
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Get queue driver config
|
|
60
|
-
*/
|
|
61
|
-
getDriver(): QueueDriversConfig[QueueDriverName] {
|
|
62
|
-
return getQueueDriver(this);
|
|
63
|
-
},
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Failed jobs table
|
|
67
|
-
*/
|
|
68
|
-
failed: {
|
|
69
|
-
database: Env.get('FAILED_JOBS_DB_CONNECTION', 'default'),
|
|
70
|
-
table: Env.get('FAILED_JOBS_TABLE', 'failed_jobs'),
|
|
71
|
-
},
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Job processing
|
|
75
|
-
*/
|
|
76
|
-
processing: {
|
|
77
|
-
timeout: Env.getInt('QUEUE_JOB_TIMEOUT', 60),
|
|
78
|
-
retries: Env.getInt('QUEUE_JOB_RETRIES', 3),
|
|
79
|
-
backoff: Env.getInt('QUEUE_JOB_BACKOFF', 0),
|
|
80
|
-
workers: Env.getInt('QUEUE_WORKERS', 1),
|
|
81
|
-
},
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
export const queueConfig = Object.freeze(queueConfigObj);
|
|
85
|
-
|
|
86
|
-
export type QueueConfig = typeof queueConfig;
|
|
22
|
+
const queueConfig = queueConfigObj;
|
|
23
|
+
export default queueConfig;
|
|
@@ -1,170 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Security Configuration
|
|
3
|
-
* JWT, CSRF, encryption and other security settings
|
|
4
|
-
* Sealed namespace for immutability
|
|
2
|
+
* Security Configuration (template)
|
|
5
3
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* Security keys can be configured per domain:
|
|
10
|
-
* - APP_KEY: Default encryption key for all operations (auto-generated)
|
|
11
|
-
* - API_KEY_SECRET: Optional API key authentication (if API_KEY_ENABLED=true)
|
|
12
|
-
* - ENCRYPTION_CIPHER: Cipher for encrypted envelope interoperability
|
|
13
|
-
* - JWT_SECRET: JWT token signing key
|
|
14
|
-
*
|
|
15
|
-
* Developers can use a single APP_KEY or configure separate keys for different
|
|
16
|
-
* security domains (e.g., different keys for different microservices).
|
|
4
|
+
* Keep this file declarative:
|
|
5
|
+
* - Core owns env parsing/default logic.
|
|
6
|
+
* - Projects can override values by editing `securityConfigObj`.
|
|
17
7
|
*/
|
|
18
8
|
|
|
19
|
-
import {
|
|
20
|
-
import { Env } from './env';
|
|
21
|
-
import { Logger } from './logger';
|
|
22
|
-
import { ErrorFactory } from '@zintrust/core';
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Helper to warn about missing secrets
|
|
26
|
-
*/
|
|
27
|
-
function warnMissingSecret(secretName: string): string {
|
|
28
|
-
Logger.error(`❌ CRITICAL: ${secretName} environment variable is not set!`);
|
|
29
|
-
Logger.error('⚠️ Application may not function correctly. Set this in production immediately.');
|
|
30
|
-
if (appConfig.isProduction()) {
|
|
31
|
-
throw ErrorFactory.createConfigError(`Missing required secret: ${secretName}`, { secretName });
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// In non-production environments, allow the app/CLI to start while still warning loudly.
|
|
35
|
-
// This is intentionally predictable for local development and test tooling.
|
|
36
|
-
return 'dev-unsafe-jwt-secret';
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
let cachedJwtSecret: string | undefined;
|
|
40
|
-
|
|
41
|
-
const securityConfigObj = {
|
|
42
|
-
/**
|
|
43
|
-
* JWT Configuration
|
|
44
|
-
*/
|
|
45
|
-
jwt: {
|
|
46
|
-
enabled: Env.getBool('JWT_ENABLED', true),
|
|
47
|
-
get secret(): string {
|
|
48
|
-
if (cachedJwtSecret !== undefined) return cachedJwtSecret;
|
|
49
|
-
const isEnabled = Env.getBool('JWT_ENABLED', true);
|
|
50
|
-
cachedJwtSecret = isEnabled
|
|
51
|
-
? Env.get('JWT_SECRET') || warnMissingSecret('JWT_SECRET')
|
|
52
|
-
: Env.get('JWT_SECRET') || '';
|
|
53
|
-
return cachedJwtSecret;
|
|
54
|
-
},
|
|
55
|
-
algorithm: Env.get('JWT_ALGORITHM', 'HS256') as 'HS256' | 'HS512' | 'RS256',
|
|
56
|
-
expiresIn: Env.get('JWT_EXPIRES_IN', '1h'),
|
|
57
|
-
refreshExpiresIn: Env.get('JWT_REFRESH_EXPIRES_IN', '7d'),
|
|
58
|
-
issuer: Env.get('JWT_ISSUER', 'zintrust'),
|
|
59
|
-
audience: Env.get('JWT_AUDIENCE', 'zintrust-api'),
|
|
60
|
-
},
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* CSRF Protection
|
|
64
|
-
*/
|
|
65
|
-
csrf: {
|
|
66
|
-
enabled: Env.getBool('CSRF_ENABLED', true),
|
|
67
|
-
headerName: Env.get('CSRF_HEADER_NAME', 'x-csrf-token'),
|
|
68
|
-
tokenName: Env.get('CSRF_TOKEN_NAME', '_csrf'),
|
|
69
|
-
cookieName: Env.get('CSRF_COOKIE_NAME', 'XSRF-TOKEN'),
|
|
70
|
-
cookieHttpOnly: Env.getBool('CSRF_COOKIE_HTTP_ONLY', true),
|
|
71
|
-
cookieSecure: Env.getBool('CSRF_COOKIE_SECURE', true),
|
|
72
|
-
cookieSameSite: Env.get('CSRF_COOKIE_SAME_SITE', 'strict') as 'strict' | 'lax' | 'none',
|
|
73
|
-
},
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Encryption
|
|
77
|
-
*/
|
|
78
|
-
encryption: {
|
|
79
|
-
// Required for framework-compatible encrypted payloads.
|
|
80
|
-
// Supported values: aes-256-cbc | aes-256-gcm (case-insensitive)
|
|
81
|
-
cipher: Env.get('ENCRYPTION_CIPHER', ''),
|
|
82
|
-
|
|
83
|
-
// Primary key used for encryption interoperability (framework-compatible envelopes).
|
|
84
|
-
// APP_KEY supports both `base64:...` and raw base64.
|
|
85
|
-
appKey: Env.get('APP_KEY', ''),
|
|
86
|
-
appPreviousKeys: Env.get('APP_PREVIOUS_KEYS', ''),
|
|
87
|
-
|
|
88
|
-
// Back-compat fields (not used by EncryptedEnvelope)
|
|
89
|
-
algorithm: Env.get('ENCRYPTION_ALGORITHM', 'aes-256-cbc'),
|
|
90
|
-
key: Env.get('ENCRYPTION_KEY', 'your-encryption-key'),
|
|
91
|
-
},
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* API Key Authentication
|
|
95
|
-
*/
|
|
96
|
-
apiKey: {
|
|
97
|
-
enabled: Env.getBool('API_KEY_ENABLED', false),
|
|
98
|
-
headerName: Env.get('API_KEY_HEADER', 'x-api-key'),
|
|
99
|
-
secret: Env.get('API_KEY_SECRET'),
|
|
100
|
-
},
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* CORS Configuration
|
|
104
|
-
*/
|
|
105
|
-
cors: {
|
|
106
|
-
enabled: Env.getBool('CORS_ENABLED', true),
|
|
107
|
-
origins: Env.get('CORS_ORIGINS', '*').split(','),
|
|
108
|
-
methods: Env.get('CORS_METHODS', 'GET,POST,PUT,PATCH,DELETE').split(','),
|
|
109
|
-
allowedHeaders: Env.get('CORS_ALLOWED_HEADERS', 'Content-Type,Authorization').split(','),
|
|
110
|
-
exposedHeaders: Env.get('CORS_EXPOSED_HEADERS', '').split(','),
|
|
111
|
-
credentials: Env.getBool('CORS_CREDENTIALS', false),
|
|
112
|
-
maxAge: Env.getInt('CORS_MAX_AGE', 86400),
|
|
113
|
-
},
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* Rate Limiting
|
|
117
|
-
*/
|
|
118
|
-
rateLimit: {
|
|
119
|
-
enabled: Env.getBool('RATE_LIMIT_ENABLED', true),
|
|
120
|
-
windowMs: Env.getInt('RATE_LIMIT_WINDOW_MS', 900000), // 15 minutes
|
|
121
|
-
maxRequests: Env.getInt('RATE_LIMIT_MAX_REQUESTS', 100),
|
|
122
|
-
message: Env.get('RATE_LIMIT_MESSAGE', 'Too many requests, please try again later'),
|
|
123
|
-
},
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* XSS Protection
|
|
127
|
-
*/
|
|
128
|
-
xss: {
|
|
129
|
-
enabled: Env.getBool('XSS_ENABLED', true),
|
|
130
|
-
reportUri: Env.get('XSS_REPORT_URI'),
|
|
131
|
-
},
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Helmet Security Headers
|
|
135
|
-
*/
|
|
136
|
-
helmet: {
|
|
137
|
-
enabled: Env.getBool('HELMET_ENABLED', true),
|
|
138
|
-
contentSecurityPolicy: Env.getBool('CSP_ENABLED', true),
|
|
139
|
-
hsts: {
|
|
140
|
-
enabled: Env.getBool('HSTS_ENABLED', true),
|
|
141
|
-
maxAge: Env.getInt('HSTS_MAX_AGE', 31536000),
|
|
142
|
-
includeSubDomains: Env.getBool('HSTS_INCLUDE_SUBDOMAINS', true),
|
|
143
|
-
},
|
|
144
|
-
},
|
|
9
|
+
import { securityConfig as coreSecurityConfig } from '@zintrust/core';
|
|
145
10
|
|
|
146
|
-
|
|
147
|
-
* Session Configuration
|
|
148
|
-
*/
|
|
149
|
-
session: {
|
|
150
|
-
name: Env.get('SESSION_NAME', 'zintrust_session'),
|
|
151
|
-
secret: Env.get('SESSION_SECRET', 'your-session-secret'),
|
|
152
|
-
expiresIn: Env.getInt('SESSION_EXPIRES_IN', 1800000), // 30 minutes
|
|
153
|
-
secure: Env.getBool('SESSION_SECURE', true),
|
|
154
|
-
httpOnly: Env.getBool('SESSION_HTTP_ONLY', true),
|
|
155
|
-
sameSite: Env.get('SESSION_SAME_SITE', 'strict') as 'strict' | 'lax' | 'none',
|
|
156
|
-
},
|
|
11
|
+
type SecurityConfigShape = typeof coreSecurityConfig;
|
|
157
12
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
password: {
|
|
162
|
-
minLength: Env.getInt('PASSWORD_MIN_LENGTH', 8),
|
|
163
|
-
requireUppercase: Env.getBool('PASSWORD_REQUIRE_UPPERCASE', true),
|
|
164
|
-
requireNumbers: Env.getBool('PASSWORD_REQUIRE_NUMBERS', true),
|
|
165
|
-
requireSpecialChars: Env.getBool('PASSWORD_REQUIRE_SPECIAL_CHARS', true),
|
|
166
|
-
bcryptRounds: Env.getInt('BCRYPT_ROUNDS', 10),
|
|
167
|
-
},
|
|
168
|
-
} as const;
|
|
13
|
+
export const securityConfigObj = {
|
|
14
|
+
...coreSecurityConfig,
|
|
15
|
+
} satisfies SecurityConfigShape;
|
|
169
16
|
|
|
170
|
-
|
|
17
|
+
const securityConfig = securityConfigObj;
|
|
18
|
+
export default securityConfig;
|
|
@@ -1,29 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Startup Configuration
|
|
2
|
+
* Startup Configuration (template)
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Keep this file declarative:
|
|
5
|
+
* - Core owns env parsing/default logic.
|
|
6
|
+
* - Projects can override values by editing `startupConfigObj`.
|
|
5
7
|
*/
|
|
6
8
|
|
|
7
|
-
import {
|
|
9
|
+
import { startupConfig as coreStartupConfig } from '@zintrust/core';
|
|
8
10
|
|
|
9
|
-
export type StartupConfig =
|
|
10
|
-
healthChecksEnabled: boolean;
|
|
11
|
-
validateSecrets: boolean;
|
|
12
|
-
requireEnv: boolean;
|
|
13
|
-
checkDatabase: boolean;
|
|
14
|
-
checkCache: boolean;
|
|
15
|
-
timeoutMs: number;
|
|
16
|
-
continueOnFailure: boolean;
|
|
17
|
-
};
|
|
11
|
+
export type StartupConfig = typeof coreStartupConfig;
|
|
18
12
|
|
|
19
|
-
export const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
requireEnv: Env.getBool('STARTUP_REQUIRE_ENV', false),
|
|
23
|
-
checkDatabase: Env.getBool('STARTUP_CHECK_DB', false),
|
|
24
|
-
checkCache: Env.getBool('STARTUP_CHECK_CACHE', false),
|
|
25
|
-
timeoutMs: Env.getInt('STARTUP_HEALTH_TIMEOUT_MS', 2500),
|
|
26
|
-
continueOnFailure: Env.getBool('STARTUP_CONTINUE_ON_FAILURE', false),
|
|
27
|
-
} satisfies StartupConfig);
|
|
13
|
+
export const startupConfigObj = {
|
|
14
|
+
...coreStartupConfig,
|
|
15
|
+
} satisfies StartupConfig;
|
|
28
16
|
|
|
17
|
+
export const startupConfig = startupConfigObj;
|
|
29
18
|
export default startupConfig;
|