@zintrust/core 0.1.5 → 0.1.7
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
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// TEMPLATE_START
|
|
2
1
|
/* eslint-disable @typescript-eslint/require-await */
|
|
3
2
|
/**
|
|
4
3
|
* SQLite Database Adapter
|
|
@@ -191,4 +190,3 @@ function createSQLiteAdapter(config: DatabaseConfig): IDatabaseAdapter {
|
|
|
191
190
|
export const SQLiteAdapter = Object.freeze({
|
|
192
191
|
create: createSQLiteAdapter,
|
|
193
192
|
});
|
|
194
|
-
// TEMPLATE_END
|
|
@@ -8,10 +8,18 @@
|
|
|
8
8
|
# Environment: development | staging | production
|
|
9
9
|
NODE_ENV=development
|
|
10
10
|
|
|
11
|
+
# Application Name
|
|
12
|
+
APP_NAME=Zintrust App
|
|
13
|
+
|
|
11
14
|
# Server Configuration
|
|
12
15
|
HOST=
|
|
13
16
|
PORT=
|
|
14
17
|
|
|
18
|
+
# Application Encryption Key (base64 required for production)
|
|
19
|
+
# Generate with: node -e "console.log(require('crypto').randomBytes(32).toString('base64'))"
|
|
20
|
+
# Used for: encryption, CSRF tokens, session tokens, API keys
|
|
21
|
+
APP_KEY=
|
|
22
|
+
|
|
15
23
|
# ============================================================================
|
|
16
24
|
# DATABASE
|
|
17
25
|
# ============================================================================
|
|
@@ -156,4 +164,3 @@ DB_SYNCHRONIZE=
|
|
|
156
164
|
|
|
157
165
|
# Database Logging
|
|
158
166
|
DB_LOGGING=
|
|
159
|
-
|
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { User } from '@app/Models/User';
|
|
7
|
-
import { Logger } from '@
|
|
8
|
-
import {
|
|
7
|
+
import { Logger } from '@zintrust/core';
|
|
8
|
+
import { IRequest } from '@zintrust/core';
|
|
9
|
+
import { IResponse } from '@zintrust/core';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* User Controller Interface
|
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
* Enables request profiling when ENABLE_PROFILER environment variable is set
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import { Logger } from '@
|
|
8
|
-
import {
|
|
7
|
+
import { Logger } from '@zintrust/core';
|
|
8
|
+
import { Middleware } from '@zintrust/core';
|
|
9
|
+
import { RequestProfiler } from '@zintrust/core';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* ProfilerMiddleware wraps request execution with performance profiling
|
|
@@ -1,22 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
type ICsrfTokenManager,
|
|
4
|
-
type IJwtManager,
|
|
5
|
-
type JwtAlgorithm,
|
|
6
|
-
type JwtManagerType,
|
|
7
|
-
type IRequest,
|
|
8
|
-
type IResponse,
|
|
9
|
-
XssProtection,
|
|
10
|
-
type ISchema,
|
|
11
|
-
type SchemaType,
|
|
12
|
-
Validator,
|
|
13
|
-
} from '@zintrust/core';
|
|
1
|
+
import type { CsrfTokenManagerType, ICsrfTokenManager } from '@zintrust/core';
|
|
2
|
+
import type { IJwtManager, JwtAlgorithm, JwtManagerType } from '@zintrust/core';
|
|
14
3
|
/**
|
|
15
4
|
* Example Middleware
|
|
16
5
|
* Common middleware patterns for Zintrust
|
|
17
6
|
*/
|
|
18
7
|
|
|
19
|
-
import { Logger } from '@
|
|
8
|
+
import { Logger } from '@zintrust/core';
|
|
9
|
+
import { IRequest } from '@zintrust/core';
|
|
10
|
+
import { IResponse } from '@zintrust/core';
|
|
11
|
+
import { XssProtection } from '@zintrust/core';
|
|
12
|
+
import type { ISchema, SchemaType } from '@zintrust/core';
|
|
13
|
+
import { Validator } from '@zintrust/core';
|
|
20
14
|
|
|
21
15
|
type JwtManagerInput = IJwtManager | JwtManagerType;
|
|
22
16
|
type CsrfManagerInput = ICsrfTokenManager | CsrfTokenManagerType;
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
* Example Post Model
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
+
import { IRelationship } from '@zintrust/core';
|
|
5
6
|
import { User } from '@app/Models/User';
|
|
6
|
-
import {
|
|
7
|
+
import { IModel, Model, ModelConfig } from '@zintrust/core';
|
|
7
8
|
|
|
8
9
|
export const PostConfig: ModelConfig = {
|
|
9
10
|
table: 'posts',
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* FileLogWriter (Node.js only)
|
|
3
|
-
*
|
|
4
|
-
* Provides best-effort file logging with daily + size-based rotation.
|
|
5
|
-
* This module imports Node built-ins and should be loaded only in Node environments.
|
|
3
|
+
* Re-exports core FileLogWriter for optional use
|
|
6
4
|
*/
|
|
7
5
|
|
|
8
6
|
import { ensureDirSafe } from '@zintrust/core';
|
|
9
|
-
import { Env } from '@
|
|
7
|
+
import { Env } from '@zintrust/core';
|
|
10
8
|
import * as fs from '@node-singletons/fs';
|
|
11
9
|
import * as path from '@node-singletons/path';
|
|
12
10
|
|
|
@@ -5,39 +5,16 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { Logger } from '@config/logger';
|
|
8
|
+
import type {
|
|
9
|
+
GetSecretOptions,
|
|
10
|
+
SecretConfig,
|
|
11
|
+
SecretsManagerInstance,
|
|
12
|
+
SetSecretOptions,
|
|
13
|
+
} from '@config/type';
|
|
8
14
|
import { ErrorFactory } from '@zintrust/core';
|
|
9
15
|
|
|
10
|
-
export interface CloudflareKV {
|
|
11
|
-
get(key: string): Promise<string | null>;
|
|
12
|
-
put(key: string, value: string, options?: { expirationTtl?: number }): Promise<void>;
|
|
13
|
-
delete(key: string): Promise<void>;
|
|
14
|
-
list(options?: { prefix?: string }): Promise<{ keys: { name: string }[] }>;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface SecretConfig {
|
|
18
|
-
platform: 'aws' | 'cloudflare' | 'deno' | 'local';
|
|
19
|
-
region?: string;
|
|
20
|
-
kv?: CloudflareKV; // Cloudflare KV namespace
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export interface SecretValue {
|
|
24
|
-
key: string;
|
|
25
|
-
value: string;
|
|
26
|
-
expiresAt?: number;
|
|
27
|
-
rotationEnabled?: boolean;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
16
|
let instance: SecretsManagerInstance | undefined;
|
|
31
17
|
|
|
32
|
-
interface SecretsManagerInstance {
|
|
33
|
-
getSecret(key: string, options?: GetSecretOptions): Promise<string>;
|
|
34
|
-
setSecret(key: string, value: string, options?: SetSecretOptions): Promise<void>;
|
|
35
|
-
deleteSecret(key: string): Promise<void>;
|
|
36
|
-
rotateSecret(key: string): Promise<void>;
|
|
37
|
-
listSecrets(pattern?: string): Promise<string[]>;
|
|
38
|
-
clearCache(key?: string): void;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
18
|
function pruneCache(
|
|
42
19
|
cache: Map<string, { value: string; expiresAt: number }>,
|
|
43
20
|
maxEntries: number
|
|
@@ -433,16 +410,6 @@ export const SECRETS = Object.freeze({
|
|
|
433
410
|
CSRF_SECRET: 'csrf/secret',
|
|
434
411
|
} as const);
|
|
435
412
|
|
|
436
|
-
export interface GetSecretOptions {
|
|
437
|
-
cacheTtl?: number; // Cache time-to-live in milliseconds
|
|
438
|
-
throwIfMissing?: boolean;
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
export interface SetSecretOptions {
|
|
442
|
-
expirationTtl?: number; // Expiration time-to-live in seconds
|
|
443
|
-
metadata?: Record<string, unknown>;
|
|
444
|
-
}
|
|
445
|
-
|
|
446
413
|
/**
|
|
447
414
|
* Helper to get database credentials using secrets manager
|
|
448
415
|
*/
|
|
@@ -1,17 +1,7 @@
|
|
|
1
1
|
import { appConfig } from '@config/app';
|
|
2
|
+
import type { StartupConfigValidationError, StartupConfigValidationResult } from '@config/type';
|
|
2
3
|
import { ErrorFactory } from '@zintrust/core';
|
|
3
4
|
|
|
4
|
-
export type StartupConfigValidationError = {
|
|
5
|
-
key: string;
|
|
6
|
-
value: unknown;
|
|
7
|
-
message: string;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export type StartupConfigValidationResult = {
|
|
11
|
-
valid: boolean;
|
|
12
|
-
errors: StartupConfigValidationError[];
|
|
13
|
-
};
|
|
14
|
-
|
|
15
5
|
const isSensitiveKey = (key: string): boolean => {
|
|
16
6
|
const normalized = key.toLowerCase();
|
|
17
7
|
return (
|
|
@@ -93,47 +83,174 @@ const getEnvString = (key: string, defaultValue: string): string => {
|
|
|
93
83
|
return env[key] ?? defaultValue;
|
|
94
84
|
};
|
|
95
85
|
|
|
86
|
+
const getEnvOptionalString = (key: string): string | undefined => {
|
|
87
|
+
const proc = getProcessLike();
|
|
88
|
+
const env = proc?.env ?? {};
|
|
89
|
+
const value = env[key];
|
|
90
|
+
if (typeof value !== 'string') return undefined;
|
|
91
|
+
const trimmed = value.trim();
|
|
92
|
+
return trimmed === '' ? undefined : trimmed;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const getEnvBoolLoose = (key: string, defaultValue: boolean): boolean => {
|
|
96
|
+
const raw = getEnvOptionalString(key);
|
|
97
|
+
if (raw === undefined) return defaultValue;
|
|
98
|
+
const normalized = raw.toLowerCase();
|
|
99
|
+
return normalized === 'true' || normalized === '1' || normalized === 'yes' || normalized === 'on';
|
|
100
|
+
};
|
|
101
|
+
|
|
96
102
|
const getEnvInt = (key: string, defaultValue: number): number => {
|
|
97
103
|
const raw = getEnvString(key, String(defaultValue));
|
|
98
104
|
return Number.parseInt(raw, 10);
|
|
99
105
|
};
|
|
100
106
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
107
|
+
type RequireEnvStringOptions = {
|
|
108
|
+
aliases?: readonly string[];
|
|
109
|
+
requiredMessage?: string;
|
|
110
|
+
minLength?: number;
|
|
111
|
+
minLengthMessage?: string;
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
const requireEnvString = (
|
|
115
|
+
errors: StartupConfigValidationError[],
|
|
116
|
+
key: string,
|
|
117
|
+
options: RequireEnvStringOptions = {}
|
|
118
|
+
): string | undefined => {
|
|
119
|
+
const value =
|
|
120
|
+
getEnvOptionalString(key) ??
|
|
121
|
+
(options.aliases ?? []).reduce<string | undefined>((found, alias) => {
|
|
122
|
+
if (found !== undefined) return found;
|
|
123
|
+
return getEnvOptionalString(alias);
|
|
124
|
+
}, undefined);
|
|
125
|
+
|
|
126
|
+
if (value === undefined) {
|
|
127
|
+
pushError(errors, key, value, options.requiredMessage ?? `${key} is required`);
|
|
128
|
+
return undefined;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (options.minLength !== undefined && value.length < options.minLength) {
|
|
132
|
+
pushError(
|
|
133
|
+
errors,
|
|
134
|
+
key,
|
|
135
|
+
value,
|
|
136
|
+
options.minLengthMessage ?? `${key} must be at least ${options.minLength} characters`
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
return value;
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
const validateSqliteDbFileRequired = (
|
|
144
|
+
errors: StartupConfigValidationError[],
|
|
145
|
+
dbConnection: string | undefined
|
|
146
|
+
): void => {
|
|
147
|
+
// sqlite convenience: accept DB_DATABASE or DB_PATH
|
|
148
|
+
if ((dbConnection ?? '').toLowerCase() !== 'sqlite') return;
|
|
149
|
+
|
|
150
|
+
const dbFile = getEnvOptionalString('DB_DATABASE') ?? getEnvOptionalString('DB_PATH');
|
|
151
|
+
if (dbFile === undefined) {
|
|
152
|
+
pushError(errors, 'DB_DATABASE', dbFile, 'DB_DATABASE (or DB_PATH) is required for sqlite');
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
const validateStrictRequiredEnv = (errors: StartupConfigValidationError[]): void => {
|
|
157
|
+
const requireEnv = getEnvBoolLoose('STARTUP_REQUIRE_ENV', false);
|
|
158
|
+
if (!requireEnv) return;
|
|
159
|
+
|
|
160
|
+
requireEnvString(errors, 'NODE_ENV');
|
|
161
|
+
requireEnvString(errors, 'APP_NAME');
|
|
162
|
+
requireEnvString(errors, 'HOST');
|
|
163
|
+
|
|
164
|
+
const portRaw = requireEnvString(errors, 'PORT', {
|
|
165
|
+
aliases: ['APP_PORT'],
|
|
166
|
+
requiredMessage: 'PORT (or APP_PORT) is required',
|
|
167
|
+
});
|
|
168
|
+
if (portRaw !== undefined) {
|
|
169
|
+
const port = Number.parseInt(portRaw, 10);
|
|
170
|
+
validateIntRange(errors, 'PORT', port, 1, 65535);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
const dbConnection = requireEnvString(errors, 'DB_CONNECTION');
|
|
174
|
+
|
|
175
|
+
requireEnvString(errors, 'APP_KEY', { minLength: 16 });
|
|
176
|
+
requireEnvString(errors, 'LOG_LEVEL');
|
|
177
|
+
requireEnvString(errors, 'LOG_CHANNEL');
|
|
104
178
|
|
|
105
|
-
|
|
106
|
-
|
|
179
|
+
validateSqliteDbFileRequired(errors, dbConnection);
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
const validateNodeEnv = (errors: StartupConfigValidationError[]): void => {
|
|
183
|
+
const nodeEnv = getEnvString('NODE_ENV', 'development');
|
|
184
|
+
validateEnum(errors, 'NODE_ENV', nodeEnv, ['development', 'production', 'testing', 'test']);
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
const validatePort = (errors: StartupConfigValidationError[]): void => {
|
|
188
|
+
// Port can be provided as PORT or APP_PORT. In non-strict mode we keep defaults.
|
|
189
|
+
const portFromPort = getEnvOptionalString('PORT');
|
|
190
|
+
const portFromAppPort = getEnvOptionalString('APP_PORT');
|
|
191
|
+
const portRaw = portFromPort ?? portFromAppPort;
|
|
107
192
|
|
|
193
|
+
if (portRaw === undefined) {
|
|
108
194
|
const appPort = getEnvInt('APP_PORT', 3000);
|
|
109
195
|
validateIntRange(errors, 'APP_PORT', appPort, 1, 65535);
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
const parsed = Number.parseInt(portRaw, 10);
|
|
200
|
+
const key = portFromPort === undefined ? 'APP_PORT' : 'PORT';
|
|
201
|
+
validateIntRange(errors, key, parsed, 1, 65535);
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
const validateLogging = (errors: StartupConfigValidationError[]): void => {
|
|
205
|
+
const logFormat = getEnvString('LOG_FORMAT', 'text');
|
|
206
|
+
validateEnum(errors, 'LOG_FORMAT', logFormat, ['text', 'json']);
|
|
207
|
+
|
|
208
|
+
const logLevel = getEnvString('LOG_LEVEL', 'debug');
|
|
209
|
+
validateEnum(errors, 'LOG_LEVEL', logLevel, ['debug', 'info', 'warn', 'error']);
|
|
210
|
+
|
|
211
|
+
// Optional (but validated when provided): LOG_CHANNEL (starter apps often use this)
|
|
212
|
+
const logChannel = getEnvOptionalString('LOG_CHANNEL');
|
|
213
|
+
if (logChannel !== undefined) {
|
|
214
|
+
validateEnum(errors, 'LOG_CHANNEL', logChannel, ['console', 'file', 'all']);
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
const validateRotationAndTimeout = (errors: StartupConfigValidationError[]): void => {
|
|
219
|
+
const logRotationSize = getEnvInt('LOG_ROTATION_SIZE', 10485760);
|
|
220
|
+
validatePositiveInt(errors, 'LOG_ROTATION_SIZE', logRotationSize);
|
|
110
221
|
|
|
111
|
-
|
|
112
|
-
|
|
222
|
+
const logRotationDays = getEnvInt('LOG_ROTATION_DAYS', 7);
|
|
223
|
+
validatePositiveInt(errors, 'LOG_ROTATION_DAYS', logRotationDays);
|
|
113
224
|
|
|
114
|
-
|
|
115
|
-
|
|
225
|
+
const startupHealthTimeoutMs = getEnvInt('STARTUP_HEALTH_TIMEOUT_MS', 2500);
|
|
226
|
+
validatePositiveInt(errors, 'STARTUP_HEALTH_TIMEOUT_MS', startupHealthTimeoutMs);
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
const validateProductionAppKey = (errors: StartupConfigValidationError[]): void => {
|
|
230
|
+
if (!appConfig.isProduction()) return;
|
|
116
231
|
|
|
117
|
-
|
|
118
|
-
|
|
232
|
+
const appKey = getEnvString('APP_KEY', '');
|
|
233
|
+
if (appKey.trim().length < 16) {
|
|
234
|
+
pushError(
|
|
235
|
+
errors,
|
|
236
|
+
'APP_KEY',
|
|
237
|
+
appKey,
|
|
238
|
+
'APP_KEY must be set and at least 16 characters in production'
|
|
239
|
+
);
|
|
240
|
+
}
|
|
241
|
+
};
|
|
119
242
|
|
|
120
|
-
|
|
121
|
-
|
|
243
|
+
export const StartupConfigValidator = Object.freeze({
|
|
244
|
+
validate(): StartupConfigValidationResult {
|
|
245
|
+
const errors: StartupConfigValidationError[] = [];
|
|
122
246
|
|
|
123
|
-
|
|
124
|
-
validatePositiveInt(errors, 'STARTUP_HEALTH_TIMEOUT_MS', startupHealthTimeoutMs);
|
|
247
|
+
validateStrictRequiredEnv(errors);
|
|
125
248
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
'APP_KEY',
|
|
132
|
-
appKey,
|
|
133
|
-
'APP_KEY must be set and at least 16 characters in production'
|
|
134
|
-
);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
249
|
+
validateNodeEnv(errors);
|
|
250
|
+
validatePort(errors);
|
|
251
|
+
validateLogging(errors);
|
|
252
|
+
validateRotationAndTimeout(errors);
|
|
253
|
+
validateProductionAppKey(errors);
|
|
137
254
|
|
|
138
255
|
return { valid: errors.length === 0, errors };
|
|
139
256
|
},
|
|
@@ -5,11 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { Env } from '@config/env';
|
|
8
|
-
|
|
9
|
-
type ProcessLike = { env?: Record<string, string | undefined> };
|
|
10
|
-
|
|
11
|
-
type Environment = 'development' | 'dev' | 'production' | 'prod' | 'pro' | 'testing' | 'test';
|
|
12
|
-
type StartMode = 'development' | 'production' | 'testing';
|
|
8
|
+
import type { Environment, ProcessLike, StartMode } from '@config/type';
|
|
13
9
|
|
|
14
10
|
const getProcessLike = (): ProcessLike | undefined => {
|
|
15
11
|
return typeof process === 'undefined' ? undefined : (process as unknown as ProcessLike);
|
|
@@ -6,42 +6,12 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { Env } from '@config/env';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export type PusherBroadcastDriverConfig = {
|
|
17
|
-
driver: 'pusher';
|
|
18
|
-
appId: string;
|
|
19
|
-
key: string;
|
|
20
|
-
secret: string;
|
|
21
|
-
cluster: string;
|
|
22
|
-
useTLS: boolean;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export type RedisBroadcastDriverConfig = {
|
|
26
|
-
driver: 'redis';
|
|
27
|
-
host: string;
|
|
28
|
-
port: number;
|
|
29
|
-
password: string;
|
|
30
|
-
channelPrefix: string;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export type RedisHttpsBroadcastDriverConfig = {
|
|
34
|
-
driver: 'redishttps';
|
|
35
|
-
endpoint: string;
|
|
36
|
-
token: string;
|
|
37
|
-
channelPrefix: string;
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
export type KnownBroadcastDriverConfig =
|
|
41
|
-
| InMemoryBroadcastDriverConfig
|
|
42
|
-
| PusherBroadcastDriverConfig
|
|
43
|
-
| RedisBroadcastDriverConfig
|
|
44
|
-
| RedisHttpsBroadcastDriverConfig;
|
|
9
|
+
import {
|
|
10
|
+
KnownBroadcastDriverConfig,
|
|
11
|
+
PusherBroadcastDriverConfig,
|
|
12
|
+
RedisBroadcastDriverConfig,
|
|
13
|
+
RedisHttpsBroadcastDriverConfig,
|
|
14
|
+
} from '@config/type';
|
|
45
15
|
|
|
46
16
|
const normalizeDriverName = (value: string): string => value.trim().toLowerCase();
|
|
47
17
|
|
|
@@ -5,48 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { Env } from '@config/env';
|
|
8
|
-
|
|
9
|
-
type MemoryCacheDriverConfig = {
|
|
10
|
-
driver: 'memory';
|
|
11
|
-
ttl: number;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
type RedisCacheDriverConfig = {
|
|
15
|
-
driver: 'redis';
|
|
16
|
-
host: string;
|
|
17
|
-
port: number;
|
|
18
|
-
ttl: number;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
type MongoCacheDriverConfig = {
|
|
22
|
-
driver: 'mongodb';
|
|
23
|
-
uri: string;
|
|
24
|
-
db: string;
|
|
25
|
-
ttl: number;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
type KvCacheDriverConfig = {
|
|
29
|
-
driver: 'kv';
|
|
30
|
-
ttl: number;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
type CacheDriverConfig =
|
|
34
|
-
| MemoryCacheDriverConfig
|
|
35
|
-
| RedisCacheDriverConfig
|
|
36
|
-
| MongoCacheDriverConfig
|
|
37
|
-
| KvCacheDriverConfig;
|
|
38
|
-
|
|
39
|
-
type CacheDrivers = {
|
|
40
|
-
memory: MemoryCacheDriverConfig;
|
|
41
|
-
redis: RedisCacheDriverConfig;
|
|
42
|
-
mongodb: MongoCacheDriverConfig;
|
|
43
|
-
kv: KvCacheDriverConfig;
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
type CacheConfigInput = {
|
|
47
|
-
default: string;
|
|
48
|
-
drivers: CacheDrivers;
|
|
49
|
-
};
|
|
8
|
+
import { CacheConfigInput, CacheDriverConfig, CacheDrivers } from '@config/type';
|
|
50
9
|
|
|
51
10
|
const getCacheDriver = (config: CacheConfigInput): CacheDriverConfig => {
|
|
52
11
|
const defaultDriver = config.default;
|
|
@@ -5,23 +5,9 @@
|
|
|
5
5
|
* This keeps runtime-specific globals out of adapters/drivers.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
import { KVNamespace, WorkersEnv } from '@config/type';
|
|
8
9
|
import type { DatabaseConfig, ID1Database } from '@zintrust/core';
|
|
9
10
|
|
|
10
|
-
export type WorkersEnv = Record<string, unknown>;
|
|
11
|
-
|
|
12
|
-
type KVNamespace = {
|
|
13
|
-
get(
|
|
14
|
-
key: string,
|
|
15
|
-
options?: { type: 'text' | 'json' | 'arrayBuffer' | 'stream' }
|
|
16
|
-
): Promise<unknown>;
|
|
17
|
-
put(
|
|
18
|
-
key: string,
|
|
19
|
-
value: string | ReadableStream | ArrayBuffer | FormData,
|
|
20
|
-
options?: { expiration?: number; expirationTtl?: number; metadata?: unknown }
|
|
21
|
-
): Promise<void>;
|
|
22
|
-
delete(key: string): Promise<void>;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
11
|
const getWorkersEnv = (): WorkersEnv | null => {
|
|
26
12
|
const env = (globalThis as unknown as { env?: unknown }).env;
|
|
27
13
|
if (env === undefined || env === null) return null;
|
|
@@ -5,57 +5,11 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { Env } from '@config/env';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
type PostgresqlConnectionConfig = {
|
|
16
|
-
driver: 'postgresql';
|
|
17
|
-
host: string;
|
|
18
|
-
port: number;
|
|
19
|
-
database: string;
|
|
20
|
-
username: string;
|
|
21
|
-
password: string;
|
|
22
|
-
ssl: boolean;
|
|
23
|
-
pooling: {
|
|
24
|
-
enabled: boolean;
|
|
25
|
-
min: number;
|
|
26
|
-
max: number;
|
|
27
|
-
idleTimeout: number;
|
|
28
|
-
connectionTimeout: number;
|
|
29
|
-
};
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
type MysqlConnectionConfig = {
|
|
33
|
-
driver: 'mysql';
|
|
34
|
-
host: string;
|
|
35
|
-
port: number;
|
|
36
|
-
database: string;
|
|
37
|
-
username: string;
|
|
38
|
-
password: string;
|
|
39
|
-
pooling: {
|
|
40
|
-
enabled: boolean;
|
|
41
|
-
min: number;
|
|
42
|
-
max: number;
|
|
43
|
-
};
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
type DatabaseConnections = {
|
|
47
|
-
sqlite: SqliteConnectionConfig;
|
|
48
|
-
postgresql: PostgresqlConnectionConfig;
|
|
49
|
-
mysql: MysqlConnectionConfig;
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
type DatabaseConnectionName = keyof DatabaseConnections;
|
|
53
|
-
type DatabaseConnectionConfig = DatabaseConnections[DatabaseConnectionName];
|
|
54
|
-
|
|
55
|
-
type DatabaseConfigShape = {
|
|
56
|
-
default: DatabaseConnectionName;
|
|
57
|
-
connections: DatabaseConnections;
|
|
58
|
-
};
|
|
8
|
+
import {
|
|
9
|
+
DatabaseConfigShape,
|
|
10
|
+
DatabaseConnectionConfig,
|
|
11
|
+
DatabaseConnectionName,
|
|
12
|
+
} from '@config/type';
|
|
59
13
|
|
|
60
14
|
const isDatabaseConnectionName = (value: string): value is DatabaseConnectionName => {
|
|
61
15
|
return value === 'sqlite' || value === 'postgresql' || value === 'mysql';
|