@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,97 @@
|
|
|
1
|
+
// TEMPLATE_START
|
|
2
|
+
/* eslint-disable @typescript-eslint/require-await */
|
|
3
|
+
/**
|
|
4
|
+
* MySQL Database Adapter
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { FeatureFlags } from '@config/features';
|
|
8
|
+
import { Logger } from '@config/logger';
|
|
9
|
+
import { ErrorFactory } from '@exceptions/ZintrustError';
|
|
10
|
+
import { DatabaseConfig, IDatabaseAdapter, QueryResult } from '@orm/DatabaseAdapter';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* MySQL adapter implementation
|
|
14
|
+
* Sealed namespace for immutability
|
|
15
|
+
*/
|
|
16
|
+
export const MySQLAdapter = Object.freeze({
|
|
17
|
+
/**
|
|
18
|
+
* Create a new MySQL adapter instance
|
|
19
|
+
*/
|
|
20
|
+
create(config: DatabaseConfig): IDatabaseAdapter {
|
|
21
|
+
let connected = false;
|
|
22
|
+
|
|
23
|
+
return {
|
|
24
|
+
async connect(): Promise<void> {
|
|
25
|
+
if (config.host === 'error') {
|
|
26
|
+
throw ErrorFactory.createConnectionError(
|
|
27
|
+
'Failed to connect to MySQL: Error: Connection failed'
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
connected = true;
|
|
31
|
+
Logger.info(`✓ MySQL connected (${config.host}:${config.port})`);
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
async disconnect(): Promise<void> {
|
|
35
|
+
connected = false;
|
|
36
|
+
Logger.info('✓ MySQL disconnected');
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
async query(_sql: string, _parameters: unknown[]): Promise<QueryResult> {
|
|
40
|
+
if (!connected) throw ErrorFactory.createConnectionError('Database not connected');
|
|
41
|
+
// Mock implementation
|
|
42
|
+
return { rows: [], rowCount: 0 };
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
async queryOne(sql: string, parameters: unknown[]): Promise<Record<string, unknown> | null> {
|
|
46
|
+
const result = await this.query(sql, parameters);
|
|
47
|
+
return result.rows[0] ?? null;
|
|
48
|
+
},
|
|
49
|
+
|
|
50
|
+
async transaction<T>(callback: (adapter: IDatabaseAdapter) => Promise<T>): Promise<T> {
|
|
51
|
+
if (!connected) throw ErrorFactory.createConnectionError('Database not connected');
|
|
52
|
+
try {
|
|
53
|
+
await this.query('START TRANSACTION', []);
|
|
54
|
+
const result = await callback(this);
|
|
55
|
+
await this.query('COMMIT', []);
|
|
56
|
+
return result;
|
|
57
|
+
} catch (error) {
|
|
58
|
+
await this.query('ROLLBACK', []);
|
|
59
|
+
throw ErrorFactory.createTryCatchError('MySQL transaction failed', error);
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
getType(): string {
|
|
64
|
+
return 'mysql';
|
|
65
|
+
},
|
|
66
|
+
isConnected(): boolean {
|
|
67
|
+
return connected;
|
|
68
|
+
},
|
|
69
|
+
async rawQuery<T = unknown>(sql: string, parameters?: unknown[]): Promise<T[]> {
|
|
70
|
+
if (!FeatureFlags.isRawQueryEnabled()) {
|
|
71
|
+
throw ErrorFactory.createConfigError('Raw SQL queries are disabled');
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (!connected) {
|
|
75
|
+
throw ErrorFactory.createConnectionError('Database not connected');
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
try {
|
|
79
|
+
Logger.warn(`Raw SQL Query executed: ${sql}`, { parameters });
|
|
80
|
+
// Mock implementation for tests
|
|
81
|
+
if (sql.includes('INVALID')) {
|
|
82
|
+
throw ErrorFactory.createDatabaseError('Invalid SQL syntax');
|
|
83
|
+
}
|
|
84
|
+
return [] as T[];
|
|
85
|
+
} catch (error) {
|
|
86
|
+
throw ErrorFactory.createTryCatchError(`Raw SQL query failed: ${sql}`, error);
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
getPlaceholder(_index: number): string {
|
|
90
|
+
return '?';
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
export default MySQLAdapter;
|
|
97
|
+
// TEMPLATE_END
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
// TEMPLATE_START
|
|
2
|
+
/* eslint-disable @typescript-eslint/require-await */
|
|
3
|
+
/**
|
|
4
|
+
* PostgreSQL Database Adapter
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { FeatureFlags } from '@config/features';
|
|
8
|
+
import { Logger } from '@config/logger';
|
|
9
|
+
import { ErrorFactory } from '@exceptions/ZintrustError';
|
|
10
|
+
import { DatabaseConfig, IDatabaseAdapter, QueryResult } from '@orm/DatabaseAdapter';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* PostgreSQL adapter implementation
|
|
14
|
+
* Sealed namespace for immutability
|
|
15
|
+
*/
|
|
16
|
+
export const PostgreSQLAdapter = Object.freeze({
|
|
17
|
+
/**
|
|
18
|
+
* Create a new PostgreSQL adapter instance
|
|
19
|
+
*/
|
|
20
|
+
create(config: DatabaseConfig): IDatabaseAdapter {
|
|
21
|
+
let connected = false;
|
|
22
|
+
|
|
23
|
+
return {
|
|
24
|
+
async connect(): Promise<void> {
|
|
25
|
+
if (config.host === 'error') {
|
|
26
|
+
throw ErrorFactory.createConnectionError(
|
|
27
|
+
'Failed to connect to PostgreSQL: Connection failed'
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
connected = true;
|
|
31
|
+
Logger.info(`✓ PostgreSQL connected (${config.host}:${config.port})`);
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
async disconnect(): Promise<void> {
|
|
35
|
+
connected = false;
|
|
36
|
+
Logger.info('✓ PostgreSQL disconnected');
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
async query(_sql: string, _parameters: unknown[]): Promise<QueryResult> {
|
|
40
|
+
if (!connected) throw ErrorFactory.createConnectionError('Database not connected');
|
|
41
|
+
// Mock implementation
|
|
42
|
+
return { rows: [], rowCount: 0 };
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
async queryOne(sql: string, parameters: unknown[]): Promise<Record<string, unknown> | null> {
|
|
46
|
+
const result = await this.query(sql, parameters);
|
|
47
|
+
return result.rows[0] ?? null;
|
|
48
|
+
},
|
|
49
|
+
|
|
50
|
+
async transaction<T>(callback: (adapter: IDatabaseAdapter) => Promise<T>): Promise<T> {
|
|
51
|
+
if (!connected) throw ErrorFactory.createConnectionError('Database not connected');
|
|
52
|
+
try {
|
|
53
|
+
await this.query('BEGIN', []);
|
|
54
|
+
const result = await callback(this);
|
|
55
|
+
await this.query('COMMIT', []);
|
|
56
|
+
return result;
|
|
57
|
+
} catch (error) {
|
|
58
|
+
await this.query('ROLLBACK', []);
|
|
59
|
+
throw ErrorFactory.createTryCatchError('PostgreSQL transaction failed', error);
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
getType(): string {
|
|
64
|
+
return 'postgresql';
|
|
65
|
+
},
|
|
66
|
+
isConnected(): boolean {
|
|
67
|
+
return connected;
|
|
68
|
+
},
|
|
69
|
+
async rawQuery<T = unknown>(sql: string, parameters?: unknown[]): Promise<T[]> {
|
|
70
|
+
if (!FeatureFlags.isRawQueryEnabled()) {
|
|
71
|
+
throw ErrorFactory.createConfigError(
|
|
72
|
+
'Raw SQL queries are disabled. Set USE_RAW_QRY=true environment variable to enable.'
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (!connected) {
|
|
77
|
+
throw ErrorFactory.createConnectionError('Database not connected');
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
Logger.warn(`Raw SQL Query executed: ${sql}`, { parameters });
|
|
81
|
+
|
|
82
|
+
try {
|
|
83
|
+
if (sql.toUpperCase().includes('INVALID')) {
|
|
84
|
+
throw ErrorFactory.createDatabaseError('Invalid SQL syntax');
|
|
85
|
+
}
|
|
86
|
+
// Mock implementation
|
|
87
|
+
return [] as T[];
|
|
88
|
+
} catch (error) {
|
|
89
|
+
throw ErrorFactory.createTryCatchError('Raw SQL Query failed', error);
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
getPlaceholder(index: number): string {
|
|
93
|
+
return `$${index}`;
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
},
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
export default PostgreSQLAdapter;
|
|
100
|
+
|
|
101
|
+
// TEMPLATE_END
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
// TEMPLATE_START
|
|
2
|
+
/* eslint-disable @typescript-eslint/require-await */
|
|
3
|
+
/**
|
|
4
|
+
* SQL Server Database Adapter
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { FeatureFlags } from '@config/features';
|
|
8
|
+
import { Logger } from '@config/logger';
|
|
9
|
+
import { ErrorFactory } from '@exceptions/ZintrustError';
|
|
10
|
+
import { DatabaseConfig, IDatabaseAdapter, QueryResult } from '@orm/DatabaseAdapter';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* SQL Server adapter implementation
|
|
14
|
+
* Sealed namespace for immutability
|
|
15
|
+
*/
|
|
16
|
+
export const SQLServerAdapter = Object.freeze({
|
|
17
|
+
/**
|
|
18
|
+
* Create a new SQL Server adapter instance
|
|
19
|
+
*/
|
|
20
|
+
create(config: DatabaseConfig): IDatabaseAdapter {
|
|
21
|
+
let connected = false;
|
|
22
|
+
|
|
23
|
+
return {
|
|
24
|
+
async connect(): Promise<void> {
|
|
25
|
+
if (config.host === 'error') {
|
|
26
|
+
throw ErrorFactory.createConnectionError(
|
|
27
|
+
'Failed to connect to SQL Server: Error: Connection failed'
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
connected = true;
|
|
31
|
+
Logger.info(`✓ SQL Server connected (${config.host}:${config.port})`);
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
async disconnect(): Promise<void> {
|
|
35
|
+
connected = false;
|
|
36
|
+
Logger.info('✓ SQL Server disconnected');
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
async query(_sql: string, _parameters: unknown[]): Promise<QueryResult> {
|
|
40
|
+
if (!connected) throw ErrorFactory.createConnectionError('Database not connected');
|
|
41
|
+
// Mock implementation
|
|
42
|
+
return { rows: [], rowCount: 0 };
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
async queryOne(sql: string, parameters: unknown[]): Promise<Record<string, unknown> | null> {
|
|
46
|
+
const result = await this.query(sql, parameters);
|
|
47
|
+
return result.rows[0] ?? null;
|
|
48
|
+
},
|
|
49
|
+
|
|
50
|
+
async transaction<T>(callback: (adapter: IDatabaseAdapter) => Promise<T>): Promise<T> {
|
|
51
|
+
try {
|
|
52
|
+
return await callback(this);
|
|
53
|
+
} catch (error) {
|
|
54
|
+
throw ErrorFactory.createTryCatchError('Transaction failed', error);
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
|
|
58
|
+
getType(): string {
|
|
59
|
+
return 'sqlserver';
|
|
60
|
+
},
|
|
61
|
+
isConnected(): boolean {
|
|
62
|
+
return connected;
|
|
63
|
+
},
|
|
64
|
+
async rawQuery<T = unknown>(sql: string, parameters?: unknown[]): Promise<T[]> {
|
|
65
|
+
if (!FeatureFlags.isRawQueryEnabled()) {
|
|
66
|
+
throw ErrorFactory.createConfigError(
|
|
67
|
+
'Raw SQL queries are disabled. Set USE_RAW_QRY=true environment variable to enable.'
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (!connected) {
|
|
72
|
+
throw ErrorFactory.createConnectionError('Database not connected');
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
Logger.warn(`Raw SQL Query executed: ${sql}`, { parameters });
|
|
76
|
+
|
|
77
|
+
try {
|
|
78
|
+
if (sql.toUpperCase().includes('INVALID')) {
|
|
79
|
+
throw ErrorFactory.createDatabaseError('Invalid SQL syntax');
|
|
80
|
+
}
|
|
81
|
+
// Mock implementation
|
|
82
|
+
return [] as T[];
|
|
83
|
+
} catch (error) {
|
|
84
|
+
throw ErrorFactory.createTryCatchError('Raw SQL Query failed', error);
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
getPlaceholder(index: number): string {
|
|
88
|
+
return `@param${index}`;
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
export default SQLServerAdapter;
|
|
95
|
+
// TEMPLATE_END
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
// TEMPLATE_START
|
|
2
|
+
/* eslint-disable @typescript-eslint/require-await */
|
|
3
|
+
/**
|
|
4
|
+
* SQLite Database Adapter
|
|
5
|
+
* Production Implementation
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { FeatureFlags } from '@config/features';
|
|
9
|
+
import { Logger } from '@config/logger';
|
|
10
|
+
import { ErrorFactory } from '@exceptions/ZintrustError';
|
|
11
|
+
import { performance } from '@node-singletons/perf-hooks';
|
|
12
|
+
import { DatabaseConfig, IDatabaseAdapter, QueryResult } from '@orm/DatabaseAdapter';
|
|
13
|
+
import Database from 'better-sqlite3';
|
|
14
|
+
|
|
15
|
+
function normalizeFilename(database: string | null | undefined): string {
|
|
16
|
+
const value = (database ?? '').trim();
|
|
17
|
+
return value.length > 0 ? value : ':memory:';
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function isSelectQuery(sql: string): boolean {
|
|
21
|
+
return sql.trimStart().toLowerCase().startsWith('select');
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function requireDb(db: Database.Database | null): Database.Database {
|
|
25
|
+
if (db === null) throw ErrorFactory.createConnectionError('Database not connected');
|
|
26
|
+
return db;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function executeQuery(
|
|
30
|
+
db: Database.Database,
|
|
31
|
+
sql: string,
|
|
32
|
+
parameters: readonly unknown[]
|
|
33
|
+
): QueryResult {
|
|
34
|
+
const start = performance.now();
|
|
35
|
+
|
|
36
|
+
const stmt = db.prepare(sql);
|
|
37
|
+
if (isSelectQuery(sql)) {
|
|
38
|
+
const rows = stmt.all(parameters) as Record<string, unknown>[];
|
|
39
|
+
Logger.debug('SQLite query executed', { durationMs: performance.now() - start, sql });
|
|
40
|
+
return { rows, rowCount: rows.length };
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const info = stmt.run(parameters);
|
|
44
|
+
Logger.debug('SQLite query executed', { durationMs: performance.now() - start, sql });
|
|
45
|
+
return { rows: [], rowCount: info.changes };
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function executeRawQuery<T>(
|
|
49
|
+
db: Database.Database,
|
|
50
|
+
sql: string,
|
|
51
|
+
parameters: readonly unknown[]
|
|
52
|
+
): T[] {
|
|
53
|
+
const stmt = db.prepare(sql);
|
|
54
|
+
if (isSelectQuery(sql)) return stmt.all(parameters) as T[];
|
|
55
|
+
stmt.run(parameters);
|
|
56
|
+
return [];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
type SQLiteAdapterState = {
|
|
60
|
+
db: Database.Database | null;
|
|
61
|
+
config: DatabaseConfig;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
async function connectSQLite(state: SQLiteAdapterState): Promise<void> {
|
|
65
|
+
if (state.db !== null) return;
|
|
66
|
+
|
|
67
|
+
const filename = normalizeFilename(state.config.database);
|
|
68
|
+
state.db = new Database(filename);
|
|
69
|
+
|
|
70
|
+
// Enable WAL mode for better concurrency
|
|
71
|
+
state.db.pragma('journal_mode = WAL');
|
|
72
|
+
|
|
73
|
+
Logger.info(`✓ SQLite connected (${filename})`);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
async function disconnectSQLite(state: SQLiteAdapterState): Promise<void> {
|
|
77
|
+
if (state.db === null) return;
|
|
78
|
+
|
|
79
|
+
state.db.close();
|
|
80
|
+
state.db = null;
|
|
81
|
+
Logger.info('✓ SQLite disconnected');
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
async function querySQLite(
|
|
85
|
+
state: SQLiteAdapterState,
|
|
86
|
+
sql: string,
|
|
87
|
+
parameters: readonly unknown[]
|
|
88
|
+
): Promise<QueryResult> {
|
|
89
|
+
const currentDb = requireDb(state.db);
|
|
90
|
+
|
|
91
|
+
try {
|
|
92
|
+
return executeQuery(currentDb, sql, parameters);
|
|
93
|
+
} catch (error: unknown) {
|
|
94
|
+
throw ErrorFactory.createTryCatchError('Query failed', { sql, parameters, cause: error });
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
async function rawQuerySQLite<T>(
|
|
99
|
+
state: SQLiteAdapterState,
|
|
100
|
+
sql: string,
|
|
101
|
+
parameters: readonly unknown[]
|
|
102
|
+
): Promise<T[]> {
|
|
103
|
+
if (!FeatureFlags.isRawQueryEnabled()) {
|
|
104
|
+
throw ErrorFactory.createConfigError('Raw SQL queries are disabled');
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const currentDb = requireDb(state.db);
|
|
108
|
+
|
|
109
|
+
Logger.warn(`Raw SQL Query executed: ${sql}`);
|
|
110
|
+
|
|
111
|
+
try {
|
|
112
|
+
return executeRawQuery<T>(currentDb, sql, parameters);
|
|
113
|
+
} catch (error: unknown) {
|
|
114
|
+
throw ErrorFactory.createTryCatchError('Raw query failed', { sql, parameters, cause: error });
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
async function transactionSQLite<T>(
|
|
119
|
+
state: SQLiteAdapterState,
|
|
120
|
+
adapter: IDatabaseAdapter,
|
|
121
|
+
callback: (adapter: IDatabaseAdapter, db: Database.Database) => Promise<T>
|
|
122
|
+
): Promise<T> {
|
|
123
|
+
const currentDb = requireDb(state.db);
|
|
124
|
+
|
|
125
|
+
await adapter.query('BEGIN', []);
|
|
126
|
+
try {
|
|
127
|
+
const result = await callback(adapter, currentDb);
|
|
128
|
+
await adapter.query('COMMIT', []);
|
|
129
|
+
return result;
|
|
130
|
+
} catch (error: unknown) {
|
|
131
|
+
await adapter.query('ROLLBACK', []);
|
|
132
|
+
throw ErrorFactory.createTryCatchError('Transaction failed', { cause: error });
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function createSQLiteAdapter(config: DatabaseConfig): IDatabaseAdapter {
|
|
137
|
+
const state: SQLiteAdapterState = { db: null, config };
|
|
138
|
+
|
|
139
|
+
const adapter: IDatabaseAdapter = {
|
|
140
|
+
async connect(): Promise<void> {
|
|
141
|
+
await connectSQLite(state);
|
|
142
|
+
},
|
|
143
|
+
|
|
144
|
+
async disconnect(): Promise<void> {
|
|
145
|
+
await disconnectSQLite(state);
|
|
146
|
+
},
|
|
147
|
+
|
|
148
|
+
async query(sql: string, parameters: unknown[] = []): Promise<QueryResult> {
|
|
149
|
+
return querySQLite(state, sql, parameters);
|
|
150
|
+
},
|
|
151
|
+
|
|
152
|
+
async queryOne(
|
|
153
|
+
sql: string,
|
|
154
|
+
parameters: unknown[] = []
|
|
155
|
+
): Promise<Record<string, unknown> | null> {
|
|
156
|
+
const result = await adapter.query(sql, parameters);
|
|
157
|
+
return result.rows[0] ?? null;
|
|
158
|
+
},
|
|
159
|
+
|
|
160
|
+
async transaction<T>(
|
|
161
|
+
callback: (adapter: IDatabaseAdapter, db: Database.Database) => Promise<T>
|
|
162
|
+
): Promise<T> {
|
|
163
|
+
return transactionSQLite(state, adapter, callback);
|
|
164
|
+
},
|
|
165
|
+
|
|
166
|
+
async rawQuery<T = unknown>(sql: string, parameters: unknown[] = []): Promise<T[]> {
|
|
167
|
+
return rawQuerySQLite<T>(state, sql, parameters);
|
|
168
|
+
},
|
|
169
|
+
|
|
170
|
+
getType(): string {
|
|
171
|
+
return 'sqlite';
|
|
172
|
+
},
|
|
173
|
+
|
|
174
|
+
isConnected(): boolean {
|
|
175
|
+
return Boolean(state.db);
|
|
176
|
+
},
|
|
177
|
+
|
|
178
|
+
getPlaceholder(_index: number): string {
|
|
179
|
+
return '?';
|
|
180
|
+
},
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
return adapter;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export const SQLiteAdapter = Object.freeze({
|
|
187
|
+
create: createSQLiteAdapter,
|
|
188
|
+
});
|
|
189
|
+
// TEMPLATE_END
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// TEMPLATE_START
|
|
2
|
+
import * as bcrypt from 'bcrypt';
|
|
3
|
+
import { sign, verify, type Secret, type SignOptions } from 'jsonwebtoken';
|
|
4
|
+
|
|
5
|
+
export const Auth = Object.freeze({
|
|
6
|
+
/**
|
|
7
|
+
* Hash a password
|
|
8
|
+
*/
|
|
9
|
+
async hash(password: string): Promise<string> {
|
|
10
|
+
const salt = await bcrypt.genSalt(10);
|
|
11
|
+
return bcrypt.hash(password, salt);
|
|
12
|
+
},
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Compare a password with a hash
|
|
16
|
+
*/
|
|
17
|
+
async compare(password: string, hash: string): Promise<boolean> {
|
|
18
|
+
return bcrypt.compare(password, hash);
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Generate a JWT token
|
|
23
|
+
*/
|
|
24
|
+
generateToken(
|
|
25
|
+
payload: Record<string, unknown>,
|
|
26
|
+
secret: Secret,
|
|
27
|
+
expiresIn: NonNullable<SignOptions['expiresIn']> = '1h'
|
|
28
|
+
): string {
|
|
29
|
+
const options: SignOptions = { expiresIn };
|
|
30
|
+
return sign(payload, secret, options);
|
|
31
|
+
},
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Verify a JWT token
|
|
35
|
+
*/
|
|
36
|
+
verifyToken<T>(token: string, secret: Secret): T {
|
|
37
|
+
return verify(token, secret) as T;
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
// TEMPLATE_END
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// TEMPLATE_START
|
|
2
|
+
|
|
3
|
+
import { Logger } from '@config/logger';
|
|
4
|
+
import { ErrorFactory } from '@exceptions/ZintrustError';
|
|
5
|
+
|
|
6
|
+
export interface QueueJob {
|
|
7
|
+
id: string;
|
|
8
|
+
data: unknown;
|
|
9
|
+
timestamp: number;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Simple In-Memory Queue
|
|
14
|
+
* For production, replace with Redis or similar.
|
|
15
|
+
*/
|
|
16
|
+
export const Queue = Object.freeze({
|
|
17
|
+
jobs: [] as QueueJob[],
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Add a job to the queue
|
|
21
|
+
*/
|
|
22
|
+
async add<T>(data: T): Promise<string> {
|
|
23
|
+
const id = await generateSecureJobId();
|
|
24
|
+
const job: QueueJob = {
|
|
25
|
+
id,
|
|
26
|
+
data,
|
|
27
|
+
timestamp: Date.now(),
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
// In a real implementation, this would push to Redis/SQS
|
|
31
|
+
Queue.jobs.push(job);
|
|
32
|
+
Logger.info(`[Queue] Job added: ${id}`);
|
|
33
|
+
return id;
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Process jobs (Placeholder)
|
|
38
|
+
*/
|
|
39
|
+
async process(handler: (job: QueueJob) => Promise<void>): Promise<void> {
|
|
40
|
+
Logger.info('[Queue] Processing jobs...');
|
|
41
|
+
const jobsToProcess = [...Queue.jobs];
|
|
42
|
+
Queue.jobs.length = 0;
|
|
43
|
+
await Promise.all(jobsToProcess.map(async (job) => handler(job)));
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
async function generateSecureJobId(): Promise<string> {
|
|
48
|
+
if (typeof globalThis.crypto?.randomUUID === 'function') {
|
|
49
|
+
return globalThis.crypto.randomUUID();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (typeof globalThis.crypto?.getRandomValues === 'function') {
|
|
53
|
+
const bytes = new Uint8Array(16);
|
|
54
|
+
globalThis.crypto.getRandomValues(bytes);
|
|
55
|
+
return bytesToHex(bytes);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Node fallback for environments without Web Crypto
|
|
59
|
+
try {
|
|
60
|
+
const nodeCrypto = await import('node:crypto');
|
|
61
|
+
return nodeCrypto.randomBytes(16).toString('hex');
|
|
62
|
+
} catch (error) {
|
|
63
|
+
throw ErrorFactory.createTryCatchError(
|
|
64
|
+
'Secure crypto API not available to generate a job id.',
|
|
65
|
+
error
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function bytesToHex(bytes: Uint8Array): string {
|
|
71
|
+
let out = '';
|
|
72
|
+
for (const b of bytes) out += b.toString(16).padStart(2, '0');
|
|
73
|
+
return out;
|
|
74
|
+
}
|
|
75
|
+
// TEMPLATE_END
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
NODE_ENV=development
|
|
2
|
+
APP_NAME={{projectName}}
|
|
3
|
+
APP_PORT={{port}}
|
|
4
|
+
APP_DEBUG=true
|
|
5
|
+
APP_KEY=
|
|
6
|
+
|
|
7
|
+
DB_CONNECTION=sqlite
|
|
8
|
+
DB_DATABASE=./database.sqlite
|
|
9
|
+
|
|
10
|
+
LOG_LEVEL=debug
|
|
11
|
+
LOG_CHANNEL=file
|
|
12
|
+
|
|
13
|
+
JWT_SECRET=
|
|
14
|
+
JWT_EXPIRES_IN=1h
|
|
15
|
+
|
|
16
|
+
CACHE_DRIVER=memory
|
|
17
|
+
CACHE_TTL=300
|
|
18
|
+
QUEUE_DRIVER=sync
|
|
19
|
+
|
|
20
|
+
MAIL_DRIVER=smtp
|
|
21
|
+
MAIL_HOST=
|
|
22
|
+
MAIL_PORT=587
|
|
23
|
+
MAIL_USERNAME=
|
|
24
|
+
MAIL_PASSWORD=
|
|
25
|
+
MAIL_FROM_ADDRESS=
|
|
26
|
+
MAIL_FROM_NAME=
|