@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
|
@@ -6,11 +6,7 @@
|
|
|
6
6
|
* Safe for both Node.js and serverless runtimes (Cloudflare Workers, Deno, Lambda)
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
env?: Record<string, string | undefined>;
|
|
11
|
-
execPath?: string;
|
|
12
|
-
platform?: string;
|
|
13
|
-
};
|
|
9
|
+
import { ProcessLike } from '@config/type';
|
|
14
10
|
|
|
15
11
|
const getProcessLike = (): ProcessLike | undefined => {
|
|
16
12
|
return typeof process === 'undefined' ? undefined : (process as unknown as ProcessLike);
|
|
@@ -35,6 +31,7 @@ const getInt = (key: string, defaultValue?: number): number => {
|
|
|
35
31
|
const env = proc?.env ?? {};
|
|
36
32
|
const value = env[key];
|
|
37
33
|
if (value === undefined || value === null) return defaultValue ?? 0;
|
|
34
|
+
if (typeof value === 'string' && value.trim() === '') return defaultValue ?? 0;
|
|
38
35
|
return Number.parseInt(value, 10);
|
|
39
36
|
};
|
|
40
37
|
|
|
@@ -62,7 +59,8 @@ export const Env = Object.freeze({
|
|
|
62
59
|
|
|
63
60
|
// Core
|
|
64
61
|
NODE_ENV: get('NODE_ENV', 'development'),
|
|
65
|
-
PORT
|
|
62
|
+
// Prefer PORT, fallback to APP_PORT for compatibility
|
|
63
|
+
PORT: getInt('PORT', getInt('APP_PORT', 3000)),
|
|
66
64
|
HOST: get('HOST', 'localhost'),
|
|
67
65
|
APP_NAME: get('APP_NAME', 'ZinTrust'),
|
|
68
66
|
APP_KEY: get('APP_KEY', ''),
|
|
@@ -71,7 +69,8 @@ export const Env = Object.freeze({
|
|
|
71
69
|
DB_CONNECTION: get('DB_CONNECTION', 'sqlite'),
|
|
72
70
|
DB_HOST: get('DB_HOST', 'localhost'),
|
|
73
71
|
DB_PORT: getInt('DB_PORT', 5432),
|
|
74
|
-
|
|
72
|
+
// Accept DB_PATH as an alias for sqlite file path (many env templates use it).
|
|
73
|
+
DB_DATABASE: get('DB_DATABASE', get('DB_PATH', 'zintrust')),
|
|
75
74
|
DB_USERNAME: get('DB_USERNAME', 'postgres'),
|
|
76
75
|
DB_PASSWORD: get('DB_PASSWORD', ''),
|
|
77
76
|
DB_READ_HOSTS: get('DB_READ_HOSTS', ''),
|
|
@@ -16,7 +16,7 @@ export { appConfig, type AppConfig } from '@config/app';
|
|
|
16
16
|
export { cacheConfig, type CacheConfig } from '@config/cache';
|
|
17
17
|
export { databaseConfig, type DatabaseConfig } from '@config/database';
|
|
18
18
|
export { microservicesConfig, type MicroservicesConfig } from '@config/microservices';
|
|
19
|
-
export { middlewareConfig
|
|
19
|
+
export { middlewareConfig } from '@config/middleware';
|
|
20
20
|
export { queueConfig, type QueueConfig } from '@config/queue';
|
|
21
21
|
export { securityConfig } from '@config/security';
|
|
22
22
|
export { storageConfig, type StorageConfig } from '@config/storage';
|
|
@@ -100,7 +100,9 @@ const getFileWriter = (): void => {
|
|
|
100
100
|
|
|
101
101
|
const shouldLogToFile = (): boolean => {
|
|
102
102
|
// Prefer dynamic lookup so late-bound env (tests, some runtimes) is respected.
|
|
103
|
-
|
|
103
|
+
const channel = Env.get('LOG_CHANNEL', '').trim().toLowerCase();
|
|
104
|
+
const channelWantsFile = channel === 'file' || channel === 'all';
|
|
105
|
+
if (!Env.getBool('LOG_TO_FILE', false) && !channelWantsFile) return false;
|
|
104
106
|
if (typeof process === 'undefined') return false;
|
|
105
107
|
return true;
|
|
106
108
|
};
|
|
@@ -5,63 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { Env } from '@config/env';
|
|
8
|
-
|
|
9
|
-
export type MailDriverName = 'disabled' | 'sendgrid' | 'smtp' | 'ses' | 'mailgun';
|
|
10
|
-
|
|
11
|
-
export type DisabledMailDriverConfig = {
|
|
12
|
-
driver: 'disabled';
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export type SendGridMailDriverConfig = {
|
|
16
|
-
driver: 'sendgrid';
|
|
17
|
-
apiKey: string;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export type MailgunMailDriverConfig = {
|
|
21
|
-
driver: 'mailgun';
|
|
22
|
-
apiKey: string;
|
|
23
|
-
domain: string;
|
|
24
|
-
baseUrl: string;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
// Placeholders for future drivers (kept config-first)
|
|
28
|
-
export type SmtpMailDriverConfig = {
|
|
29
|
-
driver: 'smtp';
|
|
30
|
-
host: string;
|
|
31
|
-
port: number;
|
|
32
|
-
username: string;
|
|
33
|
-
password: string;
|
|
34
|
-
secure: boolean | 'starttls';
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export type SesMailDriverConfig = {
|
|
38
|
-
driver: 'ses';
|
|
39
|
-
region: string;
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
export type MailDriverConfig =
|
|
43
|
-
| DisabledMailDriverConfig
|
|
44
|
-
| SendGridMailDriverConfig
|
|
45
|
-
| MailgunMailDriverConfig
|
|
46
|
-
| SmtpMailDriverConfig
|
|
47
|
-
| SesMailDriverConfig;
|
|
48
|
-
|
|
49
|
-
type MailDrivers = {
|
|
50
|
-
disabled: DisabledMailDriverConfig;
|
|
51
|
-
sendgrid: SendGridMailDriverConfig;
|
|
52
|
-
mailgun: MailgunMailDriverConfig;
|
|
53
|
-
smtp: SmtpMailDriverConfig;
|
|
54
|
-
ses: SesMailDriverConfig;
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
type MailConfigInput = {
|
|
58
|
-
default: MailDriverName;
|
|
59
|
-
from: {
|
|
60
|
-
address: string;
|
|
61
|
-
name: string;
|
|
62
|
-
};
|
|
63
|
-
drivers: MailDrivers;
|
|
64
|
-
};
|
|
8
|
+
import type { MailConfigInput, MailDriverConfig, MailDriverName, MailDrivers } from '@config/type';
|
|
65
9
|
|
|
66
10
|
const getMailDriver = (config: MailConfigInput): MailDriverConfig => {
|
|
67
11
|
const defaultDriver = config.default;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { MiddlewareConfigType } from '@config/type';
|
|
1
2
|
import { CsrfMiddleware } from '@middleware/CsrfMiddleware';
|
|
2
3
|
import { ErrorHandlerMiddleware } from '@middleware/ErrorHandlerMiddleware';
|
|
3
4
|
import { LoggingMiddleware } from '@middleware/LoggingMiddleware';
|
|
@@ -5,11 +6,6 @@ import type { Middleware } from '@middleware/MiddlewareStack';
|
|
|
5
6
|
import { RateLimiter } from '@middleware/RateLimiter';
|
|
6
7
|
import { SecurityMiddleware } from '@middleware/SecurityMiddleware';
|
|
7
8
|
|
|
8
|
-
export type MiddlewareConfig = {
|
|
9
|
-
global: Middleware[];
|
|
10
|
-
route: Record<string, Middleware>;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
9
|
const shared = Object.freeze({
|
|
14
10
|
log: LoggingMiddleware.create(),
|
|
15
11
|
error: ErrorHandlerMiddleware.create(),
|
|
@@ -18,7 +14,7 @@ const shared = Object.freeze({
|
|
|
18
14
|
csrf: CsrfMiddleware.create(),
|
|
19
15
|
} satisfies Record<string, Middleware>);
|
|
20
16
|
|
|
21
|
-
const middlewareConfigObj:
|
|
17
|
+
const middlewareConfigObj: MiddlewareConfigType = {
|
|
22
18
|
global: [shared.log, shared.error, shared.security, shared.rateLimit, shared.csrf],
|
|
23
19
|
route: shared,
|
|
24
20
|
};
|
|
@@ -6,42 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { Env } from '@config/env';
|
|
9
|
-
|
|
10
|
-
export type KnownNotificationDriverName = 'console' | 'termii' | 'twilio' | 'slack';
|
|
11
|
-
|
|
12
|
-
export type ConsoleNotificationDriverConfig = { driver: 'console' };
|
|
13
|
-
|
|
14
|
-
export type TermiiNotificationDriverConfig = {
|
|
15
|
-
driver: 'termii';
|
|
16
|
-
apiKey: string;
|
|
17
|
-
sender: string;
|
|
18
|
-
endpoint: string;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export type TwilioNotificationDriverConfig = {
|
|
22
|
-
driver: 'twilio';
|
|
23
|
-
accountSid: string;
|
|
24
|
-
authToken: string;
|
|
25
|
-
fromNumber: string;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export type SlackNotificationDriverConfig = {
|
|
29
|
-
driver: 'slack';
|
|
30
|
-
webhookUrl: string;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export type KnownNotificationDriverConfig =
|
|
34
|
-
| ConsoleNotificationDriverConfig
|
|
35
|
-
| TermiiNotificationDriverConfig
|
|
36
|
-
| TwilioNotificationDriverConfig
|
|
37
|
-
| SlackNotificationDriverConfig;
|
|
38
|
-
|
|
39
|
-
type NotificationProviders = {
|
|
40
|
-
console: ConsoleNotificationDriverConfig;
|
|
41
|
-
termii: TermiiNotificationDriverConfig;
|
|
42
|
-
twilio: TwilioNotificationDriverConfig;
|
|
43
|
-
slack: SlackNotificationDriverConfig;
|
|
44
|
-
};
|
|
9
|
+
import type { NotificationProviders } from '@config/type';
|
|
45
10
|
|
|
46
11
|
const notificationConfigObj = {
|
|
47
12
|
/**
|
|
@@ -6,55 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
import { Env } from '@config/env';
|
|
8
8
|
|
|
9
|
-
type
|
|
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
|
-
};
|
|
9
|
+
import type { QueueConfigWithDrivers, QueueDriverName, QueueDriversConfig } from '@config/type';
|
|
58
10
|
|
|
59
11
|
const getQueueDriver = (config: QueueConfigWithDrivers): QueueDriversConfig[QueueDriverName] => {
|
|
60
12
|
const driverName = config.default;
|
|
@@ -2,6 +2,18 @@
|
|
|
2
2
|
* Security Configuration
|
|
3
3
|
* JWT, CSRF, encryption and other security settings
|
|
4
4
|
* Sealed namespace for immutability
|
|
5
|
+
*
|
|
6
|
+
* APP_KEY: Primary encryption key for storage signing and app-level encryption.
|
|
7
|
+
* Set automatically during project scaffolding.
|
|
8
|
+
*
|
|
9
|
+
* Security keys can be configured per domain:
|
|
10
|
+
* - APP_KEY: Default encryption key for all operations (auto-generated)
|
|
11
|
+
* - API_KEY_SECRET: Optional API key authentication (if API_KEY_ENABLED=true)
|
|
12
|
+
* - ENCRYPTION_KEY: Optional separate encryption key (overrides APP_KEY if set)
|
|
13
|
+
* - JWT_SECRET: JWT token signing key
|
|
14
|
+
*
|
|
15
|
+
* Developers can use a single APP_KEY or configure separate keys for different
|
|
16
|
+
* security domains (e.g., different keys for different microservices).
|
|
5
17
|
*/
|
|
6
18
|
|
|
7
19
|
import { appConfig } from '@config/app';
|
|
@@ -72,7 +84,7 @@ const securityConfigObj = {
|
|
|
72
84
|
* API Key Authentication
|
|
73
85
|
*/
|
|
74
86
|
apiKey: {
|
|
75
|
-
enabled: Env.getBool('API_KEY_ENABLED',
|
|
87
|
+
enabled: Env.getBool('API_KEY_ENABLED', false),
|
|
76
88
|
headerName: Env.get('API_KEY_HEADER', 'x-api-key'),
|
|
77
89
|
secret: Env.get('API_KEY_SECRET'),
|
|
78
90
|
},
|
|
@@ -9,6 +9,7 @@ import { Env } from '@config/env';
|
|
|
9
9
|
export type StartupConfig = {
|
|
10
10
|
healthChecksEnabled: boolean;
|
|
11
11
|
validateSecrets: boolean;
|
|
12
|
+
requireEnv: boolean;
|
|
12
13
|
checkDatabase: boolean;
|
|
13
14
|
checkCache: boolean;
|
|
14
15
|
timeoutMs: number;
|
|
@@ -18,6 +19,7 @@ export type StartupConfig = {
|
|
|
18
19
|
export const startupConfig = Object.freeze({
|
|
19
20
|
healthChecksEnabled: Env.getBool('STARTUP_HEALTH_CHECKS', true),
|
|
20
21
|
validateSecrets: Env.getBool('STARTUP_VALIDATE_SECRETS', true),
|
|
22
|
+
requireEnv: Env.getBool('STARTUP_REQUIRE_ENV', false),
|
|
21
23
|
checkDatabase: Env.getBool('STARTUP_CHECK_DB', false),
|
|
22
24
|
checkCache: Env.getBool('STARTUP_CHECK_CACHE', false),
|
|
23
25
|
timeoutMs: Env.getInt('STARTUP_HEALTH_TIMEOUT_MS', 2500),
|
|
@@ -5,60 +5,12 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { Env } from '@config/env';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
root: EnvGetValue;
|
|
15
|
-
url: EnvGetValue;
|
|
16
|
-
visibility: EnvGetValue;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
type S3StorageDriverConfig = {
|
|
20
|
-
driver: 's3';
|
|
21
|
-
accessKeyId: EnvGetValue;
|
|
22
|
-
secretAccessKey: EnvGetValue;
|
|
23
|
-
region: typeof Env.AWS_REGION;
|
|
24
|
-
bucket: EnvGetValue;
|
|
25
|
-
url: EnvGetValue;
|
|
26
|
-
endpoint: EnvGetValue;
|
|
27
|
-
usePathStyleUrl: EnvGetBoolValue;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
type R2StorageDriverConfig = {
|
|
31
|
-
driver: 'r2';
|
|
32
|
-
accessKeyId: EnvGetValue;
|
|
33
|
-
secretAccessKey: EnvGetValue;
|
|
34
|
-
region: EnvGetValue;
|
|
35
|
-
bucket: EnvGetValue;
|
|
36
|
-
endpoint: EnvGetValue;
|
|
37
|
-
url: EnvGetValue;
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
type GcsStorageDriverConfig = {
|
|
41
|
-
driver: 'gcs';
|
|
42
|
-
projectId: EnvGetValue;
|
|
43
|
-
keyFile: EnvGetValue;
|
|
44
|
-
bucket: EnvGetValue;
|
|
45
|
-
url: EnvGetValue;
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
type StorageDrivers = {
|
|
49
|
-
local: LocalStorageDriverConfig;
|
|
50
|
-
s3: S3StorageDriverConfig;
|
|
51
|
-
r2: R2StorageDriverConfig;
|
|
52
|
-
gcs: GcsStorageDriverConfig;
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
type StorageDriverName = keyof StorageDrivers;
|
|
56
|
-
type StorageDriverConfig = StorageDrivers[StorageDriverName];
|
|
57
|
-
|
|
58
|
-
type StorageConfigRuntime = {
|
|
59
|
-
readonly default: string;
|
|
60
|
-
readonly drivers: StorageDrivers;
|
|
61
|
-
};
|
|
8
|
+
import type {
|
|
9
|
+
StorageConfigRuntime,
|
|
10
|
+
StorageDriverConfig,
|
|
11
|
+
StorageDriverName,
|
|
12
|
+
StorageDrivers,
|
|
13
|
+
} from '@config/type';
|
|
62
14
|
|
|
63
15
|
const isStorageDriverName = (
|
|
64
16
|
value: string,
|