@zintrust/core 0.1.19 → 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 +10 -10
- package/bin/zintrust-main.d.ts.map +1 -1
- package/bin/zintrust-main.js +9 -0
- package/package.json +2 -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/zintrust.svg +30 -0
- package/routes/api.d.ts.map +1 -1
- package/routes/api.js +41 -17
- 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/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/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 +10 -4
- 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 +1 -1
- package/src/cli/commands/NewCommand.d.ts.map +1 -1
- package/src/cli/commands/NewCommand.js +12 -4
- 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/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/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/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 +36 -4
- 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/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/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 +1 -1
- package/src/config/database.d.ts.map +1 -1
- package/src/config/database.js +92 -6
- 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 +1 -1
- package/src/config/logging/KvLogger.js +1 -1
- package/src/config/logging/SlackLogger.js +2 -2
- package/src/config/middleware.d.ts +20 -1
- package/src/config/middleware.d.ts.map +1 -1
- package/src/config/middleware.js +135 -3
- package/src/config/security.d.ts +1 -1
- package/src/config/security.js +1 -1
- package/src/config/type.d.ts +1 -1
- 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 +64 -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/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 +3 -1
- package/src/node.d.ts.map +1 -1
- package/src/node.js +6 -2
- 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/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 -99
- 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 +58 -2
- 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/metrics.d.ts +2 -0
- package/src/routes/metrics.d.ts.map +1 -0
- package/src/routes/metrics.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/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 +1 -1
- 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 +40 -0
- package/src/scripts/TemplateSync.js +86 -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/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 +3 -2
- package/src/templates/project/basic/app/Controllers/AuthController.ts.tpl +217 -0
- package/src/templates/project/basic/app/Controllers/UserController.ts.tpl +1 -12
- 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 +10 -447
- 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 -128
- package/src/templates/project/basic/config/cache.ts.tpl +15 -91
- 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 -122
- 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 +8 -23
- package/src/templates/project/basic/config/mail.ts.tpl +15 -114
- package/src/templates/project/basic/config/microservices.ts.tpl +11 -97
- package/src/templates/project/basic/config/middleware.ts.tpl +25 -43
- package/src/templates/project/basic/config/notification.ts.tpl +14 -126
- 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 -132
- package/src/templates/project/basic/config/type.ts.tpl +33 -451
- 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/routes/api.ts.tpl +71 -33
- package/src/templates/project/basic/routes/metrics.ts.tpl +22 -0
- package/src/templates/project/basic/tsconfig.json.tpl +12 -11
- 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,268 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
normalized.includes('token') ||
|
|
11
|
-
normalized.includes('key') ||
|
|
12
|
-
normalized.includes('authorization')
|
|
13
|
-
);
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
const redactValue = (key: string, value: unknown): unknown => {
|
|
17
|
-
return isSensitiveKey(key) ? '<redacted>' : value;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const pushError = (
|
|
21
|
-
errors: StartupConfigValidationError[],
|
|
22
|
-
key: string,
|
|
23
|
-
value: unknown,
|
|
24
|
-
message: string
|
|
25
|
-
): void => {
|
|
26
|
-
errors.push({ key, value: redactValue(key, value), message });
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const validateEnum = (
|
|
30
|
-
errors: StartupConfigValidationError[],
|
|
31
|
-
key: string,
|
|
32
|
-
value: string,
|
|
33
|
-
allowed: readonly string[]
|
|
34
|
-
): void => {
|
|
35
|
-
if (!allowed.includes(value)) {
|
|
36
|
-
pushError(errors, key, value, `${key} must be one of: ${allowed.join(', ')}`);
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
const validateIntRange = (
|
|
41
|
-
errors: StartupConfigValidationError[],
|
|
42
|
-
key: string,
|
|
43
|
-
value: number,
|
|
44
|
-
min: number,
|
|
45
|
-
max: number
|
|
46
|
-
): void => {
|
|
47
|
-
if (Number.isNaN(value)) {
|
|
48
|
-
pushError(errors, key, value, `${key} must be a valid integer`);
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
if (value < min || value > max) {
|
|
53
|
-
pushError(errors, key, value, `${key} must be between ${min} and ${max}`);
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
const validatePositiveInt = (
|
|
58
|
-
errors: StartupConfigValidationError[],
|
|
59
|
-
key: string,
|
|
60
|
-
value: number
|
|
61
|
-
): void => {
|
|
62
|
-
if (Number.isNaN(value)) {
|
|
63
|
-
pushError(errors, key, value, `${key} must be a valid integer`);
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
if (value <= 0) {
|
|
68
|
-
pushError(errors, key, value, `${key} must be greater than 0`);
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
type ProcessLike = {
|
|
73
|
-
env?: Record<string, string | undefined>;
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
const getProcessLike = (): ProcessLike | undefined => {
|
|
77
|
-
return typeof process === 'undefined' ? undefined : (process as unknown as ProcessLike);
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
const getEnvString = (key: string, defaultValue: string): string => {
|
|
81
|
-
const proc = getProcessLike();
|
|
82
|
-
const env = proc?.env ?? {};
|
|
83
|
-
return env[key] ?? defaultValue;
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
const getEnvOptionalString = (key: string): string | undefined => {
|
|
87
|
-
const proc = getProcessLike();
|
|
88
|
-
const env = proc?.env ?? {};
|
|
89
|
-
const value = env[key];
|
|
90
|
-
if (typeof value !== 'string') return undefined;
|
|
91
|
-
const trimmed = value.trim();
|
|
92
|
-
return trimmed === '' ? undefined : trimmed;
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
const getEnvBoolLoose = (key: string, defaultValue: boolean): boolean => {
|
|
96
|
-
const raw = getEnvOptionalString(key);
|
|
97
|
-
if (raw === undefined) return defaultValue;
|
|
98
|
-
const normalized = raw.toLowerCase();
|
|
99
|
-
return normalized === 'true' || normalized === '1' || normalized === 'yes' || normalized === 'on';
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
const getEnvInt = (key: string, defaultValue: number): number => {
|
|
103
|
-
const raw = getEnvString(key, String(defaultValue));
|
|
104
|
-
return Number.parseInt(raw, 10);
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
type RequireEnvStringOptions = {
|
|
108
|
-
aliases?: readonly string[];
|
|
109
|
-
requiredMessage?: string;
|
|
110
|
-
minLength?: number;
|
|
111
|
-
minLengthMessage?: string;
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
const requireEnvString = (
|
|
115
|
-
errors: StartupConfigValidationError[],
|
|
116
|
-
key: string,
|
|
117
|
-
options: RequireEnvStringOptions = {}
|
|
118
|
-
): string | undefined => {
|
|
119
|
-
const value =
|
|
120
|
-
getEnvOptionalString(key) ??
|
|
121
|
-
(options.aliases ?? []).reduce<string | undefined>((found, alias) => {
|
|
122
|
-
if (found !== undefined) return found;
|
|
123
|
-
return getEnvOptionalString(alias);
|
|
124
|
-
}, undefined);
|
|
125
|
-
|
|
126
|
-
if (value === undefined) {
|
|
127
|
-
pushError(errors, key, value, options.requiredMessage ?? `${key} is required`);
|
|
128
|
-
return undefined;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
if (options.minLength !== undefined && value.length < options.minLength) {
|
|
132
|
-
pushError(
|
|
133
|
-
errors,
|
|
134
|
-
key,
|
|
135
|
-
value,
|
|
136
|
-
options.minLengthMessage ?? `${key} must be at least ${options.minLength} characters`
|
|
137
|
-
);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
return value;
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
const validateSqliteDbFileRequired = (
|
|
144
|
-
errors: StartupConfigValidationError[],
|
|
145
|
-
dbConnection: string | undefined
|
|
146
|
-
): void => {
|
|
147
|
-
// sqlite convenience: accept DB_DATABASE or DB_PATH
|
|
148
|
-
if ((dbConnection ?? '').toLowerCase() !== 'sqlite') return;
|
|
149
|
-
|
|
150
|
-
const dbFile = getEnvOptionalString('DB_DATABASE') ?? getEnvOptionalString('DB_PATH');
|
|
151
|
-
if (dbFile === undefined) {
|
|
152
|
-
pushError(errors, 'DB_DATABASE', dbFile, 'DB_DATABASE (or DB_PATH) is required for sqlite');
|
|
153
|
-
}
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
const validateStrictRequiredEnv = (errors: StartupConfigValidationError[]): void => {
|
|
157
|
-
const requireEnv = getEnvBoolLoose('STARTUP_REQUIRE_ENV', false);
|
|
158
|
-
if (!requireEnv) return;
|
|
159
|
-
|
|
160
|
-
requireEnvString(errors, 'NODE_ENV');
|
|
161
|
-
requireEnvString(errors, 'APP_NAME');
|
|
162
|
-
requireEnvString(errors, 'HOST');
|
|
163
|
-
|
|
164
|
-
const portRaw = requireEnvString(errors, 'PORT', {
|
|
165
|
-
aliases: ['APP_PORT'],
|
|
166
|
-
requiredMessage: 'PORT (or APP_PORT) is required',
|
|
167
|
-
});
|
|
168
|
-
if (portRaw !== undefined) {
|
|
169
|
-
const port = Number.parseInt(portRaw, 10);
|
|
170
|
-
validateIntRange(errors, 'PORT', port, 1, 65535);
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
const dbConnection = requireEnvString(errors, 'DB_CONNECTION');
|
|
174
|
-
|
|
175
|
-
requireEnvString(errors, 'APP_KEY', { minLength: 16 });
|
|
176
|
-
requireEnvString(errors, 'LOG_LEVEL');
|
|
177
|
-
requireEnvString(errors, 'LOG_CHANNEL');
|
|
178
|
-
|
|
179
|
-
validateSqliteDbFileRequired(errors, dbConnection);
|
|
180
|
-
};
|
|
181
|
-
|
|
182
|
-
const validateNodeEnv = (errors: StartupConfigValidationError[]): void => {
|
|
183
|
-
const nodeEnv = getEnvString('NODE_ENV', 'development');
|
|
184
|
-
validateEnum(errors, 'NODE_ENV', nodeEnv, ['development', 'production', 'testing', 'test']);
|
|
185
|
-
};
|
|
186
|
-
|
|
187
|
-
const validatePort = (errors: StartupConfigValidationError[]): void => {
|
|
188
|
-
// Port can be provided as PORT or APP_PORT. In non-strict mode we keep defaults.
|
|
189
|
-
const portFromPort = getEnvOptionalString('PORT');
|
|
190
|
-
const portFromAppPort = getEnvOptionalString('APP_PORT');
|
|
191
|
-
const portRaw = portFromPort ?? portFromAppPort;
|
|
192
|
-
|
|
193
|
-
if (portRaw === undefined) {
|
|
194
|
-
const appPort = getEnvInt('APP_PORT', 3000);
|
|
195
|
-
validateIntRange(errors, 'APP_PORT', appPort, 1, 65535);
|
|
196
|
-
return;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
const parsed = Number.parseInt(portRaw, 10);
|
|
200
|
-
const key = portFromPort === undefined ? 'APP_PORT' : 'PORT';
|
|
201
|
-
validateIntRange(errors, key, parsed, 1, 65535);
|
|
202
|
-
};
|
|
203
|
-
|
|
204
|
-
const validateLogging = (errors: StartupConfigValidationError[]): void => {
|
|
205
|
-
const logFormat = getEnvString('LOG_FORMAT', 'text');
|
|
206
|
-
validateEnum(errors, 'LOG_FORMAT', logFormat, ['text', 'json']);
|
|
207
|
-
|
|
208
|
-
const logLevel = getEnvString('LOG_LEVEL', 'debug');
|
|
209
|
-
validateEnum(errors, 'LOG_LEVEL', logLevel, ['debug', 'info', 'warn', 'error']);
|
|
210
|
-
|
|
211
|
-
// Optional (but validated when provided): LOG_CHANNEL (starter apps often use this)
|
|
212
|
-
const logChannel = getEnvOptionalString('LOG_CHANNEL');
|
|
213
|
-
if (logChannel !== undefined) {
|
|
214
|
-
validateEnum(errors, 'LOG_CHANNEL', logChannel, ['console', 'file', 'all']);
|
|
215
|
-
}
|
|
216
|
-
};
|
|
217
|
-
|
|
218
|
-
const validateRotationAndTimeout = (errors: StartupConfigValidationError[]): void => {
|
|
219
|
-
const logRotationSize = getEnvInt('LOG_ROTATION_SIZE', 10485760);
|
|
220
|
-
validatePositiveInt(errors, 'LOG_ROTATION_SIZE', logRotationSize);
|
|
221
|
-
|
|
222
|
-
const logRotationDays = getEnvInt('LOG_ROTATION_DAYS', 7);
|
|
223
|
-
validatePositiveInt(errors, 'LOG_ROTATION_DAYS', logRotationDays);
|
|
224
|
-
|
|
225
|
-
const startupHealthTimeoutMs = getEnvInt('STARTUP_HEALTH_TIMEOUT_MS', 2500);
|
|
226
|
-
validatePositiveInt(errors, 'STARTUP_HEALTH_TIMEOUT_MS', startupHealthTimeoutMs);
|
|
227
|
-
};
|
|
228
|
-
|
|
229
|
-
const validateProductionAppKey = (errors: StartupConfigValidationError[]): void => {
|
|
230
|
-
if (!appConfig.isProduction()) return;
|
|
231
|
-
|
|
232
|
-
const appKey = getEnvString('APP_KEY', '');
|
|
233
|
-
if (appKey.trim().length < 16) {
|
|
234
|
-
pushError(
|
|
235
|
-
errors,
|
|
236
|
-
'APP_KEY',
|
|
237
|
-
appKey,
|
|
238
|
-
'APP_KEY must be set and at least 16 characters in production'
|
|
239
|
-
);
|
|
240
|
-
}
|
|
241
|
-
};
|
|
242
|
-
|
|
243
|
-
export const StartupConfigValidator = Object.freeze({
|
|
244
|
-
validate(): StartupConfigValidationResult {
|
|
245
|
-
const errors: StartupConfigValidationError[] = [];
|
|
246
|
-
|
|
247
|
-
validateStrictRequiredEnv(errors);
|
|
248
|
-
|
|
249
|
-
validateNodeEnv(errors);
|
|
250
|
-
validatePort(errors);
|
|
251
|
-
validateLogging(errors);
|
|
252
|
-
validateRotationAndTimeout(errors);
|
|
253
|
-
validateProductionAppKey(errors);
|
|
254
|
-
|
|
255
|
-
return { valid: errors.length === 0, errors };
|
|
256
|
-
},
|
|
257
|
-
|
|
258
|
-
assertValid(): void {
|
|
259
|
-
const result = StartupConfigValidator.validate();
|
|
260
|
-
if (result.valid) return;
|
|
261
|
-
|
|
262
|
-
throw ErrorFactory.createConfigError('Invalid startup configuration', {
|
|
263
|
-
errors: result.errors,
|
|
264
|
-
});
|
|
265
|
-
},
|
|
266
|
-
});
|
|
267
|
-
|
|
268
|
-
export default StartupConfigValidator;
|
|
1
|
+
/**
|
|
2
|
+
* Startup Config Validator (template)
|
|
3
|
+
*
|
|
4
|
+
* Keep this file declarative:
|
|
5
|
+
* - Core owns validation logic.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export { StartupConfigValidator } from '@zintrust/core';
|
|
9
|
+
export { StartupConfigValidator as default } from '@zintrust/core';
|
|
@@ -1,162 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Application Configuration
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* Application Configuration (template)
|
|
3
|
+
*
|
|
4
|
+
* Keep this file declarative:
|
|
5
|
+
* - Core owns env parsing/default logic.
|
|
6
|
+
* - Projects can override values by editing `appConfigObj`.
|
|
5
7
|
*/
|
|
6
8
|
|
|
7
|
-
import {
|
|
8
|
-
import type { Environment, ProcessLike, StartMode } from '@zintrust/core';
|
|
9
|
+
import { appConfig as coreAppConfig } from '@zintrust/core';
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
return typeof process === 'undefined' ? undefined : (process as unknown as ProcessLike);
|
|
12
|
-
};
|
|
11
|
+
type AppConfigShape = typeof coreAppConfig;
|
|
13
12
|
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return (anyEnv.get as (k: string, d?: string) => string)(key, defaultValue);
|
|
18
|
-
}
|
|
13
|
+
export const appConfigObj = {
|
|
14
|
+
...coreAppConfig,
|
|
15
|
+
} satisfies AppConfigShape;
|
|
19
16
|
|
|
20
|
-
|
|
21
|
-
const raw = proc?.env?.[key];
|
|
22
|
-
return raw ?? defaultValue;
|
|
23
|
-
};
|
|
17
|
+
export const appConfig = appConfigObj;
|
|
24
18
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
if (typeof anyEnv.getInt === 'function') {
|
|
28
|
-
return (anyEnv.getInt as (k: string, d?: number) => number)(key, defaultValue);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const raw = readEnvString(key, String(defaultValue));
|
|
32
|
-
const parsed = Number.parseInt(raw, 10);
|
|
33
|
-
return Number.isNaN(parsed) ? defaultValue : parsed;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
const readEnvBool = (key: string, defaultValue: boolean): boolean => {
|
|
37
|
-
const anyEnv = Env as unknown as { getBool?: unknown };
|
|
38
|
-
if (typeof anyEnv.getBool === 'function') {
|
|
39
|
-
return (anyEnv.getBool as (k: string, d?: boolean) => boolean)(key, defaultValue);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const raw = readEnvString(key, defaultValue ? 'true' : 'false');
|
|
43
|
-
return raw.toLowerCase() === 'true' || raw === '1';
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
const getSafeEnv = (): NodeJS.ProcessEnv => {
|
|
47
|
-
const baseEnv: Partial<NodeJS.ProcessEnv> = typeof process === 'undefined' ? {} : process.env;
|
|
48
|
-
|
|
49
|
-
return {
|
|
50
|
-
...(baseEnv as NodeJS.ProcessEnv),
|
|
51
|
-
|
|
52
|
-
// Ensure required keys exist (env.d.ts augments ProcessEnv with required fields)
|
|
53
|
-
NODE_ENV:
|
|
54
|
-
baseEnv.NODE_ENV ??
|
|
55
|
-
(readEnvString('NODE_ENV', 'development') as NodeJS.ProcessEnv['NODE_ENV']),
|
|
56
|
-
USE_RAW_QRY: baseEnv.USE_RAW_QRY ?? (readEnvString('USE_RAW_QRY', '') || undefined),
|
|
57
|
-
SERVICE_API_KEY: baseEnv.SERVICE_API_KEY ?? readEnvString('SERVICE_API_KEY', ''),
|
|
58
|
-
SERVICE_JWT_SECRET: baseEnv.SERVICE_JWT_SECRET ?? readEnvString('SERVICE_JWT_SECRET', ''),
|
|
59
|
-
BASE_URL: baseEnv['BASE_URL'] ?? readEnvString('BASE_URL', ''),
|
|
60
|
-
MODE: baseEnv['MODE'] ?? readEnvString('MODE', ''),
|
|
61
|
-
|
|
62
|
-
// Hardening for child-process usage
|
|
63
|
-
PATH:
|
|
64
|
-
typeof (Env as unknown as { SAFE_PATH?: unknown }).SAFE_PATH === 'string'
|
|
65
|
-
? (Env as unknown as { SAFE_PATH: string }).SAFE_PATH
|
|
66
|
-
: (baseEnv['PATH'] ?? ''),
|
|
67
|
-
npm_config_scripts_prepend_node_path: 'true',
|
|
68
|
-
};
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
const normalizeMode = (): StartMode => {
|
|
72
|
-
const value = (
|
|
73
|
-
typeof (Env as unknown as { NODE_ENV?: unknown }).NODE_ENV === 'string'
|
|
74
|
-
? (Env as unknown as { NODE_ENV: string }).NODE_ENV
|
|
75
|
-
: readEnvString('NODE_ENV', 'development')
|
|
76
|
-
) as Environment;
|
|
77
|
-
if (value === 'production' || value === 'pro' || value === 'prod') return 'production';
|
|
78
|
-
if (value === 'testing' || value === 'test') return 'testing';
|
|
79
|
-
return 'development';
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
const appConfigObj = {
|
|
83
|
-
/**
|
|
84
|
-
* Application name
|
|
85
|
-
*/
|
|
86
|
-
name:
|
|
87
|
-
typeof (Env as unknown as { APP_NAME?: unknown }).APP_NAME === 'string'
|
|
88
|
-
? (Env as unknown as { APP_NAME: string }).APP_NAME
|
|
89
|
-
: readEnvString('APP_NAME', 'ZinTrust'),
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Application environment
|
|
93
|
-
*/
|
|
94
|
-
environment: normalizeMode(),
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Application port
|
|
98
|
-
*/
|
|
99
|
-
port:
|
|
100
|
-
typeof (Env as unknown as { PORT?: unknown }).PORT === 'number'
|
|
101
|
-
? (Env as unknown as { PORT: number }).PORT
|
|
102
|
-
: readEnvInt('PORT', readEnvInt('APP_PORT', 3000)),
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Application host
|
|
106
|
-
*/
|
|
107
|
-
host:
|
|
108
|
-
typeof (Env as unknown as { HOST?: unknown }).HOST === 'string'
|
|
109
|
-
? (Env as unknown as { HOST: string }).HOST
|
|
110
|
-
: readEnvString('HOST', 'localhost'),
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Is development environment
|
|
114
|
-
*/
|
|
115
|
-
isDevelopment(): boolean {
|
|
116
|
-
return this.environment === 'development';
|
|
117
|
-
},
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Is production environment
|
|
121
|
-
*/
|
|
122
|
-
isProduction(): boolean {
|
|
123
|
-
return this.environment === 'production';
|
|
124
|
-
},
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* Is testing environment
|
|
128
|
-
*/
|
|
129
|
-
isTesting(): boolean {
|
|
130
|
-
return this.environment === 'testing';
|
|
131
|
-
},
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Application debug mode
|
|
135
|
-
*/
|
|
136
|
-
debug:
|
|
137
|
-
typeof (Env as unknown as { DEBUG?: unknown }).DEBUG === 'boolean'
|
|
138
|
-
? (Env as unknown as { DEBUG: boolean }).DEBUG
|
|
139
|
-
: readEnvBool('DEBUG', false),
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* Application timezone
|
|
143
|
-
*/
|
|
144
|
-
timezone: readEnvString('APP_TIMEZONE', 'UTC'),
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* Request timeout (milliseconds)
|
|
148
|
-
*/
|
|
149
|
-
requestTimeout: readEnvInt('REQUEST_TIMEOUT', 30000),
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* Max request body size
|
|
153
|
-
*/
|
|
154
|
-
maxBodySize: readEnvString('MAX_BODY_SIZE', '10mb'),
|
|
155
|
-
|
|
156
|
-
getSafeEnv,
|
|
157
|
-
} as const;
|
|
158
|
-
|
|
159
|
-
export const appConfig = Object.freeze(appConfigObj);
|
|
160
|
-
export { getSafeEnv };
|
|
19
|
+
// Keep the template API stable
|
|
20
|
+
export const getSafeEnv = appConfig.getSafeEnv;
|
|
161
21
|
|
|
162
22
|
export type AppConfig = typeof appConfig;
|
|
@@ -1,136 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Broadcast Configuration
|
|
2
|
+
* Broadcast 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 `broadcastConfigObj`.
|
|
6
7
|
*/
|
|
7
8
|
|
|
8
|
-
import
|
|
9
|
-
BroadcastConfigInput,
|
|
10
|
-
BroadcastDrivers,
|
|
11
|
-
InMemoryBroadcastDriverConfig,
|
|
12
|
-
KnownBroadcastDriverConfig,
|
|
13
|
-
PusherBroadcastDriverConfig,
|
|
14
|
-
RedisBroadcastDriverConfig,
|
|
15
|
-
RedisHttpsBroadcastDriverConfig,
|
|
16
|
-
} from '@zintrust/core';
|
|
17
|
-
import { ErrorFactory,Env } from '@zintrust/core';
|
|
9
|
+
import { broadcastConfig as coreBroadcastConfig } from '@zintrust/core';
|
|
18
10
|
|
|
19
|
-
|
|
11
|
+
type BroadcastConfigShape = typeof coreBroadcastConfig;
|
|
20
12
|
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
};
|
|
13
|
+
export const drivers = {
|
|
14
|
+
...coreBroadcastConfig.drivers,
|
|
15
|
+
} satisfies BroadcastConfigShape['drivers'];
|
|
24
16
|
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
17
|
+
export const broadcastConfigObj = {
|
|
18
|
+
...coreBroadcastConfig,
|
|
19
|
+
drivers,
|
|
20
|
+
} satisfies BroadcastConfigShape;
|
|
28
21
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
if (envSelectedRaw.trim().length > 0) {
|
|
32
|
-
throw ErrorFactory.createConfigError(`Broadcast driver not configured: ${value}`);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return hasOwn(drivers, 'inmemory') ? 'inmemory' : (Object.keys(drivers)[0] ?? 'inmemory');
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
const getPusherConfig = (): PusherBroadcastDriverConfig => ({
|
|
39
|
-
driver: 'pusher',
|
|
40
|
-
appId: Env.get('PUSHER_APP_ID', ''),
|
|
41
|
-
key: Env.get('PUSHER_APP_KEY', ''),
|
|
42
|
-
secret: Env.get('PUSHER_APP_SECRET', ''),
|
|
43
|
-
cluster: Env.get('PUSHER_APP_CLUSTER', ''),
|
|
44
|
-
useTLS: Env.getBool('PUSHER_USE_TLS', true),
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
const getRedisConfig = (): RedisBroadcastDriverConfig => ({
|
|
48
|
-
driver: 'redis',
|
|
49
|
-
host: Env.get('BROADCAST_REDIS_HOST', Env.get('REDIS_HOST', 'localhost')),
|
|
50
|
-
port: Env.getInt('BROADCAST_REDIS_PORT', Env.getInt('REDIS_PORT', 6379)),
|
|
51
|
-
password: Env.get('BROADCAST_REDIS_PASSWORD', Env.get('REDIS_PASSWORD', '')),
|
|
52
|
-
channelPrefix: Env.get('BROADCAST_CHANNEL_PREFIX', 'broadcast:'),
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
const getRedisHttpsConfig = (): RedisHttpsBroadcastDriverConfig => ({
|
|
56
|
-
driver: 'redishttps',
|
|
57
|
-
endpoint: Env.get('REDIS_HTTPS_ENDPOINT', ''),
|
|
58
|
-
token: Env.get('REDIS_HTTPS_TOKEN', ''),
|
|
59
|
-
channelPrefix: Env.get('BROADCAST_CHANNEL_PREFIX', 'broadcast:'),
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
const getBroadcastDriver = (
|
|
63
|
-
config: BroadcastConfigInput,
|
|
64
|
-
name?: string
|
|
65
|
-
): KnownBroadcastDriverConfig => {
|
|
66
|
-
const selected = normalizeDriverName(String(name ?? config.default));
|
|
67
|
-
const broadcasterName = selected === 'default' ? normalizeDriverName(config.default) : selected;
|
|
68
|
-
|
|
69
|
-
const isExplicitSelection =
|
|
70
|
-
name !== undefined &&
|
|
71
|
-
String(name).trim().length > 0 &&
|
|
72
|
-
normalizeDriverName(String(name)) !== 'default';
|
|
73
|
-
|
|
74
|
-
if (broadcasterName.length > 0 && hasOwn(config.drivers, broadcasterName)) {
|
|
75
|
-
const resolved = (config.drivers as Record<string, KnownBroadcastDriverConfig>)[
|
|
76
|
-
broadcasterName
|
|
77
|
-
];
|
|
78
|
-
if (resolved !== undefined) return resolved;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
if (isExplicitSelection) {
|
|
82
|
-
throw ErrorFactory.createConfigError(`Broadcast driver not configured: ${broadcasterName}`);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
const fallback = config.drivers['inmemory'] ?? Object.values(config.drivers)[0];
|
|
86
|
-
if (fallback !== undefined) return fallback;
|
|
87
|
-
|
|
88
|
-
throw ErrorFactory.createConfigError('No broadcast drivers are configured');
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
const broadcastConfigObj = {
|
|
92
|
-
/**
|
|
93
|
-
* Default broadcaster name (normalized).
|
|
94
|
-
*/
|
|
95
|
-
get default(): string {
|
|
96
|
-
return getDefaultBroadcaster(this.drivers);
|
|
97
|
-
},
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Broadcast drivers.
|
|
101
|
-
*
|
|
102
|
-
* You may add custom named broadcasters (e.g. `ops`, `billing`) that point to any
|
|
103
|
-
* known driver config.
|
|
104
|
-
*/
|
|
105
|
-
drivers: {
|
|
106
|
-
get inmemory(): InMemoryBroadcastDriverConfig {
|
|
107
|
-
return { driver: 'inmemory' };
|
|
108
|
-
},
|
|
109
|
-
get pusher() {
|
|
110
|
-
return getPusherConfig();
|
|
111
|
-
},
|
|
112
|
-
get redis() {
|
|
113
|
-
return getRedisConfig();
|
|
114
|
-
},
|
|
115
|
-
get redishttps() {
|
|
116
|
-
return getRedisHttpsConfig();
|
|
117
|
-
},
|
|
118
|
-
} satisfies BroadcastDrivers,
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Normalized broadcast driver name for the default broadcaster.
|
|
122
|
-
*/
|
|
123
|
-
getDriverName(): string {
|
|
124
|
-
return normalizeDriverName(this.default);
|
|
125
|
-
},
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* Get a config object for the currently selected driver.
|
|
129
|
-
* Defaults to inmemory for unknown/unsupported names.
|
|
130
|
-
*/
|
|
131
|
-
getDriverConfig(name?: string): KnownBroadcastDriverConfig {
|
|
132
|
-
return getBroadcastDriver(this, name);
|
|
133
|
-
},
|
|
134
|
-
} as const;
|
|
135
|
-
|
|
136
|
-
export default Object.freeze(broadcastConfigObj);
|
|
22
|
+
const broadcastConfig = broadcastConfigObj;
|
|
23
|
+
export default broadcastConfig;
|