@zintrust/core 0.1.39 → 0.1.41
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/bin/zintrust-main.d.ts.map +1 -1
- package/bin/zintrust-main.js +22 -1
- package/package.json +8 -4
- package/public/error-pages/404.html +2 -2
- package/src/auth/Auth.js +1 -1
- package/src/boot/Application.d.ts +1 -16
- package/src/boot/Application.d.ts.map +1 -1
- package/src/boot/Application.js +2 -262
- package/src/boot/Server.d.ts +1 -1
- package/src/boot/Server.d.ts.map +1 -1
- package/src/boot/bootstrap.js +23 -9
- package/src/boot/registry/registerRoute.d.ts +6 -0
- package/src/boot/registry/registerRoute.d.ts.map +1 -0
- package/src/boot/registry/registerRoute.js +96 -0
- package/src/boot/registry/runtime.d.ts +15 -0
- package/src/boot/registry/runtime.d.ts.map +1 -0
- package/src/boot/registry/runtime.js +353 -0
- package/src/boot/registry/type.d.ts +25 -0
- package/src/boot/registry/type.d.ts.map +1 -0
- package/src/boot/registry/type.js +1 -0
- package/src/boot/registry/worker.d.ts +6 -0
- package/src/boot/registry/worker.d.ts.map +1 -0
- package/src/boot/registry/worker.js +35 -0
- package/src/cache/drivers/KVRemoteDriver.d.ts.map +1 -1
- package/src/cache/drivers/KVRemoteDriver.js +14 -1
- package/src/cli/CLI.d.ts.map +1 -1
- package/src/cli/CLI.js +82 -34
- package/src/cli/ErrorHandler.js +1 -1
- package/src/cli/commands/ContainerProxiesCommand.d.ts +5 -0
- package/src/cli/commands/ContainerProxiesCommand.d.ts.map +1 -0
- package/src/cli/commands/ContainerProxiesCommand.js +77 -0
- package/src/cli/commands/ContainerWorkersCommand.d.ts +5 -0
- package/src/cli/commands/ContainerWorkersCommand.d.ts.map +1 -0
- package/src/cli/commands/ContainerWorkersCommand.js +57 -0
- package/src/cli/commands/DeployCommand.d.ts +16 -0
- package/src/cli/commands/DeployCommand.d.ts.map +1 -0
- package/src/cli/commands/DeployCommand.js +110 -0
- package/src/cli/commands/DeployContainerProxiesCommand.d.ts +5 -0
- package/src/cli/commands/DeployContainerProxiesCommand.d.ts.map +1 -0
- package/src/cli/commands/DeployContainerProxiesCommand.js +27 -0
- package/src/cli/commands/DeployContainerWorkersCommand.d.ts +5 -0
- package/src/cli/commands/DeployContainerWorkersCommand.d.ts.map +1 -0
- package/src/cli/commands/DeployContainerWorkersCommand.js +27 -0
- package/src/cli/commands/DockerComposeCommandUtils.d.ts +3 -0
- package/src/cli/commands/DockerComposeCommandUtils.d.ts.map +1 -0
- package/src/cli/commands/DockerComposeCommandUtils.js +34 -0
- package/src/cli/commands/DoctorArchitectureCommand.d.ts +5 -0
- package/src/cli/commands/DoctorArchitectureCommand.d.ts.map +1 -0
- package/src/cli/commands/DoctorArchitectureCommand.js +54 -0
- package/src/cli/commands/InitContainerCommand.d.ts +5 -0
- package/src/cli/commands/InitContainerCommand.d.ts.map +1 -0
- package/src/cli/commands/InitContainerCommand.js +216 -0
- package/src/cli/commands/InitProducerCommand.d.ts +5 -0
- package/src/cli/commands/InitProducerCommand.d.ts.map +1 -0
- package/src/cli/commands/InitProducerCommand.js +47 -0
- package/src/cli/commands/InitProxyCommand.d.ts +5 -0
- package/src/cli/commands/InitProxyCommand.d.ts.map +1 -0
- package/src/cli/commands/InitProxyCommand.js +442 -0
- package/src/cli/commands/MongoDBProxyCommand.d.ts +5 -0
- package/src/cli/commands/MongoDBProxyCommand.d.ts.map +1 -0
- package/src/cli/commands/MongoDBProxyCommand.js +98 -0
- package/src/cli/commands/MySqlProxyCommand.d.ts +6 -0
- package/src/cli/commands/MySqlProxyCommand.d.ts.map +1 -0
- package/src/cli/commands/MySqlProxyCommand.js +32 -0
- package/src/cli/commands/PostgresProxyCommand.d.ts +6 -0
- package/src/cli/commands/PostgresProxyCommand.d.ts.map +1 -0
- package/src/cli/commands/PostgresProxyCommand.js +32 -0
- package/src/cli/commands/ProxyCommand.d.ts +12 -0
- package/src/cli/commands/ProxyCommand.d.ts.map +1 -0
- package/src/cli/commands/ProxyCommand.js +80 -0
- package/src/cli/commands/ProxyCommandUtils.d.ts +6 -0
- package/src/cli/commands/ProxyCommandUtils.d.ts.map +1 -0
- package/src/cli/commands/ProxyCommandUtils.js +38 -0
- package/src/cli/commands/QueueRecoveryCommand.d.ts +6 -0
- package/src/cli/commands/QueueRecoveryCommand.d.ts.map +1 -0
- package/src/cli/commands/QueueRecoveryCommand.js +513 -0
- package/src/cli/commands/RedisProxyCommand.d.ts +6 -0
- package/src/cli/commands/RedisProxyCommand.d.ts.map +1 -0
- package/src/cli/commands/RedisProxyCommand.js +53 -0
- package/src/cli/commands/SmtpProxyCommand.d.ts +6 -0
- package/src/cli/commands/SmtpProxyCommand.d.ts.map +1 -0
- package/src/cli/commands/SmtpProxyCommand.js +56 -0
- package/src/cli/commands/SqlProxyCommandUtils.d.ts +46 -0
- package/src/cli/commands/SqlProxyCommandUtils.d.ts.map +1 -0
- package/src/cli/commands/SqlProxyCommandUtils.js +48 -0
- package/src/cli/commands/SqlServerProxyCommand.d.ts +5 -0
- package/src/cli/commands/SqlServerProxyCommand.d.ts.map +1 -0
- package/src/cli/commands/SqlServerProxyCommand.js +85 -0
- package/src/cli/commands/StartCommand.d.ts.map +1 -1
- package/src/cli/commands/StartCommand.js +145 -18
- package/src/cli/commands/WorkerCommands.d.ts +1 -0
- package/src/cli/commands/WorkerCommands.d.ts.map +1 -1
- package/src/cli/commands/WorkerCommands.js +140 -6
- package/src/cli/commands/index.d.ts +2 -0
- package/src/cli/commands/index.d.ts.map +1 -1
- package/src/cli/commands/index.js +2 -0
- package/src/cli/commands/runner/index.d.ts +2 -2
- package/src/cli/commands/runner/index.d.ts.map +1 -1
- package/src/cli/commands/runner/index.js +15 -4
- package/src/cli/d1/D1SqlMigrations.d.ts.map +1 -1
- package/src/cli/d1/D1SqlMigrations.js +3 -0
- package/src/cli/index.d.ts +4 -0
- package/src/cli/index.d.ts.map +1 -1
- package/src/cli/index.js +4 -0
- package/src/cli/scaffolding/ProjectScaffolder.d.ts.map +1 -1
- package/src/cli/scaffolding/ProjectScaffolder.js +2 -0
- package/src/cli/scaffolding/ServiceScaffolder.d.ts.map +1 -1
- package/src/cli/scaffolding/ServiceScaffolder.js +1 -0
- package/src/cli/utils/EnvFileLoader.d.ts +2 -1
- package/src/cli/utils/EnvFileLoader.d.ts.map +1 -1
- package/src/cli/utils/EnvFileLoader.js +22 -21
- package/src/cli/utils/spawn.d.ts.map +1 -1
- package/src/cli/utils/spawn.js +17 -10
- package/src/cli/workers/QueueWorkRunner.js +1 -1
- package/src/common/ExternalServiceUtils.d.ts.map +1 -1
- package/src/common/ExternalServiceUtils.js +7 -2
- package/src/common/HealthRoutes.d.ts.map +1 -1
- package/src/common/HealthRoutes.js +50 -2
- package/src/common/RemoteSignedJson.d.ts +1 -0
- package/src/common/RemoteSignedJson.d.ts.map +1 -1
- package/src/common/RemoteSignedJson.js +39 -13
- package/src/common/index.d.ts +1 -0
- package/src/common/index.d.ts.map +1 -1
- package/src/common/index.js +12 -1
- package/src/config/FileLogWriter.d.ts.map +1 -1
- package/src/config/FileLogWriter.js +21 -6
- package/src/config/app.d.ts +4 -0
- package/src/config/app.d.ts.map +1 -1
- package/src/config/app.js +4 -0
- package/src/config/cache.d.ts.map +1 -1
- package/src/config/cache.js +22 -2
- package/src/config/cloudflare.d.ts +5 -1
- package/src/config/cloudflare.d.ts.map +1 -1
- package/src/config/cloudflare.js +48 -0
- package/src/config/database.d.ts.map +1 -1
- package/src/config/database.js +48 -13
- package/src/config/env.d.ts +90 -2
- package/src/config/env.d.ts.map +1 -1
- package/src/config/env.js +160 -18
- package/src/config/index.d.ts +1 -0
- package/src/config/index.d.ts.map +1 -1
- package/src/config/logger.d.ts.map +1 -1
- package/src/config/logger.js +60 -16
- package/src/config/mail.d.ts.map +1 -1
- package/src/config/mail.js +16 -10
- package/src/config/middleware.d.ts +5 -0
- package/src/config/middleware.d.ts.map +1 -1
- package/src/config/middleware.js +19 -1
- package/src/config/queue.d.ts.map +1 -1
- package/src/config/queue.js +70 -9
- package/src/config/redis.d.ts.map +1 -1
- package/src/config/redis.js +48 -13
- package/src/config/storage.d.ts.map +1 -1
- package/src/config/storage.js +1 -0
- package/src/config/type.d.ts +19 -0
- package/src/config/type.d.ts.map +1 -1
- package/src/config/workers.d.ts.map +1 -1
- package/src/config/workers.js +122 -16
- package/src/functions/cloudflare.d.ts.map +1 -1
- package/src/functions/cloudflare.js +55 -1
- package/src/health/StartupHealthChecks.js +1 -1
- package/src/http/FileUpload.d.ts +3 -2
- package/src/http/FileUpload.d.ts.map +1 -1
- package/src/http/Kernel.d.ts.map +1 -1
- package/src/http/Kernel.js +2 -1
- package/src/http/error-pages/ErrorPageRenderer.d.ts +4 -0
- package/src/http/error-pages/ErrorPageRenderer.d.ts.map +1 -1
- package/src/http/error-pages/ErrorPageRenderer.js +141 -1
- package/src/http/middleware/BodyParsingMiddleware.d.ts.map +1 -1
- package/src/http/middleware/BodyParsingMiddleware.js +33 -6
- package/src/index.d.ts +25 -53
- package/src/index.d.ts.map +1 -1
- package/src/index.js +30 -14
- package/src/microservices/ServiceAuthMiddleware.d.ts.map +1 -1
- package/src/microservices/ServiceAuthMiddleware.js +12 -4
- package/src/middleware/CsrfMiddleware.d.ts.map +1 -1
- package/src/middleware/CsrfMiddleware.js +39 -10
- package/src/middleware/ErrorHandlerMiddleware.d.ts.map +1 -1
- package/src/middleware/ErrorHandlerMiddleware.js +2 -1
- package/src/migrations/MigrationLoader.js +1 -1
- package/src/migrations/schema/SchemaCompiler.d.ts.map +1 -1
- package/src/migrations/schema/SchemaCompiler.js +6 -3
- 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 +1 -1
- package/src/node-singletons/fs.d.ts.map +1 -1
- package/src/node-singletons/path.d.ts +1 -1
- package/src/node-singletons/path.d.ts.map +1 -1
- package/src/node-singletons/path.js +1 -1
- package/src/node-singletons/stream.d.ts +11 -0
- package/src/node-singletons/stream.d.ts.map +1 -0
- package/src/node-singletons/stream.js +8 -0
- package/src/observability/OpenTelemetry.d.ts +7 -0
- package/src/observability/OpenTelemetry.d.ts.map +1 -1
- package/src/observability/OpenTelemetry.js +49 -2
- package/src/orm/Database.d.ts +4 -0
- package/src/orm/Database.d.ts.map +1 -1
- package/src/orm/Database.js +80 -9
- package/src/orm/DatabaseRuntimeRegistration.d.ts.map +1 -1
- package/src/orm/DatabaseRuntimeRegistration.js +2 -0
- package/src/orm/QueryBuilder.d.ts +1 -0
- package/src/orm/QueryBuilder.d.ts.map +1 -1
- package/src/orm/QueryBuilder.js +33 -3
- package/src/orm/SchemaCompiler.d.ts.map +1 -1
- package/src/orm/SchemaCompiler.js +6 -3
- package/src/orm/adapters/D1RemoteAdapter.d.ts.map +1 -1
- package/src/orm/adapters/D1RemoteAdapter.js +14 -1
- package/src/orm/adapters/MongoDBProxyAdapter.d.ts +3 -0
- package/src/orm/adapters/MongoDBProxyAdapter.d.ts.map +1 -0
- package/src/orm/adapters/MongoDBProxyAdapter.js +128 -0
- package/src/orm/adapters/MySQLProxyAdapter.d.ts +11 -0
- package/src/orm/adapters/MySQLProxyAdapter.d.ts.map +1 -0
- package/src/orm/adapters/MySQLProxyAdapter.js +143 -0
- package/src/orm/adapters/PostgreSQLProxyAdapter.d.ts +11 -0
- package/src/orm/adapters/PostgreSQLProxyAdapter.d.ts.map +1 -0
- package/src/orm/adapters/PostgreSQLProxyAdapter.js +147 -0
- package/src/orm/adapters/ProxyCache.d.ts +9 -0
- package/src/orm/adapters/ProxyCache.d.ts.map +1 -0
- package/src/orm/adapters/ProxyCache.js +24 -0
- package/src/orm/adapters/ProxySignedRequest.d.ts +11 -0
- package/src/orm/adapters/ProxySignedRequest.d.ts.map +1 -0
- package/src/orm/adapters/ProxySignedRequest.js +30 -0
- package/src/orm/adapters/ProxySigningPath.d.ts +3 -0
- package/src/orm/adapters/ProxySigningPath.d.ts.map +1 -0
- package/src/orm/adapters/ProxySigningPath.js +25 -0
- package/src/orm/adapters/SqlProxyAdapterUtils.d.ts +19 -0
- package/src/orm/adapters/SqlProxyAdapterUtils.d.ts.map +1 -0
- package/src/orm/adapters/SqlProxyAdapterUtils.js +35 -0
- package/src/orm/adapters/SqlServerProxyAdapter.d.ts +3 -0
- package/src/orm/adapters/SqlServerProxyAdapter.d.ts.map +1 -0
- package/src/orm/adapters/SqlServerProxyAdapter.js +146 -0
- package/src/performance/Optimizer.d.ts +1 -0
- package/src/performance/Optimizer.d.ts.map +1 -1
- package/src/performance/Optimizer.js +21 -8
- package/src/proxy/ErrorHandler.d.ts +11 -0
- package/src/proxy/ErrorHandler.d.ts.map +1 -0
- package/src/proxy/ErrorHandler.js +7 -0
- package/src/proxy/PoolManager.d.ts +8 -0
- package/src/proxy/PoolManager.d.ts.map +1 -0
- package/src/proxy/PoolManager.js +18 -0
- package/src/proxy/ProxyBackend.d.ts +18 -0
- package/src/proxy/ProxyBackend.d.ts.map +1 -0
- package/src/proxy/ProxyBackend.js +1 -0
- package/src/proxy/ProxyConfig.d.ts +12 -0
- package/src/proxy/ProxyConfig.d.ts.map +1 -0
- package/src/proxy/ProxyConfig.js +1 -0
- package/src/proxy/ProxyRegistry.d.ts +10 -0
- package/src/proxy/ProxyRegistry.d.ts.map +1 -0
- package/src/proxy/ProxyRegistry.js +11 -0
- package/src/proxy/ProxyServer.d.ts +21 -0
- package/src/proxy/ProxyServer.d.ts.map +1 -0
- package/src/proxy/ProxyServer.js +84 -0
- package/src/proxy/ProxyServerUtils.d.ts +37 -0
- package/src/proxy/ProxyServerUtils.d.ts.map +1 -0
- package/src/proxy/ProxyServerUtils.js +42 -0
- package/src/proxy/ProxySigningConfigResolver.d.ts +22 -0
- package/src/proxy/ProxySigningConfigResolver.d.ts.map +1 -0
- package/src/proxy/ProxySigningConfigResolver.js +24 -0
- package/src/proxy/ProxySigningRequest.d.ts +12 -0
- package/src/proxy/ProxySigningRequest.d.ts.map +1 -0
- package/src/proxy/ProxySigningRequest.js +31 -0
- package/src/proxy/RequestValidator.d.ts +15 -0
- package/src/proxy/RequestValidator.d.ts.map +1 -0
- package/src/proxy/RequestValidator.js +25 -0
- package/src/proxy/SigningService.d.ts +39 -0
- package/src/proxy/SigningService.d.ts.map +1 -0
- package/src/proxy/SigningService.js +107 -0
- package/src/proxy/SqlPayloadValidator.d.ts +13 -0
- package/src/proxy/SqlPayloadValidator.d.ts.map +1 -0
- package/src/proxy/SqlPayloadValidator.js +14 -0
- package/src/proxy/d1/ZintrustD1Proxy.d.ts +2 -0
- package/src/proxy/d1/ZintrustD1Proxy.d.ts.map +1 -0
- package/src/proxy/d1/ZintrustD1Proxy.js +1 -0
- package/src/proxy/d1/register.d.ts +2 -0
- package/src/proxy/d1/register.d.ts.map +1 -0
- package/src/proxy/d1/register.js +5 -0
- package/src/proxy/kv/ZintrustKvProxy.d.ts +2 -0
- package/src/proxy/kv/ZintrustKvProxy.d.ts.map +1 -0
- package/src/proxy/kv/ZintrustKvProxy.js +1 -0
- package/src/proxy/kv/register.d.ts +2 -0
- package/src/proxy/kv/register.d.ts.map +1 -0
- package/src/proxy/kv/register.js +5 -0
- package/src/proxy/mongodb/MongoDBProxyServer.d.ts +33 -0
- package/src/proxy/mongodb/MongoDBProxyServer.d.ts.map +1 -0
- package/src/proxy/mongodb/MongoDBProxyServer.js +202 -0
- package/src/proxy/mongodb/register.d.ts +2 -0
- package/src/proxy/mongodb/register.d.ts.map +1 -0
- package/src/proxy/mongodb/register.js +5 -0
- package/src/proxy/mysql/MySqlProxyServer.d.ts +14 -0
- package/src/proxy/mysql/MySqlProxyServer.d.ts.map +1 -0
- package/src/proxy/mysql/MySqlProxyServer.js +169 -0
- package/src/proxy/mysql/register.d.ts +2 -0
- package/src/proxy/mysql/register.d.ts.map +1 -0
- package/src/proxy/mysql/register.js +5 -0
- package/src/proxy/postgres/PostgresProxyServer.d.ts +14 -0
- package/src/proxy/postgres/PostgresProxyServer.d.ts.map +1 -0
- package/src/proxy/postgres/PostgresProxyServer.js +140 -0
- package/src/proxy/postgres/register.d.ts +2 -0
- package/src/proxy/postgres/register.d.ts.map +1 -0
- package/src/proxy/postgres/register.js +5 -0
- package/src/proxy/redis/RedisProxyServer.d.ts +12 -0
- package/src/proxy/redis/RedisProxyServer.d.ts.map +1 -0
- package/src/proxy/redis/RedisProxyServer.js +192 -0
- package/src/proxy/redis/register.d.ts +2 -0
- package/src/proxy/redis/register.d.ts.map +1 -0
- package/src/proxy/redis/register.js +5 -0
- package/src/proxy/smtp/SmtpProxyServer.d.ts +19 -0
- package/src/proxy/smtp/SmtpProxyServer.d.ts.map +1 -0
- package/src/proxy/smtp/SmtpProxyServer.js +289 -0
- package/src/proxy/smtp/register.d.ts +2 -0
- package/src/proxy/smtp/register.d.ts.map +1 -0
- package/src/proxy/smtp/register.js +5 -0
- package/src/proxy/sqlserver/SqlServerProxyServer.d.ts +14 -0
- package/src/proxy/sqlserver/SqlServerProxyServer.d.ts.map +1 -0
- package/src/proxy/sqlserver/SqlServerProxyServer.js +168 -0
- package/src/proxy/sqlserver/register.d.ts +2 -0
- package/src/proxy/sqlserver/register.d.ts.map +1 -0
- package/src/proxy/sqlserver/register.js +5 -0
- package/src/routes/doc.d.ts.map +1 -1
- package/src/routes/doc.js +16 -2
- package/src/routes/error.d.ts +5 -4
- package/src/routes/error.d.ts.map +1 -1
- package/src/routes/error.js +15 -13
- package/src/routes/errorPages.d.ts +2 -0
- package/src/routes/errorPages.d.ts.map +1 -1
- package/src/routes/errorPages.js +144 -4
- package/src/runtime/PluginAutoImports.d.ts +1 -0
- package/src/runtime/PluginAutoImports.d.ts.map +1 -1
- package/src/runtime/PluginAutoImports.js +94 -9
- package/src/runtime/RuntimeAdapter.d.ts +8 -9
- package/src/runtime/RuntimeAdapter.d.ts.map +1 -1
- package/src/runtime/RuntimeAdapter.js +120 -34
- package/src/runtime/RuntimeServices.d.ts +47 -0
- package/src/runtime/RuntimeServices.d.ts.map +1 -0
- package/src/runtime/RuntimeServices.js +164 -0
- package/src/runtime/StartupConfigFileRegistry.d.ts +4 -4
- package/src/runtime/StartupConfigFileRegistry.d.ts.map +1 -1
- package/src/runtime/StartupConfigFileRegistry.js +12 -0
- package/src/runtime/WorkerAdapterImports.d.ts +5 -0
- package/src/runtime/WorkerAdapterImports.d.ts.map +1 -0
- package/src/runtime/WorkerAdapterImports.js +17 -0
- package/src/runtime/WorkersModule.d.ts +6 -0
- package/src/runtime/WorkersModule.d.ts.map +1 -0
- package/src/runtime/WorkersModule.js +278 -0
- package/src/runtime/adapters/CloudflareAdapter.d.ts.map +1 -1
- package/src/runtime/adapters/CloudflareAdapter.js +19 -2
- package/src/runtime/adapters/DenoAdapter.js +1 -0
- package/src/runtime/adapters/FargateAdapter.js +1 -1
- package/src/runtime/adapters/LambdaAdapter.js +1 -1
- package/src/runtime/adapters/NodeServerAdapter.js +1 -1
- package/src/runtime/detectRuntime.d.ts +10 -0
- package/src/runtime/detectRuntime.d.ts.map +1 -0
- package/src/runtime/detectRuntime.js +57 -0
- package/src/runtime/useFileLoader.d.ts.map +1 -1
- package/src/runtime/useFileLoader.js +16 -0
- package/src/scripts/TemplateImportsCheck.js +2 -2
- package/src/scripts/TemplateSync.js +3 -4
- package/src/security/CsrfTokenManager.d.ts +18 -9
- package/src/security/CsrfTokenManager.d.ts.map +1 -1
- package/src/security/CsrfTokenManager.js +204 -11
- package/src/security/Hash.d.ts +1 -1
- package/src/security/Hash.d.ts.map +1 -1
- package/src/security/Hash.js +31 -36
- package/src/seeders/SeederLoader.js +1 -1
- package/src/session/SessionManager.d.ts +3 -0
- package/src/session/SessionManager.d.ts.map +1 -1
- package/src/session/SessionManager.js +49 -10
- package/src/sockets/CloudflareSocket.d.ts +24 -0
- package/src/sockets/CloudflareSocket.d.ts.map +1 -0
- package/src/sockets/CloudflareSocket.js +259 -0
- package/src/start.d.ts.map +1 -1
- package/src/start.js +1 -8
- package/src/templates/project/basic/app/Middleware/index.ts.tpl +1 -1
- package/src/templates/project/basic/src/zintrust.plugins.wg.ts.tpl +8 -0
- package/src/toolkit/Secrets/providers/AwsSecretsManager.d.ts.map +1 -1
- package/src/toolkit/Secrets/providers/AwsSecretsManager.js +4 -2
- package/src/tools/mail/drivers/Smtp.d.ts.map +1 -1
- package/src/tools/mail/drivers/Smtp.js +223 -18
- package/src/tools/mail/index.d.ts.map +1 -1
- package/src/tools/mail/index.js +5 -4
- package/src/tools/mail/template-loader.d.ts.map +1 -1
- package/src/tools/mail/template-loader.js +197 -29
- package/src/tools/mail/templates/auth-password-reset.d.ts +3 -0
- package/src/tools/mail/templates/auth-password-reset.d.ts.map +1 -0
- package/src/tools/mail/templates/auth-password-reset.js +231 -0
- package/src/tools/mail/templates/auth-welcome.d.ts +3 -0
- package/src/tools/mail/templates/auth-welcome.d.ts.map +1 -0
- package/src/tools/mail/templates/auth-welcome.js +236 -0
- package/src/tools/mail/templates/general.d.ts +3 -0
- package/src/tools/mail/templates/general.d.ts.map +1 -0
- package/src/tools/mail/templates/general.js +109 -0
- package/src/tools/mail/templates/index.js +2 -2
- package/src/tools/mail/templates/job-completed.d.ts +3 -0
- package/src/tools/mail/templates/job-completed.d.ts.map +1 -0
- package/src/tools/mail/templates/job-completed.js +188 -0
- package/src/tools/mail/templates/notifications-new-comment.d.ts +3 -0
- package/src/tools/mail/templates/notifications-new-comment.d.ts.map +1 -0
- package/src/tools/mail/templates/notifications-new-comment.js +228 -0
- package/src/tools/mail/templates/password-reset.d.ts +3 -0
- package/src/tools/mail/templates/password-reset.d.ts.map +1 -0
- package/src/tools/mail/templates/password-reset.js +221 -0
- package/src/tools/mail/templates/performance-report.d.ts +3 -0
- package/src/tools/mail/templates/performance-report.d.ts.map +1 -0
- package/src/tools/mail/templates/performance-report.js +258 -0
- package/src/tools/mail/templates/welcome.d.ts +3 -0
- package/src/tools/mail/templates/welcome.d.ts.map +1 -0
- package/src/tools/mail/templates/welcome.js +187 -0
- package/src/tools/mail/templates/worker-alert.d.ts +3 -0
- package/src/tools/mail/templates/worker-alert.d.ts.map +1 -0
- package/src/tools/mail/templates/worker-alert.js +229 -0
- package/src/tools/notification/Notification.js +1 -1
- package/src/tools/notification/testingHelpers.js +6 -5
- package/src/tools/queue/AdvancedQueue.js +2 -6
- package/src/tools/queue/IdempotencyManager.d.ts +6 -0
- package/src/tools/queue/IdempotencyManager.d.ts.map +1 -0
- package/src/tools/queue/IdempotencyManager.js +36 -0
- package/src/tools/queue/JobHeartbeatStore.d.ts +16 -0
- package/src/tools/queue/JobHeartbeatStore.d.ts.map +1 -0
- package/src/tools/queue/JobHeartbeatStore.js +67 -0
- package/src/tools/queue/JobReconciliationRunner.d.ts +16 -0
- package/src/tools/queue/JobReconciliationRunner.d.ts.map +1 -0
- package/src/tools/queue/JobReconciliationRunner.js +88 -0
- package/src/tools/queue/JobRecoveryDaemon.d.ts +27 -0
- package/src/tools/queue/JobRecoveryDaemon.d.ts.map +1 -0
- package/src/tools/queue/JobRecoveryDaemon.js +205 -0
- package/src/tools/queue/JobStateTracker.d.ts +131 -0
- package/src/tools/queue/JobStateTracker.d.ts.map +1 -0
- package/src/tools/queue/JobStateTracker.js +387 -0
- package/src/tools/queue/JobStateTrackerDbPersistence.d.ts +12 -0
- package/src/tools/queue/JobStateTrackerDbPersistence.d.ts.map +1 -0
- package/src/tools/queue/JobStateTrackerDbPersistence.js +148 -0
- package/src/tools/queue/Queue.d.ts.map +1 -1
- package/src/tools/queue/Queue.js +160 -16
- package/src/tools/queue/QueueDataRedactor.d.ts +6 -0
- package/src/tools/queue/QueueDataRedactor.d.ts.map +1 -0
- package/src/tools/queue/QueueDataRedactor.js +45 -0
- package/src/tools/queue/QueueExtensions.d.ts.map +1 -1
- package/src/tools/queue/QueueExtensions.js +2 -1
- package/src/tools/queue/QueueReliabilityMetrics.d.ts +38 -0
- package/src/tools/queue/QueueReliabilityMetrics.d.ts.map +1 -0
- package/src/tools/queue/QueueReliabilityMetrics.js +131 -0
- package/src/tools/queue/QueueReliabilityOrchestrator.d.ts +7 -0
- package/src/tools/queue/QueueReliabilityOrchestrator.d.ts.map +1 -0
- package/src/tools/queue/QueueReliabilityOrchestrator.js +59 -0
- package/src/tools/queue/QueueRuntimeRegistration.d.ts +1 -9
- package/src/tools/queue/QueueRuntimeRegistration.d.ts.map +1 -1
- package/src/tools/queue/QueueRuntimeRegistration.js +75 -4
- package/src/tools/queue/QueueTracing.d.ts +32 -0
- package/src/tools/queue/QueueTracing.d.ts.map +1 -0
- package/src/tools/queue/QueueTracing.js +151 -0
- package/src/tools/queue/StalledJobMonitor.d.ts +5 -0
- package/src/tools/queue/StalledJobMonitor.d.ts.map +1 -0
- package/src/tools/queue/StalledJobMonitor.js +21 -0
- package/src/tools/queue/TimeoutManager.d.ts +14 -0
- package/src/tools/queue/TimeoutManager.d.ts.map +1 -0
- package/src/tools/queue/TimeoutManager.js +77 -0
- package/src/tools/queue/drivers/Redis.d.ts +1 -0
- package/src/tools/queue/drivers/Redis.d.ts.map +1 -1
- package/src/tools/queue/drivers/Redis.js +1 -0
- package/src/tools/queue/index.d.ts +10 -0
- package/src/tools/queue/index.d.ts.map +1 -1
- package/src/tools/queue/index.js +10 -0
- package/src/tools/redis/RedisKeyManager.d.ts +3 -0
- package/src/tools/redis/RedisKeyManager.d.ts.map +1 -1
- package/src/tools/redis/RedisKeyManager.js +15 -0
- package/src/tools/storage/drivers/R2.d.ts +13 -0
- package/src/tools/storage/drivers/R2.d.ts.map +1 -1
- package/src/tools/storage/drivers/R2.js +29 -0
- package/src/zintrust.plugins.d.ts +9 -0
- package/src/zintrust.plugins.d.ts.map +1 -0
- package/src/zintrust.plugins.js +7 -0
- package/src/zintrust.plugins.wg.d.ts +9 -0
- package/src/zintrust.plugins.wg.d.ts.map +1 -0
- package/src/zintrust.plugins.wg.js +7 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zintrust-main.d.ts","sourceRoot":"","sources":["../../bin/zintrust-main.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"zintrust-main.d.ts","sourceRoot":"","sources":["../../bin/zintrust-main.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAuGH,wBAAsB,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,CA0CzC;AAED,OAAO,EAAE,CAAC"}
|
package/bin/zintrust-main.js
CHANGED
|
@@ -50,6 +50,27 @@ const printFancyVersion = (version) => {
|
|
|
50
50
|
const shouldDebugArgs = (rawArgs) => {
|
|
51
51
|
return process.env['ZINTRUST_CLI_DEBUG_ARGS'] === '1' && rawArgs.includes('--verbose');
|
|
52
52
|
};
|
|
53
|
+
const normalizeProxyTargetArgs = (args) => {
|
|
54
|
+
if (args.length < 2 || args[0] !== 'proxy')
|
|
55
|
+
return args;
|
|
56
|
+
const target = args[1];
|
|
57
|
+
if (!target || target.startsWith('-') || target.includes(':'))
|
|
58
|
+
return args;
|
|
59
|
+
const normalized = target.trim().toLowerCase();
|
|
60
|
+
const aliases = {
|
|
61
|
+
redis: 'redis',
|
|
62
|
+
red: 'red',
|
|
63
|
+
smtp: 'smtp',
|
|
64
|
+
mysql: 'mysql',
|
|
65
|
+
postgres: 'postgres',
|
|
66
|
+
mongodb: 'mongodb',
|
|
67
|
+
sqlserver: 'sqlserver',
|
|
68
|
+
};
|
|
69
|
+
const mappedTarget = aliases[normalized];
|
|
70
|
+
if (!mappedTarget)
|
|
71
|
+
return args;
|
|
72
|
+
return [`proxy:${mappedTarget}`, ...args.slice(2)];
|
|
73
|
+
};
|
|
53
74
|
const handleCliFatal = async (error, context) => {
|
|
54
75
|
try {
|
|
55
76
|
const { Logger } = await import('../src/config/logger.js');
|
|
@@ -102,7 +123,7 @@ export async function run() {
|
|
|
102
123
|
// ignore
|
|
103
124
|
}
|
|
104
125
|
}
|
|
105
|
-
await cli.run(args);
|
|
126
|
+
await cli.run(normalizeProxyTargetArgs(args));
|
|
106
127
|
}
|
|
107
128
|
catch (error) {
|
|
108
129
|
await handleCliFatal(error, 'CLI execution failed');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zintrust/core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.41",
|
|
4
4
|
"description": "Production-grade TypeScript backend framework for JavaScript",
|
|
5
5
|
"homepage": "https://zintrust.com",
|
|
6
6
|
"repository": {
|
|
@@ -33,11 +33,15 @@
|
|
|
33
33
|
"./package.json": "./package.json"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"
|
|
36
|
+
"bcryptjs": "^3.0.3",
|
|
37
|
+
"bullmq": "^5.67.3",
|
|
37
38
|
"chalk": "^5.6.2",
|
|
38
|
-
"commander": "^14.0.
|
|
39
|
+
"commander": "^14.0.3",
|
|
39
40
|
"inquirer": "^13.2.2",
|
|
40
|
-
"jsonwebtoken": "^9.0.3"
|
|
41
|
+
"jsonwebtoken": "^9.0.3",
|
|
42
|
+
"@zintrust/workers": "^0.1.31",
|
|
43
|
+
"mysql2": "^3.16.3",
|
|
44
|
+
"pg": "^8.18.0"
|
|
41
45
|
},
|
|
42
46
|
"overrides": {
|
|
43
47
|
"node-forge": "1.3.3",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
<div id="header-actions">
|
|
14
14
|
<div id="toggle-theme-container">
|
|
15
15
|
<input type="checkbox" id="toggle-theme-checkbox" />
|
|
16
|
-
<
|
|
16
|
+
<span id="toggle-theme-label" for="toggle-theme-checkbox">
|
|
17
17
|
<span id="light-theme-indicator" title="Light mode">
|
|
18
18
|
<svg
|
|
19
19
|
xmlns="http://www.w3.org/2000/svg"
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
<path d="M12 3h.393a7.5 7.5 0 0 0 7.92 12.446A9 9 0 1 1 12 2.992z"></path>
|
|
52
52
|
</svg>
|
|
53
53
|
</span>
|
|
54
|
-
</
|
|
54
|
+
</span>
|
|
55
55
|
</div>
|
|
56
56
|
</div>
|
|
57
57
|
</header>
|
package/src/auth/Auth.js
CHANGED
|
@@ -2,22 +2,7 @@
|
|
|
2
2
|
* Application - Framework core entry point
|
|
3
3
|
* Handles application lifecycle, booting, and environment
|
|
4
4
|
*/
|
|
5
|
-
import type {
|
|
6
|
-
import type { IMiddlewareStack } from '../middleware/MiddlewareStack';
|
|
7
|
-
import { type IRouter } from '../routes/Router';
|
|
8
|
-
export interface IApplication {
|
|
9
|
-
boot(): Promise<void>;
|
|
10
|
-
shutdown(): Promise<void>;
|
|
11
|
-
isBooted(): boolean;
|
|
12
|
-
isDevelopment(): boolean;
|
|
13
|
-
isProduction(): boolean;
|
|
14
|
-
isTesting(): boolean;
|
|
15
|
-
getEnvironment(): string;
|
|
16
|
-
getRouter(): IRouter;
|
|
17
|
-
getContainer(): IServiceContainer;
|
|
18
|
-
getMiddlewareStack(): IMiddlewareStack;
|
|
19
|
-
getBasePath(): string;
|
|
20
|
-
}
|
|
5
|
+
import type { IApplication } from './registry/type';
|
|
21
6
|
/**
|
|
22
7
|
* Application Factory
|
|
23
8
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Application.d.ts","sourceRoot":"","sources":["../../../src/boot/Application.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"Application.d.ts","sourceRoot":"","sources":["../../../src/boot/Application.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAUH,OAAO,KAAK,EAAE,YAAY,EAAkC,MAAM,gBAAgB,CAAC;AA2DnF;;GAEG;AACH,eAAO,MAAM,WAAW;IACtB;;OAEG;sBACe,MAAM,GAAG,YAAY;EA0CvC,CAAC;AAEH,eAAe,WAAW,CAAC"}
|
package/src/boot/Application.js
CHANGED
|
@@ -2,19 +2,11 @@
|
|
|
2
2
|
* Application - Framework core entry point
|
|
3
3
|
* Handles application lifecycle, booting, and environment
|
|
4
4
|
*/
|
|
5
|
-
import { appConfig
|
|
5
|
+
import { appConfig } from '../config/index.js';
|
|
6
6
|
import { ServiceContainer } from '../container/ServiceContainer.js';
|
|
7
|
-
import { StartupHealthChecks } from '../health/StartupHealthChecks.js';
|
|
8
7
|
import { MiddlewareStack } from '../middleware/MiddlewareStack.js';
|
|
9
|
-
import broadcastConfig from '../config/broadcast.js';
|
|
10
|
-
import { FeatureFlags } from '../config/features.js';
|
|
11
|
-
import { Logger } from '../config/logger.js';
|
|
12
|
-
import notificationConfig from '../config/notification.js';
|
|
13
|
-
import { StartupConfigValidator } from '../config/StartupConfigValidator.js';
|
|
14
8
|
import { Router } from '../routes/Router.js';
|
|
15
|
-
import
|
|
16
|
-
import { pathToFileURL } from '../node-singletons/url.js';
|
|
17
|
-
import { StartupConfigFile, StartupConfigFileRegistry } from '../runtime/StartupConfigFileRegistry.js';
|
|
9
|
+
import { createLifecycle, registerFrameworkShutdownHooks } from './registry/runtime.js';
|
|
18
10
|
const ShutdownManager = Object.freeze({
|
|
19
11
|
create() {
|
|
20
12
|
const hooks = [];
|
|
@@ -56,258 +48,6 @@ const registerCoreInstances = (params) => {
|
|
|
56
48
|
params.container.singleton('container', params.container);
|
|
57
49
|
params.container.singleton('shutdownManager', params.shutdownManager);
|
|
58
50
|
};
|
|
59
|
-
const registerFrameworkShutdownHooks = (shutdownManager) => {
|
|
60
|
-
// Register framework-level shutdown hooks for long-lived resources
|
|
61
|
-
// ConnectionManager may not be initialized; shutdownIfInitialized is safe
|
|
62
|
-
// Use dynamic import without top-level await to avoid transforming the module into an async module
|
|
63
|
-
import('../orm/ConnectionManager.js')
|
|
64
|
-
.then((mod) => {
|
|
65
|
-
shutdownManager.add(async () => mod.ConnectionManager.shutdownIfInitialized());
|
|
66
|
-
})
|
|
67
|
-
.catch(() => {
|
|
68
|
-
/* ignore import failures in restrictive runtimes */
|
|
69
|
-
});
|
|
70
|
-
import('../orm/Database.js')
|
|
71
|
-
.then((mod) => {
|
|
72
|
-
shutdownManager.add(() => mod.resetDatabase());
|
|
73
|
-
})
|
|
74
|
-
.catch(() => {
|
|
75
|
-
/* ignore import failures in restrictive runtimes */
|
|
76
|
-
});
|
|
77
|
-
import('../cache/Cache.js')
|
|
78
|
-
.then((mod) => {
|
|
79
|
-
shutdownManager.add(() => mod.Cache.reset());
|
|
80
|
-
})
|
|
81
|
-
.catch(() => {
|
|
82
|
-
/* ignore import failures in restrictive runtimes */
|
|
83
|
-
});
|
|
84
|
-
// Flush file logging streams
|
|
85
|
-
import('../config/FileLogWriter.js')
|
|
86
|
-
.then((mod) => {
|
|
87
|
-
shutdownManager.add(() => mod.FileLogWriter.flush());
|
|
88
|
-
})
|
|
89
|
-
.catch(() => {
|
|
90
|
-
/* ignore import failures in restrictive runtimes */
|
|
91
|
-
});
|
|
92
|
-
import('../tools/broadcast/BroadcastRegistry.js')
|
|
93
|
-
.then((mod) => {
|
|
94
|
-
shutdownManager.add(() => mod.BroadcastRegistry.reset());
|
|
95
|
-
})
|
|
96
|
-
.catch(() => {
|
|
97
|
-
/* ignore import failures in restrictive runtimes */
|
|
98
|
-
});
|
|
99
|
-
import('../tools/storage/StorageDiskRegistry.js')
|
|
100
|
-
.then((mod) => {
|
|
101
|
-
shutdownManager.add(() => mod.StorageDiskRegistry.reset());
|
|
102
|
-
})
|
|
103
|
-
.catch(() => {
|
|
104
|
-
/* ignore import failures in restrictive runtimes */
|
|
105
|
-
});
|
|
106
|
-
import('../tools/notification/NotificationChannelRegistry.js')
|
|
107
|
-
.then((mod) => {
|
|
108
|
-
shutdownManager.add(() => mod.NotificationChannelRegistry.reset());
|
|
109
|
-
})
|
|
110
|
-
.catch(() => {
|
|
111
|
-
/* ignore import failures in restrictive runtimes */
|
|
112
|
-
});
|
|
113
|
-
import('../tools/mail/MailDriverRegistry.js')
|
|
114
|
-
.then((mod) => {
|
|
115
|
-
shutdownManager.add(() => mod.MailDriverRegistry.reset());
|
|
116
|
-
})
|
|
117
|
-
.catch(() => {
|
|
118
|
-
/* ignore import failures in restrictive runtimes */
|
|
119
|
-
});
|
|
120
|
-
import('../tools/queue/Queue.js')
|
|
121
|
-
.then((mod) => {
|
|
122
|
-
shutdownManager.add(() => mod.Queue.reset());
|
|
123
|
-
})
|
|
124
|
-
.catch(() => {
|
|
125
|
-
/* ignore import failures in restrictive runtimes */
|
|
126
|
-
});
|
|
127
|
-
import('@zintrust/workers')
|
|
128
|
-
.then((mod) => {
|
|
129
|
-
shutdownManager.add(async () => mod.WorkerShutdown.shutdown({ signal: 'APP_SHUTDOWN', timeout: 5000, forceExit: false }));
|
|
130
|
-
})
|
|
131
|
-
.catch(() => {
|
|
132
|
-
/* ignore import failures in restrictive runtimes */
|
|
133
|
-
});
|
|
134
|
-
};
|
|
135
|
-
const tryImportRoutesFromAppBase = async (resolvedBasePath) => {
|
|
136
|
-
if (resolvedBasePath === '')
|
|
137
|
-
return undefined;
|
|
138
|
-
const candidates = [
|
|
139
|
-
// Dev (tsx)
|
|
140
|
-
path.join(resolvedBasePath, 'routes', 'api.ts'),
|
|
141
|
-
// Production build output
|
|
142
|
-
path.join(resolvedBasePath, 'dist', 'routes', 'api.js'),
|
|
143
|
-
// Fallback (in case someone transpiles without /dist)
|
|
144
|
-
path.join(resolvedBasePath, 'routes', 'api.js'),
|
|
145
|
-
];
|
|
146
|
-
for (const candidate of candidates) {
|
|
147
|
-
try {
|
|
148
|
-
const url = pathToFileURL(candidate).href;
|
|
149
|
-
// Intentionally sequential to find the first working candidates
|
|
150
|
-
// eslint-disable-next-line no-await-in-loop
|
|
151
|
-
return (await import(url));
|
|
152
|
-
}
|
|
153
|
-
catch {
|
|
154
|
-
// keep trying
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
return undefined;
|
|
158
|
-
};
|
|
159
|
-
const registerRoutes = async (resolvedBasePath, router) => {
|
|
160
|
-
try {
|
|
161
|
-
const mod = await tryImportRoutesFromAppBase(resolvedBasePath);
|
|
162
|
-
if (typeof mod?.registerRoutes === 'function') {
|
|
163
|
-
mod.registerRoutes(router);
|
|
164
|
-
}
|
|
165
|
-
else {
|
|
166
|
-
const frameworkRoutes = await tryImportOptional('@routes/api');
|
|
167
|
-
if (typeof frameworkRoutes?.registerRoutes === 'function') {
|
|
168
|
-
frameworkRoutes.registerRoutes(router);
|
|
169
|
-
}
|
|
170
|
-
else {
|
|
171
|
-
Logger.warn('No app routes found and framework routes are unavailable. Ensure routes/api.ts exists in the project.');
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
// Always register core framework routes (health, metrics, doc) after app routes
|
|
175
|
-
// This ensures app can override but core routes always exist
|
|
176
|
-
const { registerCoreRoutes } = await import('../routes/CoreRoutes.js');
|
|
177
|
-
registerCoreRoutes(router);
|
|
178
|
-
}
|
|
179
|
-
catch (error) {
|
|
180
|
-
Logger.error('Failed to register routes:', error);
|
|
181
|
-
}
|
|
182
|
-
};
|
|
183
|
-
const initializeArtifactDirectories = async (resolvedBasePath) => {
|
|
184
|
-
if (resolvedBasePath === '')
|
|
185
|
-
return;
|
|
186
|
-
if (typeof process === 'undefined')
|
|
187
|
-
return;
|
|
188
|
-
let nodeFs;
|
|
189
|
-
try {
|
|
190
|
-
nodeFs = await import('../node-singletons/fs.js');
|
|
191
|
-
}
|
|
192
|
-
catch {
|
|
193
|
-
return;
|
|
194
|
-
}
|
|
195
|
-
const dirs = ['logs', 'storage', 'tmp'];
|
|
196
|
-
for (const dir of dirs) {
|
|
197
|
-
const fullPath = path.join(resolvedBasePath, dir);
|
|
198
|
-
try {
|
|
199
|
-
if (!nodeFs.existsSync(fullPath)) {
|
|
200
|
-
nodeFs.mkdirSync(fullPath, { recursive: true });
|
|
201
|
-
Logger.info(`✓ Created directory: ${dir}`);
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
catch (error) {
|
|
205
|
-
Logger.warn(`Failed to create ${dir} directory`, error);
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
};
|
|
209
|
-
const tryImportOptional = async (modulePath) => {
|
|
210
|
-
try {
|
|
211
|
-
return (await import(modulePath));
|
|
212
|
-
}
|
|
213
|
-
catch {
|
|
214
|
-
return undefined;
|
|
215
|
-
}
|
|
216
|
-
};
|
|
217
|
-
const isCompiledJsModule = () => {
|
|
218
|
-
// When running from dist, this module is compiled to .js and Node ESM resolution
|
|
219
|
-
// requires explicit file extensions for relative imports.
|
|
220
|
-
return import.meta.url.endsWith('.js');
|
|
221
|
-
};
|
|
222
|
-
const dbLoader = async () => {
|
|
223
|
-
const db = await tryImportOptional(isCompiledJsModule()
|
|
224
|
-
? '../orm/DatabaseRuntimeRegistration.js'
|
|
225
|
-
: '../orm/DatabaseRuntimeRegistration');
|
|
226
|
-
db?.registerDatabasesFromRuntimeConfig?.(databaseConfig);
|
|
227
|
-
};
|
|
228
|
-
const queuesLoader = async () => {
|
|
229
|
-
const queues = await tryImportOptional(isCompiledJsModule()
|
|
230
|
-
? '../tools/queue/QueueRuntimeRegistration.js'
|
|
231
|
-
: '../tools/queue/QueueRuntimeRegistration');
|
|
232
|
-
queues?.registerQueuesFromRuntimeConfig?.(queueConfig);
|
|
233
|
-
};
|
|
234
|
-
const cachesLoader = async () => {
|
|
235
|
-
const caches = await tryImportOptional(isCompiledJsModule()
|
|
236
|
-
? '../cache/CacheRuntimeRegistration.js'
|
|
237
|
-
: '../cache/CacheRuntimeRegistration');
|
|
238
|
-
caches?.registerCachesFromRuntimeConfig?.(cacheConfig);
|
|
239
|
-
};
|
|
240
|
-
const registerFromRuntimeConfig = async () => {
|
|
241
|
-
await dbLoader();
|
|
242
|
-
await queuesLoader();
|
|
243
|
-
await cachesLoader();
|
|
244
|
-
const broadcasters = await tryImportOptional(isCompiledJsModule()
|
|
245
|
-
? '../tools/broadcast/BroadcastRuntimeRegistration.js'
|
|
246
|
-
: '../tools/broadcast/BroadcastRuntimeRegistration');
|
|
247
|
-
broadcasters?.registerBroadcastersFromRuntimeConfig?.({
|
|
248
|
-
default: broadcastConfig.default,
|
|
249
|
-
drivers: broadcastConfig.drivers,
|
|
250
|
-
});
|
|
251
|
-
const disks = await tryImportOptional(isCompiledJsModule()
|
|
252
|
-
? '../tools/storage/StorageRuntimeRegistration.js'
|
|
253
|
-
: '../tools/storage/StorageRuntimeRegistration');
|
|
254
|
-
disks?.registerDisksFromRuntimeConfig?.(storageConfig);
|
|
255
|
-
const notifications = await tryImportOptional(isCompiledJsModule()
|
|
256
|
-
? '../tools/notification/NotificationRuntimeRegistration.js'
|
|
257
|
-
: '../tools/notification/NotificationRuntimeRegistration');
|
|
258
|
-
notifications?.registerNotificationChannelsFromRuntimeConfig?.({
|
|
259
|
-
default: notificationConfig.default,
|
|
260
|
-
drivers: notificationConfig.drivers,
|
|
261
|
-
});
|
|
262
|
-
};
|
|
263
|
-
const createLifecycle = (params) => {
|
|
264
|
-
const boot = async () => {
|
|
265
|
-
if (params.getBooted())
|
|
266
|
-
return;
|
|
267
|
-
Logger.info(`🚀 Booting ZinTrust Application in ${params.environment} mode...`);
|
|
268
|
-
StartupConfigValidator.assertValid();
|
|
269
|
-
// Preload project-owned config overrides that must be available synchronously.
|
|
270
|
-
await StartupConfigFileRegistry.preload([
|
|
271
|
-
StartupConfigFile.Middleware,
|
|
272
|
-
StartupConfigFile.Cache,
|
|
273
|
-
StartupConfigFile.Database,
|
|
274
|
-
StartupConfigFile.Queue,
|
|
275
|
-
StartupConfigFile.Storage,
|
|
276
|
-
StartupConfigFile.Mail,
|
|
277
|
-
StartupConfigFile.Broadcast,
|
|
278
|
-
StartupConfigFile.Notification,
|
|
279
|
-
]);
|
|
280
|
-
FeatureFlags.initialize();
|
|
281
|
-
await StartupHealthChecks.assertHealthy();
|
|
282
|
-
await registerFromRuntimeConfig();
|
|
283
|
-
await initializeArtifactDirectories(params.resolvedBasePath);
|
|
284
|
-
await registerRoutes(params.resolvedBasePath, params.router);
|
|
285
|
-
// Register service providers
|
|
286
|
-
// Bootstrap services
|
|
287
|
-
Logger.info('✅ Application booted successfully');
|
|
288
|
-
params.setBooted(true);
|
|
289
|
-
};
|
|
290
|
-
const shutdown = async () => {
|
|
291
|
-
Logger.info('🛑 Shutting down application...');
|
|
292
|
-
try {
|
|
293
|
-
await params.shutdownManager.run();
|
|
294
|
-
}
|
|
295
|
-
catch (error) {
|
|
296
|
-
Logger.error('Shutdown hook failed:', error);
|
|
297
|
-
}
|
|
298
|
-
// Ensure FileLogWriter.flush is attempted even if dynamic registration failed.
|
|
299
|
-
try {
|
|
300
|
-
const fileLogWriter = await tryImportOptional('@config/FileLogWriter');
|
|
301
|
-
fileLogWriter?.FileLogWriter?.flush?.();
|
|
302
|
-
}
|
|
303
|
-
catch {
|
|
304
|
-
/* best-effort */
|
|
305
|
-
}
|
|
306
|
-
params.setBooted(false);
|
|
307
|
-
Logger.info('✅ Application shut down successfully');
|
|
308
|
-
};
|
|
309
|
-
return { boot, shutdown };
|
|
310
|
-
};
|
|
311
51
|
/**
|
|
312
52
|
* Application Factory
|
|
313
53
|
*/
|
package/src/boot/Server.d.ts
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* Server - HTTP Server implementation
|
|
3
3
|
* Uses Node.js built-in HTTP server with no external dependencies
|
|
4
4
|
*/
|
|
5
|
-
import type { IApplication } from './Application';
|
|
6
5
|
import type { IKernel } from '../http/Kernel';
|
|
7
6
|
import * as http from '../node-singletons/http';
|
|
7
|
+
import type { IApplication } from './registry/type';
|
|
8
8
|
export interface IServer {
|
|
9
9
|
listen(): Promise<void>;
|
|
10
10
|
close(): Promise<void>;
|
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;
|
|
1
|
+
{"version":3,"file":"Server.d.ts","sourceRoot":"","sources":["../../../src/boot/Server.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAM5C,OAAO,KAAK,IAAI,MAAM,uBAAuB,CAAC;AAE9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEnD,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;AAkED;;;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/bootstrap.js
CHANGED
|
@@ -9,6 +9,7 @@ import { appConfig } from '../config/app.js';
|
|
|
9
9
|
import { Env } from '../config/env.js';
|
|
10
10
|
import { Logger } from '../config/logger.js';
|
|
11
11
|
import { ErrorFactory } from '../exceptions/ZintrustError.js';
|
|
12
|
+
import { loadWorkersModule } from '../runtime/WorkersModule.js';
|
|
12
13
|
let appInstance;
|
|
13
14
|
let serverInstance;
|
|
14
15
|
let isShuttingDown = false;
|
|
@@ -101,11 +102,10 @@ const gracefulShutdown = async (signal) => {
|
|
|
101
102
|
forceExitTimer.unref?.();
|
|
102
103
|
await withTimeout((async () => {
|
|
103
104
|
// Shutdown worker management system FIRST (before database closes)
|
|
104
|
-
if (appConfig.detectRuntime() === 'nodejs' || appConfig.detectRuntime() === 'lambda')
|
|
105
|
+
if ((appConfig.detectRuntime() === 'nodejs' || appConfig.detectRuntime() === 'lambda') &&
|
|
106
|
+
appConfig.dockerWorker === false) {
|
|
105
107
|
try {
|
|
106
|
-
const
|
|
107
|
-
const require = createRequire(import.meta.url);
|
|
108
|
-
const workers = require('@zintrust/workers');
|
|
108
|
+
const workers = await loadWorkersModule();
|
|
109
109
|
const workerBudgetMs = Math.min(15000, remainingMs());
|
|
110
110
|
await withTimeout(workers.WorkerShutdown.shutdown({
|
|
111
111
|
signal,
|
|
@@ -139,12 +139,16 @@ const gracefulShutdown = async (signal) => {
|
|
|
139
139
|
}
|
|
140
140
|
};
|
|
141
141
|
async function useWorkerStarter() {
|
|
142
|
+
// Check if workers are enabled in this environment
|
|
143
|
+
const workerEnabled = Env.getBool('WORKER_ENABLED', true);
|
|
144
|
+
if (!workerEnabled || appConfig.dockerWorker === true) {
|
|
145
|
+
Logger.info('Workers disabled in this runtime (WORKER_ENABLED=false && DOCKER_WORKER=true), skipping worker management initialization');
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
142
148
|
// Initialize worker management system
|
|
143
149
|
let workerInit = null;
|
|
144
150
|
try {
|
|
145
|
-
const
|
|
146
|
-
const require = createRequire(import.meta.url);
|
|
147
|
-
const workers = require('@zintrust/workers');
|
|
151
|
+
const workers = await loadWorkersModule();
|
|
148
152
|
if (workers?.WorkerInit !== undefined) {
|
|
149
153
|
workerInit = workers.WorkerInit;
|
|
150
154
|
await workers.WorkerInit.initialize({
|
|
@@ -203,12 +207,22 @@ const BootstrapFunctions = Object.freeze({
|
|
|
203
207
|
Logger.info(`ZinTrust documentation at http://${host}:${port}/doc`);
|
|
204
208
|
// Start schedules for long-running runtimes (Node.js / Fargate)
|
|
205
209
|
await startSchedulesIfNeeded(app);
|
|
206
|
-
if (appConfig.
|
|
210
|
+
if (appConfig.dockerWorker === false &&
|
|
211
|
+
(appConfig.detectRuntime() === 'nodejs' || appConfig.detectRuntime() === 'lambda')) {
|
|
207
212
|
await useWorkerStarter();
|
|
208
213
|
}
|
|
209
214
|
}
|
|
210
215
|
catch (error) {
|
|
211
|
-
|
|
216
|
+
try {
|
|
217
|
+
Logger.error('Failed to bootstrap application:', error);
|
|
218
|
+
}
|
|
219
|
+
catch {
|
|
220
|
+
// best-effort logging
|
|
221
|
+
}
|
|
222
|
+
Logger.debug('[bootstrap] start: failed', {
|
|
223
|
+
message: error instanceof Error ? error.message : String(error),
|
|
224
|
+
stack: error instanceof Error ? error.stack : undefined,
|
|
225
|
+
});
|
|
212
226
|
logBootstrapErrorDetails(error);
|
|
213
227
|
process.exit(1);
|
|
214
228
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { IRouter } from '../../routes/Router';
|
|
2
|
+
export declare const isCompiledJsModule: () => boolean;
|
|
3
|
+
export declare const tryImportOptional: <T>(modulePath: string) => Promise<T | undefined>;
|
|
4
|
+
export declare const tryImportOptionalR: <T>(modulePath: string) => Promise<T | undefined>;
|
|
5
|
+
export declare const registerMasterRoutes: (resolvedBasePath: string, router: IRouter) => Promise<void>;
|
|
6
|
+
//# sourceMappingURL=registerRoute.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registerRoute.d.ts","sourceRoot":"","sources":["../../../../src/boot/registry/registerRoute.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAQnD,eAAO,MAAM,kBAAkB,QAAO,OAKrC,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAU,CAAC,EAAE,YAAY,MAAM,KAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAMpF,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAU,CAAC,EAAE,YAAY,MAAM,KAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAOrF,CAAC;AAkEF,eAAO,MAAM,oBAAoB,GAC/B,kBAAkB,MAAM,EACxB,QAAQ,OAAO,KACd,OAAO,CAAC,IAAI,CAmBd,CAAC"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { appConfig } from '../../config/index.js';
|
|
2
|
+
import Logger from '../../config/logger.js';
|
|
3
|
+
import * as path from '../../node-singletons/path.js';
|
|
4
|
+
import { pathToFileURL } from '../../node-singletons/url.js';
|
|
5
|
+
import { detectRuntime } from '../../runtime/detectRuntime.js';
|
|
6
|
+
const isCloudflare = detectRuntime().isCloudflare;
|
|
7
|
+
export const isCompiledJsModule = () => {
|
|
8
|
+
// When running from dist, this module is compiled to .js and Node ESM resolution
|
|
9
|
+
// requires explicit file extensions for relative imports.
|
|
10
|
+
const metaUrl = typeof import.meta?.url === 'string' ? import.meta.url : '';
|
|
11
|
+
return metaUrl.endsWith('.js');
|
|
12
|
+
};
|
|
13
|
+
export const tryImportOptional = async (modulePath) => {
|
|
14
|
+
try {
|
|
15
|
+
return (await import(modulePath));
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
export const tryImportOptionalR = async (modulePath) => {
|
|
22
|
+
try {
|
|
23
|
+
return (await import(modulePath));
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
Logger.error(`Error importing module ${modulePath}:`, error);
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
const tryImportRoutesFromAppBase = async (resolvedBasePath) => {
|
|
31
|
+
if (resolvedBasePath === '')
|
|
32
|
+
return undefined;
|
|
33
|
+
const routeCandidates = appConfig.isDevelopment()
|
|
34
|
+
? [
|
|
35
|
+
path.join(resolvedBasePath, 'routes', 'api.ts'),
|
|
36
|
+
path.join(resolvedBasePath, 'routes', 'api.js'),
|
|
37
|
+
]
|
|
38
|
+
: [
|
|
39
|
+
path.join(resolvedBasePath, 'routes', 'api.js'),
|
|
40
|
+
path.join(resolvedBasePath, 'dist', 'routes', 'api.js'),
|
|
41
|
+
path.join(resolvedBasePath, 'routes', 'api.ts'),
|
|
42
|
+
path.join(resolvedBasePath, 'dist', 'routes', 'api.ts'),
|
|
43
|
+
];
|
|
44
|
+
for (const routePath of routeCandidates) {
|
|
45
|
+
try {
|
|
46
|
+
const url = pathToFileURL(routePath).href;
|
|
47
|
+
// eslint-disable-next-line no-await-in-loop
|
|
48
|
+
return (await import(url));
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
// try next candidate
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return undefined;
|
|
55
|
+
};
|
|
56
|
+
const registerAppRoutes = async (resolvedBasePath, router) => {
|
|
57
|
+
const mod = await tryImportRoutesFromAppBase(resolvedBasePath);
|
|
58
|
+
if (mod && typeof mod.registerRoutes === 'function') {
|
|
59
|
+
mod.registerRoutes(router);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
const registerFrameworkRoutes = async (resolvedBasePath, router) => {
|
|
63
|
+
const frameworkRoutes = await tryImportRoutesFromAppBase(resolvedBasePath);
|
|
64
|
+
if (frameworkRoutes && typeof frameworkRoutes.registerRoutes === 'function') {
|
|
65
|
+
frameworkRoutes.registerRoutes(router);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
const registerGlobalRoutes = (router) => {
|
|
69
|
+
const globalRoutes = globalThis.__zintrustRoutes;
|
|
70
|
+
if (globalRoutes && typeof globalRoutes.registerRoutes === 'function') {
|
|
71
|
+
globalRoutes.registerRoutes(router);
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
Logger.warn('No app routes found and framework routes are unavailable. Ensure routes/api.ts exists in the project.');
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
export const registerMasterRoutes = async (resolvedBasePath, router) => {
|
|
78
|
+
try {
|
|
79
|
+
if (isCloudflare) {
|
|
80
|
+
registerGlobalRoutes(router);
|
|
81
|
+
}
|
|
82
|
+
if (!isCloudflare) {
|
|
83
|
+
await registerAppRoutes(resolvedBasePath, router);
|
|
84
|
+
}
|
|
85
|
+
if (router.routes.length === 0) {
|
|
86
|
+
await registerFrameworkRoutes(resolvedBasePath, router);
|
|
87
|
+
}
|
|
88
|
+
// Always register core framework routes (health, metrics, doc) after app routes
|
|
89
|
+
// This ensures app can override but core routes always exist
|
|
90
|
+
const { registerCoreRoutes } = await import('../../routes/CoreRoutes.js');
|
|
91
|
+
registerCoreRoutes(router);
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
Logger.error('Failed to register routes:', error);
|
|
95
|
+
}
|
|
96
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { IShutdownManager } from './type';
|
|
2
|
+
import type { IRouter } from '../../index.js';
|
|
3
|
+
export declare const registerFrameworkShutdownHooks: (shutdownManager: IShutdownManager) => void;
|
|
4
|
+
export declare const createLifecycle: (params: {
|
|
5
|
+
environment: string;
|
|
6
|
+
resolvedBasePath: string;
|
|
7
|
+
router: IRouter;
|
|
8
|
+
shutdownManager: IShutdownManager;
|
|
9
|
+
getBooted: () => boolean;
|
|
10
|
+
setBooted: (value: boolean) => void;
|
|
11
|
+
}) => {
|
|
12
|
+
boot: () => Promise<void>;
|
|
13
|
+
shutdown: () => Promise<void>;
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../../src/boot/registry/runtime.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAOvD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AA+I9C,eAAO,MAAM,8BAA8B,GAAI,iBAAiB,gBAAgB,KAAG,IA4BlF,CAAC;AA+KF,eAAO,MAAM,eAAe,GAAI,QAAQ;IACtC,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,EAAE,MAAM,CAAC;IACzB,MAAM,EAAE,OAAO,CAAC;IAChB,eAAe,EAAE,gBAAgB,CAAC;IAClC,SAAS,EAAE,MAAM,OAAO,CAAC;IACzB,SAAS,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CACrC,KAAG;IAAE,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAAC,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAsE7D,CAAC"}
|