@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,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Microservices Configuration
|
|
3
|
+
* Microservices architecture and service discovery settings
|
|
4
|
+
* Sealed namespace for immutability
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { Env } from '@config/env';
|
|
8
|
+
|
|
9
|
+
const microservicesConfigObj = {
|
|
10
|
+
/**
|
|
11
|
+
* Enable microservices mode
|
|
12
|
+
*/
|
|
13
|
+
enabled: Env.getBool('MICROSERVICES', false),
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Enabled services (comma-separated)
|
|
17
|
+
*/
|
|
18
|
+
services: Env.get('SERVICES', '')
|
|
19
|
+
.split(',')
|
|
20
|
+
.filter((s) => s.trim()),
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Service discovery
|
|
24
|
+
*/
|
|
25
|
+
discovery: {
|
|
26
|
+
type: Env.get('SERVICE_DISCOVERY_TYPE', 'filesystem') as 'filesystem' | 'consul' | 'etcd',
|
|
27
|
+
servicesPath: Env.get('SERVICES_PATH', 'services'),
|
|
28
|
+
refreshInterval: Env.getInt('SERVICE_DISCOVERY_REFRESH_INTERVAL', 30000),
|
|
29
|
+
},
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Service Registry
|
|
33
|
+
*/
|
|
34
|
+
registry: {
|
|
35
|
+
host: Env.get('SERVICE_REGISTRY_HOST', 'localhost'),
|
|
36
|
+
port: Env.getInt('SERVICE_REGISTRY_PORT', 8500),
|
|
37
|
+
deregisterCriticalServiceAfter: Env.get('SERVICE_DEREGISTER_CRITICAL_AFTER', '30s'),
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Service Authentication
|
|
42
|
+
*/
|
|
43
|
+
auth: {
|
|
44
|
+
strategy: Env.get('SERVICE_AUTH_STRATEGY', 'none') as 'api-key' | 'jwt' | 'none' | 'custom',
|
|
45
|
+
apiKey: Env.get('SERVICE_API_KEY'),
|
|
46
|
+
jwtSecret: Env.get('SERVICE_JWT_SECRET'),
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Request Tracing
|
|
51
|
+
*/
|
|
52
|
+
tracing: {
|
|
53
|
+
enabled: Env.getBool('MICROSERVICES_TRACING', false),
|
|
54
|
+
samplingRate: Env.getInt('MICROSERVICES_TRACING_RATE', 100) / 100,
|
|
55
|
+
exportInterval: Env.getInt('TRACING_EXPORT_INTERVAL', 10000),
|
|
56
|
+
jaegerEndpoint: Env.get('JAEGER_AGENT_HOST', 'localhost'),
|
|
57
|
+
},
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Database Isolation
|
|
61
|
+
*/
|
|
62
|
+
database: {
|
|
63
|
+
isolation: Env.get('DATABASE_ISOLATION', 'shared') as 'shared' | 'isolated',
|
|
64
|
+
schema: Env.get('DATABASE_SCHEMA_PREFIX', 'microservice'),
|
|
65
|
+
},
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Service Health Check
|
|
69
|
+
*/
|
|
70
|
+
healthCheck: {
|
|
71
|
+
enabled: Env.getBool('SERVICE_HEALTH_CHECK_ENABLED', true),
|
|
72
|
+
interval: Env.getInt('SERVICE_HEALTH_CHECK_INTERVAL', 30000),
|
|
73
|
+
timeout: Env.getInt('SERVICE_HEALTH_CHECK_TIMEOUT', 5000),
|
|
74
|
+
unhealthyThreshold: Env.getInt('SERVICE_UNHEALTHY_THRESHOLD', 3),
|
|
75
|
+
healthyThreshold: Env.getInt('SERVICE_HEALTHY_THRESHOLD', 2),
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Service Communication
|
|
80
|
+
*/
|
|
81
|
+
communication: {
|
|
82
|
+
timeout: Env.getInt('SERVICE_CALL_TIMEOUT', 30000),
|
|
83
|
+
retries: Env.getInt('SERVICE_CALL_RETRIES', 3),
|
|
84
|
+
retryDelay: Env.getInt('SERVICE_CALL_RETRY_DELAY', 1000),
|
|
85
|
+
circuitBreaker: {
|
|
86
|
+
enabled: Env.getBool('CIRCUIT_BREAKER_ENABLED', true),
|
|
87
|
+
threshold: Env.getInt('CIRCUIT_BREAKER_THRESHOLD', 5),
|
|
88
|
+
timeout: Env.getInt('CIRCUIT_BREAKER_TIMEOUT', 60000),
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Service Mesh (Istio/Linkerd support)
|
|
94
|
+
*/
|
|
95
|
+
mesh: {
|
|
96
|
+
enabled: Env.getBool('SERVICE_MESH_ENABLED', false),
|
|
97
|
+
type: Env.get('SERVICE_MESH_TYPE', 'istio') as 'istio' | 'linkerd',
|
|
98
|
+
namespace: Env.get('SERVICE_MESH_NAMESPACE', 'default'),
|
|
99
|
+
},
|
|
100
|
+
} as const;
|
|
101
|
+
|
|
102
|
+
export const microservicesConfig = Object.freeze(microservicesConfigObj);
|
|
103
|
+
|
|
104
|
+
export type MicroservicesConfig = typeof microservicesConfig;
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Queue Configuration
|
|
3
|
+
* Background job and message queue settings
|
|
4
|
+
* Sealed namespace for immutability
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { Env } from '@config/env';
|
|
8
|
+
|
|
9
|
+
type QueueDriverName = 'sync' | 'database' | 'redis' | 'rabbitmq' | 'sqs';
|
|
10
|
+
|
|
11
|
+
type SyncQueueDriverConfig = {
|
|
12
|
+
driver: 'sync';
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
type DatabaseQueueDriverConfig = {
|
|
16
|
+
driver: 'database';
|
|
17
|
+
table: string;
|
|
18
|
+
connection: string;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
type RedisQueueDriverConfig = {
|
|
22
|
+
driver: 'redis';
|
|
23
|
+
host: string;
|
|
24
|
+
port: number;
|
|
25
|
+
password?: string;
|
|
26
|
+
database: number;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
type RabbitMqQueueDriverConfig = {
|
|
30
|
+
driver: 'rabbitmq';
|
|
31
|
+
host: string;
|
|
32
|
+
port: number;
|
|
33
|
+
username: string;
|
|
34
|
+
password: string;
|
|
35
|
+
vhost: string;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
type SqsQueueDriverConfig = {
|
|
39
|
+
driver: 'sqs';
|
|
40
|
+
key?: string;
|
|
41
|
+
secret?: string;
|
|
42
|
+
region: string;
|
|
43
|
+
queueUrl?: string;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
type QueueDriversConfig = {
|
|
47
|
+
sync: SyncQueueDriverConfig;
|
|
48
|
+
database: DatabaseQueueDriverConfig;
|
|
49
|
+
redis: RedisQueueDriverConfig;
|
|
50
|
+
rabbitmq: RabbitMqQueueDriverConfig;
|
|
51
|
+
sqs: SqsQueueDriverConfig;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
type QueueConfigWithDrivers = {
|
|
55
|
+
default: QueueDriverName;
|
|
56
|
+
drivers: QueueDriversConfig;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const getQueueDriver = (config: QueueConfigWithDrivers): QueueDriversConfig[QueueDriverName] => {
|
|
60
|
+
const driverName = config.default;
|
|
61
|
+
return config.drivers[driverName];
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const queueConfigObj = {
|
|
65
|
+
/**
|
|
66
|
+
* Default queue driver
|
|
67
|
+
*/
|
|
68
|
+
default: Env.get('QUEUE_DRIVER', 'sync') as QueueDriverName,
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Queue drivers
|
|
72
|
+
*/
|
|
73
|
+
drivers: {
|
|
74
|
+
sync: {
|
|
75
|
+
driver: 'sync' as const,
|
|
76
|
+
},
|
|
77
|
+
database: {
|
|
78
|
+
driver: 'database' as const,
|
|
79
|
+
table: Env.get('QUEUE_TABLE', 'jobs'),
|
|
80
|
+
connection: Env.get('QUEUE_DB_CONNECTION', 'default'),
|
|
81
|
+
},
|
|
82
|
+
redis: {
|
|
83
|
+
driver: 'redis' as const,
|
|
84
|
+
host: Env.get('REDIS_HOST', 'localhost'),
|
|
85
|
+
port: Env.getInt('REDIS_PORT', 6379),
|
|
86
|
+
password: Env.get('REDIS_PASSWORD'),
|
|
87
|
+
database: Env.getInt('REDIS_QUEUE_DB', 1),
|
|
88
|
+
},
|
|
89
|
+
rabbitmq: {
|
|
90
|
+
driver: 'rabbitmq' as const,
|
|
91
|
+
host: Env.get('RABBITMQ_HOST', 'localhost'),
|
|
92
|
+
port: Env.getInt('RABBITMQ_PORT', 5672),
|
|
93
|
+
username: Env.get('RABBITMQ_USER', 'guest'),
|
|
94
|
+
password: Env.get('RABBITMQ_PASSWORD', 'guest'),
|
|
95
|
+
vhost: Env.get('RABBITMQ_VHOST', '/'),
|
|
96
|
+
},
|
|
97
|
+
sqs: {
|
|
98
|
+
driver: 'sqs' as const,
|
|
99
|
+
key: Env.get('AWS_ACCESS_KEY_ID'),
|
|
100
|
+
secret: Env.get('AWS_SECRET_ACCESS_KEY'),
|
|
101
|
+
region: Env.AWS_REGION,
|
|
102
|
+
queueUrl: Env.get('AWS_SQS_QUEUE_URL'),
|
|
103
|
+
},
|
|
104
|
+
} satisfies QueueDriversConfig,
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Get queue driver config
|
|
108
|
+
*/
|
|
109
|
+
getDriver(): QueueDriversConfig[QueueDriverName] {
|
|
110
|
+
return getQueueDriver(this);
|
|
111
|
+
},
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Failed jobs table
|
|
115
|
+
*/
|
|
116
|
+
failed: {
|
|
117
|
+
database: Env.get('FAILED_JOBS_DB_CONNECTION', 'default'),
|
|
118
|
+
table: Env.get('FAILED_JOBS_TABLE', 'failed_jobs'),
|
|
119
|
+
},
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Job processing
|
|
123
|
+
*/
|
|
124
|
+
processing: {
|
|
125
|
+
timeout: Env.getInt('QUEUE_JOB_TIMEOUT', 60),
|
|
126
|
+
retries: Env.getInt('QUEUE_JOB_RETRIES', 3),
|
|
127
|
+
backoff: Env.getInt('QUEUE_JOB_BACKOFF', 0),
|
|
128
|
+
workers: Env.getInt('QUEUE_WORKERS', 1),
|
|
129
|
+
},
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
export const queueConfig = Object.freeze(queueConfigObj);
|
|
133
|
+
|
|
134
|
+
export type QueueConfig = typeof queueConfig;
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Security Configuration
|
|
3
|
+
* JWT, CSRF, encryption and other security settings
|
|
4
|
+
* Sealed namespace for immutability
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { Env } from '@config/env';
|
|
8
|
+
import { Logger } from '@config/logger';
|
|
9
|
+
import { ErrorFactory } from '@zintrust/core';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Helper to warn about missing secrets
|
|
13
|
+
*/
|
|
14
|
+
function warnMissingSecret(secretName: string): string {
|
|
15
|
+
Logger.error(`❌ CRITICAL: ${secretName} environment variable is not set!`);
|
|
16
|
+
Logger.error('⚠️ Application may not function correctly. Set this in production immediately.');
|
|
17
|
+
|
|
18
|
+
const nodeEnv = Env.get('NODE_ENV', 'development');
|
|
19
|
+
if (nodeEnv === 'production') {
|
|
20
|
+
throw ErrorFactory.createConfigError(`Missing required secret: ${secretName}`, { secretName });
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// In non-production environments, allow the app/CLI to start while still warning loudly.
|
|
24
|
+
// This is intentionally predictable for local development and test tooling.
|
|
25
|
+
return 'dev-unsafe-jwt-secret';
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
let cachedJwtSecret: string | undefined;
|
|
29
|
+
|
|
30
|
+
const securityConfigObj = {
|
|
31
|
+
/**
|
|
32
|
+
* JWT Configuration
|
|
33
|
+
*/
|
|
34
|
+
jwt: {
|
|
35
|
+
enabled: Env.getBool('JWT_ENABLED', true),
|
|
36
|
+
get secret(): string {
|
|
37
|
+
if (cachedJwtSecret !== undefined) return cachedJwtSecret;
|
|
38
|
+
const isEnabled = Env.getBool('JWT_ENABLED', true);
|
|
39
|
+
cachedJwtSecret = isEnabled
|
|
40
|
+
? Env.get('JWT_SECRET') || warnMissingSecret('JWT_SECRET')
|
|
41
|
+
: Env.get('JWT_SECRET') || '';
|
|
42
|
+
return cachedJwtSecret;
|
|
43
|
+
},
|
|
44
|
+
algorithm: Env.get('JWT_ALGORITHM', 'HS256') as 'HS256' | 'HS512' | 'RS256',
|
|
45
|
+
expiresIn: Env.get('JWT_EXPIRES_IN', '1h'),
|
|
46
|
+
refreshExpiresIn: Env.get('JWT_REFRESH_EXPIRES_IN', '7d'),
|
|
47
|
+
issuer: Env.get('JWT_ISSUER', '@zintrust/core'),
|
|
48
|
+
audience: Env.get('JWT_AUDIENCE', 'zintrust-api'),
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* CSRF Protection
|
|
53
|
+
*/
|
|
54
|
+
csrf: {
|
|
55
|
+
enabled: Env.getBool('CSRF_ENABLED', true),
|
|
56
|
+
headerName: Env.get('CSRF_HEADER_NAME', 'x-csrf-token'),
|
|
57
|
+
tokenName: Env.get('CSRF_TOKEN_NAME', '_csrf'),
|
|
58
|
+
cookieName: Env.get('CSRF_COOKIE_NAME', 'XSRF-TOKEN'),
|
|
59
|
+
cookieHttpOnly: Env.getBool('CSRF_COOKIE_HTTP_ONLY', true),
|
|
60
|
+
cookieSecure: Env.getBool('CSRF_COOKIE_SECURE', true),
|
|
61
|
+
cookieSameSite: Env.get('CSRF_COOKIE_SAME_SITE', 'strict') as 'strict' | 'lax' | 'none',
|
|
62
|
+
},
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Encryption
|
|
66
|
+
*/
|
|
67
|
+
encryption: {
|
|
68
|
+
algorithm: Env.get('ENCRYPTION_ALGORITHM', 'aes-256-cbc'),
|
|
69
|
+
key: Env.get('ENCRYPTION_KEY', 'your-encryption-key'),
|
|
70
|
+
},
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* API Key Authentication
|
|
74
|
+
*/
|
|
75
|
+
apiKey: {
|
|
76
|
+
enabled: Env.getBool('API_KEY_ENABLED', true),
|
|
77
|
+
headerName: Env.get('API_KEY_HEADER', 'x-api-key'),
|
|
78
|
+
secret: Env.get('API_KEY_SECRET'),
|
|
79
|
+
},
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* CORS Configuration
|
|
83
|
+
*/
|
|
84
|
+
cors: {
|
|
85
|
+
enabled: Env.getBool('CORS_ENABLED', true),
|
|
86
|
+
origins: Env.get('CORS_ORIGINS', '*').split(','),
|
|
87
|
+
methods: Env.get('CORS_METHODS', 'GET,POST,PUT,PATCH,DELETE').split(','),
|
|
88
|
+
allowedHeaders: Env.get('CORS_ALLOWED_HEADERS', 'Content-Type,Authorization').split(','),
|
|
89
|
+
exposedHeaders: Env.get('CORS_EXPOSED_HEADERS', '').split(','),
|
|
90
|
+
credentials: Env.getBool('CORS_CREDENTIALS', false),
|
|
91
|
+
maxAge: Env.getInt('CORS_MAX_AGE', 86400),
|
|
92
|
+
},
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Rate Limiting
|
|
96
|
+
*/
|
|
97
|
+
rateLimit: {
|
|
98
|
+
enabled: Env.getBool('RATE_LIMIT_ENABLED', true),
|
|
99
|
+
windowMs: Env.getInt('RATE_LIMIT_WINDOW_MS', 900000), // 15 minutes
|
|
100
|
+
maxRequests: Env.getInt('RATE_LIMIT_MAX_REQUESTS', 100),
|
|
101
|
+
message: Env.get('RATE_LIMIT_MESSAGE', 'Too many requests, please try again later'),
|
|
102
|
+
},
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* XSS Protection
|
|
106
|
+
*/
|
|
107
|
+
xss: {
|
|
108
|
+
enabled: Env.getBool('XSS_ENABLED', true),
|
|
109
|
+
reportUri: Env.get('XSS_REPORT_URI'),
|
|
110
|
+
},
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Helmet Security Headers
|
|
114
|
+
*/
|
|
115
|
+
helmet: {
|
|
116
|
+
enabled: Env.getBool('HELMET_ENABLED', true),
|
|
117
|
+
contentSecurityPolicy: Env.getBool('CSP_ENABLED', true),
|
|
118
|
+
hsts: {
|
|
119
|
+
enabled: Env.getBool('HSTS_ENABLED', true),
|
|
120
|
+
maxAge: Env.getInt('HSTS_MAX_AGE', 31536000),
|
|
121
|
+
includeSubDomains: Env.getBool('HSTS_INCLUDE_SUBDOMAINS', true),
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Session Configuration
|
|
127
|
+
*/
|
|
128
|
+
session: {
|
|
129
|
+
name: Env.get('SESSION_NAME', 'zintrust_session'),
|
|
130
|
+
secret: Env.get('SESSION_SECRET', 'your-session-secret'),
|
|
131
|
+
expiresIn: Env.getInt('SESSION_EXPIRES_IN', 1800000), // 30 minutes
|
|
132
|
+
secure: Env.getBool('SESSION_SECURE', true),
|
|
133
|
+
httpOnly: Env.getBool('SESSION_HTTP_ONLY', true),
|
|
134
|
+
sameSite: Env.get('SESSION_SAME_SITE', 'strict') as 'strict' | 'lax' | 'none',
|
|
135
|
+
},
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Password settings
|
|
139
|
+
*/
|
|
140
|
+
password: {
|
|
141
|
+
minLength: Env.getInt('PASSWORD_MIN_LENGTH', 8),
|
|
142
|
+
requireUppercase: Env.getBool('PASSWORD_REQUIRE_UPPERCASE', true),
|
|
143
|
+
requireNumbers: Env.getBool('PASSWORD_REQUIRE_NUMBERS', true),
|
|
144
|
+
requireSpecialChars: Env.getBool('PASSWORD_REQUIRE_SPECIAL_CHARS', true),
|
|
145
|
+
bcryptRounds: Env.getInt('BCRYPT_ROUNDS', 10),
|
|
146
|
+
},
|
|
147
|
+
} as const;
|
|
148
|
+
|
|
149
|
+
export const securityConfig = Object.freeze(securityConfigObj);
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Storage Configuration
|
|
3
|
+
* File storage and cloud storage settings
|
|
4
|
+
* Sealed namespace for immutability
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { Env } from '@config/env';
|
|
8
|
+
|
|
9
|
+
type EnvGetValue = ReturnType<typeof Env.get>;
|
|
10
|
+
type EnvGetBoolValue = ReturnType<typeof Env.getBool>;
|
|
11
|
+
|
|
12
|
+
type LocalStorageDriverConfig = {
|
|
13
|
+
driver: 'local';
|
|
14
|
+
root: EnvGetValue;
|
|
15
|
+
url: EnvGetValue;
|
|
16
|
+
visibility: EnvGetValue;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
type S3StorageDriverConfig = {
|
|
20
|
+
driver: 's3';
|
|
21
|
+
key: EnvGetValue;
|
|
22
|
+
secret: EnvGetValue;
|
|
23
|
+
region: typeof Env.AWS_REGION;
|
|
24
|
+
bucket: EnvGetValue;
|
|
25
|
+
url: EnvGetValue;
|
|
26
|
+
endpoint: EnvGetValue;
|
|
27
|
+
usePathStyleUrl: EnvGetBoolValue;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
type GcsStorageDriverConfig = {
|
|
31
|
+
driver: 'gcs';
|
|
32
|
+
projectId: EnvGetValue;
|
|
33
|
+
keyFile: EnvGetValue;
|
|
34
|
+
bucket: EnvGetValue;
|
|
35
|
+
url: EnvGetValue;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
type StorageDrivers = {
|
|
39
|
+
local: LocalStorageDriverConfig;
|
|
40
|
+
s3: S3StorageDriverConfig;
|
|
41
|
+
gcs: GcsStorageDriverConfig;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
type StorageDriverName = keyof StorageDrivers;
|
|
45
|
+
type StorageDriverConfig = StorageDrivers[StorageDriverName];
|
|
46
|
+
|
|
47
|
+
type StorageConfigRuntime = {
|
|
48
|
+
default: string;
|
|
49
|
+
drivers: StorageDrivers;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const isStorageDriverName = (value: string, drivers: StorageDrivers): value is StorageDriverName => {
|
|
53
|
+
return value in drivers;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const getStorageDriver = (config: StorageConfigRuntime): StorageDriverConfig => {
|
|
57
|
+
const driverName = config.default;
|
|
58
|
+
|
|
59
|
+
if (isStorageDriverName(driverName, config.drivers)) {
|
|
60
|
+
return config.drivers[driverName];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return config.drivers.local;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const storageConfigObj = {
|
|
67
|
+
/**
|
|
68
|
+
* Default storage driver
|
|
69
|
+
*/
|
|
70
|
+
default: Env.get('STORAGE_DRIVER', 'local'),
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Storage drivers configuration
|
|
74
|
+
*/
|
|
75
|
+
drivers: {
|
|
76
|
+
local: {
|
|
77
|
+
driver: 'local' as const,
|
|
78
|
+
root: Env.get('STORAGE_PATH', 'storage'),
|
|
79
|
+
url: Env.get('STORAGE_URL', '/storage'),
|
|
80
|
+
visibility: Env.get('STORAGE_VISIBILITY', 'private'),
|
|
81
|
+
},
|
|
82
|
+
s3: {
|
|
83
|
+
driver: 's3' as const,
|
|
84
|
+
key: Env.get('AWS_ACCESS_KEY_ID'),
|
|
85
|
+
secret: Env.get('AWS_SECRET_ACCESS_KEY'),
|
|
86
|
+
region: Env.AWS_REGION,
|
|
87
|
+
bucket: Env.get('AWS_S3_BUCKET'),
|
|
88
|
+
url: Env.get('AWS_S3_URL'),
|
|
89
|
+
endpoint: Env.get('AWS_S3_ENDPOINT'),
|
|
90
|
+
usePathStyleUrl: Env.getBool('AWS_S3_USE_PATH_STYLE_URL', false),
|
|
91
|
+
},
|
|
92
|
+
gcs: {
|
|
93
|
+
driver: 'gcs' as const,
|
|
94
|
+
projectId: Env.get('GCS_PROJECT_ID'),
|
|
95
|
+
keyFile: Env.get('GCS_KEY_FILE'),
|
|
96
|
+
bucket: Env.get('GCS_BUCKET'),
|
|
97
|
+
url: Env.get('GCS_URL'),
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Get storage driver config
|
|
103
|
+
*/
|
|
104
|
+
getDriver(this: StorageConfigRuntime): StorageDriverConfig {
|
|
105
|
+
return getStorageDriver(this);
|
|
106
|
+
},
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Temporary file settings
|
|
110
|
+
*/
|
|
111
|
+
temp: {
|
|
112
|
+
path: Env.get('TEMP_PATH', 'storage/temp'),
|
|
113
|
+
maxAge: Env.getInt('TEMP_FILE_MAX_AGE', 86400), // 24 hours
|
|
114
|
+
},
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Uploads settings
|
|
118
|
+
*/
|
|
119
|
+
uploads: {
|
|
120
|
+
maxSize: Env.get('MAX_UPLOAD_SIZE', '100mb'),
|
|
121
|
+
allowedMimes: Env.get('ALLOWED_UPLOAD_MIMES', 'jpg,jpeg,png,pdf,doc,docx'),
|
|
122
|
+
path: Env.get('UPLOADS_PATH', 'storage/uploads'),
|
|
123
|
+
},
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Backups settings
|
|
127
|
+
*/
|
|
128
|
+
backups: {
|
|
129
|
+
path: Env.get('BACKUPS_PATH', 'storage/backups'),
|
|
130
|
+
driver: Env.get('BACKUP_DRIVER', 's3'),
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
export const storageConfig = Object.freeze(storageConfigObj);
|
|
135
|
+
|
|
136
|
+
export type StorageConfig = typeof storageConfig;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{projectName}}",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "zin s",
|
|
8
|
+
"build": "tsc && tsc-alias",
|
|
9
|
+
"start": "zin s --mode production --no-watch",
|
|
10
|
+
"test": "vitest run",
|
|
11
|
+
"type-check": "tsc --noEmit"
|
|
12
|
+
},
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"@zintrust/core": "^0.1.0"
|
|
15
|
+
},
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"tsx": "^4.21.0",
|
|
18
|
+
"tsc-alias": "^1.8.16",
|
|
19
|
+
"typescript": "^5.9.3",
|
|
20
|
+
"vitest": "^4.0.16"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Example Routes
|
|
3
|
+
* Demonstrates routing patterns
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { UserController } from '@app/Controllers/UserController';
|
|
7
|
+
import { Env } from '@config/env';
|
|
8
|
+
import { Logger } from '@config/logger';
|
|
9
|
+
import { useDatabase, type IRouter, Router } from '@zintrust/core';
|
|
10
|
+
|
|
11
|
+
export function registerRoutes(router: IRouter): void {
|
|
12
|
+
const userController = UserController.create();
|
|
13
|
+
registerPublicRoutes(router);
|
|
14
|
+
registerApiV1Routes(router, userController);
|
|
15
|
+
registerAdminRoutes(router);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Register public routes
|
|
20
|
+
*/
|
|
21
|
+
function registerPublicRoutes(router: IRouter): void {
|
|
22
|
+
Router.get(router, '/', async (_req, res) => {
|
|
23
|
+
res.json({
|
|
24
|
+
framework: 'Zintrust Framework',
|
|
25
|
+
app_name: Env.APP_NAME,
|
|
26
|
+
version: '0.1.0',
|
|
27
|
+
env: Env.NODE_ENV ?? 'development',
|
|
28
|
+
database: Env.DB_CONNECTION ?? 'sqlite',
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
Router.get(router, '/health', async (_req, res) => {
|
|
33
|
+
try {
|
|
34
|
+
const db = useDatabase();
|
|
35
|
+
await db.query('SELECT 1');
|
|
36
|
+
|
|
37
|
+
const uptime =
|
|
38
|
+
typeof process !== 'undefined' && typeof process.uptime === 'function'
|
|
39
|
+
? process.uptime()
|
|
40
|
+
: 0;
|
|
41
|
+
|
|
42
|
+
res.json({
|
|
43
|
+
status: 'healthy',
|
|
44
|
+
timestamp: new Date().toISOString(),
|
|
45
|
+
uptime,
|
|
46
|
+
database: 'connected',
|
|
47
|
+
environment: Env.NODE_ENV ?? 'development',
|
|
48
|
+
});
|
|
49
|
+
} catch (error) {
|
|
50
|
+
Logger.error('Health check failed:', error);
|
|
51
|
+
|
|
52
|
+
const isProd =
|
|
53
|
+
typeof process !== 'undefined' &&
|
|
54
|
+
typeof process.env === 'object' &&
|
|
55
|
+
process.env !== null &&
|
|
56
|
+
process.env['NODE_ENV'] === 'production';
|
|
57
|
+
|
|
58
|
+
res.setStatus(503).json({
|
|
59
|
+
status: 'unhealthy',
|
|
60
|
+
timestamp: new Date().toISOString(),
|
|
61
|
+
database: 'disconnected',
|
|
62
|
+
error: isProd ? 'Service unavailable' : (error as Error).message,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Register API V1 routes
|
|
70
|
+
*/
|
|
71
|
+
function registerApiV1Routes(
|
|
72
|
+
router: IRouter,
|
|
73
|
+
userController: ReturnType<typeof UserController.create>
|
|
74
|
+
): void {
|
|
75
|
+
Router.group(router, '/api/v1', (r) => {
|
|
76
|
+
// Auth routes
|
|
77
|
+
Router.post(r, '/auth/login', async (_req, res) => {
|
|
78
|
+
res.json({ message: 'Login endpoint' });
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
Router.post(r, '/auth/register', async (_req, res) => {
|
|
82
|
+
res.json({ message: 'Register endpoint' });
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
// Protected routes (middleware is not modeled in Router.ts yet)
|
|
86
|
+
const pr = r;
|
|
87
|
+
|
|
88
|
+
// User resource (REST-ish)
|
|
89
|
+
Router.resource(pr, '/users', {
|
|
90
|
+
index: userController.index,
|
|
91
|
+
store: userController.store,
|
|
92
|
+
show: userController.show,
|
|
93
|
+
update: userController.update,
|
|
94
|
+
destroy: userController.destroy,
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
// If the controller exposes create/edit, wire them explicitly.
|
|
98
|
+
Router.get(pr, '/users/create', userController.create);
|
|
99
|
+
Router.get(pr, '/users/:id/edit', userController.edit);
|
|
100
|
+
|
|
101
|
+
// Custom user routes
|
|
102
|
+
Router.get(pr, '/profile', async (_req, res) => {
|
|
103
|
+
res.json({ message: 'Get user profile' });
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
Router.put(pr, '/profile', async (_req, res) => {
|
|
107
|
+
res.json({ message: 'Update user profile' });
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
// Posts resource
|
|
111
|
+
Router.get(r, '/posts', async (_req, res) => {
|
|
112
|
+
res.json({ data: [] });
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
Router.get(r, '/posts/:id', async (req, res) => {
|
|
116
|
+
const id = req.getParam('id');
|
|
117
|
+
res.json({ data: { id } });
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Register admin routes
|
|
124
|
+
*/
|
|
125
|
+
function registerAdminRoutes(router: IRouter): void {
|
|
126
|
+
Router.group(router, '/admin', (r) => {
|
|
127
|
+
Router.get(r, '/dashboard', async (_req, res) => {
|
|
128
|
+
res.json({ message: 'Admin dashboard' });
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
Router.get(r, '/users', async (_req, res) => {
|
|
132
|
+
res.json({ data: [] });
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
}
|