@zintrust/core 0.1.40 → 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 -290
- package/src/boot/Server.d.ts +1 -1
- package/src/boot/Server.d.ts.map +1 -1
- package/src/boot/bootstrap.js +23 -5
- 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 +132 -17
- 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.js +16 -15
- package/src/cli/workers/QueueWorkRunner.js +1 -1
- 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 +87 -2
- package/src/config/env.d.ts.map +1 -1
- package/src/config/env.js +156 -17
- package/src/config/index.d.ts +1 -0
- package/src/config/index.d.ts.map +1 -1
- 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 +18 -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 +30 -16
- 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.map +1 -1
- package/src/security/CsrfTokenManager.js +12 -0
- 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/src/zintrust.plugins.wg.ts.tpl +8 -0
- 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/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,286 +48,6 @@ const registerCoreInstances = (params) => {
|
|
|
56
48
|
params.container.singleton('container', params.container);
|
|
57
49
|
params.container.singleton('shutdownManager', params.shutdownManager);
|
|
58
50
|
};
|
|
59
|
-
/**
|
|
60
|
-
* Helper: Register ConnectionManager shutdown hook
|
|
61
|
-
*/
|
|
62
|
-
const registerConnectionManagerHook = (shutdownManager) => {
|
|
63
|
-
shutdownManager.add(async () => {
|
|
64
|
-
try {
|
|
65
|
-
const mod = await import('../orm/ConnectionManager.js');
|
|
66
|
-
await mod.ConnectionManager.shutdownIfInitialized();
|
|
67
|
-
}
|
|
68
|
-
catch {
|
|
69
|
-
/* ignore import failures in restrictive runtimes */
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
};
|
|
73
|
-
/**
|
|
74
|
-
* Helper: Register Worker management system shutdown hook
|
|
75
|
-
*/
|
|
76
|
-
const registerWorkerShutdownHook = async (shutdownManager) => {
|
|
77
|
-
// Ensure worker management system is asked to shutdown BEFORE databases are reset.
|
|
78
|
-
// This prevents workers from trying to access DB connections that have already
|
|
79
|
-
// been closed by subsequent shutdown hooks.
|
|
80
|
-
shutdownManager.add(async () => {
|
|
81
|
-
try {
|
|
82
|
-
const mod = (await import('@zintrust/workers'));
|
|
83
|
-
const isShuttingDown = typeof mod.WorkerShutdown.isShuttingDown === 'function'
|
|
84
|
-
? mod.WorkerShutdown.isShuttingDown()
|
|
85
|
-
: (mod.WorkerShutdown.getShutdownState?.().isShuttingDown ?? false);
|
|
86
|
-
const completedAt = mod.WorkerShutdown.getShutdownState?.().completedAt ?? null;
|
|
87
|
-
if (isShuttingDown || completedAt !== null)
|
|
88
|
-
return;
|
|
89
|
-
await mod.WorkerShutdown.shutdown({
|
|
90
|
-
signal: 'APP_SHUTDOWN',
|
|
91
|
-
timeout: 5000,
|
|
92
|
-
forceExit: false,
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
catch {
|
|
96
|
-
/* ignore import failures in restrictive runtimes */
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
return Promise.resolve(); // NOSONAR
|
|
100
|
-
};
|
|
101
|
-
/**
|
|
102
|
-
* Helper: Register Database reset hook
|
|
103
|
-
*/
|
|
104
|
-
const registerDatabaseResetHook = (shutdownManager) => {
|
|
105
|
-
shutdownManager.add(async () => {
|
|
106
|
-
try {
|
|
107
|
-
const mod = await import('../orm/Database.js');
|
|
108
|
-
mod.resetDatabase();
|
|
109
|
-
}
|
|
110
|
-
catch {
|
|
111
|
-
/* ignore import failures in restrictive runtimes */
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
};
|
|
115
|
-
/**
|
|
116
|
-
* Helper: Register generic reset hook for modules with reset() method
|
|
117
|
-
*/
|
|
118
|
-
const registerResetHook = (shutdownManager, modulePath, exportName) => {
|
|
119
|
-
shutdownManager.add(async () => {
|
|
120
|
-
try {
|
|
121
|
-
const mod = (await import(modulePath));
|
|
122
|
-
const resetModule = mod[exportName];
|
|
123
|
-
if (resetModule?.reset) {
|
|
124
|
-
resetModule.reset();
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
catch {
|
|
128
|
-
/* ignore import failures in restrictive runtimes */
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
};
|
|
132
|
-
/**
|
|
133
|
-
* Helper: Register FileLogWriter flush hook
|
|
134
|
-
*/
|
|
135
|
-
const registerFileLogFlushHook = (shutdownManager) => {
|
|
136
|
-
shutdownManager.add(async () => {
|
|
137
|
-
try {
|
|
138
|
-
const mod = await import('../config/FileLogWriter.js');
|
|
139
|
-
mod.FileLogWriter.flush();
|
|
140
|
-
}
|
|
141
|
-
catch {
|
|
142
|
-
/* ignore import failures in restrictive runtimes */
|
|
143
|
-
}
|
|
144
|
-
});
|
|
145
|
-
};
|
|
146
|
-
const registerFrameworkShutdownHooks = (shutdownManager) => {
|
|
147
|
-
// Register framework-level shutdown hooks for long-lived resources
|
|
148
|
-
registerConnectionManagerHook(shutdownManager);
|
|
149
|
-
// Ensure worker management system is asked to shutdown BEFORE databases are reset
|
|
150
|
-
void registerWorkerShutdownHook(shutdownManager);
|
|
151
|
-
// Database and cache reset
|
|
152
|
-
registerDatabaseResetHook(shutdownManager);
|
|
153
|
-
registerResetHook(shutdownManager, '@cache/Cache', 'Cache');
|
|
154
|
-
// File logging
|
|
155
|
-
registerFileLogFlushHook(shutdownManager);
|
|
156
|
-
// Registry resets
|
|
157
|
-
registerResetHook(shutdownManager, '@broadcast/BroadcastRegistry', 'BroadcastRegistry');
|
|
158
|
-
registerResetHook(shutdownManager, '@storage/StorageDiskRegistry', 'StorageDiskRegistry');
|
|
159
|
-
registerResetHook(shutdownManager, '@notification/NotificationChannelRegistry', 'NotificationChannelRegistry');
|
|
160
|
-
registerResetHook(shutdownManager, '@mail/MailDriverRegistry', 'MailDriverRegistry');
|
|
161
|
-
registerResetHook(shutdownManager, '@tools/queue/Queue', 'Queue');
|
|
162
|
-
};
|
|
163
|
-
const tryImportRoutesFromAppBase = async (resolvedBasePath) => {
|
|
164
|
-
if (resolvedBasePath === '')
|
|
165
|
-
return undefined;
|
|
166
|
-
const candidates = [
|
|
167
|
-
// Dev (tsx)
|
|
168
|
-
path.join(resolvedBasePath, 'routes', 'api.ts'),
|
|
169
|
-
// Production build output
|
|
170
|
-
path.join(resolvedBasePath, 'dist', 'routes', 'api.js'),
|
|
171
|
-
// Fallback (in case someone transpiles without /dist)
|
|
172
|
-
path.join(resolvedBasePath, 'routes', 'api.js'),
|
|
173
|
-
];
|
|
174
|
-
for (const candidate of candidates) {
|
|
175
|
-
try {
|
|
176
|
-
const url = pathToFileURL(candidate).href;
|
|
177
|
-
// Intentionally sequential to find the first working candidates
|
|
178
|
-
// eslint-disable-next-line no-await-in-loop
|
|
179
|
-
return (await import(url));
|
|
180
|
-
}
|
|
181
|
-
catch {
|
|
182
|
-
// keep trying
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
return undefined;
|
|
186
|
-
};
|
|
187
|
-
const registerRoutes = async (resolvedBasePath, router) => {
|
|
188
|
-
try {
|
|
189
|
-
const mod = await tryImportRoutesFromAppBase(resolvedBasePath);
|
|
190
|
-
if (typeof mod?.registerRoutes === 'function') {
|
|
191
|
-
mod.registerRoutes(router);
|
|
192
|
-
}
|
|
193
|
-
else {
|
|
194
|
-
const frameworkRoutes = await tryImportOptional('@routes/api');
|
|
195
|
-
if (typeof frameworkRoutes?.registerRoutes === 'function') {
|
|
196
|
-
frameworkRoutes.registerRoutes(router);
|
|
197
|
-
}
|
|
198
|
-
else {
|
|
199
|
-
Logger.warn('No app routes found and framework routes are unavailable. Ensure routes/api.ts exists in the project.');
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
// Always register core framework routes (health, metrics, doc) after app routes
|
|
203
|
-
// This ensures app can override but core routes always exist
|
|
204
|
-
const { registerCoreRoutes } = await import('../routes/CoreRoutes.js');
|
|
205
|
-
registerCoreRoutes(router);
|
|
206
|
-
}
|
|
207
|
-
catch (error) {
|
|
208
|
-
Logger.error('Failed to register routes:', error);
|
|
209
|
-
}
|
|
210
|
-
};
|
|
211
|
-
const initializeArtifactDirectories = async (resolvedBasePath) => {
|
|
212
|
-
if (resolvedBasePath === '')
|
|
213
|
-
return;
|
|
214
|
-
if (typeof process === 'undefined')
|
|
215
|
-
return;
|
|
216
|
-
let nodeFs;
|
|
217
|
-
try {
|
|
218
|
-
nodeFs = await import('../node-singletons/fs.js');
|
|
219
|
-
}
|
|
220
|
-
catch {
|
|
221
|
-
return;
|
|
222
|
-
}
|
|
223
|
-
const dirs = ['logs', 'storage', 'tmp'];
|
|
224
|
-
for (const dir of dirs) {
|
|
225
|
-
const fullPath = path.join(resolvedBasePath, dir);
|
|
226
|
-
try {
|
|
227
|
-
if (!nodeFs.existsSync(fullPath)) {
|
|
228
|
-
nodeFs.mkdirSync(fullPath, { recursive: true });
|
|
229
|
-
Logger.info(`✓ Created directory: ${dir}`);
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
catch (error) {
|
|
233
|
-
Logger.warn(`Failed to create ${dir} directory`, error);
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
};
|
|
237
|
-
const tryImportOptional = async (modulePath) => {
|
|
238
|
-
try {
|
|
239
|
-
return (await import(modulePath));
|
|
240
|
-
}
|
|
241
|
-
catch {
|
|
242
|
-
return undefined;
|
|
243
|
-
}
|
|
244
|
-
};
|
|
245
|
-
const isCompiledJsModule = () => {
|
|
246
|
-
// When running from dist, this module is compiled to .js and Node ESM resolution
|
|
247
|
-
// requires explicit file extensions for relative imports.
|
|
248
|
-
return import.meta.url.endsWith('.js');
|
|
249
|
-
};
|
|
250
|
-
const dbLoader = async () => {
|
|
251
|
-
const db = await tryImportOptional(isCompiledJsModule()
|
|
252
|
-
? '../orm/DatabaseRuntimeRegistration.js'
|
|
253
|
-
: '../orm/DatabaseRuntimeRegistration');
|
|
254
|
-
db?.registerDatabasesFromRuntimeConfig?.(databaseConfig);
|
|
255
|
-
};
|
|
256
|
-
const queuesLoader = async () => {
|
|
257
|
-
const queues = await tryImportOptional(isCompiledJsModule()
|
|
258
|
-
? '../tools/queue/QueueRuntimeRegistration.js'
|
|
259
|
-
: '../tools/queue/QueueRuntimeRegistration');
|
|
260
|
-
queues?.registerQueuesFromRuntimeConfig?.(queueConfig);
|
|
261
|
-
};
|
|
262
|
-
const cachesLoader = async () => {
|
|
263
|
-
const caches = await tryImportOptional(isCompiledJsModule()
|
|
264
|
-
? '../cache/CacheRuntimeRegistration.js'
|
|
265
|
-
: '../cache/CacheRuntimeRegistration');
|
|
266
|
-
caches?.registerCachesFromRuntimeConfig?.(cacheConfig);
|
|
267
|
-
};
|
|
268
|
-
const registerFromRuntimeConfig = async () => {
|
|
269
|
-
await dbLoader();
|
|
270
|
-
await queuesLoader();
|
|
271
|
-
await cachesLoader();
|
|
272
|
-
const broadcasters = await tryImportOptional(isCompiledJsModule()
|
|
273
|
-
? '../tools/broadcast/BroadcastRuntimeRegistration.js'
|
|
274
|
-
: '../tools/broadcast/BroadcastRuntimeRegistration');
|
|
275
|
-
broadcasters?.registerBroadcastersFromRuntimeConfig?.({
|
|
276
|
-
default: broadcastConfig.default,
|
|
277
|
-
drivers: broadcastConfig.drivers,
|
|
278
|
-
});
|
|
279
|
-
const disks = await tryImportOptional(isCompiledJsModule()
|
|
280
|
-
? '../tools/storage/StorageRuntimeRegistration.js'
|
|
281
|
-
: '../tools/storage/StorageRuntimeRegistration');
|
|
282
|
-
disks?.registerDisksFromRuntimeConfig?.(storageConfig);
|
|
283
|
-
const notifications = await tryImportOptional(isCompiledJsModule()
|
|
284
|
-
? '../tools/notification/NotificationRuntimeRegistration.js'
|
|
285
|
-
: '../tools/notification/NotificationRuntimeRegistration');
|
|
286
|
-
notifications?.registerNotificationChannelsFromRuntimeConfig?.({
|
|
287
|
-
default: notificationConfig.default,
|
|
288
|
-
drivers: notificationConfig.drivers,
|
|
289
|
-
});
|
|
290
|
-
};
|
|
291
|
-
const createLifecycle = (params) => {
|
|
292
|
-
const boot = async () => {
|
|
293
|
-
if (params.getBooted())
|
|
294
|
-
return;
|
|
295
|
-
Logger.info(`🚀 Booting ZinTrust Application in ${params.environment} mode...`);
|
|
296
|
-
StartupConfigValidator.assertValid();
|
|
297
|
-
// Preload project-owned config overrides that must be available synchronously.
|
|
298
|
-
await StartupConfigFileRegistry.preload([
|
|
299
|
-
StartupConfigFile.Middleware,
|
|
300
|
-
StartupConfigFile.Cache,
|
|
301
|
-
StartupConfigFile.Database,
|
|
302
|
-
StartupConfigFile.Queue,
|
|
303
|
-
StartupConfigFile.Storage,
|
|
304
|
-
StartupConfigFile.Mail,
|
|
305
|
-
StartupConfigFile.Broadcast,
|
|
306
|
-
StartupConfigFile.Notification,
|
|
307
|
-
]);
|
|
308
|
-
FeatureFlags.initialize();
|
|
309
|
-
await StartupHealthChecks.assertHealthy();
|
|
310
|
-
await registerFromRuntimeConfig();
|
|
311
|
-
await initializeArtifactDirectories(params.resolvedBasePath);
|
|
312
|
-
await registerRoutes(params.resolvedBasePath, params.router);
|
|
313
|
-
// Register service providers
|
|
314
|
-
// Bootstrap services
|
|
315
|
-
Logger.info('✅ Application booted successfully');
|
|
316
|
-
params.setBooted(true);
|
|
317
|
-
};
|
|
318
|
-
const shutdown = async () => {
|
|
319
|
-
Logger.info('🛑 Shutting down application...');
|
|
320
|
-
try {
|
|
321
|
-
await params.shutdownManager.run();
|
|
322
|
-
}
|
|
323
|
-
catch (error) {
|
|
324
|
-
Logger.error('Shutdown hook failed:', error);
|
|
325
|
-
}
|
|
326
|
-
// Ensure FileLogWriter.flush is attempted even if dynamic registration failed.
|
|
327
|
-
try {
|
|
328
|
-
const fileLogWriter = await tryImportOptional('@config/FileLogWriter');
|
|
329
|
-
fileLogWriter?.FileLogWriter?.flush?.();
|
|
330
|
-
}
|
|
331
|
-
catch {
|
|
332
|
-
/* best-effort */
|
|
333
|
-
}
|
|
334
|
-
params.setBooted(false);
|
|
335
|
-
Logger.info('✅ Application shut down successfully');
|
|
336
|
-
};
|
|
337
|
-
return { boot, shutdown };
|
|
338
|
-
};
|
|
339
51
|
/**
|
|
340
52
|
* Application Factory
|
|
341
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,9 +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 workers = await
|
|
108
|
+
const workers = await loadWorkersModule();
|
|
107
109
|
const workerBudgetMs = Math.min(15000, remainingMs());
|
|
108
110
|
await withTimeout(workers.WorkerShutdown.shutdown({
|
|
109
111
|
signal,
|
|
@@ -137,10 +139,16 @@ const gracefulShutdown = async (signal) => {
|
|
|
137
139
|
}
|
|
138
140
|
};
|
|
139
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
|
+
}
|
|
140
148
|
// Initialize worker management system
|
|
141
149
|
let workerInit = null;
|
|
142
150
|
try {
|
|
143
|
-
const workers = await
|
|
151
|
+
const workers = await loadWorkersModule();
|
|
144
152
|
if (workers?.WorkerInit !== undefined) {
|
|
145
153
|
workerInit = workers.WorkerInit;
|
|
146
154
|
await workers.WorkerInit.initialize({
|
|
@@ -199,12 +207,22 @@ const BootstrapFunctions = Object.freeze({
|
|
|
199
207
|
Logger.info(`ZinTrust documentation at http://${host}:${port}/doc`);
|
|
200
208
|
// Start schedules for long-running runtimes (Node.js / Fargate)
|
|
201
209
|
await startSchedulesIfNeeded(app);
|
|
202
|
-
if (appConfig.
|
|
210
|
+
if (appConfig.dockerWorker === false &&
|
|
211
|
+
(appConfig.detectRuntime() === 'nodejs' || appConfig.detectRuntime() === 'lambda')) {
|
|
203
212
|
await useWorkerStarter();
|
|
204
213
|
}
|
|
205
214
|
}
|
|
206
215
|
catch (error) {
|
|
207
|
-
|
|
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
|
+
});
|
|
208
226
|
logBootstrapErrorDetails(error);
|
|
209
227
|
process.exit(1);
|
|
210
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"}
|