@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
package/routes/health.js
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Health Routes
|
|
3
|
+
* Provides health, liveness, and readiness endpoints.
|
|
4
|
+
*/
|
|
5
|
+
import { appConfig } from '../src/config/index.js';
|
|
6
|
+
import { RuntimeHealthProbes } from '../src/health/RuntimeHealthProbes.js';
|
|
7
|
+
import { Env } from '../src/config/env.js';
|
|
8
|
+
import { Logger } from '../src/config/logger.js';
|
|
9
|
+
import { useDatabase } from '../src/orm/Database.js';
|
|
10
|
+
import { QueryBuilder } from '../src/orm/QueryBuilder.js';
|
|
11
|
+
import { Router } from '../src/routing/Router.js';
|
|
12
|
+
export function registerHealthRoutes(router) {
|
|
13
|
+
registerHealthRoute(router);
|
|
14
|
+
registerHealthLiveRoute(router);
|
|
15
|
+
registerHealthReadyRoute(router);
|
|
16
|
+
}
|
|
17
|
+
function registerHealthRoute(router) {
|
|
18
|
+
Router.get(router, '/health', async (_req, res) => {
|
|
19
|
+
const environment = Env.NODE_ENV ?? 'development';
|
|
20
|
+
try {
|
|
21
|
+
const db = useDatabase();
|
|
22
|
+
const maybeIsConnected = db.isConnected;
|
|
23
|
+
const maybeConnect = db.connect;
|
|
24
|
+
if (typeof maybeIsConnected === 'function' && maybeIsConnected.call(db) === false) {
|
|
25
|
+
if (typeof maybeConnect === 'function') {
|
|
26
|
+
await maybeConnect.call(db);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
await QueryBuilder.ping(db);
|
|
30
|
+
const uptime = typeof process !== 'undefined' && typeof process.uptime === 'function'
|
|
31
|
+
? process.uptime()
|
|
32
|
+
: 0;
|
|
33
|
+
res.json({
|
|
34
|
+
status: 'healthy',
|
|
35
|
+
timestamp: new Date().toISOString(),
|
|
36
|
+
uptime,
|
|
37
|
+
database: 'connected',
|
|
38
|
+
environment,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
Logger.error('Health check failed:', error);
|
|
43
|
+
const isProd = environment === 'production' || environment === 'prod';
|
|
44
|
+
res.setStatus(503).json({
|
|
45
|
+
status: 'unhealthy',
|
|
46
|
+
timestamp: new Date().toISOString(),
|
|
47
|
+
database: 'disconnected',
|
|
48
|
+
error: isProd ? 'Service unavailable' : error.message,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
function registerHealthLiveRoute(router) {
|
|
54
|
+
Router.get(router, '/health/live', async (_req, res) => {
|
|
55
|
+
const uptime = typeof process !== 'undefined' && typeof process.uptime === 'function' ? process.uptime() : 0;
|
|
56
|
+
res.json({
|
|
57
|
+
status: 'alive',
|
|
58
|
+
timestamp: new Date().toISOString(),
|
|
59
|
+
uptime,
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
function registerHealthReadyRoute(router) {
|
|
64
|
+
Router.get(router, '/health/ready', async (_req, res) => {
|
|
65
|
+
const startTime = Date.now();
|
|
66
|
+
const environment = appConfig.environment;
|
|
67
|
+
let databaseResponseTime = null;
|
|
68
|
+
let cacheResponseTime = null;
|
|
69
|
+
try {
|
|
70
|
+
const db = useDatabase();
|
|
71
|
+
const maybeIsConnected = db.isConnected;
|
|
72
|
+
const maybeConnect = db.connect;
|
|
73
|
+
if (typeof maybeIsConnected === 'function' && maybeIsConnected.call(db) === false) {
|
|
74
|
+
if (typeof maybeConnect === 'function') {
|
|
75
|
+
await maybeConnect.call(db);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
await QueryBuilder.ping(db);
|
|
79
|
+
databaseResponseTime = Date.now() - startTime;
|
|
80
|
+
// Only probe KV at runtime when explicitly configured.
|
|
81
|
+
cacheResponseTime = await RuntimeHealthProbes.pingKvCache(2000);
|
|
82
|
+
res.json({
|
|
83
|
+
status: 'ready',
|
|
84
|
+
timestamp: new Date().toISOString(),
|
|
85
|
+
environment,
|
|
86
|
+
dependencies: {
|
|
87
|
+
database: {
|
|
88
|
+
status: 'ready',
|
|
89
|
+
responseTime: databaseResponseTime,
|
|
90
|
+
},
|
|
91
|
+
...(cacheResponseTime === null
|
|
92
|
+
? {}
|
|
93
|
+
: {
|
|
94
|
+
cache: {
|
|
95
|
+
status: 'ready',
|
|
96
|
+
responseTime: cacheResponseTime,
|
|
97
|
+
},
|
|
98
|
+
}),
|
|
99
|
+
},
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
Logger.error('Readiness check failed:', error);
|
|
104
|
+
const isProd = environment === 'production';
|
|
105
|
+
const responseTime = Date.now() - startTime;
|
|
106
|
+
const dependencies = {
|
|
107
|
+
database: {
|
|
108
|
+
status: databaseResponseTime === null ? 'unavailable' : 'ready',
|
|
109
|
+
responseTime: databaseResponseTime ?? responseTime,
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
if (RuntimeHealthProbes.getCacheDriverName() === 'kv') {
|
|
113
|
+
dependencies['cache'] = {
|
|
114
|
+
status: 'unavailable',
|
|
115
|
+
responseTime: cacheResponseTime ?? responseTime,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
res.setStatus(503).json({
|
|
119
|
+
status: 'not_ready',
|
|
120
|
+
timestamp: new Date().toISOString(),
|
|
121
|
+
environment,
|
|
122
|
+
dependencies,
|
|
123
|
+
error: isProd ? 'Service unavailable' : error.message,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Metrics Routes
|
|
3
|
+
*
|
|
4
|
+
* Exposes Prometheus metrics when enabled.
|
|
5
|
+
*/
|
|
6
|
+
import { type IRouter } from '../src/routing/Router';
|
|
7
|
+
export declare function registerMetricsRoutes(router: IRouter): void;
|
|
8
|
+
export default registerMetricsRoutes;
|
|
9
|
+
//# sourceMappingURL=metrics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metrics.d.ts","sourceRoot":"","sources":["../../routes/metrics.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAE,KAAK,OAAO,EAAU,MAAM,iBAAiB,CAAC;AAEvD,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAW3D;AAED,eAAe,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Metrics Routes
|
|
3
|
+
*
|
|
4
|
+
* Exposes Prometheus metrics when enabled.
|
|
5
|
+
*/
|
|
6
|
+
import { PrometheusMetrics } from '../src/observability/PrometheusMetrics.js';
|
|
7
|
+
import { Env } from '../src/config/env.js';
|
|
8
|
+
import { Router } from '../src/routing/Router.js';
|
|
9
|
+
export function registerMetricsRoutes(router) {
|
|
10
|
+
if (Env.getBool('METRICS_ENABLED', false) === false)
|
|
11
|
+
return;
|
|
12
|
+
const pathFromEnv = Env.get('METRICS_PATH', '/metrics').trim();
|
|
13
|
+
const path = pathFromEnv === '' ? '/metrics' : pathFromEnv;
|
|
14
|
+
Router.get(router, path, async (_req, res) => {
|
|
15
|
+
const { contentType, body } = await PrometheusMetrics.getMetricsText();
|
|
16
|
+
res.setHeader('Content-Type', contentType);
|
|
17
|
+
res.send(body);
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
export default registerMetricsRoutes;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenAPI Routes
|
|
3
|
+
*
|
|
4
|
+
* Serves a generated OpenAPI spec from the in-memory RouteRegistry.
|
|
5
|
+
*/
|
|
6
|
+
import { type IRouter } from '../src/routing/Router';
|
|
7
|
+
export declare function registerOpenApiRoutes(router: IRouter): void;
|
|
8
|
+
export default registerOpenApiRoutes;
|
|
9
|
+
//# sourceMappingURL=openapi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openapi.d.ts","sourceRoot":"","sources":["../../routes/openapi.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAE,KAAK,OAAO,EAAU,MAAM,iBAAiB,CAAC;AA2CvD,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAuC3D;AAED,eAAe,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenAPI Routes
|
|
3
|
+
*
|
|
4
|
+
* Serves a generated OpenAPI spec from the in-memory RouteRegistry.
|
|
5
|
+
*/
|
|
6
|
+
import { OpenApiGenerator } from '../src/openapi/OpenApiGenerator.js';
|
|
7
|
+
import { Env } from '../src/config/env.js';
|
|
8
|
+
import { Router } from '../src/routing/Router.js';
|
|
9
|
+
import { RouteRegistry } from '../src/routing/RouteRegistry.js';
|
|
10
|
+
const getServerUrl = () => {
|
|
11
|
+
const explicit = Env.BASE_URL;
|
|
12
|
+
if (explicit.trim() !== '')
|
|
13
|
+
return explicit;
|
|
14
|
+
const host = Env.HOST;
|
|
15
|
+
const port = Env.PORT;
|
|
16
|
+
if (host.trim() === '' || Number.isNaN(port) || port <= 0)
|
|
17
|
+
return undefined;
|
|
18
|
+
return `http://${host}:${port}`;
|
|
19
|
+
};
|
|
20
|
+
const getDocsHtml = (specUrl) => `<!doctype html>
|
|
21
|
+
<html lang="en">
|
|
22
|
+
<head>
|
|
23
|
+
<meta charset="utf-8" />
|
|
24
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
25
|
+
<title>${Env.APP_NAME} API Docs</title>
|
|
26
|
+
<link rel="stylesheet" href="https://unpkg.com/swagger-ui-dist@5/swagger-ui.css" />
|
|
27
|
+
<style>
|
|
28
|
+
html, body { margin: 0; padding: 0; }
|
|
29
|
+
#swagger-ui { box-sizing: border-box; }
|
|
30
|
+
</style>
|
|
31
|
+
</head>
|
|
32
|
+
<body>
|
|
33
|
+
<div id="swagger-ui"></div>
|
|
34
|
+
<script src="https://unpkg.com/swagger-ui-dist@5/swagger-ui-bundle.js"></script>
|
|
35
|
+
<script src="https://unpkg.com/swagger-ui-dist@5/swagger-ui-standalone-preset.js"></script>
|
|
36
|
+
<script>
|
|
37
|
+
window.onload = function () {
|
|
38
|
+
window.ui = SwaggerUIBundle({
|
|
39
|
+
url: ${JSON.stringify(specUrl)},
|
|
40
|
+
dom_id: '#swagger-ui',
|
|
41
|
+
presets: [SwaggerUIBundle.presets.apis, SwaggerUIStandalonePreset],
|
|
42
|
+
layout: 'BaseLayout'
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
</script>
|
|
46
|
+
</body>
|
|
47
|
+
</html>`;
|
|
48
|
+
export function registerOpenApiRoutes(router) {
|
|
49
|
+
Router.get(router, '/openapi.json', async (_req, res) => {
|
|
50
|
+
// Convert readonly to mutable array for OpenApiGenerator
|
|
51
|
+
const routes = Array.from(RouteRegistry.list());
|
|
52
|
+
const doc = OpenApiGenerator.generate(routes, {
|
|
53
|
+
title: Env.APP_NAME,
|
|
54
|
+
version: Env.get('APP_VERSION', '0.0.0'),
|
|
55
|
+
serverUrl: getServerUrl(),
|
|
56
|
+
excludePaths: ['/openapi.json', '/docs'],
|
|
57
|
+
});
|
|
58
|
+
res.json(doc);
|
|
59
|
+
}, {
|
|
60
|
+
meta: {
|
|
61
|
+
summary: 'OpenAPI spec',
|
|
62
|
+
tags: ['Docs'],
|
|
63
|
+
responseStatus: 200,
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
Router.get(router, '/docs', async (_req, res) => {
|
|
67
|
+
res.html(getDocsHtml('/openapi.json'));
|
|
68
|
+
}, {
|
|
69
|
+
meta: {
|
|
70
|
+
summary: 'Swagger UI',
|
|
71
|
+
tags: ['Docs'],
|
|
72
|
+
responseStatus: 200,
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
export default registerOpenApiRoutes;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../routes/storage.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,OAAO,EAAU,MAAM,iBAAiB,CAAC;AAIvD,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAiC3D;AAED,eAAe,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { HTTP_HEADERS } from '../src/config/constants.js';
|
|
2
|
+
import { Env } from '../src/config/env.js';
|
|
3
|
+
import { Router } from '../src/routing/Router.js';
|
|
4
|
+
import { LocalSignedUrl } from '../src/tools/storage/LocalSignedUrl.js';
|
|
5
|
+
import { Storage } from '../src/tools/storage/index.js';
|
|
6
|
+
export function registerStorageRoutes(router) {
|
|
7
|
+
Router.get(router, '/storage/download', async (req, res) => {
|
|
8
|
+
const tokenRaw = req.getQueryParam('token');
|
|
9
|
+
const token = typeof tokenRaw === 'string' ? tokenRaw : '';
|
|
10
|
+
if (token.trim() === '') {
|
|
11
|
+
res.setStatus(400).json({ message: 'Missing token' });
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const appKey = Env.get('APP_KEY', '');
|
|
15
|
+
if (appKey.trim() === '') {
|
|
16
|
+
res.setStatus(500).json({ message: 'Storage signing is not configured' });
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
try {
|
|
20
|
+
const payload = LocalSignedUrl.verifyToken(token, appKey);
|
|
21
|
+
// Only local disk is supported by this route.
|
|
22
|
+
if (payload.disk !== 'local') {
|
|
23
|
+
res.setStatus(400).json({ message: 'Unsupported disk' });
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const contents = await Storage.get('local', payload.key);
|
|
27
|
+
res.setHeader(HTTP_HEADERS.CONTENT_TYPE, 'application/octet-stream');
|
|
28
|
+
res.setStatus(200).send(contents);
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
res.setStatus(403).json({ message: 'Invalid or expired token' });
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
export default registerStorageRoutes;
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Application - Framework core entry point
|
|
3
3
|
* Handles application lifecycle, booting, and environment
|
|
4
4
|
*/
|
|
5
|
-
import { IServiceContainer } from '../container/ServiceContainer';
|
|
6
|
-
import { IMiddlewareStack } from '../middleware/MiddlewareStack';
|
|
5
|
+
import type { IServiceContainer } from '../container/ServiceContainer';
|
|
6
|
+
import type { IMiddlewareStack } from '../middleware/MiddlewareStack';
|
|
7
7
|
import { type IRouter } from '../routing/Router';
|
|
8
8
|
export interface IApplication {
|
|
9
9
|
boot(): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Application.d.ts","sourceRoot":"","sources":["../../../src/boot/Application.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,iBAAiB,
|
|
1
|
+
{"version":3,"file":"Application.d.ts","sourceRoot":"","sources":["../../../src/boot/Application.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAGtE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAErE,OAAO,EAAE,KAAK,OAAO,EAAU,MAAM,kBAAkB,CAAC;AASxD,MAAM,WAAW,YAAY;IAC3B,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACtB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1B,QAAQ,IAAI,OAAO,CAAC;IACpB,aAAa,IAAI,OAAO,CAAC;IACzB,YAAY,IAAI,OAAO,CAAC;IACxB,SAAS,IAAI,OAAO,CAAC;IACrB,cAAc,IAAI,MAAM,CAAC;IACzB,SAAS,IAAI,OAAO,CAAC;IACrB,YAAY,IAAI,iBAAiB,CAAC;IAClC,kBAAkB,IAAI,gBAAgB,CAAC;IACvC,WAAW,IAAI,MAAM,CAAC;CACvB;AAqVD;;GAEG;AACH,eAAO,MAAM,WAAW;IACtB;;OAEG;sBACe,MAAM,GAAG,YAAY;EA0CvC,CAAC;AAEH,eAAe,WAAW,CAAC"}
|
package/src/boot/Application.js
CHANGED
|
@@ -88,6 +88,16 @@ const registerFrameworkShutdownHooks = (shutdownManager) => {
|
|
|
88
88
|
/* ignore import failures in restrictive runtimes */
|
|
89
89
|
});
|
|
90
90
|
/* c8 ignore stop */
|
|
91
|
+
// Flush file logging streams
|
|
92
|
+
import('../config/FileLogWriter.js')
|
|
93
|
+
.then((mod) => {
|
|
94
|
+
shutdownManager.add(() => mod.FileLogWriter.flush());
|
|
95
|
+
})
|
|
96
|
+
/* c8 ignore start */
|
|
97
|
+
.catch(() => {
|
|
98
|
+
/* ignore import failures in restrictive runtimes */
|
|
99
|
+
});
|
|
100
|
+
/* c8 ignore stop */
|
|
91
101
|
import('../tools/broadcast/BroadcastRegistry.js')
|
|
92
102
|
.then((mod) => {
|
|
93
103
|
shutdownManager.add(() => mod.BroadcastRegistry.reset());
|
|
@@ -162,10 +172,15 @@ const registerRoutes = async (resolvedBasePath, router) => {
|
|
|
162
172
|
const mod = await tryImportRoutesFromAppBase(resolvedBasePath);
|
|
163
173
|
if (typeof mod?.registerRoutes === 'function') {
|
|
164
174
|
mod.registerRoutes(router);
|
|
165
|
-
return;
|
|
166
175
|
}
|
|
167
|
-
|
|
168
|
-
|
|
176
|
+
else {
|
|
177
|
+
const { registerRoutes: registerFrameworkRoutes } = await import('../routes/api.js');
|
|
178
|
+
registerFrameworkRoutes(router);
|
|
179
|
+
}
|
|
180
|
+
// Always register core framework routes (health, metrics, doc) after app routes
|
|
181
|
+
// This ensures app can override but core routes always exist
|
|
182
|
+
const { registerCoreRoutes } = await import('../routing/CoreRoutes.js');
|
|
183
|
+
registerCoreRoutes(router);
|
|
169
184
|
}
|
|
170
185
|
catch (error) {
|
|
171
186
|
Logger.error('Failed to register routes:', error);
|
package/src/boot/Server.d.ts
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
* Server - HTTP Server implementation
|
|
3
3
|
* Uses Node.js built-in HTTP server with no external dependencies
|
|
4
4
|
*/
|
|
5
|
-
import { IApplication } from './Application';
|
|
5
|
+
import type { IApplication } from './Application';
|
|
6
|
+
import type { IKernel } from '../http/Kernel';
|
|
6
7
|
import * as http from '../node-singletons/http';
|
|
7
8
|
export interface IServer {
|
|
8
9
|
listen(): Promise<void>;
|
|
@@ -17,7 +18,7 @@ export declare const Server: Readonly<{
|
|
|
17
18
|
/**
|
|
18
19
|
* Create a new server instance
|
|
19
20
|
*/
|
|
20
|
-
create(app: IApplication, port?: number, host?: string): IServer;
|
|
21
|
+
create(app: IApplication, port?: number, host?: string, kernel?: IKernel | null): IServer;
|
|
21
22
|
}>;
|
|
22
23
|
export default Server;
|
|
23
24
|
//# sourceMappingURL=Server.d.ts.map
|
package/src/boot/Server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Server.d.ts","sourceRoot":"","sources":["../../../src/boot/Server.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"Server.d.ts","sourceRoot":"","sources":["../../../src/boot/Server.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAMtD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAM5C,OAAO,KAAK,IAAI,MAAM,uBAAuB,CAAC;AAI9C,MAAM,WAAW,OAAO;IACtB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACxB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,aAAa,IAAI,IAAI,CAAC,MAAM,CAAC;CAC9B;AA2DD;;;GAGG;AACH,eAAO,MAAM,MAAM;IACjB;;OAEG;gBACS,YAAY,SAAS,MAAM,SAAS,MAAM,WAAU,OAAO,GAAG,IAAI,GAAU,OAAO;EA4D/F,CAAC;AAEH,eAAe,MAAM,CAAC"}
|
package/src/boot/Server.js
CHANGED
|
@@ -2,194 +2,57 @@
|
|
|
2
2
|
* Server - HTTP Server implementation
|
|
3
3
|
* Uses Node.js built-in HTTP server with no external dependencies
|
|
4
4
|
*/
|
|
5
|
-
import { esmDirname } from '../common/index.js';
|
|
6
5
|
import { appConfig } from '../config/app.js';
|
|
7
|
-
import { HTTP_HEADERS
|
|
6
|
+
import { HTTP_HEADERS } from '../config/constants.js';
|
|
8
7
|
import { Logger } from '../config/logger.js';
|
|
8
|
+
import { ServiceContainer } from '../container/ServiceContainer.js';
|
|
9
9
|
import { ErrorFactory } from '../exceptions/ZintrustError.js';
|
|
10
|
+
import { Kernel } from '../http/Kernel.js';
|
|
10
11
|
import { Request } from '../http/Request.js';
|
|
11
12
|
import { Response } from '../http/Response.js';
|
|
12
|
-
import * as fs from '../node-singletons/fs.js';
|
|
13
13
|
import * as http from '../node-singletons/http.js';
|
|
14
|
-
import
|
|
15
|
-
import { Router } from '../routing/Router.js';
|
|
16
|
-
const MIME_TYPES_MAP = {
|
|
17
|
-
'.html': MIME_TYPES.HTML,
|
|
18
|
-
'.js': MIME_TYPES.JS,
|
|
19
|
-
'.css': MIME_TYPES.CSS,
|
|
20
|
-
'.json': MIME_TYPES.JSON,
|
|
21
|
-
'.png': MIME_TYPES.PNG,
|
|
22
|
-
'.jpg': MIME_TYPES.JPG,
|
|
23
|
-
'.gif': MIME_TYPES.GIF,
|
|
24
|
-
'.svg': MIME_TYPES.SVG,
|
|
25
|
-
'.wav': MIME_TYPES.WAV,
|
|
26
|
-
'.mp4': MIME_TYPES.MP4,
|
|
27
|
-
'.woff': MIME_TYPES.WOFF,
|
|
28
|
-
'.ttf': MIME_TYPES.TTF,
|
|
29
|
-
'.eot': MIME_TYPES.EOT,
|
|
30
|
-
'.otf': MIME_TYPES.OTF,
|
|
31
|
-
'.wasm': MIME_TYPES.WASM,
|
|
32
|
-
};
|
|
33
|
-
const findPackageRoot = (startDir) => {
|
|
34
|
-
let current = startDir;
|
|
35
|
-
for (let i = 0; i < 10; i++) {
|
|
36
|
-
if (fs.existsSync(path.join(current, 'package.json')))
|
|
37
|
-
return current;
|
|
38
|
-
const parent = path.dirname(current);
|
|
39
|
-
if (parent === current)
|
|
40
|
-
break;
|
|
41
|
-
current = parent;
|
|
42
|
-
}
|
|
43
|
-
return startDir;
|
|
44
|
-
};
|
|
45
|
-
const getFrameworkPublicRoots = () => {
|
|
46
|
-
const thisDir = esmDirname(import.meta.url);
|
|
47
|
-
const packageRoot = findPackageRoot(thisDir);
|
|
48
|
-
return [
|
|
49
|
-
path.join(packageRoot, 'dist/public'),
|
|
50
|
-
path.join(packageRoot, 'public'), // Fallback for shipped package
|
|
51
|
-
];
|
|
52
|
-
};
|
|
53
|
-
const getDocsPublicRoot = () => {
|
|
54
|
-
// First try app-local roots (developer app override), then fall back to framework-shipped assets.
|
|
55
|
-
const appRoots = [path.join(process.cwd(), 'public')];
|
|
56
|
-
const candidates = [...appRoots, ...getFrameworkPublicRoots()];
|
|
57
|
-
const hasDocsEntrypoint = (root) => {
|
|
58
|
-
const directIndex = path.join(root, 'index.html');
|
|
59
|
-
return fs.existsSync(directIndex);
|
|
60
|
-
};
|
|
61
|
-
// Prefer a root that actually contains docs assets.
|
|
62
|
-
for (const candidate of candidates) {
|
|
63
|
-
if (fs.existsSync(candidate) && hasDocsEntrypoint(candidate))
|
|
64
|
-
return candidate;
|
|
65
|
-
}
|
|
66
|
-
// Fall back to the first existing directory.
|
|
67
|
-
for (const candidate of candidates) {
|
|
68
|
-
if (fs.existsSync(candidate))
|
|
69
|
-
return candidate;
|
|
70
|
-
}
|
|
71
|
-
return candidates[0];
|
|
72
|
-
};
|
|
73
|
-
/**
|
|
74
|
-
* Map URL path to physical file path
|
|
75
|
-
*/
|
|
76
|
-
const mapStaticPath = (urlPath) => {
|
|
77
|
-
const publicRoot = getDocsPublicRoot();
|
|
78
|
-
const normalize = (p) => (p.startsWith('/') ? p.slice(1) : p);
|
|
79
|
-
// /doc acts as a mount for the docs/static site.
|
|
80
|
-
if (urlPath === '/doc' || urlPath === '/doc/')
|
|
81
|
-
return publicRoot;
|
|
82
|
-
if (urlPath.startsWith('/doc/'))
|
|
83
|
-
return path.join(publicRoot, normalize(urlPath.slice('/doc/'.length)));
|
|
84
|
-
// Also serve app-local static files from the same public root.
|
|
85
|
-
return path.join(publicRoot, normalize(urlPath));
|
|
86
|
-
};
|
|
87
|
-
/**
|
|
88
|
-
* Send static file to response
|
|
89
|
-
*/
|
|
90
|
-
const sendStaticFile = (filePath, response) => {
|
|
91
|
-
const ext = path.extname(filePath).toLowerCase();
|
|
92
|
-
const contentType = MIME_TYPES_MAP[ext] || 'application/octet-stream';
|
|
93
|
-
const content = fs.readFileSync(filePath);
|
|
94
|
-
response.setStatus(200);
|
|
95
|
-
response.setHeader('Content-Type', contentType);
|
|
96
|
-
response.send(content);
|
|
97
|
-
};
|
|
98
|
-
/**
|
|
99
|
-
* Serve static files from docs-website
|
|
100
|
-
*/
|
|
101
|
-
// eslint-disable-next-line @typescript-eslint/require-await
|
|
102
|
-
const serveStatic = async (request, response) => {
|
|
103
|
-
const urlPath = request.getPath();
|
|
104
|
-
let filePath = mapStaticPath(urlPath);
|
|
105
|
-
if (!filePath)
|
|
106
|
-
return false;
|
|
107
|
-
try {
|
|
108
|
-
// If it's a directory, look for index.html
|
|
109
|
-
if (fs.existsSync(filePath) && fs.statSync(filePath).isDirectory()) {
|
|
110
|
-
filePath = path.join(filePath, 'index.html');
|
|
111
|
-
}
|
|
112
|
-
// Handle clean URLs (try adding .html)
|
|
113
|
-
if (!fs.existsSync(filePath) && !path.extname(filePath)) {
|
|
114
|
-
const htmlPath = `${filePath}.html`;
|
|
115
|
-
if (fs.existsSync(htmlPath)) {
|
|
116
|
-
filePath = htmlPath;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
if (fs.existsSync(filePath)) {
|
|
120
|
-
sendStaticFile(filePath, response);
|
|
121
|
-
return true;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
catch (error) {
|
|
125
|
-
ErrorFactory.createTryCatchError(`Error serving static file ${filePath}`, error);
|
|
126
|
-
}
|
|
127
|
-
return false;
|
|
128
|
-
};
|
|
14
|
+
import { ErrorRouting } from '../routing/error.js';
|
|
129
15
|
/**
|
|
130
16
|
* Set security headers on response
|
|
131
17
|
*/
|
|
132
|
-
const getContentSecurityPolicyForPath = (
|
|
133
|
-
// Default CSP for the API/framework
|
|
134
|
-
|
|
18
|
+
const getContentSecurityPolicyForPath = () => {
|
|
19
|
+
// Default CSP for the API/framework
|
|
20
|
+
return ("default-src 'self'; " +
|
|
135
21
|
"script-src 'self' 'unsafe-inline'; " +
|
|
136
22
|
"style-src 'self' 'unsafe-inline'; " +
|
|
137
23
|
"img-src 'self' data:; " +
|
|
138
|
-
"font-src 'self';";
|
|
139
|
-
// Docs pages intentionally load external assets (Tailwind CDN + Google Fonts).
|
|
140
|
-
// Keep this relaxation scoped to the docs base path.
|
|
141
|
-
if (!requestPath.startsWith('/doc'))
|
|
142
|
-
return baseCsp;
|
|
143
|
-
return ("default-src 'self'; " +
|
|
144
|
-
"script-src 'self' 'unsafe-inline' 'unsafe-eval' https://cdn.tailwindcss.com; " +
|
|
145
|
-
"script-src-elem 'self' 'unsafe-inline' https://cdn.tailwindcss.com; " +
|
|
146
|
-
"style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; " +
|
|
147
|
-
"style-src-elem 'self' 'unsafe-inline' https://fonts.googleapis.com; " +
|
|
148
|
-
"img-src 'self' data: https:; " +
|
|
149
|
-
"font-src 'self' data: https://fonts.gstatic.com;");
|
|
24
|
+
"font-src 'self';");
|
|
150
25
|
};
|
|
151
|
-
const setSecurityHeaders = (res
|
|
26
|
+
const setSecurityHeaders = (res) => {
|
|
152
27
|
res.setHeader(HTTP_HEADERS.X_POWERED_BY, 'ZinTrust');
|
|
153
28
|
res.setHeader(HTTP_HEADERS.X_CONTENT_TYPE_OPTIONS, 'nosniff');
|
|
154
29
|
res.setHeader(HTTP_HEADERS.X_FRAME_OPTIONS, 'DENY');
|
|
155
30
|
res.setHeader(HTTP_HEADERS.X_XSS_PROTECTION, '1; mode=block');
|
|
156
31
|
res.setHeader(HTTP_HEADERS.REFERRER_POLICY, 'strict-origin-when-cross-origin');
|
|
157
|
-
res.setHeader(HTTP_HEADERS.CONTENT_SECURITY_POLICY, getContentSecurityPolicyForPath(
|
|
32
|
+
res.setHeader(HTTP_HEADERS.CONTENT_SECURITY_POLICY, getContentSecurityPolicyForPath());
|
|
158
33
|
};
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
const handleRequest = async (app, req, res) => {
|
|
34
|
+
const handleRequest = async (params, req, res) => {
|
|
35
|
+
let request;
|
|
36
|
+
let response;
|
|
163
37
|
try {
|
|
164
|
-
|
|
165
|
-
const requestPath = typeof req?.url === 'string' ? req.url : '/';
|
|
166
|
-
setSecurityHeaders(res, requestPath);
|
|
38
|
+
setSecurityHeaders(res);
|
|
167
39
|
if (!req) {
|
|
168
40
|
throw ErrorFactory.createConnectionError('Request object is missing');
|
|
169
41
|
}
|
|
170
|
-
const
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
if (route === null) {
|
|
176
|
-
// Try serving static files from docs-website
|
|
177
|
-
if (await serveStatic(request, response)) {
|
|
178
|
-
return;
|
|
179
|
-
}
|
|
180
|
-
// 404 Not Found
|
|
181
|
-
response.setStatus(404).json({ message: 'Not Found' });
|
|
182
|
-
}
|
|
183
|
-
else {
|
|
184
|
-
// Handler found, execute route handler
|
|
185
|
-
request.setParams(route.params);
|
|
186
|
-
await route.handler(request, response);
|
|
187
|
-
}
|
|
42
|
+
const kernel = params.getKernel();
|
|
43
|
+
request = Request.create(req);
|
|
44
|
+
response = Response.create(res);
|
|
45
|
+
// Delegate request lifecycle to Kernel (routing + middleware + handler execution).
|
|
46
|
+
await kernel.handleRequest(request, response);
|
|
188
47
|
}
|
|
189
48
|
catch (error) {
|
|
190
49
|
ErrorFactory.createTryCatchError('Server error:', error);
|
|
191
|
-
|
|
192
|
-
|
|
50
|
+
// Prefer wrapper-based error handling when available.
|
|
51
|
+
if (request !== undefined && response !== undefined) {
|
|
52
|
+
ErrorRouting.handleInternalServerErrorWithWrappers(request, response, error);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
ErrorRouting.handleInternalServerErrorRaw(res);
|
|
193
56
|
}
|
|
194
57
|
};
|
|
195
58
|
/**
|
|
@@ -200,10 +63,21 @@ export const Server = Object.freeze({
|
|
|
200
63
|
/**
|
|
201
64
|
* Create a new server instance
|
|
202
65
|
*/
|
|
203
|
-
create(app, port, host) {
|
|
66
|
+
create(app, port, host, kernel = null) {
|
|
204
67
|
const serverPort = port ?? appConfig.port;
|
|
205
68
|
const serverHost = host ?? appConfig.host;
|
|
206
|
-
|
|
69
|
+
let kernelInstance = kernel;
|
|
70
|
+
const getKernel = () => {
|
|
71
|
+
if (kernelInstance !== null)
|
|
72
|
+
return kernelInstance;
|
|
73
|
+
const anyApp = app;
|
|
74
|
+
const container = typeof anyApp.getContainer === 'function'
|
|
75
|
+
? anyApp.getContainer()
|
|
76
|
+
: ServiceContainer.create();
|
|
77
|
+
kernelInstance = Kernel.create(app.getRouter(), container);
|
|
78
|
+
return kernelInstance;
|
|
79
|
+
};
|
|
80
|
+
const httpServer = http.createServer(async (req, res) => handleRequest({ getKernel }, req, res));
|
|
207
81
|
const sockets = new Set();
|
|
208
82
|
httpServer.on('connection', (socket) => {
|
|
209
83
|
sockets.add(socket);
|
|
@@ -220,7 +94,7 @@ export const Server = Object.freeze({
|
|
|
220
94
|
async close() {
|
|
221
95
|
return new Promise((resolve) => {
|
|
222
96
|
httpServer.close(() => {
|
|
223
|
-
Logger.info('
|
|
97
|
+
Logger.info('ZinTrust server stopped');
|
|
224
98
|
resolve();
|
|
225
99
|
});
|
|
226
100
|
// Ensure keep-alive / hanging connections don't block shutdown
|
package/src/boot/bootstrap.js
CHANGED
|
@@ -126,7 +126,7 @@ const BootstrapFunctions = Object.freeze({
|
|
|
126
126
|
// Boot application
|
|
127
127
|
await app.boot();
|
|
128
128
|
// Get port and host from environment
|
|
129
|
-
const port = Env.getInt('PORT',
|
|
129
|
+
const port = Env.getInt('PORT', 7777);
|
|
130
130
|
const host = Env.get('HOST', 'localhost');
|
|
131
131
|
// Create and start server
|
|
132
132
|
const server = Server.create(app, port, host);
|
package/src/cache/Cache.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Central cache management and driver resolution
|
|
4
4
|
* Sealed namespace pattern - all exports through Cache namespace
|
|
5
5
|
*/
|
|
6
|
-
import { CacheDriver } from './CacheDriver';
|
|
6
|
+
import type { CacheDriver } from './CacheDriver';
|
|
7
7
|
type CacheStore = Readonly<{
|
|
8
8
|
get: <T>(key: string) => Promise<T | null>;
|
|
9
9
|
set: <T>(key: string, value: T, ttl?: number) => Promise<void>;
|