@zintrust/core 0.1.0
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/z.d.ts +7 -0
- package/bin/z.d.ts.map +1 -0
- package/bin/z.js +6 -0
- package/bin/zin.d.ts +7 -0
- package/bin/zin.d.ts.map +1 -0
- package/bin/zin.js +6 -0
- package/bin/zintrust-microservices.d.ts +7 -0
- package/bin/zintrust-microservices.d.ts.map +1 -0
- package/bin/zintrust-microservices.js +165 -0
- package/bin/zintrust.d.ts +9 -0
- package/bin/zintrust.d.ts.map +1 -0
- package/bin/zintrust.js +51 -0
- package/bin/zt.d.ts +7 -0
- package/bin/zt.d.ts.map +1 -0
- package/bin/zt.js +6 -0
- package/package.json +80 -0
- package/src/boot/Application.d.ts +31 -0
- package/src/boot/Application.d.ts.map +1 -0
- package/src/boot/Application.js +159 -0
- package/src/boot/Server.d.ts +23 -0
- package/src/boot/Server.d.ts.map +1 -0
- package/src/boot/Server.js +236 -0
- package/src/boot/bootstrap.d.ts +7 -0
- package/src/boot/bootstrap.d.ts.map +1 -0
- package/src/boot/bootstrap.js +64 -0
- package/src/builder/BundleOptimizer.d.ts +42 -0
- package/src/builder/BundleOptimizer.d.ts.map +1 -0
- package/src/builder/BundleOptimizer.js +356 -0
- package/src/cache/Cache.d.ts +26 -0
- package/src/cache/Cache.d.ts.map +1 -0
- package/src/cache/Cache.js +89 -0
- package/src/cache/CacheDriver.d.ts +28 -0
- package/src/cache/CacheDriver.d.ts.map +1 -0
- package/src/cache/CacheDriver.js +6 -0
- package/src/cache/drivers/KVDriver.d.ts +12 -0
- package/src/cache/drivers/KVDriver.d.ts.map +1 -0
- package/src/cache/drivers/KVDriver.js +54 -0
- package/src/cache/drivers/MemoryDriver.d.ts +12 -0
- package/src/cache/drivers/MemoryDriver.d.ts.map +1 -0
- package/src/cache/drivers/MemoryDriver.js +50 -0
- package/src/cache/drivers/MongoDriver.d.ts +17 -0
- package/src/cache/drivers/MongoDriver.d.ts.map +1 -0
- package/src/cache/drivers/MongoDriver.js +80 -0
- package/src/cache/drivers/RedisDriver.d.ts +12 -0
- package/src/cache/drivers/RedisDriver.d.ts.map +1 -0
- package/src/cache/drivers/RedisDriver.js +79 -0
- package/src/cli/BaseCommand.d.ts +39 -0
- package/src/cli/BaseCommand.d.ts.map +1 -0
- package/src/cli/BaseCommand.js +58 -0
- package/src/cli/CLI.d.ts +21 -0
- package/src/cli/CLI.d.ts.map +1 -0
- package/src/cli/CLI.js +203 -0
- package/src/cli/ErrorHandler.d.ts +23 -0
- package/src/cli/ErrorHandler.d.ts.map +1 -0
- package/src/cli/ErrorHandler.js +95 -0
- package/src/cli/PromptHelper.d.ts +47 -0
- package/src/cli/PromptHelper.d.ts.map +1 -0
- package/src/cli/PromptHelper.js +155 -0
- package/src/cli/commands/AddCommand.d.ts +15 -0
- package/src/cli/commands/AddCommand.d.ts.map +1 -0
- package/src/cli/commands/AddCommand.js +817 -0
- package/src/cli/commands/ConfigCommand.d.ts +15 -0
- package/src/cli/commands/ConfigCommand.d.ts.map +1 -0
- package/src/cli/commands/ConfigCommand.js +273 -0
- package/src/cli/commands/D1MigrateCommand.d.ts +15 -0
- package/src/cli/commands/D1MigrateCommand.d.ts.map +1 -0
- package/src/cli/commands/D1MigrateCommand.js +73 -0
- package/src/cli/commands/DebugCommand.d.ts +15 -0
- package/src/cli/commands/DebugCommand.d.ts.map +1 -0
- package/src/cli/commands/DebugCommand.js +52 -0
- package/src/cli/commands/FixCommand.d.ts +15 -0
- package/src/cli/commands/FixCommand.d.ts.map +1 -0
- package/src/cli/commands/FixCommand.js +80 -0
- package/src/cli/commands/KeyGenerateCommand.d.ts +9 -0
- package/src/cli/commands/KeyGenerateCommand.d.ts.map +1 -0
- package/src/cli/commands/KeyGenerateCommand.js +76 -0
- package/src/cli/commands/LogsCommand.d.ts +19 -0
- package/src/cli/commands/LogsCommand.d.ts.map +1 -0
- package/src/cli/commands/LogsCommand.js +185 -0
- package/src/cli/commands/MigrateCommand.d.ts +15 -0
- package/src/cli/commands/MigrateCommand.d.ts.map +1 -0
- package/src/cli/commands/MigrateCommand.js +56 -0
- package/src/cli/commands/NewCommand.d.ts +32 -0
- package/src/cli/commands/NewCommand.d.ts.map +1 -0
- package/src/cli/commands/NewCommand.js +280 -0
- package/src/cli/commands/PluginCommand.d.ts +9 -0
- package/src/cli/commands/PluginCommand.d.ts.map +1 -0
- package/src/cli/commands/PluginCommand.js +94 -0
- package/src/cli/commands/PrepareCommand.d.ts +8 -0
- package/src/cli/commands/PrepareCommand.d.ts.map +1 -0
- package/src/cli/commands/PrepareCommand.js +51 -0
- package/src/cli/commands/QACommand.d.ts +33 -0
- package/src/cli/commands/QACommand.d.ts.map +1 -0
- package/src/cli/commands/QACommand.js +490 -0
- package/src/cli/commands/SimulateCommand.d.ts +12 -0
- package/src/cli/commands/SimulateCommand.d.ts.map +1 -0
- package/src/cli/commands/SimulateCommand.js +79 -0
- package/src/cli/commands/StartCommand.d.ts +5 -0
- package/src/cli/commands/StartCommand.d.ts.map +1 -0
- package/src/cli/commands/StartCommand.js +227 -0
- package/src/cli/commands/index.d.ts +11 -0
- package/src/cli/commands/index.d.ts.map +1 -0
- package/src/cli/commands/index.js +10 -0
- package/src/cli/config/ConfigManager.d.ts +42 -0
- package/src/cli/config/ConfigManager.d.ts.map +1 -0
- package/src/cli/config/ConfigManager.js +175 -0
- package/src/cli/config/ConfigSchema.d.ts +195 -0
- package/src/cli/config/ConfigSchema.d.ts.map +1 -0
- package/src/cli/config/ConfigSchema.js +171 -0
- package/src/cli/config/ConfigValidator.d.ts +41 -0
- package/src/cli/config/ConfigValidator.d.ts.map +1 -0
- package/src/cli/config/ConfigValidator.js +200 -0
- package/src/cli/config/index.d.ts +8 -0
- package/src/cli/config/index.d.ts.map +1 -0
- package/src/cli/config/index.js +7 -0
- package/src/cli/debug/Dashboard.d.ts +34 -0
- package/src/cli/debug/Dashboard.d.ts.map +1 -0
- package/src/cli/debug/Dashboard.js +152 -0
- package/src/cli/index.d.ts +14 -0
- package/src/cli/index.d.ts.map +1 -0
- package/src/cli/index.js +14 -0
- package/src/cli/logger/Logger.d.ts +43 -0
- package/src/cli/logger/Logger.d.ts.map +1 -0
- package/src/cli/logger/Logger.js +137 -0
- package/src/cli/scaffolding/ControllerGenerator.d.ts +44 -0
- package/src/cli/scaffolding/ControllerGenerator.d.ts.map +1 -0
- package/src/cli/scaffolding/ControllerGenerator.js +540 -0
- package/src/cli/scaffolding/FactoryGenerator.d.ts +47 -0
- package/src/cli/scaffolding/FactoryGenerator.d.ts.map +1 -0
- package/src/cli/scaffolding/FactoryGenerator.js +356 -0
- package/src/cli/scaffolding/FeatureScaffolder.d.ts +40 -0
- package/src/cli/scaffolding/FeatureScaffolder.d.ts.map +1 -0
- package/src/cli/scaffolding/FeatureScaffolder.js +747 -0
- package/src/cli/scaffolding/FileGenerator.d.ts +31 -0
- package/src/cli/scaffolding/FileGenerator.d.ts.map +1 -0
- package/src/cli/scaffolding/FileGenerator.js +222 -0
- package/src/cli/scaffolding/MigrationGenerator.d.ts +35 -0
- package/src/cli/scaffolding/MigrationGenerator.d.ts.map +1 -0
- package/src/cli/scaffolding/MigrationGenerator.js +257 -0
- package/src/cli/scaffolding/ModelGenerator.d.ts +81 -0
- package/src/cli/scaffolding/ModelGenerator.d.ts.map +1 -0
- package/src/cli/scaffolding/ModelGenerator.js +249 -0
- package/src/cli/scaffolding/ProjectScaffolder.d.ts +66 -0
- package/src/cli/scaffolding/ProjectScaffolder.d.ts.map +1 -0
- package/src/cli/scaffolding/ProjectScaffolder.js +439 -0
- package/src/cli/scaffolding/RequestFactoryGenerator.d.ts +50 -0
- package/src/cli/scaffolding/RequestFactoryGenerator.d.ts.map +1 -0
- package/src/cli/scaffolding/RequestFactoryGenerator.js +465 -0
- package/src/cli/scaffolding/ResponseFactoryGenerator.d.ts +43 -0
- package/src/cli/scaffolding/ResponseFactoryGenerator.d.ts.map +1 -0
- package/src/cli/scaffolding/ResponseFactoryGenerator.js +321 -0
- package/src/cli/scaffolding/RouteGenerator.d.ts +66 -0
- package/src/cli/scaffolding/RouteGenerator.d.ts.map +1 -0
- package/src/cli/scaffolding/RouteGenerator.js +306 -0
- package/src/cli/scaffolding/SeederGenerator.d.ts +47 -0
- package/src/cli/scaffolding/SeederGenerator.d.ts.map +1 -0
- package/src/cli/scaffolding/SeederGenerator.js +286 -0
- package/src/cli/scaffolding/ServiceIntegrationTestGenerator.d.ts +40 -0
- package/src/cli/scaffolding/ServiceIntegrationTestGenerator.d.ts.map +1 -0
- package/src/cli/scaffolding/ServiceIntegrationTestGenerator.js +267 -0
- package/src/cli/scaffolding/ServiceRequestFactoryGenerator.d.ts +45 -0
- package/src/cli/scaffolding/ServiceRequestFactoryGenerator.d.ts.map +1 -0
- package/src/cli/scaffolding/ServiceRequestFactoryGenerator.js +397 -0
- package/src/cli/scaffolding/ServiceScaffolder.d.ts +45 -0
- package/src/cli/scaffolding/ServiceScaffolder.d.ts.map +1 -0
- package/src/cli/scaffolding/ServiceScaffolder.js +367 -0
- package/src/cli/scaffolding/TemplateEngine.d.ts +35 -0
- package/src/cli/scaffolding/TemplateEngine.d.ts.map +1 -0
- package/src/cli/scaffolding/TemplateEngine.js +379 -0
- package/src/cli/scaffolding/WorkflowGenerator.d.ts +31 -0
- package/src/cli/scaffolding/WorkflowGenerator.d.ts.map +1 -0
- package/src/cli/scaffolding/WorkflowGenerator.js +193 -0
- package/src/cli/scaffolding/index.d.ts +34 -0
- package/src/cli/scaffolding/index.d.ts.map +1 -0
- package/src/cli/scaffolding/index.js +18 -0
- package/src/cli/utils/DistPackager.d.ts +8 -0
- package/src/cli/utils/DistPackager.d.ts.map +1 -0
- package/src/cli/utils/DistPackager.js +94 -0
- package/src/cli/utils/EnvFileLoader.d.ts +21 -0
- package/src/cli/utils/EnvFileLoader.d.ts.map +1 -0
- package/src/cli/utils/EnvFileLoader.js +166 -0
- package/src/cli/utils/spawn.d.ts +11 -0
- package/src/cli/utils/spawn.d.ts.map +1 -0
- package/src/cli/utils/spawn.js +81 -0
- package/src/common/index.d.ts +87 -0
- package/src/common/index.d.ts.map +1 -0
- package/src/common/index.js +207 -0
- package/src/config/SecretsManager.d.ts +122 -0
- package/src/config/SecretsManager.d.ts.map +1 -0
- package/src/config/SecretsManager.js +328 -0
- package/src/config/app.d.ts +56 -0
- package/src/config/app.d.ts.map +1 -0
- package/src/config/app.js +77 -0
- package/src/config/cache.d.ts +76 -0
- package/src/config/cache.d.ts.map +1 -0
- package/src/config/cache.js +62 -0
- package/src/config/constants.d.ts +108 -0
- package/src/config/constants.d.ts.map +1 -0
- package/src/config/constants.js +64 -0
- package/src/config/database.d.ts +122 -0
- package/src/config/database.d.ts.map +1 -0
- package/src/config/database.js +89 -0
- package/src/config/env.d.ts +56 -0
- package/src/config/env.d.ts.map +1 -0
- package/src/config/env.js +133 -0
- package/src/config/features.d.ts +27 -0
- package/src/config/features.d.ts.map +1 -0
- package/src/config/features.js +49 -0
- package/src/config/index.d.ts +554 -0
- package/src/config/index.d.ts.map +1 -0
- package/src/config/index.js +31 -0
- package/src/config/logger.d.ts +17 -0
- package/src/config/logger.d.ts.map +1 -0
- package/src/config/logger.js +77 -0
- package/src/config/microservices.d.ts +88 -0
- package/src/config/microservices.d.ts.map +1 -0
- package/src/config/microservices.js +90 -0
- package/src/config/queue.d.ts +107 -0
- package/src/config/queue.d.ts.map +1 -0
- package/src/config/queue.js +74 -0
- package/src/config/security.d.ts +108 -0
- package/src/config/security.d.ts.map +1 -0
- package/src/config/security.js +134 -0
- package/src/config/storage.d.ts +105 -0
- package/src/config/storage.d.ts.map +1 -0
- package/src/config/storage.js +79 -0
- package/src/container/ServiceContainer.d.ts +25 -0
- package/src/container/ServiceContainer.d.ts.map +1 -0
- package/src/container/ServiceContainer.js +75 -0
- package/src/database/migrations/index.d.ts +2 -0
- package/src/database/migrations/index.d.ts.map +1 -0
- package/src/database/migrations/index.js +1 -0
- package/src/exceptions/ZintrustError.d.ts +88 -0
- package/src/exceptions/ZintrustError.d.ts.map +1 -0
- package/src/exceptions/ZintrustError.js +110 -0
- package/src/features/Auth.d.ts +20 -0
- package/src/features/Auth.d.ts.map +1 -0
- package/src/features/Auth.js +32 -0
- package/src/features/Queue.d.ts +21 -0
- package/src/features/Queue.d.ts.map +1 -0
- package/src/features/Queue.js +59 -0
- package/src/functions/cloudflare.d.ts +5 -0
- package/src/functions/cloudflare.d.ts.map +1 -0
- package/src/functions/cloudflare.js +34 -0
- package/src/functions/deno.d.ts +3 -0
- package/src/functions/deno.d.ts.map +1 -0
- package/src/functions/deno.js +31 -0
- package/src/functions/lambda.d.ts +2 -0
- package/src/functions/lambda.d.ts.map +1 -0
- package/src/functions/lambda.js +32 -0
- package/src/http/Controller.d.ts +20 -0
- package/src/http/Controller.d.ts.map +1 -0
- package/src/http/Controller.js +46 -0
- package/src/http/Kernel.d.ts +24 -0
- package/src/http/Kernel.d.ts.map +1 -0
- package/src/http/Kernel.js +72 -0
- package/src/http/Request.d.ts +36 -0
- package/src/http/Request.d.ts.map +1 -0
- package/src/http/Request.js +142 -0
- package/src/http/Response.d.ts +32 -0
- package/src/http/Response.d.ts.map +1 -0
- package/src/http/Response.js +70 -0
- package/src/index.d.ts +43 -0
- package/src/index.d.ts.map +1 -0
- package/src/index.js +37 -0
- package/src/microservices/MicroserviceBootstrap.d.ts +75 -0
- package/src/microservices/MicroserviceBootstrap.d.ts.map +1 -0
- package/src/microservices/MicroserviceBootstrap.js +285 -0
- package/src/microservices/MicroserviceGenerator.d.ts +27 -0
- package/src/microservices/MicroserviceGenerator.d.ts.map +1 -0
- package/src/microservices/MicroserviceGenerator.js +436 -0
- package/src/microservices/MicroserviceManager.d.ts +68 -0
- package/src/microservices/MicroserviceManager.d.ts.map +1 -0
- package/src/microservices/MicroserviceManager.js +266 -0
- package/src/microservices/PostgresAdapter.d.ts +90 -0
- package/src/microservices/PostgresAdapter.d.ts.map +1 -0
- package/src/microservices/PostgresAdapter.js +286 -0
- package/src/microservices/RequestTracingMiddleware.d.ts +41 -0
- package/src/microservices/RequestTracingMiddleware.d.ts.map +1 -0
- package/src/microservices/RequestTracingMiddleware.js +122 -0
- package/src/microservices/ServiceAuthMiddleware.d.ts +58 -0
- package/src/microservices/ServiceAuthMiddleware.d.ts.map +1 -0
- package/src/microservices/ServiceAuthMiddleware.js +240 -0
- package/src/microservices/ServiceBundler.d.ts +45 -0
- package/src/microservices/ServiceBundler.d.ts.map +1 -0
- package/src/microservices/ServiceBundler.js +297 -0
- package/src/microservices/ServiceHealthMonitor.d.ts +96 -0
- package/src/microservices/ServiceHealthMonitor.d.ts.map +1 -0
- package/src/microservices/ServiceHealthMonitor.js +379 -0
- package/src/middleware/CsrfMiddleware.d.ts +19 -0
- package/src/middleware/CsrfMiddleware.d.ts.map +1 -0
- package/src/middleware/CsrfMiddleware.js +121 -0
- package/src/middleware/MiddlewareStack.d.ts +27 -0
- package/src/middleware/MiddlewareStack.d.ts.map +1 -0
- package/src/middleware/MiddlewareStack.js +43 -0
- package/src/middleware/RateLimiter.d.ts +22 -0
- package/src/middleware/RateLimiter.d.ts.map +1 -0
- package/src/middleware/RateLimiter.js +72 -0
- package/src/middleware/SecurityMiddleware.d.ts +33 -0
- package/src/middleware/SecurityMiddleware.d.ts.map +1 -0
- package/src/middleware/SecurityMiddleware.js +106 -0
- package/src/middleware/index.d.ts +9 -0
- package/src/middleware/index.d.ts.map +1 -0
- package/src/middleware/index.js +8 -0
- package/src/node-singletons/child-process.d.ts +7 -0
- package/src/node-singletons/child-process.d.ts.map +1 -0
- package/src/node-singletons/child-process.js +6 -0
- package/src/node-singletons/crypto.d.ts +7 -0
- package/src/node-singletons/crypto.d.ts.map +1 -0
- package/src/node-singletons/crypto.js +6 -0
- package/src/node-singletons/events.d.ts +7 -0
- package/src/node-singletons/events.d.ts.map +1 -0
- package/src/node-singletons/events.js +6 -0
- package/src/node-singletons/fs.d.ts +12 -0
- package/src/node-singletons/fs.d.ts.map +1 -0
- package/src/node-singletons/fs.js +14 -0
- package/src/node-singletons/http.d.ts +8 -0
- package/src/node-singletons/http.d.ts.map +1 -0
- package/src/node-singletons/http.js +6 -0
- package/src/node-singletons/index.d.ts +30 -0
- package/src/node-singletons/index.d.ts.map +1 -0
- package/src/node-singletons/index.js +31 -0
- package/src/node-singletons/os.d.ts +9 -0
- package/src/node-singletons/os.d.ts.map +1 -0
- package/src/node-singletons/os.js +9 -0
- package/src/node-singletons/path.d.ts +7 -0
- package/src/node-singletons/path.d.ts.map +1 -0
- package/src/node-singletons/path.js +6 -0
- package/src/node-singletons/perf-hooks.d.ts +7 -0
- package/src/node-singletons/perf-hooks.d.ts.map +1 -0
- package/src/node-singletons/perf-hooks.js +6 -0
- package/src/node-singletons/readline.d.ts +10 -0
- package/src/node-singletons/readline.d.ts.map +1 -0
- package/src/node-singletons/readline.js +9 -0
- package/src/node-singletons/url.d.ts +7 -0
- package/src/node-singletons/url.d.ts.map +1 -0
- package/src/node-singletons/url.js +6 -0
- package/src/orm/ConnectionManager.d.ts +118 -0
- package/src/orm/ConnectionManager.d.ts.map +1 -0
- package/src/orm/ConnectionManager.js +401 -0
- package/src/orm/Database.d.ts +31 -0
- package/src/orm/Database.d.ts.map +1 -0
- package/src/orm/Database.js +163 -0
- package/src/orm/DatabaseAdapter.d.ts +96 -0
- package/src/orm/DatabaseAdapter.d.ts.map +1 -0
- package/src/orm/DatabaseAdapter.js +40 -0
- package/src/orm/Model.d.ts +91 -0
- package/src/orm/Model.d.ts.map +1 -0
- package/src/orm/Model.js +206 -0
- package/src/orm/QueryBuilder.d.ts +52 -0
- package/src/orm/QueryBuilder.d.ts.map +1 -0
- package/src/orm/QueryBuilder.js +134 -0
- package/src/orm/Relationships.d.ts +53 -0
- package/src/orm/Relationships.d.ts.map +1 -0
- package/src/orm/Relationships.js +98 -0
- package/src/orm/Schema.d.ts +123 -0
- package/src/orm/Schema.d.ts.map +1 -0
- package/src/orm/Schema.js +169 -0
- package/src/orm/adapters/D1Adapter.d.ts +15 -0
- package/src/orm/adapters/D1Adapter.d.ts.map +1 -0
- package/src/orm/adapters/D1Adapter.js +125 -0
- package/src/orm/adapters/MySQLAdapter.d.ts +16 -0
- package/src/orm/adapters/MySQLAdapter.d.ts.map +1 -0
- package/src/orm/adapters/MySQLAdapter.js +87 -0
- package/src/orm/adapters/PostgreSQLAdapter.d.ts +16 -0
- package/src/orm/adapters/PostgreSQLAdapter.d.ts.map +1 -0
- package/src/orm/adapters/PostgreSQLAdapter.js +87 -0
- package/src/orm/adapters/SQLServerAdapter.d.ts +16 -0
- package/src/orm/adapters/SQLServerAdapter.d.ts.map +1 -0
- package/src/orm/adapters/SQLServerAdapter.js +81 -0
- package/src/orm/adapters/SQLiteAdapter.d.ts +11 -0
- package/src/orm/adapters/SQLiteAdapter.d.ts.map +1 -0
- package/src/orm/adapters/SQLiteAdapter.js +131 -0
- package/src/performance/Benchmark.d.ts +87 -0
- package/src/performance/Benchmark.d.ts.map +1 -0
- package/src/performance/Benchmark.js +304 -0
- package/src/performance/CodeGenerationBenchmark.d.ts +23 -0
- package/src/performance/CodeGenerationBenchmark.d.ts.map +1 -0
- package/src/performance/CodeGenerationBenchmark.js +249 -0
- package/src/performance/Optimizer.d.ts +99 -0
- package/src/performance/Optimizer.d.ts.map +1 -0
- package/src/performance/Optimizer.js +396 -0
- package/src/performance/establish-baseline.d.ts +9 -0
- package/src/performance/establish-baseline.d.ts.map +1 -0
- package/src/performance/establish-baseline.js +55 -0
- package/src/profiling/MemoryProfiler.d.ts +32 -0
- package/src/profiling/MemoryProfiler.d.ts.map +1 -0
- package/src/profiling/MemoryProfiler.js +84 -0
- package/src/profiling/N1Detector.d.ts +16 -0
- package/src/profiling/N1Detector.d.ts.map +1 -0
- package/src/profiling/N1Detector.js +120 -0
- package/src/profiling/QueryLogger.d.ts +107 -0
- package/src/profiling/QueryLogger.d.ts.map +1 -0
- package/src/profiling/QueryLogger.js +148 -0
- package/src/profiling/RequestProfiler.d.ts +30 -0
- package/src/profiling/RequestProfiler.d.ts.map +1 -0
- package/src/profiling/RequestProfiler.js +94 -0
- package/src/profiling/types.d.ts +77 -0
- package/src/profiling/types.d.ts.map +1 -0
- package/src/profiling/types.js +5 -0
- package/src/routing/Router.d.ts +52 -0
- package/src/routing/Router.d.ts.map +1 -0
- package/src/routing/Router.js +191 -0
- package/src/runtime/PluginManager.d.ts +30 -0
- package/src/runtime/PluginManager.d.ts.map +1 -0
- package/src/runtime/PluginManager.js +197 -0
- package/src/runtime/PluginRegistry.d.ts +22 -0
- package/src/runtime/PluginRegistry.d.ts.map +1 -0
- package/src/runtime/PluginRegistry.js +93 -0
- package/src/runtime/RuntimeAdapter.d.ts +126 -0
- package/src/runtime/RuntimeAdapter.d.ts.map +1 -0
- package/src/runtime/RuntimeAdapter.js +127 -0
- package/src/runtime/RuntimeDetector.d.ts +15 -0
- package/src/runtime/RuntimeDetector.d.ts.map +1 -0
- package/src/runtime/RuntimeDetector.js +219 -0
- package/src/runtime/adapters/CloudflareAdapter.d.ts +43 -0
- package/src/runtime/adapters/CloudflareAdapter.d.ts.map +1 -0
- package/src/runtime/adapters/CloudflareAdapter.js +175 -0
- package/src/runtime/adapters/DenoAdapter.d.ts +30 -0
- package/src/runtime/adapters/DenoAdapter.d.ts.map +1 -0
- package/src/runtime/adapters/DenoAdapter.js +191 -0
- package/src/runtime/adapters/FargateAdapter.d.ts +40 -0
- package/src/runtime/adapters/FargateAdapter.d.ts.map +1 -0
- package/src/runtime/adapters/FargateAdapter.js +156 -0
- package/src/runtime/adapters/LambdaAdapter.d.ts +13 -0
- package/src/runtime/adapters/LambdaAdapter.d.ts.map +1 -0
- package/src/runtime/adapters/LambdaAdapter.js +302 -0
- package/src/runtime/adapters/NodeServerAdapter.d.ts +16 -0
- package/src/runtime/adapters/NodeServerAdapter.d.ts.map +1 -0
- package/src/runtime/adapters/NodeServerAdapter.js +199 -0
- package/src/scripts/TemplateSync.d.ts +7 -0
- package/src/scripts/TemplateSync.d.ts.map +1 -0
- package/src/scripts/TemplateSync.js +234 -0
- package/src/security/CsrfTokenManager.d.ts +28 -0
- package/src/security/CsrfTokenManager.d.ts.map +1 -0
- package/src/security/CsrfTokenManager.js +78 -0
- package/src/security/Encryptor.d.ts +15 -0
- package/src/security/Encryptor.d.ts.map +1 -0
- package/src/security/Encryptor.js +142 -0
- package/src/security/JwtManager.d.ts +41 -0
- package/src/security/JwtManager.d.ts.map +1 -0
- package/src/security/JwtManager.js +229 -0
- package/src/security/UrlValidator.d.ts +21 -0
- package/src/security/UrlValidator.d.ts.map +1 -0
- package/src/security/UrlValidator.js +42 -0
- package/src/security/XssProtection.d.ts +24 -0
- package/src/security/XssProtection.d.ts.map +1 -0
- package/src/security/XssProtection.js +133 -0
- package/src/templates/TemplateRegistry.d.ts +40 -0
- package/src/templates/TemplateRegistry.d.ts.map +1 -0
- package/src/templates/TemplateRegistry.js +78 -0
- package/src/templates/TemplateRegistry.ts +91 -0
- package/src/templates/adapters/MySQLAdapter.ts.tpl +97 -0
- package/src/templates/adapters/PostgreSQLAdapter.ts.tpl +101 -0
- package/src/templates/adapters/SQLServerAdapter.ts.tpl +95 -0
- package/src/templates/adapters/SQLiteAdapter.ts.tpl +189 -0
- package/src/templates/features/Auth.ts.tpl +40 -0
- package/src/templates/features/Queue.ts.tpl +75 -0
- package/src/templates/project/basic/.env.example.tpl +26 -0
- package/src/templates/project/basic/.env.tpl +164 -0
- package/src/templates/project/basic/README.md.tpl +13 -0
- package/src/templates/project/basic/app/Controllers/UserController.ts.tpl +155 -0
- package/src/templates/project/basic/app/Middleware/ProfilerMiddleware.ts.tpl +55 -0
- package/src/templates/project/basic/app/Middleware/index.ts.tpl +304 -0
- package/src/templates/project/basic/app/Models/Post.ts.tpl +30 -0
- package/src/templates/project/basic/app/Models/User.ts.tpl +53 -0
- package/src/templates/project/basic/config/SecretsManager.ts.tpl +453 -0
- package/src/templates/project/basic/config/app.ts.tpl +97 -0
- package/src/templates/project/basic/config/cache.ts.tpl +117 -0
- package/src/templates/project/basic/config/constants.ts.tpl +70 -0
- package/src/templates/project/basic/config/database.ts.tpl +152 -0
- package/src/templates/project/basic/config/env.ts.tpl +148 -0
- package/src/templates/project/basic/config/features.ts.tpl +57 -0
- package/src/templates/project/basic/config/index.ts.tpl +36 -0
- package/src/templates/project/basic/config/logger.ts.tpl +95 -0
- package/src/templates/project/basic/config/microservices.ts.tpl +104 -0
- package/src/templates/project/basic/config/queue.ts.tpl +134 -0
- package/src/templates/project/basic/config/security.ts.tpl +149 -0
- package/src/templates/project/basic/config/storage.ts.tpl +136 -0
- package/src/templates/project/basic/database/factories/.gitkeep.tpl +0 -0
- package/src/templates/project/basic/database/migrations/.gitkeep.tpl +0 -0
- package/src/templates/project/basic/database/migrations/index.ts.tpl +2 -0
- package/src/templates/project/basic/database/seeders/.gitkeep.tpl +0 -0
- package/src/templates/project/basic/package.json.tpl +22 -0
- package/src/templates/project/basic/routes/api.ts.tpl +135 -0
- package/src/templates/project/basic/src/index.ts.tpl +49 -0
- package/src/templates/project/basic/template.json +17 -0
- package/src/templates/project/basic/tsconfig.json.tpl +20 -0
- package/src/validation/ValidationError.d.ts +42 -0
- package/src/validation/ValidationError.d.ts.map +1 -0
- package/src/validation/ValidationError.js +53 -0
- package/src/validation/Validator.d.ts +60 -0
- package/src/validation/Validator.d.ts.map +1 -0
- package/src/validation/Validator.js +190 -0
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cache Configuration
|
|
3
|
+
* Caching drivers and settings
|
|
4
|
+
* Sealed namespace for immutability
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { Env } from '@config/env';
|
|
8
|
+
|
|
9
|
+
type MemoryCacheDriverConfig = {
|
|
10
|
+
driver: 'memory';
|
|
11
|
+
ttl: number;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
type RedisCacheDriverConfig = {
|
|
15
|
+
driver: 'redis';
|
|
16
|
+
host: string;
|
|
17
|
+
port: number;
|
|
18
|
+
password: string | undefined;
|
|
19
|
+
database: number;
|
|
20
|
+
ttl: number;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
type MemcachedCacheDriverConfig = {
|
|
24
|
+
driver: 'memcached';
|
|
25
|
+
servers: string[];
|
|
26
|
+
ttl: number;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
type FileCacheDriverConfig = {
|
|
30
|
+
driver: 'file';
|
|
31
|
+
path: string;
|
|
32
|
+
ttl: number;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
type CacheDriverConfig =
|
|
36
|
+
| MemoryCacheDriverConfig
|
|
37
|
+
| RedisCacheDriverConfig
|
|
38
|
+
| MemcachedCacheDriverConfig
|
|
39
|
+
| FileCacheDriverConfig;
|
|
40
|
+
|
|
41
|
+
type CacheDrivers = {
|
|
42
|
+
memory: MemoryCacheDriverConfig;
|
|
43
|
+
redis: RedisCacheDriverConfig;
|
|
44
|
+
memcached: MemcachedCacheDriverConfig;
|
|
45
|
+
file: FileCacheDriverConfig;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
type CacheConfigInput = {
|
|
49
|
+
default: string;
|
|
50
|
+
drivers: CacheDrivers;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const getCacheDriver = (config: CacheConfigInput): CacheDriverConfig => {
|
|
54
|
+
const defaultDriver = config.default;
|
|
55
|
+
|
|
56
|
+
if (Object.prototype.hasOwnProperty.call(config.drivers, defaultDriver)) {
|
|
57
|
+
const driverName = defaultDriver as keyof CacheDrivers;
|
|
58
|
+
return config.drivers[driverName];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return config.drivers.memory;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const cacheConfigObj = {
|
|
65
|
+
/**
|
|
66
|
+
* Default cache driver
|
|
67
|
+
*/
|
|
68
|
+
default: Env.get('CACHE_DRIVER', 'memory'),
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Cache drivers
|
|
72
|
+
*/
|
|
73
|
+
drivers: {
|
|
74
|
+
memory: {
|
|
75
|
+
driver: 'memory' as const,
|
|
76
|
+
ttl: Env.getInt('CACHE_MEMORY_TTL', 3600),
|
|
77
|
+
},
|
|
78
|
+
redis: {
|
|
79
|
+
driver: 'redis' as const,
|
|
80
|
+
host: Env.get('REDIS_HOST', 'localhost'),
|
|
81
|
+
port: Env.getInt('REDIS_PORT', 6379),
|
|
82
|
+
password: Env.get('REDIS_PASSWORD'),
|
|
83
|
+
database: Env.getInt('REDIS_DB', 0),
|
|
84
|
+
ttl: Env.getInt('CACHE_REDIS_TTL', 3600),
|
|
85
|
+
},
|
|
86
|
+
memcached: {
|
|
87
|
+
driver: 'memcached' as const,
|
|
88
|
+
servers: Env.get('MEMCACHED_SERVERS', 'localhost:11211').split(','),
|
|
89
|
+
ttl: Env.getInt('CACHE_MEMCACHED_TTL', 3600),
|
|
90
|
+
},
|
|
91
|
+
file: {
|
|
92
|
+
driver: 'file' as const,
|
|
93
|
+
path: Env.get('CACHE_FILE_PATH', 'storage/cache'),
|
|
94
|
+
ttl: Env.getInt('CACHE_FILE_TTL', 3600),
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Get cache driver config
|
|
100
|
+
*/
|
|
101
|
+
getDriver(): CacheDriverConfig {
|
|
102
|
+
return getCacheDriver(this);
|
|
103
|
+
},
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Key prefix for all cache keys
|
|
107
|
+
*/
|
|
108
|
+
keyPrefix: Env.get('CACHE_KEY_PREFIX', 'zintrust:'),
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Default cache TTL (seconds)
|
|
112
|
+
*/
|
|
113
|
+
ttl: Env.getInt('CACHE_DEFAULT_TTL', 3600),
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
export const cacheConfig = Object.freeze(cacheConfigObj);
|
|
117
|
+
export type CacheConfig = typeof cacheConfig;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Framework Constants
|
|
3
|
+
* Centralized string literals to prevent duplication (SonarQube S1192)
|
|
4
|
+
* Sealed namespace for immutability
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const HTTP_HEADERS = {
|
|
8
|
+
CONTENT_TYPE: 'Content-Type',
|
|
9
|
+
ACCEPT: 'Accept',
|
|
10
|
+
AUTHORIZATION: 'Authorization',
|
|
11
|
+
X_TRACE_ID: 'X-Trace-Id',
|
|
12
|
+
X_SERVICE_CALL: 'X-Service-Call',
|
|
13
|
+
X_POWERED_BY: 'X-Powered-By',
|
|
14
|
+
X_CONTENT_TYPE_OPTIONS: 'X-Content-Type-Options',
|
|
15
|
+
X_FRAME_OPTIONS: 'X-Frame-Options',
|
|
16
|
+
X_XSS_PROTECTION: 'X-XSS-Protection',
|
|
17
|
+
REFERRER_POLICY: 'Referrer-Policy',
|
|
18
|
+
CONTENT_SECURITY_POLICY: 'Content-Security-Policy',
|
|
19
|
+
} as const;
|
|
20
|
+
|
|
21
|
+
const MIME_TYPES = {
|
|
22
|
+
JSON: 'application/json',
|
|
23
|
+
HTML: 'text/html',
|
|
24
|
+
TEXT: 'text/plain',
|
|
25
|
+
JS: 'text/javascript',
|
|
26
|
+
CSS: 'text/css',
|
|
27
|
+
PNG: 'image/png',
|
|
28
|
+
JPG: 'image/jpg',
|
|
29
|
+
GIF: 'image/gif',
|
|
30
|
+
SVG: 'image/svg+xml',
|
|
31
|
+
WAV: 'audio/wav',
|
|
32
|
+
MP4: 'video/mp4',
|
|
33
|
+
WOFF: 'application/font-woff',
|
|
34
|
+
TTF: 'application/font-ttf',
|
|
35
|
+
EOT: 'application/vnd.ms-fontobject',
|
|
36
|
+
OTF: 'application/font-otf',
|
|
37
|
+
WASM: 'application/wasm',
|
|
38
|
+
} as const;
|
|
39
|
+
|
|
40
|
+
const ENV_KEYS = {
|
|
41
|
+
NODE_ENV: 'NODE_ENV',
|
|
42
|
+
PORT: 'PORT',
|
|
43
|
+
HOST: 'HOST',
|
|
44
|
+
APP_NAME: 'APP_NAME',
|
|
45
|
+
DB_CONNECTION: 'DB_CONNECTION',
|
|
46
|
+
DB_HOST: 'DB_HOST',
|
|
47
|
+
DB_PORT: 'DB_PORT',
|
|
48
|
+
DB_DATABASE: 'DB_DATABASE',
|
|
49
|
+
DB_USERNAME: 'DB_USERNAME',
|
|
50
|
+
DB_PASSWORD: 'DB_PASSWORD', // NOSONARQUBE
|
|
51
|
+
} as const;
|
|
52
|
+
|
|
53
|
+
const DEFAULTS = {
|
|
54
|
+
CONNECTION: 'default',
|
|
55
|
+
DOMAIN: 'default',
|
|
56
|
+
NAMESPACE: 'default',
|
|
57
|
+
} as const;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Constants namespace - sealed for immutability
|
|
61
|
+
*/
|
|
62
|
+
export const Constants = Object.freeze({
|
|
63
|
+
HTTP_HEADERS,
|
|
64
|
+
MIME_TYPES,
|
|
65
|
+
ENV_KEYS,
|
|
66
|
+
DEFAULTS,
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
// Re-export for backward compatibility
|
|
70
|
+
export { DEFAULTS, ENV_KEYS, HTTP_HEADERS, MIME_TYPES };
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Database Configuration
|
|
3
|
+
* Database connections and pooling settings
|
|
4
|
+
* Sealed namespace for immutability
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { Env } from '@config/env';
|
|
8
|
+
|
|
9
|
+
type SqliteConnectionConfig = {
|
|
10
|
+
driver: 'sqlite';
|
|
11
|
+
database: string;
|
|
12
|
+
migrations: string;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
type PostgresqlConnectionConfig = {
|
|
16
|
+
driver: 'postgresql';
|
|
17
|
+
host: string;
|
|
18
|
+
port: number;
|
|
19
|
+
database: string;
|
|
20
|
+
username: string;
|
|
21
|
+
password: string;
|
|
22
|
+
ssl: boolean;
|
|
23
|
+
pooling: {
|
|
24
|
+
enabled: boolean;
|
|
25
|
+
min: number;
|
|
26
|
+
max: number;
|
|
27
|
+
idleTimeout: number;
|
|
28
|
+
connectionTimeout: number;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
type MysqlConnectionConfig = {
|
|
33
|
+
driver: 'mysql';
|
|
34
|
+
host: string;
|
|
35
|
+
port: number;
|
|
36
|
+
database: string;
|
|
37
|
+
username: string;
|
|
38
|
+
password: string;
|
|
39
|
+
pooling: {
|
|
40
|
+
enabled: boolean;
|
|
41
|
+
min: number;
|
|
42
|
+
max: number;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
type DatabaseConnections = {
|
|
47
|
+
sqlite: SqliteConnectionConfig;
|
|
48
|
+
postgresql: PostgresqlConnectionConfig;
|
|
49
|
+
mysql: MysqlConnectionConfig;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
type DatabaseConnectionName = keyof DatabaseConnections;
|
|
53
|
+
type DatabaseConnectionConfig = DatabaseConnections[DatabaseConnectionName];
|
|
54
|
+
|
|
55
|
+
type DatabaseConfigShape = {
|
|
56
|
+
default: DatabaseConnectionName;
|
|
57
|
+
connections: DatabaseConnections;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const isDatabaseConnectionName = (value: string): value is DatabaseConnectionName => {
|
|
61
|
+
return value === 'sqlite' || value === 'postgresql' || value === 'mysql';
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const getDefaultConnection = (): DatabaseConnectionName => {
|
|
65
|
+
const value = Env.DB_CONNECTION;
|
|
66
|
+
return isDatabaseConnectionName(value) ? value : 'sqlite';
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const getDatabaseConnection = (config: DatabaseConfigShape): DatabaseConnectionConfig => {
|
|
70
|
+
const connName: DatabaseConnectionName = config.default;
|
|
71
|
+
return config.connections[connName];
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const databaseConfigObj = {
|
|
75
|
+
/**
|
|
76
|
+
* Default database connection
|
|
77
|
+
*/
|
|
78
|
+
default: getDefaultConnection(),
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Database connections
|
|
82
|
+
*/
|
|
83
|
+
connections: {
|
|
84
|
+
sqlite: {
|
|
85
|
+
driver: 'sqlite' as const,
|
|
86
|
+
database: Env.DB_DATABASE,
|
|
87
|
+
migrations: 'database/migrations',
|
|
88
|
+
},
|
|
89
|
+
postgresql: {
|
|
90
|
+
driver: 'postgresql' as const,
|
|
91
|
+
host: Env.DB_HOST,
|
|
92
|
+
port: Env.DB_PORT,
|
|
93
|
+
database: Env.DB_DATABASE,
|
|
94
|
+
username: Env.DB_USERNAME,
|
|
95
|
+
password: Env.DB_PASSWORD,
|
|
96
|
+
ssl: Env.getBool('DB_SSL', false),
|
|
97
|
+
pooling: {
|
|
98
|
+
enabled: Env.getBool('DB_POOLING', true),
|
|
99
|
+
min: Env.getInt('DB_POOL_MIN', 5),
|
|
100
|
+
max: Env.getInt('DB_POOL_MAX', 20),
|
|
101
|
+
idleTimeout: Env.getInt('DB_IDLE_TIMEOUT', 30000),
|
|
102
|
+
connectionTimeout: Env.getInt('DB_CONNECTION_TIMEOUT', 10000),
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
mysql: {
|
|
106
|
+
driver: 'mysql' as const,
|
|
107
|
+
host: Env.DB_HOST,
|
|
108
|
+
port: Env.DB_PORT,
|
|
109
|
+
database: Env.DB_DATABASE,
|
|
110
|
+
username: Env.DB_USERNAME,
|
|
111
|
+
password: Env.DB_PASSWORD,
|
|
112
|
+
pooling: {
|
|
113
|
+
enabled: Env.getBool('DB_POOLING', true),
|
|
114
|
+
min: Env.getInt('DB_POOL_MIN', 5),
|
|
115
|
+
max: Env.getInt('DB_POOL_MAX', 20),
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Get current connection config
|
|
122
|
+
*/
|
|
123
|
+
getConnection(this: DatabaseConfigShape): DatabaseConnectionConfig {
|
|
124
|
+
return getDatabaseConnection(this);
|
|
125
|
+
},
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Enable query logging
|
|
129
|
+
*/
|
|
130
|
+
logging: {
|
|
131
|
+
enabled: Env.DEBUG,
|
|
132
|
+
level: Env.get('DB_LOG_LEVEL', 'debug'),
|
|
133
|
+
},
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Migration settings
|
|
137
|
+
*/
|
|
138
|
+
migrations: {
|
|
139
|
+
directory: 'database/migrations',
|
|
140
|
+
extension: Env.get('DB_MIGRATION_EXT', '.ts'),
|
|
141
|
+
},
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Seeding settings
|
|
145
|
+
*/
|
|
146
|
+
seeders: {
|
|
147
|
+
directory: 'database/seeders',
|
|
148
|
+
},
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
export const databaseConfig = Object.freeze(databaseConfigObj);
|
|
152
|
+
export type DatabaseConfig = typeof databaseConfig;
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Environment Configuration
|
|
3
|
+
* Type-safe access to environment variables
|
|
4
|
+
*
|
|
5
|
+
* Sealed namespace pattern - all exports through Env namespace
|
|
6
|
+
* Safe for both Node.js and serverless runtimes (Cloudflare Workers, Deno, Lambda)
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
type ProcessLike = {
|
|
10
|
+
env?: Record<string, string | undefined>;
|
|
11
|
+
execPath?: string;
|
|
12
|
+
platform?: string;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const getProcessLike = (): ProcessLike | undefined => {
|
|
16
|
+
return typeof process === 'undefined' ? undefined : (process as unknown as ProcessLike);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const dirnameFromExecPath = (execPath: string, platform?: string): string => {
|
|
20
|
+
const separator = platform === 'win32' ? '\\' : '/';
|
|
21
|
+
const lastSep = execPath.lastIndexOf(separator);
|
|
22
|
+
if (lastSep <= 0) return '';
|
|
23
|
+
return execPath.slice(0, lastSep);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
// Private helper functions
|
|
27
|
+
const get = (key: string, defaultValue?: string): string => {
|
|
28
|
+
const proc = getProcessLike();
|
|
29
|
+
const env = proc?.env ?? {};
|
|
30
|
+
return env[key] ?? defaultValue ?? '';
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const getInt = (key: string, defaultValue?: number): number => {
|
|
34
|
+
const proc = getProcessLike();
|
|
35
|
+
const env = proc?.env ?? {};
|
|
36
|
+
const value = env[key];
|
|
37
|
+
if (value === undefined || value === null) return defaultValue ?? 0;
|
|
38
|
+
return Number.parseInt(value, 10);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const getBool = (key: string, defaultValue?: boolean): boolean => {
|
|
42
|
+
const proc = getProcessLike();
|
|
43
|
+
const env = proc?.env ?? {};
|
|
44
|
+
const value = env[key];
|
|
45
|
+
if (value === undefined || value === null) return defaultValue ?? false;
|
|
46
|
+
return value.toLowerCase() === 'true' || value === '1';
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const getDefaultLogLevel = (): 'debug' | 'info' | 'warn' | 'error' => {
|
|
50
|
+
const NODE_ENV_VALUE = get('NODE_ENV', 'development');
|
|
51
|
+
if (NODE_ENV_VALUE === 'production') return 'info';
|
|
52
|
+
if (NODE_ENV_VALUE === 'testing') return 'error';
|
|
53
|
+
return 'debug';
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
// Sealed namespace with all environment configuration
|
|
57
|
+
export const Env = Object.freeze({
|
|
58
|
+
// Helper functions
|
|
59
|
+
get,
|
|
60
|
+
getInt,
|
|
61
|
+
getBool,
|
|
62
|
+
|
|
63
|
+
// Core
|
|
64
|
+
NODE_ENV: get('NODE_ENV', 'development'),
|
|
65
|
+
PORT: getInt('APP_PORT', 3000),
|
|
66
|
+
HOST: get('HOST', 'localhost'),
|
|
67
|
+
APP_NAME: get('APP_NAME', 'ZinTrust'),
|
|
68
|
+
APP_KEY: get('APP_KEY', ''),
|
|
69
|
+
|
|
70
|
+
// Database
|
|
71
|
+
DB_CONNECTION: get('DB_CONNECTION', 'sqlite'),
|
|
72
|
+
DB_HOST: get('DB_HOST', 'localhost'),
|
|
73
|
+
DB_PORT: getInt('DB_PORT', 5432),
|
|
74
|
+
DB_DATABASE: get('DB_DATABASE', '@zintrust/core'),
|
|
75
|
+
DB_USERNAME: get('DB_USERNAME', 'postgres'),
|
|
76
|
+
DB_PASSWORD: get('DB_PASSWORD', ''),
|
|
77
|
+
DB_READ_HOSTS: get('DB_READ_HOSTS', ''),
|
|
78
|
+
|
|
79
|
+
// Cloudflare
|
|
80
|
+
D1_DATABASE_ID: get('D1_DATABASE_ID'),
|
|
81
|
+
KV_NAMESPACE_ID: get('KV_NAMESPACE_ID'),
|
|
82
|
+
|
|
83
|
+
// Cache
|
|
84
|
+
CACHE_DRIVER: get('CACHE_DRIVER', 'memory'),
|
|
85
|
+
REDIS_HOST: get('REDIS_HOST', 'localhost'),
|
|
86
|
+
REDIS_PORT: getInt('REDIS_PORT', 6379),
|
|
87
|
+
REDIS_PASSWORD: get('REDIS_PASSWORD', ''),
|
|
88
|
+
MONGO_URI: get('MONGO_URI'),
|
|
89
|
+
MONGO_DB: get('MONGO_DB', 'zintrust_cache'),
|
|
90
|
+
|
|
91
|
+
// AWS
|
|
92
|
+
AWS_REGION: get('AWS_REGION', 'us-east-1'),
|
|
93
|
+
AWS_LAMBDA_FUNCTION_NAME: get('AWS_LAMBDA_FUNCTION_NAME'),
|
|
94
|
+
AWS_LAMBDA_FUNCTION_VERSION: get('AWS_LAMBDA_FUNCTION_VERSION'),
|
|
95
|
+
AWS_EXECUTION_ENV: get('AWS_EXECUTION_ENV'),
|
|
96
|
+
LAMBDA_TASK_ROOT: get('LAMBDA_TASK_ROOT'),
|
|
97
|
+
|
|
98
|
+
// Microservices
|
|
99
|
+
MICROSERVICES: get('MICROSERVICES'),
|
|
100
|
+
SERVICES: get('SERVICES'),
|
|
101
|
+
MICROSERVICES_TRACING: getBool('MICROSERVICES_TRACING'),
|
|
102
|
+
MICROSERVICES_TRACING_RATE: Number.parseFloat(get('MICROSERVICES_TRACING_RATE', '1.0')),
|
|
103
|
+
DATABASE_ISOLATION: get('DATABASE_ISOLATION', 'shared'),
|
|
104
|
+
SERVICE_API_KEY: get('SERVICE_API_KEY'),
|
|
105
|
+
SERVICE_JWT_SECRET: get('SERVICE_JWT_SECRET'),
|
|
106
|
+
|
|
107
|
+
// Security
|
|
108
|
+
DEBUG: getBool('DEBUG', false),
|
|
109
|
+
ENABLE_MICROSERVICES: getBool('ENABLE_MICROSERVICES', false),
|
|
110
|
+
TOKEN_TTL: getInt('TOKEN_TTL', 3600000),
|
|
111
|
+
TOKEN_LENGTH: getInt('TOKEN_LENGTH', 32),
|
|
112
|
+
|
|
113
|
+
// Deployment
|
|
114
|
+
ENVIRONMENT: get('ENVIRONMENT', 'development'),
|
|
115
|
+
REQUEST_TIMEOUT: getInt('REQUEST_TIMEOUT', 30000),
|
|
116
|
+
MAX_BODY_SIZE: getInt('MAX_BODY_SIZE', 10485760),
|
|
117
|
+
|
|
118
|
+
// Logging
|
|
119
|
+
LOG_LEVEL: get('LOG_LEVEL', getDefaultLogLevel()) as 'debug' | 'info' | 'warn' | 'error',
|
|
120
|
+
DISABLE_LOGGING: getBool('DISABLE_LOGGING', false),
|
|
121
|
+
|
|
122
|
+
// Paths (safely constructed for Node.js environments)
|
|
123
|
+
NODE_BIN_DIR: (() => {
|
|
124
|
+
try {
|
|
125
|
+
const proc = getProcessLike();
|
|
126
|
+
if (proc?.execPath === null || proc?.execPath === undefined) return '';
|
|
127
|
+
return dirnameFromExecPath(proc.execPath, proc.platform);
|
|
128
|
+
} catch {
|
|
129
|
+
// Fallback for non-Node environments
|
|
130
|
+
return '';
|
|
131
|
+
}
|
|
132
|
+
})(),
|
|
133
|
+
SAFE_PATH: (() => {
|
|
134
|
+
try {
|
|
135
|
+
const proc = getProcessLike();
|
|
136
|
+
if (proc?.execPath === null || proc?.execPath === undefined) return '';
|
|
137
|
+
|
|
138
|
+
const binDir = dirnameFromExecPath(proc.execPath, proc.platform);
|
|
139
|
+
if (proc.platform === 'win32') {
|
|
140
|
+
return [String.raw`C:\Windows\System32`, String.raw`C:\Windows`, binDir].join(';');
|
|
141
|
+
}
|
|
142
|
+
return ['/usr/bin', '/bin', '/usr/sbin', '/sbin', binDir].join(':');
|
|
143
|
+
} catch {
|
|
144
|
+
// Fallback for non-Node environments
|
|
145
|
+
return '';
|
|
146
|
+
}
|
|
147
|
+
})(),
|
|
148
|
+
});
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Env } from '@config/env';
|
|
2
|
+
import { Logger } from '@config/logger';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Feature Flags State
|
|
6
|
+
* Internal state managed by the module
|
|
7
|
+
*/
|
|
8
|
+
let _rawQueryEnabled = false;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Feature Flags - Controls access to advanced/experimental features
|
|
12
|
+
* Sealed namespace for immutability
|
|
13
|
+
*/
|
|
14
|
+
export const FeatureFlags = Object.freeze({
|
|
15
|
+
/**
|
|
16
|
+
* Initialize all feature flags from environment
|
|
17
|
+
* Called once during application bootstrap
|
|
18
|
+
*/
|
|
19
|
+
initialize(): void {
|
|
20
|
+
_rawQueryEnabled = Env.get('USE_RAW_QRY') === 'true';
|
|
21
|
+
|
|
22
|
+
if (_rawQueryEnabled) {
|
|
23
|
+
Logger.warn(
|
|
24
|
+
'⚠️ FEATURE FLAG ENABLED: Raw SQL Queries are now available via adapter.rawQuery()'
|
|
25
|
+
);
|
|
26
|
+
Logger.warn('⚠️ This bypasses QueryBuilder safety - use only when necessary');
|
|
27
|
+
Logger.warn('⚠️ Ensure parameters are properly bound to prevent SQL injection');
|
|
28
|
+
} else {
|
|
29
|
+
Logger.info('🔒 Raw SQL Queries are DISABLED (default, recommended for production)');
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Check if raw queries are enabled
|
|
35
|
+
* Returns cached flag value (no environment lookup)
|
|
36
|
+
*/
|
|
37
|
+
isRawQueryEnabled(): boolean {
|
|
38
|
+
return _rawQueryEnabled;
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Reset flags (primarily for testing)
|
|
43
|
+
*/
|
|
44
|
+
reset(): void {
|
|
45
|
+
_rawQueryEnabled = false;
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Set raw query enabled state
|
|
50
|
+
* Primarily for testing to avoid 'as any' type casting
|
|
51
|
+
*/
|
|
52
|
+
setRawQueryEnabled(enabled: boolean): void {
|
|
53
|
+
_rawQueryEnabled = enabled;
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
export default FeatureFlags;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration Exports
|
|
3
|
+
* Central export point for all configuration
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { appConfig } from '@config/app';
|
|
7
|
+
import { cacheConfig } from '@config/cache';
|
|
8
|
+
import { databaseConfig } from '@config/database';
|
|
9
|
+
import { microservicesConfig } from '@config/microservices';
|
|
10
|
+
import { queueConfig } from '@config/queue';
|
|
11
|
+
import { securityConfig } from '@config/security';
|
|
12
|
+
import { storageConfig } from '@config/storage';
|
|
13
|
+
|
|
14
|
+
export { appConfig, type AppConfig } from '@config/app';
|
|
15
|
+
export { cacheConfig, type CacheConfig } from '@config/cache';
|
|
16
|
+
export { databaseConfig, type DatabaseConfig } from '@config/database';
|
|
17
|
+
export { microservicesConfig, type MicroservicesConfig } from '@config/microservices';
|
|
18
|
+
export { queueConfig, type QueueConfig } from '@config/queue';
|
|
19
|
+
export { securityConfig } from '@config/security';
|
|
20
|
+
export { storageConfig, type StorageConfig } from '@config/storage';
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Combined configuration object
|
|
24
|
+
* Sealed namespace for immutability
|
|
25
|
+
*/
|
|
26
|
+
export const config = Object.freeze({
|
|
27
|
+
app: appConfig,
|
|
28
|
+
database: databaseConfig,
|
|
29
|
+
storage: storageConfig,
|
|
30
|
+
security: securityConfig,
|
|
31
|
+
microservices: microservicesConfig,
|
|
32
|
+
cache: cacheConfig,
|
|
33
|
+
queue: queueConfig,
|
|
34
|
+
} as const);
|
|
35
|
+
|
|
36
|
+
export type Config = typeof config;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logger utility - Central logging configuration
|
|
3
|
+
* Sealed namespace pattern - all exports through Logger namespace
|
|
4
|
+
* Replaces console.* calls throughout the codebase
|
|
5
|
+
*/
|
|
6
|
+
import { Env } from '@config/env';
|
|
7
|
+
|
|
8
|
+
interface ILogger {
|
|
9
|
+
debug(message: string, data?: unknown, category?: string): void;
|
|
10
|
+
info(message: string, data?: unknown, category?: string): void;
|
|
11
|
+
warn(message: string, data?: unknown, category?: string): void;
|
|
12
|
+
error(message: string, error?: unknown, category?: string): void;
|
|
13
|
+
fatal(message: string, error?: unknown, category?: string): void;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const isDevelopment = Env.NODE_ENV === 'development' || Env.NODE_ENV === undefined;
|
|
17
|
+
const isProduction = Env.NODE_ENV === 'production';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Helper to extract error message from unknown error type
|
|
21
|
+
*/
|
|
22
|
+
const getErrorMessage = (error?: unknown): string => {
|
|
23
|
+
if (error === undefined) {
|
|
24
|
+
return '';
|
|
25
|
+
}
|
|
26
|
+
if (error instanceof Error) {
|
|
27
|
+
return error.message;
|
|
28
|
+
}
|
|
29
|
+
return String(error);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
// Private helper functions
|
|
33
|
+
const logDebug = (message: string, data?: unknown, category?: string): void => {
|
|
34
|
+
String(category);
|
|
35
|
+
if (isDevelopment) {
|
|
36
|
+
console.debug(`[DEBUG] ${message}`, data ?? ''); // eslint-disable-line no-console
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const logInfo = (message: string, data?: unknown, category?: string): void => {
|
|
41
|
+
String(category);
|
|
42
|
+
console.log(`[INFO] ${message}`, data ?? ''); // eslint-disable-line no-console
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const logWarn = (message: string, data?: unknown, category?: string): void => {
|
|
46
|
+
String(category);
|
|
47
|
+
console.warn(`[WARN] ${message}`, data ?? ''); // eslint-disable-line no-console
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const logError = (message: string, error?: unknown, category?: string): void => {
|
|
51
|
+
const errorMessage = getErrorMessage(error);
|
|
52
|
+
String(category);
|
|
53
|
+
console.error(`[ERROR] ${message}`, errorMessage); // eslint-disable-line no-console
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const logFatal = (message: string, error?: unknown, category?: string): void => {
|
|
57
|
+
const errorMessage = getErrorMessage(error);
|
|
58
|
+
String(category);
|
|
59
|
+
console.error(`[FATAL] ${message}`, errorMessage); // eslint-disable-line no-console
|
|
60
|
+
if (isProduction && typeof process !== 'undefined') {
|
|
61
|
+
process.exit(1);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const createLoggerScope = (scope: string): ILogger => {
|
|
66
|
+
return {
|
|
67
|
+
debug(message: string, data?: unknown): void {
|
|
68
|
+
logDebug(`[${scope}] ${message}`, data, scope);
|
|
69
|
+
},
|
|
70
|
+
info(message: string, data?: unknown): void {
|
|
71
|
+
logInfo(`[${scope}] ${message}`, data, scope);
|
|
72
|
+
},
|
|
73
|
+
warn(message: string, data?: unknown): void {
|
|
74
|
+
logWarn(`[${scope}] ${message}`, data, scope);
|
|
75
|
+
},
|
|
76
|
+
error(message: string, error?: unknown): void {
|
|
77
|
+
logError(`[${scope}] ${message}`, error, scope);
|
|
78
|
+
},
|
|
79
|
+
fatal(message: string, error?: unknown): void {
|
|
80
|
+
logFatal(`[${scope}] ${message}`, error, scope);
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
// Sealed namespace with all logger functionality
|
|
86
|
+
export const Logger = Object.freeze({
|
|
87
|
+
debug: logDebug,
|
|
88
|
+
info: logInfo,
|
|
89
|
+
warn: logWarn,
|
|
90
|
+
error: logError,
|
|
91
|
+
fatal: logFatal,
|
|
92
|
+
scope: createLoggerScope,
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
export default Logger;
|