@zintrust/core 0.1.19 → 0.1.21
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 +3 -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 +66 -13
- 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 +2 -0
- 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 +324 -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 +229 -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 +76 -26
- 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/ModelGenerator.js +1 -1
- 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 +28 -7
- 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 +14 -28
- package/src/config/broadcast.d.ts.map +1 -1
- package/src/config/broadcast.js +69 -35
- package/src/config/cache.d.ts +13 -45
- package/src/config/cache.d.ts.map +1 -1
- package/src/config/cache.js +69 -25
- package/src/config/cloudflare.d.ts +1 -1
- package/src/config/cloudflare.d.ts.map +1 -1
- package/src/config/database.d.ts +22 -64
- package/src/config/database.d.ts.map +1 -1
- package/src/config/database.js +191 -37
- package/src/config/env.d.ts +12 -0
- package/src/config/env.d.ts.map +1 -1
- package/src/config/env.js +14 -0
- package/src/config/index.d.ts +33 -137
- 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/mail.d.ts +19 -55
- package/src/config/mail.d.ts.map +1 -1
- package/src/config/mail.js +63 -21
- package/src/config/middleware.d.ts +44 -1
- package/src/config/middleware.d.ts.map +1 -1
- package/src/config/middleware.js +157 -5
- package/src/config/notification.d.ts +14 -27
- package/src/config/notification.d.ts.map +1 -1
- package/src/config/notification.js +82 -36
- package/src/config/queue.d.ts +21 -51
- package/src/config/queue.d.ts.map +1 -1
- package/src/config/queue.js +72 -27
- package/src/config/security.d.ts +1 -1
- package/src/config/security.js +1 -1
- package/src/config/storage.d.ts +27 -34
- package/src/config/storage.d.ts.map +1 -1
- package/src/config/storage.js +97 -56
- package/src/config/type.d.ts +13 -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 +156 -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 +73 -12
- package/src/index.d.ts.map +1 -1
- package/src/index.js +60 -5
- package/src/microservices/PostgresAdapter.d.ts.map +1 -1
- package/src/microservices/PostgresAdapter.js +0 -1
- 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 +339 -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 +5 -2
- package/src/orm/Database.d.ts.map +1 -1
- package/src/orm/Database.js +219 -63
- package/src/orm/DatabaseAdapter.d.ts +14 -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 +12 -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 +406 -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 +59 -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 +7 -6
- package/src/performance/Optimizer.d.ts.map +1 -1
- package/src/performance/Optimizer.js +170 -55
- 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 +27 -0
- package/src/routing/doc.d.ts.map +1 -0
- package/src/routing/doc.js +110 -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 +27 -0
- package/src/routing/publicRoot.d.ts.map +1 -0
- package/src/routing/publicRoot.js +110 -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/StartupConfigFileRegistry.d.ts +20 -0
- package/src/runtime/StartupConfigFileRegistry.d.ts.map +1 -0
- package/src/runtime/StartupConfigFileRegistry.js +44 -0
- 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/runtime/useFileLoader.d.ts +26 -0
- package/src/runtime/useFileLoader.d.ts.map +1 -0
- package/src/runtime/useFileLoader.js +188 -0
- package/src/scripts/TemplateImportsCheck.js +40 -0
- package/src/scripts/TemplateSync.js +90 -24
- 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/security/XssProtection.d.ts.map +1 -1
- package/src/security/XssProtection.js +62 -14
- 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 +29 -126
- package/src/templates/project/basic/config/cache.ts.tpl +12 -70
- 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 +66 -123
- 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/logging/HttpLogger.ts.tpl +7 -114
- package/src/templates/project/basic/config/mail.ts.tpl +9 -62
- 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 +13 -114
- package/src/templates/project/basic/config/queue.ts.tpl +9 -40
- 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 +57 -137
- package/src/templates/project/basic/config/type.ts.tpl +32 -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/src/index.ts.tpl +3 -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/config/logging/KvLogger.ts.tpl +0 -181
- package/src/templates/project/basic/config/logging/SlackLogger.ts.tpl +0 -156
- package/src/templates/project/basic/database/migrations/index.ts.tpl +0 -2
|
@@ -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;
|
|
@@ -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;AAUxD,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;AAyYD;;GAEG;AACH,eAAO,MAAM,WAAW;IACtB;;OAEG;sBACe,MAAM,GAAG,YAAY;EA0CvC,CAAC;AAEH,eAAe,WAAW,CAAC"}
|
package/src/boot/Application.js
CHANGED
|
@@ -7,6 +7,7 @@ import { ServiceContainer } from '../container/ServiceContainer.js';
|
|
|
7
7
|
import { StartupHealthChecks } from '../health/StartupHealthChecks.js';
|
|
8
8
|
import { MiddlewareStack } from '../middleware/MiddlewareStack.js';
|
|
9
9
|
import { Router } from '../routing/Router.js';
|
|
10
|
+
import { StartupConfigFile, StartupConfigFileRegistry } from '../runtime/StartupConfigFileRegistry.js';
|
|
10
11
|
import broadcastConfig from '../config/broadcast.js';
|
|
11
12
|
import { FeatureFlags } from '../config/features.js';
|
|
12
13
|
import { Logger } from '../config/logger.js';
|
|
@@ -88,6 +89,16 @@ const registerFrameworkShutdownHooks = (shutdownManager) => {
|
|
|
88
89
|
/* ignore import failures in restrictive runtimes */
|
|
89
90
|
});
|
|
90
91
|
/* c8 ignore stop */
|
|
92
|
+
// Flush file logging streams
|
|
93
|
+
import('../config/FileLogWriter.js')
|
|
94
|
+
.then((mod) => {
|
|
95
|
+
shutdownManager.add(() => mod.FileLogWriter.flush());
|
|
96
|
+
})
|
|
97
|
+
/* c8 ignore start */
|
|
98
|
+
.catch(() => {
|
|
99
|
+
/* ignore import failures in restrictive runtimes */
|
|
100
|
+
});
|
|
101
|
+
/* c8 ignore stop */
|
|
91
102
|
import('../tools/broadcast/BroadcastRegistry.js')
|
|
92
103
|
.then((mod) => {
|
|
93
104
|
shutdownManager.add(() => mod.BroadcastRegistry.reset());
|
|
@@ -162,10 +173,15 @@ const registerRoutes = async (resolvedBasePath, router) => {
|
|
|
162
173
|
const mod = await tryImportRoutesFromAppBase(resolvedBasePath);
|
|
163
174
|
if (typeof mod?.registerRoutes === 'function') {
|
|
164
175
|
mod.registerRoutes(router);
|
|
165
|
-
return;
|
|
166
176
|
}
|
|
167
|
-
|
|
168
|
-
|
|
177
|
+
else {
|
|
178
|
+
const { registerRoutes: registerFrameworkRoutes } = await import('../routes/api.js');
|
|
179
|
+
registerFrameworkRoutes(router);
|
|
180
|
+
}
|
|
181
|
+
// Always register core framework routes (health, metrics, doc) after app routes
|
|
182
|
+
// This ensures app can override but core routes always exist
|
|
183
|
+
const { registerCoreRoutes } = await import('../routing/CoreRoutes.js');
|
|
184
|
+
registerCoreRoutes(router);
|
|
169
185
|
}
|
|
170
186
|
catch (error) {
|
|
171
187
|
Logger.error('Failed to register routes:', error);
|
|
@@ -205,21 +221,47 @@ const tryImportOptional = async (modulePath) => {
|
|
|
205
221
|
return undefined;
|
|
206
222
|
}
|
|
207
223
|
};
|
|
208
|
-
const
|
|
209
|
-
|
|
224
|
+
const isCompiledJsModule = () => {
|
|
225
|
+
// When running from dist, this module is compiled to .js and Node ESM resolution
|
|
226
|
+
// requires explicit file extensions for relative imports.
|
|
227
|
+
return import.meta.url.endsWith('.js');
|
|
228
|
+
};
|
|
229
|
+
const dbLoader = async () => {
|
|
230
|
+
const db = await tryImportOptional(isCompiledJsModule()
|
|
231
|
+
? '../orm/DatabaseRuntimeRegistration.js'
|
|
232
|
+
: '../orm/DatabaseRuntimeRegistration');
|
|
210
233
|
db?.registerDatabasesFromRuntimeConfig?.(databaseConfig);
|
|
211
|
-
|
|
234
|
+
};
|
|
235
|
+
const queuesLoader = async () => {
|
|
236
|
+
const queues = await tryImportOptional(isCompiledJsModule()
|
|
237
|
+
? '../tools/queue/QueueRuntimeRegistration.js'
|
|
238
|
+
: '../tools/queue/QueueRuntimeRegistration');
|
|
212
239
|
queues?.registerQueuesFromRuntimeConfig?.(queueConfig);
|
|
213
|
-
|
|
240
|
+
};
|
|
241
|
+
const cachesLoader = async () => {
|
|
242
|
+
const caches = await tryImportOptional(isCompiledJsModule()
|
|
243
|
+
? '../cache/CacheRuntimeRegistration.js'
|
|
244
|
+
: '../cache/CacheRuntimeRegistration');
|
|
214
245
|
caches?.registerCachesFromRuntimeConfig?.(cacheConfig);
|
|
215
|
-
|
|
246
|
+
};
|
|
247
|
+
const registerFromRuntimeConfig = async () => {
|
|
248
|
+
await dbLoader();
|
|
249
|
+
await queuesLoader();
|
|
250
|
+
await cachesLoader();
|
|
251
|
+
const broadcasters = await tryImportOptional(isCompiledJsModule()
|
|
252
|
+
? '../tools/broadcast/BroadcastRuntimeRegistration.js'
|
|
253
|
+
: '../tools/broadcast/BroadcastRuntimeRegistration');
|
|
216
254
|
broadcasters?.registerBroadcastersFromRuntimeConfig?.({
|
|
217
255
|
default: broadcastConfig.default,
|
|
218
256
|
drivers: broadcastConfig.drivers,
|
|
219
257
|
});
|
|
220
|
-
const disks = await tryImportOptional(
|
|
258
|
+
const disks = await tryImportOptional(isCompiledJsModule()
|
|
259
|
+
? '../tools/storage/StorageRuntimeRegistration.js'
|
|
260
|
+
: '../tools/storage/StorageRuntimeRegistration');
|
|
221
261
|
disks?.registerDisksFromRuntimeConfig?.(storageConfig);
|
|
222
|
-
const notifications = await tryImportOptional(
|
|
262
|
+
const notifications = await tryImportOptional(isCompiledJsModule()
|
|
263
|
+
? '../tools/notification/NotificationRuntimeRegistration.js'
|
|
264
|
+
: '../tools/notification/NotificationRuntimeRegistration');
|
|
223
265
|
notifications?.registerNotificationChannelsFromRuntimeConfig?.({
|
|
224
266
|
default: notificationConfig.default,
|
|
225
267
|
drivers: notificationConfig.drivers,
|
|
@@ -231,6 +273,17 @@ const createLifecycle = (params) => {
|
|
|
231
273
|
return;
|
|
232
274
|
Logger.info(`🚀 Booting Zintrust Application in ${params.environment} mode...`);
|
|
233
275
|
StartupConfigValidator.assertValid();
|
|
276
|
+
// Preload project-owned config overrides that must be available synchronously.
|
|
277
|
+
await StartupConfigFileRegistry.preload([
|
|
278
|
+
StartupConfigFile.Middleware,
|
|
279
|
+
StartupConfigFile.Cache,
|
|
280
|
+
StartupConfigFile.Database,
|
|
281
|
+
StartupConfigFile.Queue,
|
|
282
|
+
StartupConfigFile.Storage,
|
|
283
|
+
StartupConfigFile.Mail,
|
|
284
|
+
StartupConfigFile.Broadcast,
|
|
285
|
+
StartupConfigFile.Notification,
|
|
286
|
+
]);
|
|
234
287
|
FeatureFlags.initialize();
|
|
235
288
|
await StartupHealthChecks.assertHealthy();
|
|
236
289
|
await registerFromRuntimeConfig();
|
|
@@ -287,9 +340,9 @@ export const Application = Object.freeze({
|
|
|
287
340
|
boot,
|
|
288
341
|
shutdown,
|
|
289
342
|
isBooted: () => booted,
|
|
290
|
-
isDevelopment: () =>
|
|
291
|
-
isProduction: () =>
|
|
292
|
-
isTesting: () =>
|
|
343
|
+
isDevelopment: () => appConfig.isDevelopment(),
|
|
344
|
+
isProduction: () => appConfig.isProduction(),
|
|
345
|
+
isTesting: () => appConfig.isTesting(),
|
|
293
346
|
getEnvironment: () => environment,
|
|
294
347
|
getRouter: () => router,
|
|
295
348
|
getContainer: () => container,
|
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
|
@@ -8,6 +8,8 @@ import { Server } from './Server.js';
|
|
|
8
8
|
import { Env } from '../config/env.js';
|
|
9
9
|
import { Logger } from '../config/logger.js';
|
|
10
10
|
import { ErrorFactory } from '../exceptions/ZintrustError.js';
|
|
11
|
+
// Register plugins (adapters, drivers, etc.)
|
|
12
|
+
// import '@/zintrust.plugins';
|
|
11
13
|
let appInstance;
|
|
12
14
|
let serverInstance;
|
|
13
15
|
let isShuttingDown = false;
|
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>;
|
package/src/cache/Cache.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Cache.d.ts","sourceRoot":"","sources":["../../../src/cache/Cache.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"Cache.d.ts","sourceRoot":"","sources":["../../../src/cache/Cache.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAmHtD,KAAK,UAAU,GAAG,QAAQ,CAAC;IACzB,GAAG,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;IAC3C,GAAG,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/D,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACvC,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3B,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACvC,SAAS,EAAE,MAAM,WAAW,CAAC;CAC9B,CAAC,CAAC;AA0CH,eAAO,MAAM,KAAK;UA1FC,CAAC,OAAO,MAAM,KAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;UAQlC,CAAC,OAAO,MAAM,SAAS,CAAC,QAAQ,MAAM,KAAG,OAAO,CAAC,IAAI,CAAC;kBAOjD,MAAM,KAAG,OAAO,CAAC,IAAI,CAAC;iBAOtB,OAAO,CAAC,IAAI,CAAC;eAOb,MAAM,KAAG,OAAO,CAAC,OAAO,CAAC;qBAQ3B,WAAW;mBAaX,MAAM,KAAG,UAAU;iBAmCvB,IAAI;EAcpB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,KAAK;UAxGC,CAAC,OAAO,MAAM,KAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;UAQlC,CAAC,OAAO,MAAM,SAAS,CAAC,QAAQ,MAAM,KAAG,OAAO,CAAC,IAAI,CAAC;kBAOjD,MAAM,KAAG,OAAO,CAAC,IAAI,CAAC;iBAOtB,OAAO,CAAC,IAAI,CAAC;eAOb,MAAM,KAAG,OAAO,CAAC,OAAO,CAAC;qBAQ3B,WAAW;mBAaX,MAAM,KAAG,UAAU;iBAmCvB,IAAI;EAmBI,CAAC"}
|
|
@@ -23,6 +23,10 @@ export interface CacheDriver {
|
|
|
23
23
|
* Check if an item exists in the cache
|
|
24
24
|
*/
|
|
25
25
|
has(key: string): Promise<boolean>;
|
|
26
|
+
/**
|
|
27
|
+
* Dispose of resources (optional cleanup method)
|
|
28
|
+
*/
|
|
29
|
+
dispose?(): Promise<void>;
|
|
26
30
|
}
|
|
27
31
|
export declare const CACHE_DRIVER_INTERFACE = "CacheDriver";
|
|
28
32
|
//# sourceMappingURL=CacheDriver.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CacheDriver.d.ts","sourceRoot":"","sources":["../../../src/cache/CacheDriver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;IAEvC;;OAEG;IACH,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE3D;;OAEG;IACH,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEnC;;OAEG;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAEvB;;OAEG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"CacheDriver.d.ts","sourceRoot":"","sources":["../../../src/cache/CacheDriver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;IAEvC;;OAEG;IACH,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE3D;;OAEG;IACH,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEnC;;OAEG;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAEvB;;OAEG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAEnC;;OAEG;IACH,OAAO,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3B;AAGD,eAAO,MAAM,sBAAsB,gBAAgB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KVDriver.d.ts","sourceRoot":"","sources":["../../../../src/cache/drivers/KVDriver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"KVDriver.d.ts","sourceRoot":"","sources":["../../../../src/cache/drivers/KVDriver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAoDtD;;GAEG;AACH,eAAO,MAAM,QAAQ;kBAhDF,WAAW;EAkD5B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MemoryDriver.d.ts","sourceRoot":"","sources":["../../../../src/cache/drivers/MemoryDriver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"MemoryDriver.d.ts","sourceRoot":"","sources":["../../../../src/cache/drivers/MemoryDriver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AA0EtD;;GAEG;AACH,eAAO,MAAM,YAAY;kBAtEN,WAAW;EAwE5B,CAAC"}
|
|
@@ -9,6 +9,17 @@
|
|
|
9
9
|
*/
|
|
10
10
|
const create = () => {
|
|
11
11
|
const storage = new Map();
|
|
12
|
+
// Background cleanup interval (runs every 60 seconds)
|
|
13
|
+
const cleanupInterval = setInterval(() => {
|
|
14
|
+
const now = Date.now();
|
|
15
|
+
for (const [key, item] of storage.entries()) {
|
|
16
|
+
if (item.expires !== null && item.expires < now) {
|
|
17
|
+
storage.delete(key);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}, 60_000); // 60 seconds
|
|
21
|
+
// Unref so it doesn't keep process alive
|
|
22
|
+
cleanupInterval.unref();
|
|
12
23
|
return {
|
|
13
24
|
async get(key) {
|
|
14
25
|
await Promise.resolve();
|
|
@@ -45,6 +56,11 @@ const create = () => {
|
|
|
45
56
|
}
|
|
46
57
|
return true;
|
|
47
58
|
},
|
|
59
|
+
async dispose() {
|
|
60
|
+
clearInterval(cleanupInterval);
|
|
61
|
+
storage.clear();
|
|
62
|
+
await Promise.resolve();
|
|
63
|
+
},
|
|
48
64
|
};
|
|
49
65
|
};
|
|
50
66
|
/**
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* MongoDB Cache Driver
|
|
3
3
|
* Uses MongoDB Atlas Data API (HTTPS) for zero-dependency integration
|
|
4
4
|
*/
|
|
5
|
-
import { CacheDriver } from '../CacheDriver';
|
|
5
|
+
import type { CacheDriver } from '../CacheDriver';
|
|
6
6
|
/**
|
|
7
7
|
* MongoDB Cache Driver
|
|
8
8
|
* Uses MongoDB Atlas Data API (HTTPS) for zero-dependency integration
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MongoDriver.d.ts","sourceRoot":"","sources":["../../../../src/cache/drivers/MongoDriver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"MongoDriver.d.ts","sourceRoot":"","sources":["../../../../src/cache/drivers/MongoDriver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAKtD;;;;GAIG;AACH,eAAO,MAAM,WAAW;IACtB;;OAEG;cACO,WAAW;EA4ErB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RedisDriver.d.ts","sourceRoot":"","sources":["../../../../src/cache/drivers/RedisDriver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AA+
|
|
1
|
+
{"version":3,"file":"RedisDriver.d.ts","sourceRoot":"","sources":["../../../../src/cache/drivers/RedisDriver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AA+EtD;;GAEG;AACH,eAAO,MAAM,WAAW;kBA1EL,WAAW;EA4E5B,CAAC"}
|
package/src/cli/CLI.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CLI.d.ts","sourceRoot":"","sources":["../../../src/cli/CLI.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"CLI.d.ts","sourceRoot":"","sources":["../../../src/cli/CLI.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAqCH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC,MAAM,WAAW,IAAI;IACnB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACnC,UAAU,IAAI,OAAO,CAAC;CACvB;AA2LD;;;;;;;GAOG;AACH,eAAO,MAAM,GAAG;cACJ,IAAI;EAed,CAAC"}
|