@zintrust/core 0.1.4 → 0.1.6
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 +2 -2
- package/bin/z.d.ts.map +1 -1
- package/bin/z.js +3 -2
- package/bin/zin.d.ts +2 -2
- package/bin/zin.d.ts.map +1 -1
- package/bin/zin.js +3 -2
- package/bin/zintrust-main.d.ts +9 -0
- package/bin/zintrust-main.d.ts.map +1 -0
- package/bin/zintrust-main.js +101 -0
- package/bin/zintrust-microservices.js +7 -7
- package/bin/zintrust.d.ts +5 -4
- package/bin/zintrust.d.ts.map +1 -1
- package/bin/zintrust.js +7 -87
- package/bin/zt.d.ts +2 -2
- package/bin/zt.d.ts.map +1 -1
- package/bin/zt.js +3 -2
- package/package.json +13 -3
- package/public/index.html +4 -0
- package/src/boot/Application.js +13 -13
- package/src/boot/Server.d.ts.map +1 -1
- package/src/boot/Server.js +47 -39
- package/src/boot/bootstrap.js +71 -36
- package/src/builder/BundleOptimizer.js +3 -3
- package/src/cache/Cache.js +6 -6
- package/src/cache/drivers/KVDriver.js +2 -2
- package/src/cache/drivers/MongoDriver.js +3 -3
- package/src/cache/drivers/RedisDriver.js +3 -3
- package/src/cli/BaseCommand.d.ts +2 -0
- package/src/cli/BaseCommand.d.ts.map +1 -1
- package/src/cli/BaseCommand.js +12 -2
- package/src/cli/CLI.js +23 -23
- package/src/cli/ErrorHandler.d.ts.map +1 -1
- package/src/cli/ErrorHandler.js +14 -8
- package/src/cli/commands/AddCommand.js +15 -15
- package/src/cli/commands/ConfigCommand.js +6 -6
- package/src/cli/commands/D1MigrateCommand.js +6 -6
- package/src/cli/commands/DebugCommand.js +3 -3
- package/src/cli/commands/FixCommand.js +5 -5
- package/src/cli/commands/KeyGenerateCommand.js +5 -5
- package/src/cli/commands/LogsCleanupCommand.js +2 -2
- package/src/cli/commands/LogsCommand.js +6 -6
- package/src/cli/commands/MakeMailTemplateCommand.d.ts.map +1 -1
- package/src/cli/commands/MakeMailTemplateCommand.js +8 -7
- package/src/cli/commands/MakeNotificationTemplateCommand.d.ts.map +1 -1
- package/src/cli/commands/MakeNotificationTemplateCommand.js +8 -7
- package/src/cli/commands/MigrateCommand.js +2 -2
- package/src/cli/commands/NewCommand.js +11 -11
- package/src/cli/commands/PluginCommand.js +3 -3
- package/src/cli/commands/PrepareCommand.js +6 -6
- package/src/cli/commands/QACommand.js +8 -8
- package/src/cli/commands/SecretsCommand.js +3 -3
- package/src/cli/commands/SimulateCommand.js +6 -6
- package/src/cli/commands/StartCommand.js +7 -7
- package/src/cli/commands/TemplatesCommand.js +5 -5
- package/src/cli/commands/index.js +12 -12
- package/src/cli/config/ConfigManager.js +5 -5
- package/src/cli/config/ConfigValidator.js +1 -1
- package/src/cli/config/index.js +3 -3
- package/src/cli/debug/Dashboard.js +3 -3
- package/src/cli/index.js +10 -10
- package/src/cli/logger/Logger.js +2 -2
- package/src/cli/scaffolding/ControllerGenerator.d.ts.map +1 -1
- package/src/cli/scaffolding/ControllerGenerator.js +48 -64
- package/src/cli/scaffolding/FactoryGenerator.js +6 -6
- package/src/cli/scaffolding/FeatureScaffolder.js +8 -8
- package/src/cli/scaffolding/FileGenerator.js +4 -4
- package/src/cli/scaffolding/MigrationGenerator.js +4 -4
- package/src/cli/scaffolding/ModelGenerator.js +5 -5
- package/src/cli/scaffolding/ProjectScaffolder.d.ts.map +1 -1
- package/src/cli/scaffolding/ProjectScaffolder.js +78 -15
- package/src/cli/scaffolding/RequestFactoryGenerator.js +5 -5
- package/src/cli/scaffolding/ResponseFactoryGenerator.js +5 -5
- package/src/cli/scaffolding/RouteGenerator.js +4 -4
- package/src/cli/scaffolding/SeederGenerator.js +7 -7
- package/src/cli/scaffolding/ServiceIntegrationTestGenerator.js +5 -5
- package/src/cli/scaffolding/ServiceRequestFactoryGenerator.js +4 -4
- package/src/cli/scaffolding/ServiceScaffolder.d.ts.map +1 -1
- package/src/cli/scaffolding/ServiceScaffolder.js +24 -23
- package/src/cli/scaffolding/TemplateEngine.d.ts.map +1 -1
- package/src/cli/scaffolding/TemplateEngine.js +0 -2
- package/src/cli/scaffolding/TemplateGenerator.js +4 -4
- package/src/cli/scaffolding/WorkflowGenerator.js +4 -4
- package/src/cli/scaffolding/index.js +16 -16
- package/src/cli/utils/DistPackager.js +4 -4
- package/src/cli/utils/EnvFileLoader.js +2 -2
- package/src/cli/utils/spawn.d.ts.map +1 -1
- package/src/cli/utils/spawn.js +18 -7
- package/src/common/AwsSigV4.js +1 -1
- package/src/common/index.js +5 -5
- package/src/common/uuid.js +2 -2
- package/src/config/FileLogWriter.js +4 -4
- package/src/config/SecretsManager.d.ts +1 -42
- package/src/config/SecretsManager.d.ts.map +1 -1
- package/src/config/SecretsManager.js +2 -2
- package/src/config/StartupConfigValidator.d.ts +1 -9
- package/src/config/StartupConfigValidator.d.ts.map +1 -1
- package/src/config/StartupConfigValidator.js +115 -22
- package/src/config/app.d.ts +1 -1
- package/src/config/app.d.ts.map +1 -1
- package/src/config/app.js +1 -1
- package/src/config/broadcast.d.ts +1 -26
- package/src/config/broadcast.d.ts.map +1 -1
- package/src/config/broadcast.js +1 -1
- package/src/config/cache.d.ts +1 -22
- package/src/config/cache.d.ts.map +1 -1
- package/src/config/cache.js +1 -1
- package/src/config/cloudflare.d.ts +1 -13
- package/src/config/cloudflare.d.ts.map +1 -1
- package/src/config/database.d.ts +2 -47
- package/src/config/database.d.ts.map +1 -1
- package/src/config/database.js +1 -1
- package/src/config/env.d.ts.map +1 -1
- package/src/config/env.js +6 -2
- package/src/config/features.js +2 -2
- package/src/config/index.d.ts +10 -287
- package/src/config/index.d.ts.map +1 -1
- package/src/config/index.js +16 -16
- package/src/config/logger.d.ts.map +1 -1
- package/src/config/logger.js +10 -8
- package/src/config/logging/HttpLogger.js +4 -4
- package/src/config/logging/KvLogger.js +2 -2
- package/src/config/logging/SlackLogger.js +3 -3
- package/src/config/mail.d.ts +1 -27
- package/src/config/mail.d.ts.map +1 -1
- package/src/config/mail.js +1 -1
- package/src/config/microservices.js +1 -1
- package/src/config/middleware.d.ts +2 -6
- package/src/config/middleware.d.ts.map +1 -1
- package/src/config/middleware.js +5 -5
- package/src/config/notification.d.ts +0 -21
- package/src/config/notification.d.ts.map +1 -1
- package/src/config/notification.js +1 -1
- package/src/config/queue.d.ts +1 -39
- package/src/config/queue.d.ts.map +1 -1
- package/src/config/queue.js +1 -1
- package/src/config/security.d.ts +12 -0
- package/src/config/security.d.ts.map +1 -1
- package/src/config/security.js +17 -5
- package/src/config/startup.d.ts +2 -0
- package/src/config/startup.d.ts.map +1 -1
- package/src/config/startup.js +2 -1
- package/src/config/storage.d.ts +1 -48
- package/src/config/storage.d.ts.map +1 -1
- package/src/config/storage.js +1 -1
- package/src/config/type.d.ts +335 -0
- package/src/config/type.d.ts.map +1 -0
- package/src/config/type.js +1 -0
- package/src/container/ServiceContainer.js +1 -1
- package/src/exceptions/ZintrustError.js +1 -1
- package/src/features/Queue.js +2 -2
- package/src/functions/cloudflare.js +4 -4
- package/src/functions/deno.js +4 -4
- package/src/functions/lambda.js +4 -4
- package/src/health/RuntimeHealthProbes.js +3 -3
- package/src/health/StartupHealthChecks.js +9 -9
- package/src/http/Kernel.js +10 -10
- package/src/http/RequestContext.js +2 -2
- package/src/http/Response.js +1 -1
- package/src/index.d.ts +36 -1
- package/src/index.d.ts.map +1 -1
- package/src/index.js +69 -36
- package/src/microservices/MicroserviceBootstrap.js +5 -5
- package/src/microservices/MicroserviceGenerator.js +10 -10
- package/src/microservices/MicroserviceManager.js +4 -4
- package/src/microservices/PostgresAdapter.js +3 -3
- package/src/microservices/RequestTracingMiddleware.js +3 -3
- package/src/microservices/ServiceAuthMiddleware.js +3 -3
- package/src/microservices/ServiceBundler.js +3 -3
- package/src/microservices/ServiceHealthMonitor.js +2 -2
- package/src/middleware/CsrfMiddleware.js +3 -3
- package/src/middleware/ErrorHandlerMiddleware.js +4 -4
- package/src/middleware/LoggingMiddleware.js +3 -3
- package/src/middleware/RateLimiter.js +1 -1
- package/src/middleware/index.js +6 -6
- package/src/node-singletons/http.d.ts +2 -2
- package/src/node-singletons/http.d.ts.map +1 -1
- package/src/node-singletons/http.js +1 -1
- package/src/node-singletons/index.js +14 -14
- package/src/node-singletons/path.d.ts +1 -1
- package/src/node.d.ts +5 -0
- package/src/node.d.ts.map +1 -0
- package/src/node.js +4 -0
- package/src/orm/ConnectionManager.js +3 -3
- package/src/orm/Database.js +8 -8
- package/src/orm/Model.js +5 -5
- package/src/orm/QueryBuilder.js +1 -1
- package/src/orm/Relationships.js +1 -1
- package/src/orm/adapters/D1Adapter.js +5 -5
- package/src/orm/adapters/MySQLAdapter.d.ts.map +1 -1
- package/src/orm/adapters/MySQLAdapter.js +4 -6
- package/src/orm/adapters/PostgreSQLAdapter.d.ts.map +1 -1
- package/src/orm/adapters/PostgreSQLAdapter.js +4 -6
- package/src/orm/adapters/SQLServerAdapter.d.ts.map +1 -1
- package/src/orm/adapters/SQLServerAdapter.js +4 -6
- package/src/orm/adapters/SQLiteAdapter.d.ts.map +1 -1
- package/src/orm/adapters/SQLiteAdapter.js +5 -7
- package/src/performance/CodeGenerationBenchmark.js +5 -5
- package/src/performance/Optimizer.js +3 -3
- package/src/performance/establish-baseline.js +4 -4
- package/src/profiling/RequestProfiler.js +4 -4
- package/src/runtime/PluginManager.js +8 -8
- package/src/runtime/RuntimeDetector.d.ts.map +1 -1
- package/src/runtime/RuntimeDetector.js +22 -12
- package/src/runtime/adapters/CloudflareAdapter.js +3 -3
- package/src/runtime/adapters/DenoAdapter.js +2 -2
- package/src/runtime/adapters/FargateAdapter.js +4 -4
- package/src/runtime/adapters/LambdaAdapter.js +4 -4
- package/src/runtime/adapters/NodeServerAdapter.js +4 -4
- package/src/scheduler/ScheduleRunner.js +2 -2
- package/src/scheduler/index.js +1 -1
- package/src/schedules/index.js +1 -1
- package/src/schedules/log-cleanup.js +2 -2
- package/src/scripts/GenerateEnvArtifacts.js +4 -4
- package/src/scripts/TemplateSync.js +8 -6
- package/src/security/CsrfTokenManager.js +2 -2
- package/src/security/Encryptor.js +3 -3
- package/src/security/Hash.js +2 -2
- package/src/security/JwtManager.js +2 -2
- package/src/security/StartupSecretValidation.js +4 -4
- package/src/security/UrlValidator.js +1 -1
- package/src/security/Xss.js +1 -1
- package/src/security/XssProtection.d.ts.map +1 -1
- package/src/security/XssProtection.js +8 -3
- package/src/templates/adapters/MySQLAdapter.ts.tpl +0 -2
- package/src/templates/adapters/PostgreSQLAdapter.ts.tpl +0 -3
- package/src/templates/adapters/SQLServerAdapter.ts.tpl +0 -2
- package/src/templates/adapters/SQLiteAdapter.ts.tpl +0 -2
- package/src/templates/project/basic/.env.tpl +8 -1
- package/src/templates/project/basic/app/Controllers/UserController.ts.tpl +3 -2
- package/src/templates/project/basic/app/Middleware/ProfilerMiddleware.ts.tpl +3 -2
- package/src/templates/project/basic/app/Middleware/index.ts.tpl +8 -14
- package/src/templates/project/basic/app/Models/Post.ts.tpl +2 -1
- package/src/templates/project/basic/app/Models/User.ts.tpl +1 -1
- package/src/templates/project/basic/app/Toolkit/Broadcast/sendBroadcast.ts.tpl +1 -1
- package/src/templates/project/basic/app/Toolkit/Mail/sendWelcomeEmail.ts.tpl +1 -1
- package/src/templates/project/basic/app/Toolkit/Notification/sendSlackNotification.ts.tpl +1 -1
- package/src/templates/project/basic/app/Toolkit/Notification/sendSms.ts.tpl +1 -1
- package/src/templates/project/basic/config/FileLogWriter.ts.tpl +2 -4
- package/src/templates/project/basic/config/SecretsManager.ts.tpl +6 -39
- package/src/templates/project/basic/config/StartupConfigValidator.ts.tpl +154 -37
- package/src/templates/project/basic/config/app.ts.tpl +1 -5
- package/src/templates/project/basic/config/broadcast.ts.tpl +6 -36
- package/src/templates/project/basic/config/cache.ts.tpl +1 -42
- package/src/templates/project/basic/config/cloudflare.ts.tpl +1 -15
- package/src/templates/project/basic/config/database.ts.tpl +5 -51
- package/src/templates/project/basic/config/env.ts.tpl +6 -7
- package/src/templates/project/basic/config/features.ts.tpl +1 -1
- package/src/templates/project/basic/config/index.ts.tpl +1 -1
- package/src/templates/project/basic/config/logger.ts.tpl +3 -1
- package/src/templates/project/basic/config/logging/HttpLogger.ts.tpl +1 -1
- package/src/templates/project/basic/config/logging/KvLogger.ts.tpl +1 -1
- package/src/templates/project/basic/config/logging/SlackLogger.ts.tpl +1 -1
- package/src/templates/project/basic/config/mail.ts.tpl +1 -57
- package/src/templates/project/basic/config/microservices.ts.tpl +1 -1
- package/src/templates/project/basic/config/middleware.ts.tpl +2 -6
- package/src/templates/project/basic/config/notification.ts.tpl +1 -36
- package/src/templates/project/basic/config/queue.ts.tpl +1 -49
- package/src/templates/project/basic/config/security.ts.tpl +13 -1
- package/src/templates/project/basic/config/startup.ts.tpl +2 -0
- package/src/templates/project/basic/config/storage.ts.tpl +6 -54
- package/src/templates/project/basic/config/type.ts.tpl +414 -0
- package/src/templates/project/basic/package.json.tpl +1 -0
- package/src/templates/project/basic/routes/api.ts.tpl +1 -1
- package/src/templates/project/basic/routes/broadcast.ts.tpl +1 -1
- package/src/templates/project/basic/routes/health.ts.tpl +1 -1
- package/src/templates/project/basic/routes/storage.ts.tpl +1 -1
- package/src/templates/project/basic/src/index.ts.tpl +49 -41
- package/src/templates/project/basic/template.json +1 -1
- package/src/templates/project/basic/tsconfig.json.tpl +3 -1
- package/src/toolkit/Secrets/EnvFile.js +3 -3
- package/src/toolkit/Secrets/Manifest.js +3 -3
- package/src/toolkit/Secrets/index.js +5 -5
- package/src/toolkit/Secrets/providers/AwsSecretsManager.js +2 -2
- package/src/toolkit/Secrets/providers/CloudflareKv.js +1 -1
- package/src/tools/broadcast/Broadcast.js +6 -6
- package/src/tools/broadcast/drivers/BaseDriver.js +1 -1
- package/src/tools/broadcast/drivers/Pusher.d.ts +1 -1
- package/src/tools/broadcast/drivers/Pusher.d.ts.map +1 -1
- package/src/tools/broadcast/drivers/Pusher.js +2 -2
- package/src/tools/broadcast/drivers/Redis.js +1 -1
- package/src/tools/broadcast/drivers/RedisHttps.js +3 -3
- package/src/tools/broadcast/index.js +6 -6
- package/src/tools/http/Http.js +4 -4
- package/src/tools/http/HttpResponse.js +1 -1
- package/src/tools/http/index.js +2 -2
- package/src/tools/mail/Mail.js +8 -8
- package/src/tools/mail/attachments.js +1 -1
- package/src/tools/mail/drivers/BaseDriver.js +1 -1
- package/src/tools/mail/drivers/Mailgun.js +1 -1
- package/src/tools/mail/drivers/SendGrid.js +1 -1
- package/src/tools/mail/drivers/Ses.js +2 -2
- package/src/tools/mail/drivers/Smtp.js +4 -4
- package/src/tools/mail/templates/markdown/index.js +3 -3
- package/src/tools/mail/templates/markdown/registry.js +5 -5
- package/src/tools/mail/templates/markdown/validator.js +1 -1
- package/src/tools/mail/testing.js +1 -1
- package/src/tools/notification/Notification.js +1 -1
- package/src/tools/notification/Registry.js +3 -3
- package/src/tools/notification/Service.js +3 -3
- package/src/tools/notification/config.js +1 -1
- package/src/tools/notification/drivers/BaseDriver.js +1 -1
- package/src/tools/notification/drivers/Slack.js +1 -1
- package/src/tools/notification/drivers/Termii.js +1 -1
- package/src/tools/notification/drivers/Twilio.js +1 -1
- package/src/tools/notification/templates/markdown/index.js +3 -3
- package/src/tools/notification/templates/markdown/registry.js +5 -5
- package/src/tools/notification/testing.js +1 -1
- package/src/tools/notification/testingHelpers.js +2 -2
- package/src/tools/queue/Queue.js +1 -1
- package/src/tools/queue/drivers/InMemory.js +1 -1
- package/src/tools/queue/drivers/Redis.js +2 -2
- package/src/tools/storage/LocalSignedUrl.js +2 -2
- package/src/tools/storage/drivers/Gcs.js +1 -1
- package/src/tools/storage/drivers/Local.js +5 -5
- package/src/tools/storage/drivers/R2.js +2 -2
- package/src/tools/storage/drivers/S3.js +3 -3
- package/src/tools/storage/index.js +6 -6
- package/src/tools/storage/testing.js +1 -1
- package/src/tools/templates/MarkdownRenderer.js +2 -2
- package/src/tools/templates/index.js +1 -1
- package/src/validation/Validator.js +3 -3
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
* New Command - Project scaffolding CLI command
|
|
3
3
|
* Handles creation of new Zintrust projects
|
|
4
4
|
*/
|
|
5
|
-
import { BaseCommand } from '../BaseCommand';
|
|
6
|
-
import { PromptHelper } from '../PromptHelper';
|
|
7
|
-
import { ProjectScaffolder } from '../scaffolding/ProjectScaffolder';
|
|
8
|
-
import { SpawnUtil } from '../utils/spawn';
|
|
9
|
-
import { extractErrorMessage, resolvePackageManager } from '../../common/index';
|
|
10
|
-
import { appConfig } from '../../config/app';
|
|
11
|
-
import { ErrorFactory } from '../../exceptions/ZintrustError';
|
|
12
|
-
import { execFileSync } from '../../node-singletons/child-process';
|
|
13
|
-
import * as path from '../../node-singletons/path';
|
|
5
|
+
import { BaseCommand } from '../BaseCommand.js';
|
|
6
|
+
import { PromptHelper } from '../PromptHelper.js';
|
|
7
|
+
import { ProjectScaffolder } from '../scaffolding/ProjectScaffolder.js';
|
|
8
|
+
import { SpawnUtil } from '../utils/spawn.js';
|
|
9
|
+
import { extractErrorMessage, resolvePackageManager } from '../../common/index.js';
|
|
10
|
+
import { appConfig } from '../../config/app.js';
|
|
11
|
+
import { ErrorFactory } from '../../exceptions/ZintrustError.js';
|
|
12
|
+
import { execFileSync } from '../../node-singletons/child-process.js';
|
|
13
|
+
import * as path from '../../node-singletons/path.js';
|
|
14
14
|
import chalk from 'chalk';
|
|
15
15
|
const getGitBinary = () => 'git';
|
|
16
16
|
const checkGitInstalled = () => {
|
|
@@ -52,7 +52,7 @@ const getBooleanOption = (options, key, fallback) => {
|
|
|
52
52
|
const getProjectDefaults = (name, options) => {
|
|
53
53
|
const template = getStringOption(options, 'template', 'basic');
|
|
54
54
|
const database = getStringOption(options, 'database', 'sqlite');
|
|
55
|
-
const portRaw = getStringOption(options, 'port', '
|
|
55
|
+
const portRaw = getStringOption(options, 'port', '7777');
|
|
56
56
|
const portParsed = Number.parseInt(portRaw, 10);
|
|
57
57
|
const port = Number.isFinite(portParsed) && portParsed > 0 ? portParsed : 3000;
|
|
58
58
|
const author = getStringOption(options, 'author', '');
|
|
@@ -202,7 +202,7 @@ const addOptions = (command) => {
|
|
|
202
202
|
command.argument('<name>', 'Project name');
|
|
203
203
|
command.option('--template <type>', 'Project template (basic, api, microservice, fullstack)', 'basic');
|
|
204
204
|
command.option('--database <type>', 'Database driver (sqlite, mysql, postgresql)', 'sqlite');
|
|
205
|
-
command.option('--port <number>', 'Default port number', '
|
|
205
|
+
command.option('--port <number>', 'Default port number', '7777');
|
|
206
206
|
command.option('--author <name>', 'Project author');
|
|
207
207
|
command.option('--description <text>', 'Project description');
|
|
208
208
|
command.option('--interactive', 'Run in interactive mode', true);
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* Plugin Command
|
|
3
3
|
* Manage framework plugins (install, uninstall, list)
|
|
4
4
|
*/
|
|
5
|
-
import { BaseCommand } from '../BaseCommand';
|
|
6
|
-
import { Logger } from '../../config/logger';
|
|
7
|
-
import { PluginManager } from '../../runtime/PluginManager';
|
|
5
|
+
import { BaseCommand } from '../BaseCommand.js';
|
|
6
|
+
import { Logger } from '../../config/logger.js';
|
|
7
|
+
import { PluginManager } from '../../runtime/PluginManager.js';
|
|
8
8
|
export const PluginCommand = Object.freeze({
|
|
9
9
|
create() {
|
|
10
10
|
return BaseCommand.create({
|
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
* Makes the local dist/ folder installable via `file:/.../dist`.
|
|
4
4
|
* Usage: zintrust prepare
|
|
5
5
|
*/
|
|
6
|
-
import { DistPackager } from '../utils/DistPackager';
|
|
7
|
-
import { SpawnUtil } from '../utils/spawn';
|
|
8
|
-
import { resolveNpmPath } from '../../common/index';
|
|
9
|
-
import { Logger } from '../../config/logger';
|
|
10
|
-
import { ErrorFactory } from '../../exceptions/ZintrustError';
|
|
11
|
-
import * as path from '../../node-singletons/path';
|
|
6
|
+
import { DistPackager } from '../utils/DistPackager.js';
|
|
7
|
+
import { SpawnUtil } from '../utils/spawn.js';
|
|
8
|
+
import { resolveNpmPath } from '../../common/index.js';
|
|
9
|
+
import { Logger } from '../../config/logger.js';
|
|
10
|
+
import { ErrorFactory } from '../../exceptions/ZintrustError.js';
|
|
11
|
+
import * as path from '../../node-singletons/path.js';
|
|
12
12
|
import chalk from 'chalk';
|
|
13
13
|
import { Command } from 'commander';
|
|
14
14
|
export const PrepareCommand = {
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
* QA Command - Unified Quality Assurance
|
|
3
3
|
* Runs linting, type-checking, tests, and SonarQube
|
|
4
4
|
*/
|
|
5
|
-
import { BaseCommand } from '../BaseCommand';
|
|
6
|
-
import { extractErrorMessageStrict, resolveNpmPath } from '../../common/index';
|
|
7
|
-
import { Logger } from '../../config/logger';
|
|
8
|
-
import { ErrorFactory } from '../../exceptions/ZintrustError';
|
|
9
|
-
import { execFileSync } from '../../node-singletons/child-process';
|
|
10
|
-
import { existsSync } from '../../node-singletons/fs';
|
|
11
|
-
import { resolve } from '../../node-singletons/path';
|
|
5
|
+
import { BaseCommand } from '../BaseCommand.js';
|
|
6
|
+
import { extractErrorMessageStrict, resolveNpmPath } from '../../common/index.js';
|
|
7
|
+
import { Logger } from '../../config/logger.js';
|
|
8
|
+
import { ErrorFactory } from '../../exceptions/ZintrustError.js';
|
|
9
|
+
import { execFileSync } from '../../node-singletons/child-process.js';
|
|
10
|
+
import { existsSync } from '../../node-singletons/fs.js';
|
|
11
|
+
import { resolve } from '../../node-singletons/path.js';
|
|
12
12
|
const QA_REPORT_CSS = `
|
|
13
13
|
:root {
|
|
14
14
|
--qa-bg: #f8fafc;
|
|
@@ -414,7 +414,7 @@ const generateReport = async (results) => {
|
|
|
414
414
|
const reportPath = 'coverage/qa-report.html';
|
|
415
415
|
const reportCssPath = 'coverage/qa-report.css';
|
|
416
416
|
try {
|
|
417
|
-
const { fsPromises } = await import('../../node-singletons/fs');
|
|
417
|
+
const { fsPromises } = await import('../../node-singletons/fs.js');
|
|
418
418
|
await fsPromises.writeFile(reportPath, htmlContent);
|
|
419
419
|
await fsPromises.writeFile(reportCssPath, QA_REPORT_CSS);
|
|
420
420
|
Logger.info(`QA report generated: ${reportPath}`);
|
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
* zin secrets push --provider aws|cloudflare [--manifest secrets.manifest.json] [--in .env] [--dry-run]
|
|
9
9
|
* zin secrets doctor --provider aws|cloudflare
|
|
10
10
|
*/
|
|
11
|
-
import { BaseCommand } from '../BaseCommand';
|
|
12
|
-
import { ErrorFactory } from '../../exceptions/ZintrustError';
|
|
13
|
-
import { SecretsToolkit } from '../../toolkit/Secrets';
|
|
11
|
+
import { BaseCommand } from '../BaseCommand.js';
|
|
12
|
+
import { ErrorFactory } from '../../exceptions/ZintrustError.js';
|
|
13
|
+
import { SecretsToolkit } from '../../toolkit/Secrets/index.js';
|
|
14
14
|
const isUnknownArray = (value) => Array.isArray(value);
|
|
15
15
|
const getArg = (args, index) => {
|
|
16
16
|
if (!isUnknownArray(args))
|
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
* IMPORTANT: this uses the same ProjectScaffolder as `zin new`.
|
|
5
5
|
* Usage: zin -sim my-blog
|
|
6
6
|
*/
|
|
7
|
-
import { ProjectScaffolder } from '../scaffolding/ProjectScaffolder';
|
|
8
|
-
import { DistPackager } from '../utils/DistPackager';
|
|
9
|
-
import { Logger } from '../../config/logger';
|
|
10
|
-
import { ErrorFactory } from '../../exceptions/ZintrustError';
|
|
11
|
-
import fs from '../../node-singletons/fs';
|
|
12
|
-
import * as path from '../../node-singletons/path';
|
|
7
|
+
import { ProjectScaffolder } from '../scaffolding/ProjectScaffolder.js';
|
|
8
|
+
import { DistPackager } from '../utils/DistPackager.js';
|
|
9
|
+
import { Logger } from '../../config/logger.js';
|
|
10
|
+
import { ErrorFactory } from '../../exceptions/ZintrustError.js';
|
|
11
|
+
import fs from '../../node-singletons/fs.js';
|
|
12
|
+
import * as path from '../../node-singletons/path.js';
|
|
13
13
|
import chalk from 'chalk';
|
|
14
14
|
import { Command } from 'commander';
|
|
15
15
|
const rewriteSimulatedAppDependencyToDist = (appPath, distPath) => {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { BaseCommand } from '../BaseCommand';
|
|
2
|
-
import { EnvFileLoader } from '../utils/EnvFileLoader';
|
|
3
|
-
import { SpawnUtil } from '../utils/spawn';
|
|
4
|
-
import { resolveNpmPath } from '../../common/index';
|
|
5
|
-
import { ErrorFactory } from '../../exceptions/ZintrustError';
|
|
6
|
-
import { existsSync, readFileSync } from '../../node-singletons/fs';
|
|
7
|
-
import * as path from '../../node-singletons/path';
|
|
1
|
+
import { BaseCommand } from '../BaseCommand.js';
|
|
2
|
+
import { EnvFileLoader } from '../utils/EnvFileLoader.js';
|
|
3
|
+
import { SpawnUtil } from '../utils/spawn.js';
|
|
4
|
+
import { resolveNpmPath } from '../../common/index.js';
|
|
5
|
+
import { ErrorFactory } from '../../exceptions/ZintrustError.js';
|
|
6
|
+
import { existsSync, readFileSync } from '../../node-singletons/fs.js';
|
|
7
|
+
import * as path from '../../node-singletons/path.js';
|
|
8
8
|
const isValidModeInput = (value) => value === 'development' ||
|
|
9
9
|
value === 'dev' ||
|
|
10
10
|
value === 'production' ||
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { BaseCommand } from '../BaseCommand';
|
|
2
|
-
import { ErrorHandler } from '../ErrorHandler';
|
|
3
|
-
import { ErrorFactory } from '../../exceptions/ZintrustError';
|
|
4
|
-
import { listTemplates as listMail, renderTemplate as renderMail } from '../../tools/mail/templates/markdown';
|
|
5
|
-
import { listTemplates as listNotification, renderTemplate as renderNotification, } from '../../tools/notification/templates/markdown';
|
|
1
|
+
import { BaseCommand } from '../BaseCommand.js';
|
|
2
|
+
import { ErrorHandler } from '../ErrorHandler.js';
|
|
3
|
+
import { ErrorFactory } from '../../exceptions/ZintrustError.js';
|
|
4
|
+
import { listTemplates as listMail, renderTemplate as renderMail } from '../../tools/mail/templates/markdown/index.js';
|
|
5
|
+
import { listTemplates as listNotification, renderTemplate as renderNotification, } from '../../tools/notification/templates/markdown/index.js';
|
|
6
6
|
const listForScope = (scope) => {
|
|
7
7
|
let items = [];
|
|
8
8
|
if (scope === 'mail' || scope === 'all')
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* CLI Commands Module Index
|
|
3
3
|
*/
|
|
4
|
-
export { AddCommand } from '../commands/AddCommand';
|
|
5
|
-
export { ConfigCommand } from '../commands/ConfigCommand';
|
|
6
|
-
export { DebugCommand } from '../commands/DebugCommand';
|
|
7
|
-
export { LogsCleanupCommand } from '../commands/LogsCleanupCommand';
|
|
8
|
-
export { MakeMailTemplateCommand } from '../commands/MakeMailTemplateCommand';
|
|
9
|
-
export { MakeNotificationTemplateCommand } from '../commands/MakeNotificationTemplateCommand';
|
|
10
|
-
export { MigrateCommand } from '../commands/MigrateCommand';
|
|
11
|
-
export { NewCommand } from '../commands/NewCommand';
|
|
12
|
-
export { PrepareCommand } from '../commands/PrepareCommand';
|
|
13
|
-
export { SecretsCommand } from '../commands/SecretsCommand';
|
|
14
|
-
export { StartCommand } from '../commands/StartCommand';
|
|
15
|
-
export { TemplatesCommand } from '../commands/TemplatesCommand';
|
|
4
|
+
export { AddCommand } from '../commands/AddCommand.js';
|
|
5
|
+
export { ConfigCommand } from '../commands/ConfigCommand.js';
|
|
6
|
+
export { DebugCommand } from '../commands/DebugCommand.js';
|
|
7
|
+
export { LogsCleanupCommand } from '../commands/LogsCleanupCommand.js';
|
|
8
|
+
export { MakeMailTemplateCommand } from '../commands/MakeMailTemplateCommand.js';
|
|
9
|
+
export { MakeNotificationTemplateCommand } from '../commands/MakeNotificationTemplateCommand.js';
|
|
10
|
+
export { MigrateCommand } from '../commands/MigrateCommand.js';
|
|
11
|
+
export { NewCommand } from '../commands/NewCommand.js';
|
|
12
|
+
export { PrepareCommand } from '../commands/PrepareCommand.js';
|
|
13
|
+
export { SecretsCommand } from '../commands/SecretsCommand.js';
|
|
14
|
+
export { StartCommand } from '../commands/StartCommand.js';
|
|
15
|
+
export { TemplatesCommand } from '../commands/TemplatesCommand.js';
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
* Configuration Manager
|
|
3
3
|
* Handles reading, writing, and managing configuration files
|
|
4
4
|
*/
|
|
5
|
-
import { ConfigPaths, DEFAULT_CONFIG, getConfigValue, setConfigValue, } from '../config/ConfigSchema';
|
|
6
|
-
import { Logger } from '../../config/logger';
|
|
7
|
-
import { ErrorFactory } from '../../exceptions/ZintrustError';
|
|
8
|
-
import { fsPromises as fs } from '../../node-singletons/fs';
|
|
9
|
-
import * as path from '../../node-singletons/path';
|
|
5
|
+
import { ConfigPaths, DEFAULT_CONFIG, getConfigValue, setConfigValue, } from '../config/ConfigSchema.js';
|
|
6
|
+
import { Logger } from '../../config/logger.js';
|
|
7
|
+
import { ErrorFactory } from '../../exceptions/ZintrustError.js';
|
|
8
|
+
import { fsPromises as fs } from '../../node-singletons/fs.js';
|
|
9
|
+
import * as path from '../../node-singletons/path.js';
|
|
10
10
|
/**
|
|
11
11
|
* Deep merge helper
|
|
12
12
|
*/
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Configuration Validator
|
|
3
3
|
* Validates configuration against schema and rules
|
|
4
4
|
*/
|
|
5
|
-
import { CONFIG_RULES, getConfigValue, } from '../config/ConfigSchema';
|
|
5
|
+
import { CONFIG_RULES, getConfigValue, } from '../config/ConfigSchema.js';
|
|
6
6
|
/**
|
|
7
7
|
* Validate entire config against schema
|
|
8
8
|
*/
|
package/src/cli/config/index.js
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
* Configuration Module
|
|
3
3
|
* Exports config management classes
|
|
4
4
|
*/
|
|
5
|
-
export { ConfigManager } from '../config/ConfigManager';
|
|
6
|
-
export { CONFIG_RULES, ConfigPaths, DEFAULT_CONFIG, getConfigValue, getDefaultValue, setConfigValue, } from '../config/ConfigSchema';
|
|
7
|
-
export { ConfigValidator } from '../config/ConfigValidator';
|
|
5
|
+
export { ConfigManager } from '../config/ConfigManager.js';
|
|
6
|
+
export { CONFIG_RULES, ConfigPaths, DEFAULT_CONFIG, getConfigValue, getDefaultValue, setConfigValue, } from '../config/ConfigSchema.js';
|
|
7
|
+
export { ConfigValidator } from '../config/ConfigValidator.js';
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* Debug Dashboard
|
|
3
3
|
* Terminal-based real-time monitoring UI
|
|
4
4
|
*/
|
|
5
|
-
import { randomInt } from '../../node-singletons/crypto';
|
|
6
|
-
import * as os from '../../node-singletons/os';
|
|
7
|
-
import * as readline from '../../node-singletons/readline';
|
|
5
|
+
import { randomInt } from '../../node-singletons/crypto.js';
|
|
6
|
+
import * as os from '../../node-singletons/os.js';
|
|
7
|
+
import * as readline from '../../node-singletons/readline.js';
|
|
8
8
|
import chalk from 'chalk';
|
|
9
9
|
const formatBytes = (bytes) => {
|
|
10
10
|
const units = ['B', 'KB', 'MB', 'GB'];
|
package/src/cli/index.js
CHANGED
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
* CLI Module Index
|
|
3
3
|
* Exports all CLI components
|
|
4
4
|
*/
|
|
5
|
-
export { BaseCommand } from './BaseCommand';
|
|
6
|
-
export { CLI } from './CLI';
|
|
7
|
-
export { ErrorHandler, EXIT_CODES } from './ErrorHandler';
|
|
8
|
-
export { PromptHelper } from './PromptHelper';
|
|
5
|
+
export { BaseCommand } from './BaseCommand.js';
|
|
6
|
+
export { CLI } from './CLI.js';
|
|
7
|
+
export { ErrorHandler, EXIT_CODES } from './ErrorHandler.js';
|
|
8
|
+
export { PromptHelper } from './PromptHelper.js';
|
|
9
9
|
// Export commands
|
|
10
|
-
export { AddCommand } from './commands/AddCommand';
|
|
11
|
-
export { ConfigCommand } from './commands/ConfigCommand';
|
|
12
|
-
export { DebugCommand } from './commands/DebugCommand';
|
|
13
|
-
export { MigrateCommand } from './commands/MigrateCommand';
|
|
14
|
-
export { NewCommand } from './commands/NewCommand';
|
|
15
|
-
export { SecretsCommand } from './commands/SecretsCommand';
|
|
10
|
+
export { AddCommand } from './commands/AddCommand.js';
|
|
11
|
+
export { ConfigCommand } from './commands/ConfigCommand.js';
|
|
12
|
+
export { DebugCommand } from './commands/DebugCommand.js';
|
|
13
|
+
export { MigrateCommand } from './commands/MigrateCommand.js';
|
|
14
|
+
export { NewCommand } from './commands/NewCommand.js';
|
|
15
|
+
export { SecretsCommand } from './commands/SecretsCommand.js';
|
package/src/cli/logger/Logger.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Logger - File-Based Logging System
|
|
3
3
|
* Logs to files with rotation, retention policies, and multiple log levels
|
|
4
4
|
*/
|
|
5
|
-
import * as fs from '../../node-singletons/fs';
|
|
6
|
-
import * as path from '../../node-singletons/path';
|
|
5
|
+
import * as fs from '../../node-singletons/fs.js';
|
|
6
|
+
import * as path from '../../node-singletons/path.js';
|
|
7
7
|
const levelPriority = {
|
|
8
8
|
debug: 0,
|
|
9
9
|
info: 1,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ControllerGenerator.d.ts","sourceRoot":"","sources":["../../../../src/cli/scaffolding/ControllerGenerator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,UAAU,GAAG,KAAK,GAAG,SAAS,GAAG,WAAW,GAAG,SAAS,CAAC;AAE/F,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,MAAM,CAAC;IACvB,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED,MAAM,WAAW,yBAAyB;IACxC,OAAO,EAAE,OAAO,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;CACjB;AAcD;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,iBAAiB,GAAG;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,CAgChG;AAED;;GAEG;AAEH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,yBAAyB,CAAC,CA2CjG;
|
|
1
|
+
{"version":3,"file":"ControllerGenerator.d.ts","sourceRoot":"","sources":["../../../../src/cli/scaffolding/ControllerGenerator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,UAAU,GAAG,KAAK,GAAG,SAAS,GAAG,WAAW,GAAG,SAAS,CAAC;AAE/F,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,MAAM,CAAC;IACvB,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED,MAAM,WAAW,yBAAyB;IACxC,OAAO,EAAE,OAAO,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;CACjB;AAcD;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,iBAAiB,GAAG;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,CAgChG;AAED;;GAEG;AAEH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,yBAAyB,CAAC,CA2CjG;AA4bD;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,cAAc,EAAE,CAEpD;AAED;;GAEG;AACH,eAAO,MAAM,mBAAmB;;;;EAI9B,CAAC"}
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* ControllerGenerator - Generate controller files
|
|
3
3
|
* Creates CRUD controllers with validation and error handling
|
|
4
4
|
*/
|
|
5
|
-
import { FileGenerator } from '../scaffolding/FileGenerator';
|
|
6
|
-
import { Logger } from '../../config/logger';
|
|
7
|
-
import * as path from '../../node-singletons/path';
|
|
5
|
+
import { FileGenerator } from '../scaffolding/FileGenerator.js';
|
|
6
|
+
import { Logger } from '../../config/logger.js';
|
|
7
|
+
import * as path from '../../node-singletons/path.js';
|
|
8
8
|
/**
|
|
9
9
|
* ControllerGenerator creates HTTP request handlers
|
|
10
10
|
*/
|
|
@@ -117,11 +117,14 @@ function generateCrudController(options) {
|
|
|
117
117
|
* Auto-generated CRUD controller
|
|
118
118
|
*/
|
|
119
119
|
|
|
120
|
-
import { IRequest } from '
|
|
121
|
-
import { IResponse } from '../../http/Response';
|
|
122
|
-
import { Controller } from '../../http/Controller';
|
|
120
|
+
import { type IRequest, type IResponse, Controller } from '@zintrust/core';
|
|
123
121
|
import { ${modelName} } from '@app/Models/${modelName}';
|
|
124
122
|
|
|
123
|
+
function handleError(res: IResponse, error: unknown): void {
|
|
124
|
+
const message = error instanceof Error ? error.message : 'Internal server error';
|
|
125
|
+
res.setStatus(500).json({ error: message });
|
|
126
|
+
}
|
|
127
|
+
|
|
125
128
|
export const ${className} = Object.freeze({
|
|
126
129
|
...Controller,
|
|
127
130
|
${buildIndexMethod(modelName)},
|
|
@@ -133,8 +136,6 @@ ${buildStoreMethod(modelName)},
|
|
|
133
136
|
${buildUpdateMethod(modelName)},
|
|
134
137
|
|
|
135
138
|
${buildDestroyMethod(modelName)},
|
|
136
|
-
|
|
137
|
-
${buildHandleErrorMethod()},
|
|
138
139
|
});
|
|
139
140
|
`;
|
|
140
141
|
}
|
|
@@ -259,18 +260,6 @@ function buildDestroyMethod(modelName) {
|
|
|
259
260
|
}
|
|
260
261
|
}`;
|
|
261
262
|
}
|
|
262
|
-
/**
|
|
263
|
-
* Build handle error method
|
|
264
|
-
*/
|
|
265
|
-
function buildHandleErrorMethod() {
|
|
266
|
-
return ` /**
|
|
267
|
-
* Handle controller errors
|
|
268
|
-
*/
|
|
269
|
-
handleError(res: IResponse, error: unknown): void {
|
|
270
|
-
const message = error instanceof Error ? error.message : 'Internal server error';
|
|
271
|
-
res.setStatus(500).json({ error: message });
|
|
272
|
-
}`;
|
|
273
|
-
}
|
|
274
263
|
/**
|
|
275
264
|
* Generate Resource controller (alias for CRUD)
|
|
276
265
|
*/
|
|
@@ -287,29 +276,31 @@ function generateApiController(options) {
|
|
|
287
276
|
* Auto-generated API controller
|
|
288
277
|
*/
|
|
289
278
|
|
|
290
|
-
import { IRequest } from '
|
|
291
|
-
|
|
292
|
-
|
|
279
|
+
import { type IRequest, type IResponse, Controller } from '@zintrust/core';
|
|
280
|
+
|
|
281
|
+
function handleError(res: IResponse, error: unknown): void {
|
|
282
|
+
const message = error instanceof Error ? error.message : 'Internal server error';
|
|
283
|
+
res.setStatus(500).json({ error: message });
|
|
284
|
+
}
|
|
293
285
|
|
|
294
286
|
export const ${className} = {\n ...Controller,
|
|
295
|
-
${buildApiControllerBody()},
|
|
287
|
+
${buildApiControllerBody(className)},
|
|
296
288
|
};
|
|
297
289
|
`;
|
|
298
290
|
}
|
|
299
291
|
/**
|
|
300
292
|
* Build API controller body
|
|
301
293
|
*/
|
|
302
|
-
function buildApiControllerBody() {
|
|
303
|
-
return `${buildApiMainHandler()},
|
|
294
|
+
function buildApiControllerBody(className) {
|
|
295
|
+
return `${buildApiMainHandler(className)},
|
|
304
296
|
|
|
305
297
|
${buildApiMethodHandlers()},
|
|
306
|
-
|
|
307
|
-
${buildHandleErrorMethod()}`;
|
|
298
|
+
`;
|
|
308
299
|
}
|
|
309
300
|
/**
|
|
310
301
|
* Build API main handler
|
|
311
302
|
*/
|
|
312
|
-
function buildApiMainHandler() {
|
|
303
|
+
function buildApiMainHandler(className) {
|
|
313
304
|
return ` /**
|
|
314
305
|
* API endpoint template
|
|
315
306
|
*/
|
|
@@ -319,13 +310,13 @@ function buildApiMainHandler() {
|
|
|
319
310
|
|
|
320
311
|
// Route to appropriate handler
|
|
321
312
|
if (method === 'GET') {
|
|
322
|
-
await handleGet(req, res);
|
|
313
|
+
await ${className}.handleGet(req, res);
|
|
323
314
|
} else if (method === 'POST') {
|
|
324
|
-
await handlePost(req, res);
|
|
315
|
+
await ${className}.handlePost(req, res);
|
|
325
316
|
} else if (method === 'PUT') {
|
|
326
|
-
await handlePut(req, res);
|
|
317
|
+
await ${className}.handlePut(req, res);
|
|
327
318
|
} else if (method === 'DELETE') {
|
|
328
|
-
await handleDelete(req, res);
|
|
319
|
+
await ${className}.handleDelete(req, res);
|
|
329
320
|
} else {
|
|
330
321
|
res.setStatus(405).json({ error: 'Method not allowed' });
|
|
331
322
|
}
|
|
@@ -376,9 +367,12 @@ function generateGraphQLController(options) {
|
|
|
376
367
|
* Auto-generated GraphQL controller
|
|
377
368
|
*/
|
|
378
369
|
|
|
379
|
-
import { IRequest } from '
|
|
380
|
-
|
|
381
|
-
|
|
370
|
+
import { type IRequest, type IResponse, Controller } from '@zintrust/core';
|
|
371
|
+
|
|
372
|
+
function handleError(res: IResponse, error: unknown): void {
|
|
373
|
+
const message = error instanceof Error ? error.message : 'GraphQL error';
|
|
374
|
+
res.setStatus(500).json({ errors: [{ message }] });
|
|
375
|
+
}
|
|
382
376
|
|
|
383
377
|
export const ${className} = {\n ...Controller,
|
|
384
378
|
/**
|
|
@@ -387,14 +381,15 @@ export const ${className} = {\n ...Controller,
|
|
|
387
381
|
async handle(req: IRequest, res: IResponse): Promise<void> {
|
|
388
382
|
try {
|
|
389
383
|
if (req.getMethod() !== 'POST') {
|
|
390
|
-
|
|
384
|
+
res.setStatus(405).json({ error: 'Method not allowed' });
|
|
385
|
+
return;
|
|
391
386
|
}
|
|
392
387
|
|
|
393
388
|
const body = req.getBody() as Record<string, unknown>;
|
|
394
389
|
const query = body.query as string;
|
|
395
390
|
|
|
396
391
|
// TODO: Execute GraphQL query
|
|
397
|
-
const result = await executeQuery(query);
|
|
392
|
+
const result = await ${className}.executeQuery(query);
|
|
398
393
|
|
|
399
394
|
res.json(result);
|
|
400
395
|
} catch (error) {
|
|
@@ -409,14 +404,6 @@ export const ${className} = {\n ...Controller,
|
|
|
409
404
|
// TODO: Implement GraphQL execution
|
|
410
405
|
return { data: null };
|
|
411
406
|
},
|
|
412
|
-
|
|
413
|
-
/**
|
|
414
|
-
* Handle controller errors
|
|
415
|
-
*/
|
|
416
|
-
handleError(res: IResponse, error: unknown): void {
|
|
417
|
-
const message = error instanceof Error ? error.message : 'GraphQL error';
|
|
418
|
-
res.setStatus(500).json({ errors: [{ message }] });
|
|
419
|
-
},
|
|
420
407
|
};
|
|
421
408
|
`;
|
|
422
409
|
}
|
|
@@ -430,7 +417,7 @@ function generateWebSocketController(options) {
|
|
|
430
417
|
* Auto-generated WebSocket controller
|
|
431
418
|
*/
|
|
432
419
|
|
|
433
|
-
import { Logger } from '../../config/logger';
|
|
420
|
+
import { Logger } from '../../config/logger.js';
|
|
434
421
|
|
|
435
422
|
export const ${className} = {
|
|
436
423
|
/**
|
|
@@ -467,20 +454,23 @@ function generateWebhookController(options) {
|
|
|
467
454
|
* Auto-generated Webhook controller
|
|
468
455
|
*/
|
|
469
456
|
|
|
470
|
-
import { IRequest } from '
|
|
471
|
-
import {
|
|
472
|
-
|
|
473
|
-
|
|
457
|
+
import { type IRequest, type IResponse, Controller } from '@zintrust/core';
|
|
458
|
+
import { Logger } from '../../config/logger.js';
|
|
459
|
+
|
|
460
|
+
function handleError(res: IResponse, error: unknown): void {
|
|
461
|
+
const message = error instanceof Error ? error.message : 'Webhook error';
|
|
462
|
+
res.setStatus(500).json({ error: message });
|
|
463
|
+
}
|
|
474
464
|
|
|
475
465
|
export const ${className} = {\n ...Controller,
|
|
476
|
-
${buildWebhookControllerBody()},
|
|
466
|
+
${buildWebhookControllerBody(className)},
|
|
477
467
|
};
|
|
478
468
|
`;
|
|
479
469
|
}
|
|
480
470
|
/**
|
|
481
471
|
* Build Webhook controller body
|
|
482
472
|
*/
|
|
483
|
-
function buildWebhookControllerBody() {
|
|
473
|
+
function buildWebhookControllerBody(className) {
|
|
484
474
|
return ` /**
|
|
485
475
|
* Handle incoming webhook
|
|
486
476
|
*/
|
|
@@ -488,12 +478,13 @@ function buildWebhookControllerBody() {
|
|
|
488
478
|
try {
|
|
489
479
|
// Verify webhook signature
|
|
490
480
|
const signature = req.getHeader('x-webhook-signature');
|
|
491
|
-
if (verifySignature(req, signature as string) === false) {
|
|
492
|
-
|
|
481
|
+
if (${className}.verifySignature(req, signature as string) === false) {
|
|
482
|
+
res.setStatus(401).json({ error: 'Invalid signature' });
|
|
483
|
+
return;
|
|
493
484
|
}
|
|
494
485
|
|
|
495
486
|
const body = req.getBody();
|
|
496
|
-
await processWebhook(body);
|
|
487
|
+
await ${className}.processWebhook(body);
|
|
497
488
|
|
|
498
489
|
res.json({ success: true });
|
|
499
490
|
} catch (error) {
|
|
@@ -516,14 +507,7 @@ function buildWebhookControllerBody() {
|
|
|
516
507
|
// TODO: Implement webhook processing
|
|
517
508
|
Logger.info('Processing webhook:', { payload });
|
|
518
509
|
},
|
|
519
|
-
|
|
520
|
-
/**
|
|
521
|
-
* Handle controller errors
|
|
522
|
-
*/
|
|
523
|
-
handleError(res: IResponse, error: unknown): void {
|
|
524
|
-
const message = error instanceof Error ? error.message : 'Webhook error';
|
|
525
|
-
res.setStatus(500).json({ error: message });
|
|
526
|
-
}`;
|
|
510
|
+
`;
|
|
527
511
|
}
|
|
528
512
|
/**
|
|
529
513
|
* Get available controller types
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
* Factory Generator
|
|
3
3
|
* Generates test data factory modules for models
|
|
4
4
|
*/
|
|
5
|
-
import { FileGenerator } from '../scaffolding/FileGenerator';
|
|
6
|
-
import { CommonUtils } from '../../common/index';
|
|
7
|
-
import { Logger } from '../../config/logger';
|
|
8
|
-
import { ErrorFactory } from '../../exceptions/ZintrustError';
|
|
9
|
-
import { fsPromises as fs } from '../../node-singletons/fs';
|
|
10
|
-
import * as path from '../../node-singletons/path';
|
|
5
|
+
import { FileGenerator } from '../scaffolding/FileGenerator.js';
|
|
6
|
+
import { CommonUtils } from '../../common/index.js';
|
|
7
|
+
import { Logger } from '../../config/logger.js';
|
|
8
|
+
import { ErrorFactory } from '../../exceptions/ZintrustError.js';
|
|
9
|
+
import { fsPromises as fs } from '../../node-singletons/fs.js';
|
|
10
|
+
import * as path from '../../node-singletons/path.js';
|
|
11
11
|
/**
|
|
12
12
|
* Factory Generator - Generates test data factories
|
|
13
13
|
*/
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* FeatureScaffolder - Generate features within a service
|
|
3
3
|
* Features like authentication, payments, logging, API docs, etc.
|
|
4
4
|
*/
|
|
5
|
-
import { FileGenerator } from '../scaffolding/FileGenerator';
|
|
6
|
-
import { Logger } from '../../config/logger';
|
|
7
|
-
import * as path from '../../node-singletons/path';
|
|
5
|
+
import { FileGenerator } from '../scaffolding/FileGenerator.js';
|
|
6
|
+
import { Logger } from '../../config/logger.js';
|
|
7
|
+
import * as path from '../../node-singletons/path.js';
|
|
8
8
|
/**
|
|
9
9
|
* FeatureScaffolder adds features to services
|
|
10
10
|
*/
|
|
@@ -208,7 +208,7 @@ const PAYMENTS_TEMPLATE = `/**
|
|
|
208
208
|
* Handles payment processing and transactions
|
|
209
209
|
*/
|
|
210
210
|
|
|
211
|
-
import { randomBytes } from '../../node-singletons/crypto';
|
|
211
|
+
import { randomBytes } from '../../node-singletons/crypto.js';
|
|
212
212
|
|
|
213
213
|
export interface PaymentConfig {
|
|
214
214
|
provider: 'stripe' | 'paypal' | 'square';
|
|
@@ -266,7 +266,7 @@ const LOGGING_TEMPLATE = `/**
|
|
|
266
266
|
* Structured logging with multiple transports
|
|
267
267
|
*/
|
|
268
268
|
|
|
269
|
-
import { Logger } from '../../config/logger';
|
|
269
|
+
import { Logger } from '../../config/logger.js';
|
|
270
270
|
|
|
271
271
|
export type LogLevel = 'debug' | 'info' | 'warn' | 'error';
|
|
272
272
|
|
|
@@ -429,7 +429,7 @@ const EMAIL_TEMPLATE = `/**
|
|
|
429
429
|
* Handles email sending
|
|
430
430
|
*/
|
|
431
431
|
|
|
432
|
-
import { randomBytes } from '../../node-singletons/crypto';
|
|
432
|
+
import { randomBytes } from '../../node-singletons/crypto.js';
|
|
433
433
|
|
|
434
434
|
export interface EmailConfig {
|
|
435
435
|
provider: 'sendgrid' | 'mailgun' | 'nodemailer';
|
|
@@ -547,7 +547,7 @@ const QUEUE_TEMPLATE = `/**
|
|
|
547
547
|
* Job queue processing
|
|
548
548
|
*/
|
|
549
549
|
|
|
550
|
-
import { randomBytes } from '../../node-singletons/crypto';
|
|
550
|
+
import { randomBytes } from '../../node-singletons/crypto.js';
|
|
551
551
|
|
|
552
552
|
export interface Job {
|
|
553
553
|
id: string;
|
|
@@ -720,7 +720,7 @@ This feature provides \${name} functionality for the service.
|
|
|
720
720
|
## Usage
|
|
721
721
|
|
|
722
722
|
\`\`\`typescript
|
|
723
|
-
import \${name}Service from './index';
|
|
723
|
+
import \${name}Service from './index.js';
|
|
724
724
|
|
|
725
725
|
const service = \${name}Service.create(config);
|
|
726
726
|
// Use service...
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
* Handles creation of files and directories
|
|
4
4
|
* Sealed namespace with file I/O operations
|
|
5
5
|
*/
|
|
6
|
-
import { Logger } from '../../config/logger';
|
|
7
|
-
import { ErrorFactory } from '../../exceptions/ZintrustError';
|
|
8
|
-
import fs from '../../node-singletons/fs';
|
|
9
|
-
import * as path from '../../node-singletons/path';
|
|
6
|
+
import { Logger } from '../../config/logger.js';
|
|
7
|
+
import { ErrorFactory } from '../../exceptions/ZintrustError.js';
|
|
8
|
+
import fs from '../../node-singletons/fs.js';
|
|
9
|
+
import * as path from '../../node-singletons/path.js';
|
|
10
10
|
/**
|
|
11
11
|
* Create a directory recursively
|
|
12
12
|
*/
|