@zintrust/core 0.1.19 → 0.1.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -10
- package/bin/zintrust-main.d.ts.map +1 -1
- package/bin/zintrust-main.js +9 -0
- package/package.json +2 -2
- package/public/error-pages/404.html +145 -0
- package/public/error-pages/500.html +266 -0
- package/public/error-pages/error.css +628 -0
- package/public/error-pages/error.js +428 -0
- package/public/zintrust.svg +30 -0
- package/routes/api.d.ts.map +1 -1
- package/routes/api.js +41 -17
- package/routes/metrics.d.ts +9 -0
- package/routes/metrics.d.ts.map +1 -0
- package/routes/metrics.js +20 -0
- package/routes/openapi.d.ts +9 -0
- package/routes/openapi.d.ts.map +1 -0
- package/routes/openapi.js +76 -0
- package/src/boot/Application.d.ts +2 -2
- package/src/boot/Application.d.ts.map +1 -1
- package/src/boot/Application.js +18 -3
- package/src/boot/Server.d.ts +3 -2
- package/src/boot/Server.d.ts.map +1 -1
- package/src/boot/Server.js +39 -165
- package/src/cache/Cache.d.ts +1 -1
- package/src/cache/Cache.d.ts.map +1 -1
- package/src/cache/CacheDriver.d.ts +4 -0
- package/src/cache/CacheDriver.d.ts.map +1 -1
- package/src/cache/drivers/KVDriver.d.ts +1 -1
- package/src/cache/drivers/KVDriver.d.ts.map +1 -1
- package/src/cache/drivers/MemoryDriver.d.ts +1 -1
- package/src/cache/drivers/MemoryDriver.d.ts.map +1 -1
- package/src/cache/drivers/MemoryDriver.js +16 -0
- package/src/cache/drivers/MongoDriver.d.ts +1 -1
- package/src/cache/drivers/MongoDriver.d.ts.map +1 -1
- package/src/cache/drivers/RedisDriver.d.ts +1 -1
- package/src/cache/drivers/RedisDriver.d.ts.map +1 -1
- package/src/cli/CLI.d.ts.map +1 -1
- package/src/cli/CLI.js +10 -4
- package/src/cli/commands/AddCommand.d.ts +2 -2
- package/src/cli/commands/AddCommand.d.ts.map +1 -1
- package/src/cli/commands/AddCommand.js +135 -58
- package/src/cli/commands/ConfigCommand.d.ts +1 -1
- package/src/cli/commands/ConfigCommand.d.ts.map +1 -1
- package/src/cli/commands/CreateCommand.d.ts +15 -0
- package/src/cli/commands/CreateCommand.d.ts.map +1 -0
- package/src/cli/commands/CreateCommand.js +143 -0
- package/src/cli/commands/D1MigrateCommand.d.ts +1 -1
- package/src/cli/commands/D1MigrateCommand.d.ts.map +1 -1
- package/src/cli/commands/D1MigrateCommand.js +16 -20
- package/src/cli/commands/DbSeedCommand.d.ts +9 -0
- package/src/cli/commands/DbSeedCommand.d.ts.map +1 -0
- package/src/cli/commands/DbSeedCommand.js +171 -0
- package/src/cli/commands/DebugCommand.d.ts +1 -1
- package/src/cli/commands/DebugCommand.d.ts.map +1 -1
- package/src/cli/commands/FixCommand.d.ts +1 -1
- package/src/cli/commands/FixCommand.d.ts.map +1 -1
- package/src/cli/commands/JwtDevCommand.d.ts +8 -0
- package/src/cli/commands/JwtDevCommand.d.ts.map +1 -0
- package/src/cli/commands/JwtDevCommand.js +114 -0
- package/src/cli/commands/KeyGenerateCommand.d.ts +1 -1
- package/src/cli/commands/KeyGenerateCommand.d.ts.map +1 -1
- package/src/cli/commands/LogsCommand.d.ts +2 -2
- package/src/cli/commands/LogsCommand.d.ts.map +1 -1
- package/src/cli/commands/LogsCommand.js +36 -2
- package/src/cli/commands/MakeMailTemplateCommand.d.ts +1 -1
- package/src/cli/commands/MakeMailTemplateCommand.d.ts.map +1 -1
- package/src/cli/commands/MakeNotificationTemplateCommand.d.ts +1 -1
- package/src/cli/commands/MakeNotificationTemplateCommand.d.ts.map +1 -1
- package/src/cli/commands/MigrateCommand.d.ts +1 -1
- package/src/cli/commands/MigrateCommand.d.ts.map +1 -1
- package/src/cli/commands/MigrateCommand.js +291 -35
- package/src/cli/commands/NewCommand.d.ts +1 -1
- package/src/cli/commands/NewCommand.d.ts.map +1 -1
- package/src/cli/commands/NewCommand.js +12 -4
- package/src/cli/commands/PluginCommand.d.ts +1 -1
- package/src/cli/commands/PluginCommand.d.ts.map +1 -1
- package/src/cli/commands/PrepareCommand.d.ts +1 -1
- package/src/cli/commands/PrepareCommand.d.ts.map +1 -1
- package/src/cli/commands/QACommand.d.ts +2 -2
- package/src/cli/commands/QACommand.d.ts.map +1 -1
- package/src/cli/commands/RoutesCommand.d.ts +10 -0
- package/src/cli/commands/RoutesCommand.d.ts.map +1 -0
- package/src/cli/commands/RoutesCommand.js +242 -0
- package/src/cli/commands/SimulateCommand.d.ts +1 -1
- package/src/cli/commands/SimulateCommand.d.ts.map +1 -1
- package/src/cli/commands/index.d.ts +3 -0
- package/src/cli/commands/index.d.ts.map +1 -1
- package/src/cli/commands/index.js +3 -0
- package/src/cli/config/ConfigManager.d.ts +1 -1
- package/src/cli/config/ConfigManager.d.ts.map +1 -1
- package/src/cli/config/ConfigValidator.d.ts +1 -1
- package/src/cli/config/ConfigValidator.d.ts.map +1 -1
- package/src/cli/config/ConfigValidator.js +1 -1
- package/src/cli/d1/D1SqlMigrations.d.ts +20 -0
- package/src/cli/d1/D1SqlMigrations.d.ts.map +1 -0
- package/src/cli/d1/D1SqlMigrations.js +224 -0
- package/src/cli/d1/WranglerConfig.d.ts +4 -0
- package/src/cli/d1/WranglerConfig.d.ts.map +1 -0
- package/src/cli/d1/WranglerConfig.js +122 -0
- package/src/cli/d1/WranglerD1.d.ts +11 -0
- package/src/cli/d1/WranglerD1.d.ts.map +1 -0
- package/src/cli/d1/WranglerD1.js +16 -0
- package/src/cli/scaffolding/ControllerGenerator.d.ts.map +1 -1
- package/src/cli/scaffolding/ControllerGenerator.js +72 -22
- package/src/cli/scaffolding/FactoryGenerator.d.ts.map +1 -1
- package/src/cli/scaffolding/FactoryGenerator.js +3 -1
- package/src/cli/scaffolding/GovernanceScaffolder.d.ts +23 -0
- package/src/cli/scaffolding/GovernanceScaffolder.d.ts.map +1 -0
- package/src/cli/scaffolding/GovernanceScaffolder.js +327 -0
- package/src/cli/scaffolding/MigrationGenerator.d.ts +10 -0
- package/src/cli/scaffolding/MigrationGenerator.d.ts.map +1 -1
- package/src/cli/scaffolding/MigrationGenerator.js +137 -51
- package/src/cli/scaffolding/ProjectScaffolder.d.ts.map +1 -1
- package/src/cli/scaffolding/ProjectScaffolder.js +36 -4
- package/src/cli/scaffolding/RouteGenerator.d.ts.map +1 -1
- package/src/cli/scaffolding/RouteGenerator.js +79 -43
- package/src/cli/scaffolding/SeederGenerator.d.ts +5 -0
- package/src/cli/scaffolding/SeederGenerator.d.ts.map +1 -1
- package/src/cli/scaffolding/SeederGenerator.js +63 -15
- package/src/cli/scaffolding/ServiceScaffolder.d.ts.map +1 -1
- package/src/cli/scaffolding/ServiceScaffolder.js +24 -3
- package/src/cli/scaffolding/index.d.ts +2 -0
- package/src/cli/scaffolding/index.d.ts.map +1 -1
- package/src/cli/scaffolding/index.js +1 -0
- package/src/common/index.d.ts +8 -0
- package/src/common/index.d.ts.map +1 -1
- package/src/common/index.js +28 -0
- package/src/common/utility.d.ts +38 -0
- package/src/common/utility.d.ts.map +1 -0
- package/src/common/utility.js +101 -0
- package/src/config/FileLogWriter.d.ts +2 -1
- package/src/config/FileLogWriter.d.ts.map +1 -1
- package/src/config/FileLogWriter.js +83 -2
- package/src/config/app.d.ts.map +1 -1
- package/src/config/app.js +3 -1
- package/src/config/broadcast.d.ts +1 -1
- package/src/config/broadcast.d.ts.map +1 -1
- package/src/config/cache.d.ts +1 -1
- package/src/config/cache.d.ts.map +1 -1
- package/src/config/cloudflare.d.ts +1 -1
- package/src/config/cloudflare.d.ts.map +1 -1
- package/src/config/database.d.ts +1 -1
- package/src/config/database.d.ts.map +1 -1
- package/src/config/database.js +92 -6
- package/src/config/env.d.ts +6 -0
- package/src/config/env.d.ts.map +1 -1
- package/src/config/env.js +7 -0
- package/src/config/index.d.ts +1 -1
- package/src/config/logging/KvLogger.js +1 -1
- package/src/config/logging/SlackLogger.js +2 -2
- package/src/config/middleware.d.ts +20 -1
- package/src/config/middleware.d.ts.map +1 -1
- package/src/config/middleware.js +135 -3
- package/src/config/security.d.ts +1 -1
- package/src/config/security.js +1 -1
- package/src/config/type.d.ts +1 -1
- package/src/config/type.d.ts.map +1 -1
- package/src/events/EventDispatcher.d.ts.map +1 -1
- package/src/events/EventDispatcher.js +6 -4
- package/src/exceptions/ZintrustError.d.ts +7 -0
- package/src/exceptions/ZintrustError.d.ts.map +1 -1
- package/src/exceptions/ZintrustError.js +56 -0
- package/src/features/Auth.d.ts +1 -1
- package/src/features/Auth.d.ts.map +1 -1
- package/src/features/Auth.js +3 -3
- package/src/features/Queue.js +1 -1
- package/src/functions/cloudflare.d.ts.map +1 -1
- package/src/functions/cloudflare.js +3 -14
- package/src/functions/deno.d.ts.map +1 -1
- package/src/functions/deno.js +3 -14
- package/src/functions/lambda.d.ts.map +1 -1
- package/src/functions/lambda.js +3 -14
- package/src/health/StartupHealthChecks.js +1 -1
- package/src/http/Controller.d.ts +2 -2
- package/src/http/Controller.d.ts.map +1 -1
- package/src/http/FileUpload.d.ts +68 -0
- package/src/http/FileUpload.d.ts.map +1 -0
- package/src/http/FileUpload.js +120 -0
- package/src/http/Kernel.d.ts +5 -5
- package/src/http/Kernel.d.ts.map +1 -1
- package/src/http/Kernel.js +139 -23
- package/src/http/Request.d.ts +20 -1
- package/src/http/Request.d.ts.map +1 -1
- package/src/http/Request.js +23 -0
- package/src/http/RequestContext.d.ts +6 -0
- package/src/http/RequestContext.d.ts.map +1 -1
- package/src/http/RequestContext.js +77 -1
- package/src/http/Response.d.ts +1 -1
- package/src/http/Response.d.ts.map +1 -1
- package/src/http/ValidationHelper.d.ts +78 -0
- package/src/http/ValidationHelper.d.ts.map +1 -0
- package/src/http/ValidationHelper.js +121 -0
- package/src/http/error-pages/ErrorPageRenderer.d.ts +17 -0
- package/src/http/error-pages/ErrorPageRenderer.d.ts.map +1 -0
- package/src/http/error-pages/ErrorPageRenderer.js +88 -0
- package/src/http/middleware/BodyParsingMiddleware.d.ts +12 -0
- package/src/http/middleware/BodyParsingMiddleware.d.ts.map +1 -0
- package/src/http/middleware/BodyParsingMiddleware.js +251 -0
- package/src/http/middleware/FileUploadMiddleware.d.ts +12 -0
- package/src/http/middleware/FileUploadMiddleware.d.ts.map +1 -0
- package/src/http/middleware/FileUploadMiddleware.js +74 -0
- package/src/http/parsers/BodyParsers.d.ts +32 -0
- package/src/http/parsers/BodyParsers.d.ts.map +1 -0
- package/src/http/parsers/BodyParsers.js +159 -0
- package/src/http/parsers/MultipartParser.d.ts +33 -0
- package/src/http/parsers/MultipartParser.d.ts.map +1 -0
- package/src/http/parsers/MultipartParser.js +129 -0
- package/src/http/parsers/MultipartParserRegistry.d.ts +34 -0
- package/src/http/parsers/MultipartParserRegistry.d.ts.map +1 -0
- package/src/http/parsers/MultipartParserRegistry.js +20 -0
- package/src/http/validated.d.ts +12 -0
- package/src/http/validated.d.ts.map +1 -0
- package/src/http/validated.js +41 -0
- package/src/index.d.ts +64 -7
- package/src/index.d.ts.map +1 -1
- package/src/index.js +59 -5
- package/src/microservices/RequestTracingMiddleware.d.ts +2 -2
- package/src/microservices/RequestTracingMiddleware.d.ts.map +1 -1
- package/src/microservices/RequestTracingMiddleware.js +3 -0
- package/src/microservices/ServiceAuthMiddleware.d.ts +2 -2
- package/src/microservices/ServiceAuthMiddleware.d.ts.map +1 -1
- package/src/middleware/AuthMiddleware.d.ts +10 -0
- package/src/middleware/AuthMiddleware.d.ts.map +1 -0
- package/src/middleware/AuthMiddleware.js +16 -0
- package/src/middleware/CsrfMiddleware.d.ts +11 -1
- package/src/middleware/CsrfMiddleware.d.ts.map +1 -1
- package/src/middleware/CsrfMiddleware.js +33 -0
- package/src/middleware/JwtAuthMiddleware.d.ts +11 -0
- package/src/middleware/JwtAuthMiddleware.d.ts.map +1 -0
- package/src/middleware/JwtAuthMiddleware.js +73 -0
- package/src/middleware/LoggingMiddleware.d.ts.map +1 -1
- package/src/middleware/LoggingMiddleware.js +8 -3
- package/src/middleware/MiddlewareStack.d.ts +2 -2
- package/src/middleware/MiddlewareStack.d.ts.map +1 -1
- package/src/middleware/RateLimiter.d.ts +2 -2
- package/src/middleware/RateLimiter.d.ts.map +1 -1
- package/src/middleware/SanitizeBodyMiddleware.d.ts +12 -0
- package/src/middleware/SanitizeBodyMiddleware.d.ts.map +1 -0
- package/src/middleware/SanitizeBodyMiddleware.js +31 -0
- package/src/middleware/SecurityMiddleware.d.ts +1 -1
- package/src/middleware/SecurityMiddleware.d.ts.map +1 -1
- package/src/middleware/SessionMiddleware.d.ts +1 -1
- package/src/middleware/SessionMiddleware.d.ts.map +1 -1
- package/src/middleware/ValidationMiddleware.d.ts +25 -0
- package/src/middleware/ValidationMiddleware.d.ts.map +1 -0
- package/src/middleware/ValidationMiddleware.js +251 -0
- package/src/migrations/MigrationDiscovery.d.ts +5 -0
- package/src/migrations/MigrationDiscovery.d.ts.map +1 -0
- package/src/migrations/MigrationDiscovery.js +16 -0
- package/src/migrations/MigrationLoader.d.ts +5 -0
- package/src/migrations/MigrationLoader.d.ts.map +1 -0
- package/src/migrations/MigrationLoader.js +43 -0
- package/src/migrations/MigrationLock.d.ts +4 -0
- package/src/migrations/MigrationLock.d.ts.map +1 -0
- package/src/migrations/MigrationLock.js +33 -0
- package/src/migrations/Migrator.d.ts +23 -0
- package/src/migrations/Migrator.d.ts.map +1 -0
- package/src/migrations/Migrator.js +4 -0
- package/src/migrations/MigratorFactory.d.ts +25 -0
- package/src/migrations/MigratorFactory.d.ts.map +1 -0
- package/src/migrations/MigratorFactory.js +323 -0
- package/src/migrations/schema/Blueprint.d.ts +5 -0
- package/src/migrations/schema/Blueprint.d.ts.map +1 -0
- package/src/migrations/schema/Blueprint.js +189 -0
- package/src/migrations/schema/Schema.d.ts +8 -0
- package/src/migrations/schema/Schema.d.ts.map +1 -0
- package/src/migrations/schema/Schema.js +141 -0
- package/src/migrations/schema/SchemaCompiler.d.ts +20 -0
- package/src/migrations/schema/SchemaCompiler.d.ts.map +1 -0
- package/src/migrations/schema/SchemaCompiler.js +262 -0
- package/src/migrations/schema/index.d.ts +5 -0
- package/src/migrations/schema/index.d.ts.map +1 -0
- package/src/migrations/schema/index.js +3 -0
- package/src/migrations/schema/types.d.ts +86 -0
- package/src/migrations/schema/types.d.ts.map +1 -0
- package/src/migrations/schema/types.js +1 -0
- package/src/migrations/types.d.ts +45 -0
- package/src/migrations/types.d.ts.map +1 -0
- package/src/migrations/types.js +1 -0
- package/src/node-singletons/crypto.d.ts +1 -1
- package/src/node-singletons/crypto.d.ts.map +1 -1
- package/src/node-singletons/crypto.js +1 -1
- package/src/node-singletons/fs.d.ts +2 -2
- package/src/node-singletons/fs.d.ts.map +1 -1
- package/src/node-singletons/fs.js +1 -1
- package/src/node-singletons/util.d.ts +6 -0
- package/src/node-singletons/util.d.ts.map +1 -0
- package/src/node-singletons/util.js +5 -0
- package/src/node.d.ts +3 -1
- package/src/node.d.ts.map +1 -1
- package/src/node.js +6 -2
- package/src/observability/OpenTelemetry.d.ts +62 -0
- package/src/observability/OpenTelemetry.d.ts.map +1 -0
- package/src/observability/OpenTelemetry.js +167 -0
- package/src/observability/PrometheusMetrics.d.ts +25 -0
- package/src/observability/PrometheusMetrics.d.ts.map +1 -0
- package/src/observability/PrometheusMetrics.js +114 -0
- package/src/openapi/OpenApiGenerator.d.ts +68 -0
- package/src/openapi/OpenApiGenerator.d.ts.map +1 -0
- package/src/openapi/OpenApiGenerator.js +287 -0
- package/src/orm/Database.d.ts +4 -2
- package/src/orm/Database.d.ts.map +1 -1
- package/src/orm/Database.js +142 -29
- package/src/orm/DatabaseAdapter.d.ts +13 -0
- package/src/orm/DatabaseAdapter.d.ts.map +1 -1
- package/src/orm/DatabaseAdapterRegistry.d.ts.map +1 -1
- package/src/orm/DatabaseAdapterRegistry.js +3 -1
- package/src/orm/Model.d.ts +30 -2
- package/src/orm/Model.d.ts.map +1 -1
- package/src/orm/Model.js +255 -62
- package/src/orm/QueryBuilder.d.ts +22 -1
- package/src/orm/QueryBuilder.d.ts.map +1 -1
- package/src/orm/QueryBuilder.js +405 -99
- package/src/orm/Relationships.d.ts +7 -1
- package/src/orm/Relationships.d.ts.map +1 -1
- package/src/orm/Relationships.js +18 -0
- package/src/orm/SchemaCompiler.d.ts +9 -0
- package/src/orm/SchemaCompiler.d.ts.map +1 -0
- package/src/orm/SchemaCompiler.js +145 -0
- package/src/orm/adapters/D1Adapter.d.ts +1 -1
- package/src/orm/adapters/D1Adapter.d.ts.map +1 -1
- package/src/orm/adapters/MySQLAdapter.d.ts +1 -1
- package/src/orm/adapters/MySQLAdapter.d.ts.map +1 -1
- package/src/orm/adapters/MySQLAdapter.js +88 -69
- package/src/orm/adapters/PostgreSQLAdapter.d.ts +1 -1
- package/src/orm/adapters/PostgreSQLAdapter.d.ts.map +1 -1
- package/src/orm/adapters/PostgreSQLAdapter.js +88 -69
- package/src/orm/adapters/SQLServerAdapter.d.ts +1 -1
- package/src/orm/adapters/SQLServerAdapter.d.ts.map +1 -1
- package/src/orm/adapters/SQLiteAdapter.d.ts +1 -1
- package/src/orm/adapters/SQLiteAdapter.d.ts.map +1 -1
- package/src/orm/adapters/SQLiteAdapter.js +58 -2
- package/src/orm/maintenance/SqliteMaintenance.d.ts +5 -0
- package/src/orm/maintenance/SqliteMaintenance.d.ts.map +1 -0
- package/src/orm/maintenance/SqliteMaintenance.js +14 -0
- package/src/orm/migrations/MigrationStore.d.ts +38 -0
- package/src/orm/migrations/MigrationStore.d.ts.map +1 -0
- package/src/orm/migrations/MigrationStore.js +157 -0
- package/src/performance/CodeGenerationBenchmark.d.ts.map +1 -1
- package/src/performance/Optimizer.d.ts +1 -0
- package/src/performance/Optimizer.d.ts.map +1 -1
- package/src/performance/Optimizer.js +37 -3
- package/src/profiling/MemoryProfiler.d.ts +1 -1
- package/src/profiling/MemoryProfiler.d.ts.map +1 -1
- package/src/profiling/N1Detector.d.ts +1 -1
- package/src/profiling/N1Detector.d.ts.map +1 -1
- package/src/profiling/QueryLogger.d.ts +1 -1
- package/src/profiling/QueryLogger.d.ts.map +1 -1
- package/src/profiling/RequestProfiler.d.ts +3 -3
- package/src/profiling/RequestProfiler.d.ts.map +1 -1
- package/src/routes/metrics.d.ts +2 -0
- package/src/routes/metrics.d.ts.map +1 -0
- package/src/routes/metrics.js +1 -0
- package/src/routing/CoreRoutes.d.ts +12 -0
- package/src/routing/CoreRoutes.d.ts.map +1 -0
- package/src/routing/CoreRoutes.js +151 -0
- package/src/routing/RouteRegistry.d.ts +39 -0
- package/src/routing/RouteRegistry.d.ts.map +1 -0
- package/src/routing/RouteRegistry.js +44 -0
- package/src/routing/Router.d.ts +26 -9
- package/src/routing/Router.d.ts.map +1 -1
- package/src/routing/Router.js +79 -35
- package/src/routing/common.d.ts +15 -0
- package/src/routing/common.d.ts.map +1 -0
- package/src/routing/common.js +47 -0
- package/src/routing/doc.d.ts +28 -0
- package/src/routing/doc.d.ts.map +1 -0
- package/src/routing/doc.js +95 -0
- package/src/routing/error.d.ts +21 -0
- package/src/routing/error.d.ts.map +1 -0
- package/src/routing/error.js +126 -0
- package/src/routing/errorPages.d.ts +14 -0
- package/src/routing/errorPages.d.ts.map +1 -0
- package/src/routing/errorPages.js +103 -0
- package/src/routing/publicRoot.d.ts +18 -0
- package/src/routing/publicRoot.d.ts.map +1 -0
- package/src/routing/publicRoot.js +49 -0
- package/src/runtime/PluginAutoImports.d.ts +21 -0
- package/src/runtime/PluginAutoImports.d.ts.map +1 -0
- package/src/runtime/PluginAutoImports.js +59 -0
- package/src/runtime/PluginManager.d.ts +1 -5
- package/src/runtime/PluginManager.d.ts.map +1 -1
- package/src/runtime/PluginManager.js +25 -18
- package/src/runtime/RuntimeDetector.d.ts +1 -1
- package/src/runtime/RuntimeDetector.d.ts.map +1 -1
- package/src/runtime/adapters/CloudflareAdapter.d.ts +1 -1
- package/src/runtime/adapters/CloudflareAdapter.d.ts.map +1 -1
- package/src/runtime/adapters/CloudflareAdapter.js +1 -1
- package/src/runtime/adapters/DenoAdapter.d.ts +1 -1
- package/src/runtime/adapters/DenoAdapter.d.ts.map +1 -1
- package/src/runtime/adapters/DenoAdapter.js +1 -1
- package/src/runtime/adapters/LambdaAdapter.d.ts +1 -1
- package/src/runtime/adapters/LambdaAdapter.d.ts.map +1 -1
- package/src/runtime/adapters/LambdaAdapter.js +1 -1
- package/src/runtime/adapters/NodeServerAdapter.d.ts +1 -1
- package/src/runtime/adapters/NodeServerAdapter.d.ts.map +1 -1
- package/src/runtime/getKernel.d.ts +9 -0
- package/src/runtime/getKernel.d.ts.map +1 -0
- package/src/runtime/getKernel.js +27 -0
- package/src/scripts/TemplateImportsCheck.js +40 -0
- package/src/scripts/TemplateSync.js +86 -20
- package/src/security/Encryptor.d.ts.map +1 -1
- package/src/security/Encryptor.js +64 -7
- package/src/security/JwtManager.d.ts +1 -0
- package/src/security/JwtManager.d.ts.map +1 -1
- package/src/security/JwtManager.js +33 -0
- package/src/security/Sanitizer.d.ts +76 -0
- package/src/security/Sanitizer.d.ts.map +1 -0
- package/src/security/Sanitizer.js +412 -0
- package/src/security/TokenRevocation.d.ts +7 -0
- package/src/security/TokenRevocation.d.ts.map +1 -0
- package/src/security/TokenRevocation.js +57 -0
- package/src/seeders/SeederDiscovery.d.ts +5 -0
- package/src/seeders/SeederDiscovery.d.ts.map +1 -0
- package/src/seeders/SeederDiscovery.js +21 -0
- package/src/seeders/SeederLoader.d.ts +5 -0
- package/src/seeders/SeederLoader.d.ts.map +1 -0
- package/src/seeders/SeederLoader.js +60 -0
- package/src/seeders/types.d.ts +18 -0
- package/src/seeders/types.d.ts.map +1 -0
- package/src/seeders/types.js +1 -0
- package/src/session/SessionManager.js +1 -1
- package/src/templates/adapters/MySQLAdapter.ts.tpl +109 -85
- package/src/templates/adapters/PostgreSQLAdapter.ts.tpl +129 -88
- package/src/templates/adapters/SQLServerAdapter.ts.tpl +5 -9
- package/src/templates/adapters/SQLiteAdapter.ts.tpl +78 -11
- package/src/templates/features/Queue.ts.tpl +3 -2
- package/src/templates/project/basic/app/Controllers/AuthController.ts.tpl +217 -0
- package/src/templates/project/basic/app/Controllers/UserController.ts.tpl +1 -12
- package/src/templates/project/basic/app/Types/controller.ts.tpl +46 -0
- package/src/templates/project/basic/config/FileLogWriter.ts.tpl +5 -236
- package/src/templates/project/basic/config/SecretsManager.ts.tpl +10 -447
- package/src/templates/project/basic/config/StartupConfigValidator.ts.tpl +9 -268
- package/src/templates/project/basic/config/app.ts.tpl +13 -153
- package/src/templates/project/basic/config/broadcast.ts.tpl +15 -128
- package/src/templates/project/basic/config/cache.ts.tpl +15 -91
- package/src/templates/project/basic/config/cloudflare.ts.tpl +4 -39
- package/src/templates/project/basic/config/constants.ts.tpl +9 -65
- package/src/templates/project/basic/config/database.ts.tpl +29 -122
- package/src/templates/project/basic/config/env.ts.tpl +5 -169
- package/src/templates/project/basic/config/features.ts.tpl +6 -54
- package/src/templates/project/basic/config/index.ts.tpl +8 -23
- package/src/templates/project/basic/config/mail.ts.tpl +15 -114
- package/src/templates/project/basic/config/microservices.ts.tpl +11 -97
- package/src/templates/project/basic/config/middleware.ts.tpl +25 -43
- package/src/templates/project/basic/config/notification.ts.tpl +14 -126
- package/src/templates/project/basic/config/queue.ts.tpl +16 -79
- package/src/templates/project/basic/config/security.ts.tpl +11 -163
- package/src/templates/project/basic/config/startup.ts.tpl +10 -21
- package/src/templates/project/basic/config/storage.ts.tpl +15 -132
- package/src/templates/project/basic/config/type.ts.tpl +33 -451
- package/src/templates/project/basic/database/factories/UserFactory.ts.tpl +80 -0
- package/src/templates/project/basic/database/migrations/create_tasks_table.ts.tpl +28 -0
- package/src/templates/project/basic/database/migrations/create_users_table.ts.tpl +29 -0
- package/src/templates/project/basic/database/seeders/DatabaseSeeder.ts.tpl +19 -0
- package/src/templates/project/basic/database/seeders/UserSeeder.ts.tpl +18 -0
- package/src/templates/project/basic/database/seeders/index.ts.tpl +2 -0
- package/src/templates/project/basic/routes/api.ts.tpl +71 -33
- package/src/templates/project/basic/routes/metrics.ts.tpl +22 -0
- package/src/templates/project/basic/tsconfig.json.tpl +12 -11
- package/src/testing/TestEnvironment.d.ts +40 -0
- package/src/testing/TestEnvironment.d.ts.map +1 -0
- package/src/testing/TestEnvironment.js +141 -0
- package/src/testing/TestHttp.d.ts +29 -0
- package/src/testing/TestHttp.d.ts.map +1 -0
- package/src/testing/TestHttp.js +96 -0
- package/src/testing/index.d.ts +5 -0
- package/src/testing/index.d.ts.map +1 -0
- package/src/testing/index.js +2 -0
- package/src/time/DateTime.d.ts +181 -0
- package/src/time/DateTime.d.ts.map +1 -0
- package/src/time/DateTime.js +300 -0
- package/src/time/index.d.ts +7 -0
- package/src/time/index.d.ts.map +1 -0
- package/src/time/index.js +5 -0
- package/src/tools/http/Http.d.ts.map +1 -1
- package/src/tools/http/Http.js +4 -0
- package/src/tools/mail/drivers/Smtp.js +1 -1
- package/src/tools/queue/drivers/InMemory.d.ts +1 -1
- package/src/tools/queue/drivers/InMemory.d.ts.map +1 -1
- package/src/tools/queue/drivers/InMemory.js +1 -1
- package/src/tools/queue/drivers/Redis.d.ts +1 -1
- package/src/tools/queue/drivers/Redis.d.ts.map +1 -1
- package/src/tools/queue/drivers/Redis.js +1 -1
- package/src/validation/ValidationError.d.ts.map +1 -1
- package/src/validation/ValidationError.js +4 -2
- package/src/validation/Validator.d.ts +49 -16
- package/src/validation/Validator.d.ts.map +1 -1
- package/src/validation/Validator.js +307 -5
- package/src/common/uuid.d.ts +0 -3
- package/src/common/uuid.d.ts.map +0 -1
- package/src/common/uuid.js +0 -30
- package/src/templates/project/basic/.env.example.tpl +0 -74
- package/src/templates/project/basic/.env.tpl +0 -166
- package/src/templates/project/basic/database/migrations/index.ts.tpl +0 -2
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { ErrorFactory } from '../exceptions/ZintrustError.js';
|
|
2
|
+
import { randomBytes } from '../node-singletons/crypto.js';
|
|
3
|
+
export const generateUuid = () => {
|
|
4
|
+
if (typeof globalThis?.crypto?.randomUUID === 'function')
|
|
5
|
+
return globalThis.crypto.randomUUID();
|
|
6
|
+
return `${Date.now()}-${Math.random().toString(36).slice(2, 9)}`; // NOSONAR
|
|
7
|
+
};
|
|
8
|
+
export function generateSecureJobId(errMsg = 'Secure crypto API not available to generate a job id.') {
|
|
9
|
+
if (typeof globalThis.crypto?.randomUUID === 'function') {
|
|
10
|
+
return globalThis.crypto.randomUUID();
|
|
11
|
+
}
|
|
12
|
+
if (typeof globalThis.crypto?.getRandomValues === 'function') {
|
|
13
|
+
const bytes = new Uint8Array(16);
|
|
14
|
+
globalThis.crypto.getRandomValues(bytes);
|
|
15
|
+
return bytesToHex(bytes);
|
|
16
|
+
}
|
|
17
|
+
// Node fallback for environments without Web Crypto
|
|
18
|
+
try {
|
|
19
|
+
return randomBytes(16).toString('hex');
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
throw ErrorFactory.createTryCatchError(errMsg || 'Secure crypto API not available to generate a job id.', error);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export const getString = (value) => (typeof value === 'string' ? value : '');
|
|
26
|
+
function bytesToHex(bytes) {
|
|
27
|
+
let out = '';
|
|
28
|
+
for (const b of bytes)
|
|
29
|
+
out += b.toString(16).padStart(2, '0');
|
|
30
|
+
return out;
|
|
31
|
+
}
|
|
32
|
+
export function isEmpty(value) {
|
|
33
|
+
return (value === null ||
|
|
34
|
+
value === undefined ||
|
|
35
|
+
value === false ||
|
|
36
|
+
value === 0 ||
|
|
37
|
+
value === '' ||
|
|
38
|
+
value === '0');
|
|
39
|
+
}
|
|
40
|
+
export function toStr(value) {
|
|
41
|
+
return String(value ?? '');
|
|
42
|
+
}
|
|
43
|
+
export function stripSpaces(value) {
|
|
44
|
+
return toStr(value).replaceAll(' ', '');
|
|
45
|
+
}
|
|
46
|
+
export function sanitize(value, pattern, stripSpace = false) {
|
|
47
|
+
const input = stripSpace ? stripSpaces(value) : toStr(value);
|
|
48
|
+
return input.replace(pattern, '');
|
|
49
|
+
}
|
|
50
|
+
export function isNumericString(value) {
|
|
51
|
+
const trimmed = value.trim();
|
|
52
|
+
if (trimmed.length === 0)
|
|
53
|
+
return false;
|
|
54
|
+
const n = Number(trimmed);
|
|
55
|
+
return Number.isFinite(n);
|
|
56
|
+
}
|
|
57
|
+
export function toPlusDecimal(num, dec = 8) {
|
|
58
|
+
if (isEmpty(num))
|
|
59
|
+
return 0;
|
|
60
|
+
const numStr = toStr(num);
|
|
61
|
+
const hasDot = numStr.includes('.');
|
|
62
|
+
const hasExponent = /e/i.test(numStr);
|
|
63
|
+
const normalized = hasExponent ? Number(numStr).toFixed(dec + 1) : numStr;
|
|
64
|
+
const valueNew = hasDot
|
|
65
|
+
? (() => {
|
|
66
|
+
const [whole, frac = ''] = normalized.split('.');
|
|
67
|
+
return Number.parseFloat(`${whole}.${frac.slice(0, dec)}`);
|
|
68
|
+
})()
|
|
69
|
+
: Number.parseFloat(normalized);
|
|
70
|
+
if (valueNew < 0 && String(valueNew).startsWith('-')) {
|
|
71
|
+
return 0;
|
|
72
|
+
}
|
|
73
|
+
return valueNew;
|
|
74
|
+
}
|
|
75
|
+
export function toMinusDecimal(num, dec = 8) {
|
|
76
|
+
if (isEmpty(num))
|
|
77
|
+
return 0;
|
|
78
|
+
const numStr = toStr(num);
|
|
79
|
+
const hasDot = numStr.includes('.');
|
|
80
|
+
const hasExponent = /e/i.test(numStr);
|
|
81
|
+
const normalized = hasExponent ? Number(numStr).toFixed(dec + 1) : numStr;
|
|
82
|
+
if (hasDot) {
|
|
83
|
+
const [whole, frac = ''] = normalized.split('.');
|
|
84
|
+
return Number.parseFloat(`${whole}.${frac.slice(0, dec)}`);
|
|
85
|
+
}
|
|
86
|
+
return Number.parseFloat(normalized);
|
|
87
|
+
}
|
|
88
|
+
export const nowIso = () => new Date().toISOString();
|
|
89
|
+
export const Utilities = Object.freeze({
|
|
90
|
+
generateUuid,
|
|
91
|
+
getString,
|
|
92
|
+
generateSecureJobId,
|
|
93
|
+
isEmpty,
|
|
94
|
+
toStr,
|
|
95
|
+
stripSpaces,
|
|
96
|
+
sanitize,
|
|
97
|
+
isNumericString,
|
|
98
|
+
toPlusDecimal,
|
|
99
|
+
toMinusDecimal,
|
|
100
|
+
nowIso,
|
|
101
|
+
});
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* FileLogWriter (Node.js only)
|
|
3
3
|
*
|
|
4
4
|
* Provides best-effort file logging with daily + size-based rotation.
|
|
5
|
-
*
|
|
5
|
+
* Uses async write streams to avoid blocking the event loop.
|
|
6
6
|
*/
|
|
7
7
|
type CleanOnceOptions = {
|
|
8
8
|
logsDir?: string;
|
|
@@ -17,6 +17,7 @@ type CleanOnceOptions = {
|
|
|
17
17
|
export declare const cleanOnce: (options?: CleanOnceOptions) => string[];
|
|
18
18
|
export declare const FileLogWriter: Readonly<{
|
|
19
19
|
write(line: string): void;
|
|
20
|
+
flush(): void;
|
|
20
21
|
}>;
|
|
21
22
|
export default FileLogWriter;
|
|
22
23
|
//# sourceMappingURL=FileLogWriter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileLogWriter.d.ts","sourceRoot":"","sources":["../../../src/config/FileLogWriter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"FileLogWriter.d.ts","sourceRoot":"","sources":["../../../src/config/FileLogWriter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAwGH,KAAK,gBAAgB,GAAG;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAiFF;;;GAGG;AACH,eAAO,MAAM,SAAS,GAAI,UAAU,gBAAgB,KAAG,MAAM,EAsB5D,CAAC;AAwEF,eAAO,MAAM,aAAa;gBACZ,MAAM,GAAG,IAAI;aAqChB,IAAI;EAQb,CAAC;AAEH,eAAe,aAAa,CAAC"}
|
|
@@ -2,12 +2,34 @@
|
|
|
2
2
|
* FileLogWriter (Node.js only)
|
|
3
3
|
*
|
|
4
4
|
* Provides best-effort file logging with daily + size-based rotation.
|
|
5
|
-
*
|
|
5
|
+
* Uses async write streams to avoid blocking the event loop.
|
|
6
6
|
*/
|
|
7
7
|
import { ensureDirSafe } from '../common/index.js';
|
|
8
8
|
import { Env } from './env.js';
|
|
9
9
|
import * as fs from '../node-singletons/fs.js';
|
|
10
10
|
import * as path from '../node-singletons/path.js';
|
|
11
|
+
// Write stream cache to avoid recreating streams
|
|
12
|
+
const streamCache = new Map();
|
|
13
|
+
const pendingWrites = new Map();
|
|
14
|
+
const canUseWriteStreams = () => {
|
|
15
|
+
try {
|
|
16
|
+
// Vitest's ESM module mocks can throw when accessing missing exports.
|
|
17
|
+
// Treat missing createWriteStream as "no stream support".
|
|
18
|
+
return (typeof fs.createWriteStream === 'function');
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
const appendFileSafe = (logFile, content) => {
|
|
25
|
+
try {
|
|
26
|
+
// Some tests/mock environments provide only appendFileSync (no streams).
|
|
27
|
+
fs.appendFileSync(logFile, content);
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
// best-effort
|
|
31
|
+
}
|
|
32
|
+
};
|
|
11
33
|
const getCwdSafe = () => {
|
|
12
34
|
try {
|
|
13
35
|
if (typeof process === 'undefined' || typeof process.cwd !== 'function')
|
|
@@ -160,6 +182,12 @@ const rotateIfNeeded = (logFile, maxSizeBytes) => {
|
|
|
160
182
|
const stat = fs.statSync(logFile);
|
|
161
183
|
if (stat.size <= maxSizeBytes)
|
|
162
184
|
return;
|
|
185
|
+
// Close and clear existing stream before rotation
|
|
186
|
+
const stream = streamCache.get(logFile);
|
|
187
|
+
if (stream !== undefined) {
|
|
188
|
+
stream.end();
|
|
189
|
+
streamCache.delete(logFile);
|
|
190
|
+
}
|
|
163
191
|
const ext = '.log';
|
|
164
192
|
const base = logFile.endsWith(ext) ? logFile.slice(0, -ext.length) : logFile;
|
|
165
193
|
const rotated = `${base}-${Date.now()}${ext}`;
|
|
@@ -169,6 +197,38 @@ const rotateIfNeeded = (logFile, maxSizeBytes) => {
|
|
|
169
197
|
// best-effort
|
|
170
198
|
}
|
|
171
199
|
};
|
|
200
|
+
const getOrCreateStream = (logFile) => {
|
|
201
|
+
let stream = streamCache.get(logFile);
|
|
202
|
+
if (stream === undefined || stream.destroyed) {
|
|
203
|
+
const createWriteStream = fs
|
|
204
|
+
.createWriteStream;
|
|
205
|
+
stream = createWriteStream(logFile, { flags: 'a', encoding: 'utf-8' });
|
|
206
|
+
// Clean up on error
|
|
207
|
+
stream.on('error', () => {
|
|
208
|
+
streamCache.delete(logFile);
|
|
209
|
+
});
|
|
210
|
+
streamCache.set(logFile, stream);
|
|
211
|
+
}
|
|
212
|
+
return stream;
|
|
213
|
+
};
|
|
214
|
+
const flushPendingWrites = (logFile) => {
|
|
215
|
+
const pending = pendingWrites.get(logFile);
|
|
216
|
+
if (pending === undefined || pending.length === 0)
|
|
217
|
+
return;
|
|
218
|
+
const lines = pending.join('');
|
|
219
|
+
if (!canUseWriteStreams()) {
|
|
220
|
+
appendFileSafe(logFile, lines);
|
|
221
|
+
pendingWrites.delete(logFile);
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
const stream = getOrCreateStream(logFile);
|
|
225
|
+
stream.write(lines, (error) => {
|
|
226
|
+
if (error !== null && error !== undefined) {
|
|
227
|
+
// Silent failure for best-effort logging
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
pendingWrites.delete(logFile);
|
|
231
|
+
};
|
|
172
232
|
export const FileLogWriter = Object.freeze({
|
|
173
233
|
write(line) {
|
|
174
234
|
const cwd = getCwdSafe();
|
|
@@ -179,8 +239,20 @@ export const FileLogWriter = Object.freeze({
|
|
|
179
239
|
const dateStr = getDateStr(new Date());
|
|
180
240
|
const logFile = path.join(logsDir, `app-${dateStr}.log`);
|
|
181
241
|
rotateIfNeeded(logFile, Env.LOG_ROTATION_SIZE);
|
|
242
|
+
// In test environments we sometimes mock @node-singletons/fs without stream APIs.
|
|
243
|
+
// Fall back to synchronous append to avoid runtime crashes.
|
|
244
|
+
if (!canUseWriteStreams()) {
|
|
245
|
+
appendFileSafe(logFile, `${line}\n`);
|
|
246
|
+
cleanupOldLogs(logsDir, Env.LOG_ROTATION_DAYS);
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
182
249
|
try {
|
|
183
|
-
|
|
250
|
+
// Buffer writes for async processing
|
|
251
|
+
const pending = pendingWrites.get(logFile) ?? [];
|
|
252
|
+
pending.push(`${line}\n`);
|
|
253
|
+
pendingWrites.set(logFile, pending);
|
|
254
|
+
// Flush on next tick to batch multiple rapid writes
|
|
255
|
+
process.nextTick(() => flushPendingWrites(logFile));
|
|
184
256
|
}
|
|
185
257
|
catch {
|
|
186
258
|
// best-effort
|
|
@@ -188,5 +260,14 @@ export const FileLogWriter = Object.freeze({
|
|
|
188
260
|
}
|
|
189
261
|
cleanupOldLogs(logsDir, Env.LOG_ROTATION_DAYS);
|
|
190
262
|
},
|
|
263
|
+
// Flush all streams (for graceful shutdown)
|
|
264
|
+
flush() {
|
|
265
|
+
for (const [logFile, stream] of streamCache.entries()) {
|
|
266
|
+
flushPendingWrites(logFile);
|
|
267
|
+
stream.end();
|
|
268
|
+
}
|
|
269
|
+
streamCache.clear();
|
|
270
|
+
pendingWrites.clear();
|
|
271
|
+
},
|
|
191
272
|
});
|
|
192
273
|
export default FileLogWriter;
|
package/src/config/app.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../../src/config/app.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAA4B,SAAS,EAAE,MAAM,cAAc,CAAC;AAsCxE,QAAA,MAAM,UAAU,QAAO,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../../src/config/app.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAA4B,SAAS,EAAE,MAAM,cAAc,CAAC;AAsCxE,QAAA,MAAM,UAAU,QAAO,MAAM,CAAC,UA0B7B,CAAC;AA0FF,eAAO,MAAM,SAAS;IA5EpB;;OAEG;;IAMH;;OAEG;;IAGH;;OAEG;;IAMH;;OAEG;;IAMH;;OAEG;kCACc,OAAO;IAIxB;;OAEG;iCACa,OAAO;IAIvB;;OAEG;8BACU,OAAO;IAIpB;;OAEG;;IAMH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;+BA9GkB,MAAM,CAAC,UAAU;EAoHY,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,CAAC;AAEtB,MAAM,MAAM,SAAS,GAAG,OAAO,SAAS,CAAC"}
|
package/src/config/app.js
CHANGED
|
@@ -42,7 +42,9 @@ const getSafeEnv = () => {
|
|
|
42
42
|
readEnvString('NODE_ENV', 'development'),
|
|
43
43
|
USE_RAW_QRY: baseEnv.USE_RAW_QRY ?? (readEnvString('USE_RAW_QRY', '') || undefined),
|
|
44
44
|
SERVICE_API_KEY: baseEnv.SERVICE_API_KEY ?? readEnvString('SERVICE_API_KEY', ''),
|
|
45
|
-
SERVICE_JWT_SECRET: baseEnv.SERVICE_JWT_SECRET ??
|
|
45
|
+
SERVICE_JWT_SECRET: baseEnv.SERVICE_JWT_SECRET ??
|
|
46
|
+
readEnvString('SERVICE_JWT_SECRET', '') ??
|
|
47
|
+
readEnvString('APP_KEY', ''),
|
|
46
48
|
BASE_URL: baseEnv['BASE_URL'] ?? readEnvString('BASE_URL', ''),
|
|
47
49
|
MODE: baseEnv['MODE'] ?? readEnvString('MODE', ''),
|
|
48
50
|
// Hardening for child-process usage
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Centralizes broadcast driver selection and provider env mappings.
|
|
5
5
|
* Driver selection must be dynamic (tests may mutate process.env).
|
|
6
6
|
*/
|
|
7
|
-
import { InMemoryBroadcastDriverConfig, KnownBroadcastDriverConfig, PusherBroadcastDriverConfig, RedisBroadcastDriverConfig, RedisHttpsBroadcastDriverConfig } from './type';
|
|
7
|
+
import type { InMemoryBroadcastDriverConfig, KnownBroadcastDriverConfig, PusherBroadcastDriverConfig, RedisBroadcastDriverConfig, RedisHttpsBroadcastDriverConfig } from './type';
|
|
8
8
|
declare const _default: Readonly<{
|
|
9
9
|
/**
|
|
10
10
|
* Default broadcaster name (normalized).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"broadcast.d.ts","sourceRoot":"","sources":["../../../src/config/broadcast.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,
|
|
1
|
+
{"version":3,"file":"broadcast.d.ts","sourceRoot":"","sources":["../../../src/config/broadcast.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAGV,6BAA6B,EAC7B,0BAA0B,EAC1B,2BAA2B,EAC3B,0BAA0B,EAC1B,+BAA+B,EAChC,MAAM,cAAc,CAAC;;IA4EpB;;OAEG;sBACY,MAAM;IAIrB;;;;;OAKG;;2BAEe,6BAA6B;;;;;IAc/C;;OAEG;kCACc,MAAM;IAIvB;;;OAGG;sCACoB,MAAM,KAAG,0BAA0B;;AAK5D,wBAAiD"}
|
package/src/config/cache.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../../src/config/cache.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAoB,iBAAiB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../../src/config/cache.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAoB,iBAAiB,EAAE,MAAM,cAAc,CAAC;AA2FxE,eAAO,MAAM,WAAW;IA/DtB;;OAEG;;IAaH;;OAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;IA4BH;;OAEG;qBACc,MAAM,GAAG,iBAAiB;IAI3C;;OAEG;;IAGH;;OAEG;;EAImD,CAAC;AACzD,MAAM,MAAM,WAAW,GAAG,OAAO,WAAW,CAAC"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Centralizes access to Workers bindings via globalThis.env.
|
|
5
5
|
* This keeps runtime-specific globals out of adapters/drivers.
|
|
6
6
|
*/
|
|
7
|
-
import { KVNamespace, WorkersEnv } from './type';
|
|
7
|
+
import type { KVNamespace, WorkersEnv } from './type';
|
|
8
8
|
import type { DatabaseConfig, ID1Database } from '../orm/DatabaseAdapter';
|
|
9
9
|
export declare const Cloudflare: Readonly<{
|
|
10
10
|
getWorkersEnv: () => WorkersEnv | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cloudflare.d.ts","sourceRoot":"","sources":["../../../src/config/cloudflare.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"cloudflare.d.ts","sourceRoot":"","sources":["../../../src/config/cloudflare.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AA8BxE,eAAO,MAAM,UAAU;yBA5BG,UAAU,GAAG,IAAI;2BAOb,cAAc,KAAG,WAAW,GAAG,IAAI;4CAanB,WAAW,GAAG,IAAI;EAY9D,CAAC"}
|
package/src/config/database.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Database connections and pooling settings
|
|
4
4
|
* Sealed namespace for immutability
|
|
5
5
|
*/
|
|
6
|
-
import { DatabaseConfigShape, DatabaseConnectionConfig } from './type';
|
|
6
|
+
import type { DatabaseConfigShape, DatabaseConnectionConfig } from './type';
|
|
7
7
|
export declare const databaseConfig: Readonly<{
|
|
8
8
|
/**
|
|
9
9
|
* Default database connection
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../../../src/config/database.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,
|
|
1
|
+
{"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../../../src/config/database.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EACV,mBAAmB,EACnB,wBAAwB,EAEzB,MAAM,cAAc,CAAC;AAkNtB,eAAO,MAAM,cAAc;IAzCzB;;OAEG;;IAGH;;OAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAGH;;OAEG;wBACiB,mBAAmB,GAAG,wBAAwB;IAIlE;;OAEG;;;;;IAMH;;OAEG;;;;;IAMH;;OAEG;;;;EAMyD,CAAC;AAC/D,MAAM,MAAM,cAAc,GAAG,OAAO,cAAc,CAAC"}
|
package/src/config/database.js
CHANGED
|
@@ -5,6 +5,92 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { Env } from './env.js';
|
|
7
7
|
import { ErrorFactory } from '../exceptions/ZintrustError.js';
|
|
8
|
+
const isNodeProcess = () => {
|
|
9
|
+
return typeof process !== 'undefined' && typeof process.cwd === 'function';
|
|
10
|
+
};
|
|
11
|
+
const isExplicitEnvValue = (key) => {
|
|
12
|
+
if (!isNodeProcess())
|
|
13
|
+
return false;
|
|
14
|
+
const raw = process.env[key];
|
|
15
|
+
return typeof raw === 'string' && raw.trim() !== '';
|
|
16
|
+
};
|
|
17
|
+
const looksLikeSqliteFilePath = (value) => {
|
|
18
|
+
const v = value.trim();
|
|
19
|
+
if (v === '')
|
|
20
|
+
return false;
|
|
21
|
+
if (v === ':memory:')
|
|
22
|
+
return true;
|
|
23
|
+
// Heuristic: if it's a path, has an extension, or is explicitly relative.
|
|
24
|
+
if (v.includes('/') || v.includes('\\'))
|
|
25
|
+
return true;
|
|
26
|
+
if (v.startsWith('.'))
|
|
27
|
+
return true;
|
|
28
|
+
if (v.startsWith('~'))
|
|
29
|
+
return true;
|
|
30
|
+
if (v.endsWith('.sqlite') || v.endsWith('.db'))
|
|
31
|
+
return true;
|
|
32
|
+
// Otherwise it's likely a placeholder name (e.g. "zintrust"), not a file path.
|
|
33
|
+
return false;
|
|
34
|
+
};
|
|
35
|
+
const toSafeDbBasename = (raw) => {
|
|
36
|
+
const trimmed = raw.trim();
|
|
37
|
+
if (trimmed === '')
|
|
38
|
+
return 'zintrust';
|
|
39
|
+
// Conservative filename allowlist: letters/numbers/_/-, collapse everything else.
|
|
40
|
+
// Avoid regexes that can exhibit catastrophic backtracking; do deterministic collapsing/trimming.
|
|
41
|
+
const collapsed = trimmed.toLowerCase().replaceAll(/[^a-z0-9_-]+/g, '-');
|
|
42
|
+
// Collapse consecutive hyphens deterministically without regex backtracking.
|
|
43
|
+
let normalized = '';
|
|
44
|
+
let prevHyphen = false;
|
|
45
|
+
for (const element of collapsed) {
|
|
46
|
+
const ch = element;
|
|
47
|
+
if (ch === '-') {
|
|
48
|
+
if (!prevHyphen) {
|
|
49
|
+
normalized += ch;
|
|
50
|
+
prevHyphen = true;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
normalized += ch;
|
|
55
|
+
prevHyphen = false;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
// Trim leading/trailing hyphens deterministically without regex.
|
|
59
|
+
let start = 0;
|
|
60
|
+
let end = normalized.length;
|
|
61
|
+
while (start < end && normalized.charAt(start) === '-')
|
|
62
|
+
start++;
|
|
63
|
+
while (end > start && normalized.charAt(end - 1) === '-')
|
|
64
|
+
end--;
|
|
65
|
+
const result = normalized.slice(start, end);
|
|
66
|
+
return result === '' ? 'zintrust' : result;
|
|
67
|
+
};
|
|
68
|
+
const resolveSqliteDefaultBasename = () => {
|
|
69
|
+
const service = typeof process.env['SERVICE_NAME'] === 'string' ? process.env['SERVICE_NAME'] : '';
|
|
70
|
+
if (service.trim() !== '')
|
|
71
|
+
return toSafeDbBasename(service);
|
|
72
|
+
const app = typeof process.env['APP_NAME'] === 'string' ? process.env['APP_NAME'] : '';
|
|
73
|
+
if (app.trim() !== '')
|
|
74
|
+
return toSafeDbBasename(app);
|
|
75
|
+
return 'zintrust';
|
|
76
|
+
};
|
|
77
|
+
const resolveDefaultSqliteDatabasePath = () => {
|
|
78
|
+
// Respect explicit sqlite *file path* configuration.
|
|
79
|
+
// Note: we intentionally treat plain names like "zintrust" as placeholders, not file paths,
|
|
80
|
+
// to avoid creating stray DB files in the project root.
|
|
81
|
+
if (isExplicitEnvValue('DB_DATABASE') || isExplicitEnvValue('DB_PATH')) {
|
|
82
|
+
const configured = Env.DB_DATABASE;
|
|
83
|
+
if (looksLikeSqliteFilePath(configured))
|
|
84
|
+
return configured;
|
|
85
|
+
}
|
|
86
|
+
// Only change the default behavior for dev/testing; production should be explicit.
|
|
87
|
+
if (!isNodeProcess() || Env.NODE_ENV === 'production')
|
|
88
|
+
return Env.DB_DATABASE;
|
|
89
|
+
// Store dev sqlite files in project-local metadata folder.
|
|
90
|
+
// Note: the SQLite adapter ensures the parent directory exists.
|
|
91
|
+
const base = resolveSqliteDefaultBasename();
|
|
92
|
+
return `.zintrust/dbs/${base}.sqlite`;
|
|
93
|
+
};
|
|
8
94
|
const hasOwn = (obj, key) => {
|
|
9
95
|
return Object.hasOwn(obj, key);
|
|
10
96
|
};
|
|
@@ -35,7 +121,7 @@ const getDatabaseConnection = (config) => {
|
|
|
35
121
|
const connections = {
|
|
36
122
|
sqlite: {
|
|
37
123
|
driver: 'sqlite',
|
|
38
|
-
database:
|
|
124
|
+
database: resolveDefaultSqliteDatabasePath(),
|
|
39
125
|
migrations: 'database/migrations',
|
|
40
126
|
},
|
|
41
127
|
d1: {
|
|
@@ -47,10 +133,10 @@ const connections = {
|
|
|
47
133
|
postgresql: {
|
|
48
134
|
driver: 'postgresql',
|
|
49
135
|
host: Env.DB_HOST,
|
|
50
|
-
port: Env.
|
|
51
|
-
database: Env.
|
|
52
|
-
username: Env.
|
|
53
|
-
password: Env.
|
|
136
|
+
port: Env.DB_PORT_POSTGRESQL,
|
|
137
|
+
database: Env.DB_DATABASE_POSTGRESQL,
|
|
138
|
+
username: Env.DB_USERNAME_POSTGRESQL,
|
|
139
|
+
password: Env.DB_PASSWORD_POSTGRESQL,
|
|
54
140
|
ssl: Env.getBool('DB_SSL', false),
|
|
55
141
|
pooling: {
|
|
56
142
|
enabled: Env.getBool('DB_POOLING', true),
|
|
@@ -93,7 +179,7 @@ const databaseConfigObj = {
|
|
|
93
179
|
* Enable query logging
|
|
94
180
|
*/
|
|
95
181
|
logging: {
|
|
96
|
-
enabled: Env.DEBUG,
|
|
182
|
+
enabled: Env.getBool('DB_LOG_QUERIES', Env.DEBUG),
|
|
97
183
|
level: Env.get('DB_LOG_LEVEL', 'debug'),
|
|
98
184
|
},
|
|
99
185
|
/**
|
package/src/config/env.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export declare const Env: Readonly<{
|
|
|
12
12
|
NODE_ENV: string;
|
|
13
13
|
PORT: number;
|
|
14
14
|
HOST: string;
|
|
15
|
+
BASE_URL: string;
|
|
15
16
|
APP_NAME: string;
|
|
16
17
|
APP_KEY: string;
|
|
17
18
|
APP_PREVIOUS_KEYS: string;
|
|
@@ -22,6 +23,11 @@ export declare const Env: Readonly<{
|
|
|
22
23
|
DB_USERNAME: string;
|
|
23
24
|
DB_PASSWORD: string;
|
|
24
25
|
DB_READ_HOSTS: string;
|
|
26
|
+
DB_PORT_POSTGRESQL: number;
|
|
27
|
+
DB_DATABASE_POSTGRESQL: string;
|
|
28
|
+
DB_USERNAME_POSTGRESQL: string;
|
|
29
|
+
DB_PASSWORD_POSTGRESQL: string;
|
|
30
|
+
DB_READ_HOSTS_POSTGRESQL: string;
|
|
25
31
|
D1_DATABASE_ID: string;
|
|
26
32
|
KV_NAMESPACE_ID: string;
|
|
27
33
|
D1_REMOTE_URL: string;
|
package/src/config/env.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../../src/config/env.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AA+CH,eAAO,MAAM,GAAG;eA/BE,MAAM,iBAAiB,MAAM,KAAG,MAAM;kBAMnC,MAAM,iBAAiB,MAAM,KAAG,MAAM;mBASrC,MAAM,iBAAiB,OAAO,KAAG,OAAO
|
|
1
|
+
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../../src/config/env.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AA+CH,eAAO,MAAM,GAAG;eA/BE,MAAM,iBAAiB,MAAM,KAAG,MAAM;kBAMnC,MAAM,iBAAiB,MAAM,KAAG,MAAM;mBASrC,MAAM,iBAAiB,OAAO,KAAG,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eA4GP,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO;;;;;;;;;EAkCxF,CAAC"}
|
package/src/config/env.js
CHANGED
|
@@ -58,6 +58,7 @@ export const Env = Object.freeze({
|
|
|
58
58
|
// Prefer PORT, fallback to APP_PORT for compatibility
|
|
59
59
|
PORT: getInt('PORT', getInt('APP_PORT', 3000)),
|
|
60
60
|
HOST: get('HOST', 'localhost'),
|
|
61
|
+
BASE_URL: get('BASE_URL', ''),
|
|
61
62
|
APP_NAME: get('APP_NAME', 'ZinTrust'),
|
|
62
63
|
APP_KEY: get('APP_KEY', ''),
|
|
63
64
|
// Optional key rotation support (comma-separated or JSON array of keys)
|
|
@@ -71,6 +72,12 @@ export const Env = Object.freeze({
|
|
|
71
72
|
DB_USERNAME: get('DB_USERNAME', 'postgres'),
|
|
72
73
|
DB_PASSWORD: get('DB_PASSWORD', ''),
|
|
73
74
|
DB_READ_HOSTS: get('DB_READ_HOSTS', ''),
|
|
75
|
+
// PostgreSQL-specific configuration (with _POSTGRESQL suffix to avoid conflicts with MySQL)
|
|
76
|
+
DB_PORT_POSTGRESQL: getInt('DB_PORT_POSTGRESQL', 5432),
|
|
77
|
+
DB_DATABASE_POSTGRESQL: get('DB_DATABASE_POSTGRESQL', 'postgres'),
|
|
78
|
+
DB_USERNAME_POSTGRESQL: get('DB_USERNAME_POSTGRESQL', 'postgres'),
|
|
79
|
+
DB_PASSWORD_POSTGRESQL: get('DB_PASSWORD_POSTGRESQL', ''),
|
|
80
|
+
DB_READ_HOSTS_POSTGRESQL: get('DB_READ_HOSTS_POSTGRESQL', ''),
|
|
74
81
|
// Cloudflare
|
|
75
82
|
D1_DATABASE_ID: get('D1_DATABASE_ID'),
|
|
76
83
|
KV_NAMESPACE_ID: get('KV_NAMESPACE_ID'),
|
package/src/config/index.d.ts
CHANGED
|
@@ -130,7 +130,7 @@ export declare const config: Readonly<{
|
|
|
130
130
|
readonly enabled: boolean;
|
|
131
131
|
readonly secret: string;
|
|
132
132
|
readonly algorithm: "HS256" | "HS512" | "RS256";
|
|
133
|
-
readonly expiresIn:
|
|
133
|
+
readonly expiresIn: number;
|
|
134
134
|
readonly refreshExpiresIn: string;
|
|
135
135
|
readonly issuer: string;
|
|
136
136
|
readonly audience: string;
|
|
@@ -125,7 +125,7 @@ const flushSoon = async () => {
|
|
|
125
125
|
export const KvLogger = Object.freeze({
|
|
126
126
|
async enqueue(event) {
|
|
127
127
|
if (!isEnabled())
|
|
128
|
-
return
|
|
128
|
+
return;
|
|
129
129
|
buffer.push(event);
|
|
130
130
|
// Basic size guard: flush if it gets too large
|
|
131
131
|
const maxBatch = 100;
|
|
@@ -104,10 +104,10 @@ const scheduleFlush = async () => {
|
|
|
104
104
|
export const SlackLogger = Object.freeze({
|
|
105
105
|
async enqueue(event) {
|
|
106
106
|
if (!isEnabled())
|
|
107
|
-
return
|
|
107
|
+
return;
|
|
108
108
|
const levels = getLevels();
|
|
109
109
|
if (!levels.has(event.level))
|
|
110
|
-
return
|
|
110
|
+
return;
|
|
111
111
|
const key = dedupeKeyFor(event);
|
|
112
112
|
if (dedupeKeys.has(key))
|
|
113
113
|
return scheduleFlush();
|
|
@@ -1,4 +1,23 @@
|
|
|
1
|
-
import { MiddlewareConfigType } from './type';
|
|
1
|
+
import type { MiddlewareConfigType } from './type';
|
|
2
|
+
export declare const MiddlewareKeys: Readonly<{
|
|
3
|
+
log: true;
|
|
4
|
+
error: true;
|
|
5
|
+
security: true;
|
|
6
|
+
rateLimit: true;
|
|
7
|
+
sanitizeBody: true;
|
|
8
|
+
fillRateLimit: true;
|
|
9
|
+
authRateLimit: true;
|
|
10
|
+
userMutationRateLimit: true;
|
|
11
|
+
csrf: true;
|
|
12
|
+
auth: true;
|
|
13
|
+
jwt: true;
|
|
14
|
+
validateLogin: true;
|
|
15
|
+
validateRegister: true;
|
|
16
|
+
validateUserStore: true;
|
|
17
|
+
validateUserUpdate: true;
|
|
18
|
+
validateUserFill: true;
|
|
19
|
+
}>;
|
|
20
|
+
export type MiddlewareKey = keyof typeof MiddlewareKeys;
|
|
2
21
|
export declare function createMiddlewareConfig(): MiddlewareConfigType;
|
|
3
22
|
export declare const middlewareConfig: MiddlewareConfigType;
|
|
4
23
|
export default middlewareConfig;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../../src/config/middleware.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../../src/config/middleware.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AA8DzD,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;EAiBuB,CAAC;AAEnD,MAAM,MAAM,aAAa,GAAG,MAAM,OAAO,cAAc,CAAC;AA2KxD,wBAAgB,sBAAsB,IAAI,oBAAoB,CAkB7D;AA0BD,eAAO,MAAM,gBAAgB,EAAE,oBAY7B,CAAC;AAEH,eAAe,gBAAgB,CAAC"}
|