@zintrust/core 0.1.50 → 0.1.52
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.js +0 -0
- package/bin/zin.js +0 -0
- package/bin/zintrust.js +0 -0
- package/bin/zt.js +0 -0
- package/package.json +3 -2
- package/src/boot/bootstrap.js +2 -6
- package/src/boot/registry/runtime.d.ts.map +1 -1
- package/src/boot/registry/runtime.js +6 -1
- package/src/cli/scaffolding/ProjectScaffolder.d.ts.map +1 -1
- package/src/cli/scaffolding/ProjectScaffolder.js +27 -50
- package/src/cli/scaffolding/env.d.ts +2 -0
- package/src/cli/scaffolding/env.d.ts.map +1 -0
- package/src/cli/scaffolding/env.js +549 -0
- package/src/cli/utils/EnvFileLoader.js +1 -1
- package/src/config/logger.d.ts.map +1 -1
- package/src/config/logger.js +56 -9
- package/src/index.js +3 -3
- package/src/proxy/d1/ZintrustD1Proxy.d.ts.map +1 -1
- package/src/proxy/d1/ZintrustD1Proxy.js +4 -4
- package/src/proxy/kv/ZintrustKvProxy.js +1 -1
- package/src/runtime/PluginAutoImports.js +1 -1
- package/src/runtime/WorkersModule.d.ts.map +1 -1
- package/src/runtime/WorkersModule.js +66 -0
- package/src/templates/project/basic/src/zintrust.plugins.ts.tpl +22 -0
- package/src/zintrust.plugins.d.ts +3 -9
- package/src/zintrust.plugins.d.ts.map +1 -1
- package/src/zintrust.plugins.js +3 -10
- package/src/zintrust.plugins.wg.d.ts +0 -1
- package/src/zintrust.plugins.wg.d.ts.map +1 -1
- package/src/zintrust.plugins.wg.js +0 -1
- package/src/zintrust.comon.d.ts +0 -9
- package/src/zintrust.comon.d.ts.map +0 -1
- package/src/zintrust.comon.js +0 -15
package/bin/z.js
CHANGED
|
File without changes
|
package/bin/zin.js
CHANGED
|
File without changes
|
package/bin/zintrust.js
CHANGED
|
File without changes
|
package/bin/zt.js
CHANGED
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zintrust/core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.52",
|
|
4
4
|
"description": "Production-grade TypeScript backend framework for JavaScript",
|
|
5
5
|
"homepage": "https://zintrust.com",
|
|
6
6
|
"repository": {
|
|
@@ -62,7 +62,8 @@
|
|
|
62
62
|
"node-forge": "1.3.3",
|
|
63
63
|
"cross-spawn": "^7.0.5",
|
|
64
64
|
"glob": "^11.1.0",
|
|
65
|
-
"minimatch": "^10.2.
|
|
65
|
+
"minimatch": "^10.2.2",
|
|
66
|
+
"rollup": "^4.59.0",
|
|
66
67
|
"undici": "^6.23.0"
|
|
67
68
|
},
|
|
68
69
|
"bin": {
|
package/src/boot/bootstrap.js
CHANGED
|
@@ -156,7 +156,7 @@ const gracefulShutdown = async (signal) => {
|
|
|
156
156
|
};
|
|
157
157
|
async function useWorkerStarter() {
|
|
158
158
|
// Check if workers are enabled in this environment
|
|
159
|
-
const workerEnabled = Env.getBool('WORKER_ENABLED',
|
|
159
|
+
const workerEnabled = Env.getBool('WORKER_ENABLED', false);
|
|
160
160
|
if (!workerEnabled || appConfig.dockerWorker === true) {
|
|
161
161
|
Logger.info('Workers disabled in this runtime (WORKER_ENABLED=false && DOCKER_WORKER=true), skipping worker management initialization');
|
|
162
162
|
return;
|
|
@@ -202,7 +202,7 @@ const BootstrapFunctions = Object.freeze({
|
|
|
202
202
|
}
|
|
203
203
|
catch (error) {
|
|
204
204
|
// best-effort; run without plugins if loader fails (e.g. non-Node runtime)
|
|
205
|
-
Logger.
|
|
205
|
+
Logger.warn('Plugin auto-imports loader skipped:', error);
|
|
206
206
|
}
|
|
207
207
|
// Create application instance
|
|
208
208
|
// if (Env.ZINTRUST_PROJECT_ROOT) {
|
|
@@ -235,10 +235,6 @@ const BootstrapFunctions = Object.freeze({
|
|
|
235
235
|
catch {
|
|
236
236
|
// best-effort logging
|
|
237
237
|
}
|
|
238
|
-
Logger.debug('[bootstrap] start: failed', {
|
|
239
|
-
message: error instanceof Error ? error.message : String(error),
|
|
240
|
-
stack: error instanceof Error ? error.stack : undefined,
|
|
241
|
-
});
|
|
242
238
|
logBootstrapErrorDetails(error);
|
|
243
239
|
process.exit(1);
|
|
244
240
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../../src/boot/registry/runtime.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../../src/boot/registry/runtime.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAOvD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AA+I9C,eAAO,MAAM,8BAA8B,GAAI,iBAAiB,gBAAgB,KAAG,IA4BlF,CAAC;AAyLF,eAAO,MAAM,eAAe,GAAI,QAAQ;IACtC,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,EAAE,MAAM,CAAC;IACzB,MAAM,EAAE,OAAO,CAAC;IAChB,eAAe,EAAE,gBAAgB,CAAC;IAClC,SAAS,EAAE,MAAM,OAAO,CAAC;IACzB,SAAS,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CACrC,KAAG;IAAE,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAAC,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CA2E7D,CAAC"}
|
|
@@ -4,6 +4,7 @@ import { loadQueueMonitorModule, loadWorkersModule } from '../../runtime/Workers
|
|
|
4
4
|
import { registerCachesFromRuntimeConfig } from '../../cache/CacheRuntimeRegistration.js';
|
|
5
5
|
import broadcastConfig from '../../config/broadcast.js';
|
|
6
6
|
import { Cloudflare } from '../../config/cloudflare.js';
|
|
7
|
+
import { Env } from '../../config/env.js';
|
|
7
8
|
import { FeatureFlags } from '../../config/features.js';
|
|
8
9
|
import { Logger } from '../../config/logger.js';
|
|
9
10
|
import notificationConfig from '../../config/notification.js';
|
|
@@ -330,12 +331,16 @@ export const createLifecycle = (params) => {
|
|
|
330
331
|
await registerFromRuntimeConfig();
|
|
331
332
|
await initializeArtifactDirectories(params.resolvedBasePath);
|
|
332
333
|
await registerMasterRoutes(params.resolvedBasePath, params.router);
|
|
333
|
-
|
|
334
|
+
const workerEnabled = Env.getBool('WORKER_ENABLED', false);
|
|
335
|
+
if (Cloudflare.getWorkersEnv() === null && appConfig.dockerWorker === false && workerEnabled) {
|
|
334
336
|
await initializeWorkers(params.router);
|
|
335
337
|
await initializeQueueMonitor(params.router);
|
|
336
338
|
await initializeQueueHttpGateway(params.router);
|
|
337
339
|
await initializeScheduleHttpGateway(params.router);
|
|
338
340
|
}
|
|
341
|
+
else if (!workerEnabled) {
|
|
342
|
+
Logger.info('Skipping worker module initialization (WORKER_ENABLED=false).');
|
|
343
|
+
}
|
|
339
344
|
// Register service providers
|
|
340
345
|
// Bootstrap services
|
|
341
346
|
Logger.info('✅ Application booted successfully');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProjectScaffolder.d.ts","sourceRoot":"","sources":["../../../../src/cli/scaffolding/ProjectScaffolder.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"ProjectScaffolder.d.ts","sourceRoot":"","sources":["../../../../src/cli/scaffolding/ProjectScaffolder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAWH,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,MAAM,cAAc,GAAG,sBAAsB,CAAC;AAEpD,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC/B;AAED,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,KAAK,CAAC;CACf;AAED,MAAM,WAAW,kBAAkB;IACjC,cAAc,CAAC,OAAO,EAAE,sBAAsB,GAAG,IAAI,CAAC;IACtD,YAAY,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACxC,eAAe,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS,CAAC;IACpE,cAAc,IAAI,MAAM,CAAC;IACzB,sBAAsB,IAAI,OAAO,CAAC;IAClC,iBAAiB,IAAI,MAAM,CAAC;IAC5B,WAAW,CAAC,OAAO,CAAC,EAAE,sBAAsB,GAAG,MAAM,CAAC;IACtD,gBAAgB,IAAI,OAAO,CAAC;IAC5B,aAAa,IAAI,OAAO,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;CAC3E;AAodD,wBAAgB,qBAAqB,IAAI,MAAM,EAAE,CAEhD;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS,CAsBrE;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,sBAAsB,GAAG;IAChE,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CAsBA;AA4ID;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,WAAW,GAAE,MAAsB,GAAG,kBAAkB,CAsB/F;AAED,wBAAsB,eAAe,CACnC,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,sBAAsB,GAC9B,OAAO,CAAC,qBAAqB,CAAC,CAEhC;AAED;;GAEG;AACH,eAAO,MAAM,iBAAiB;;;;;;EAM5B,CAAC"}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Handles directory structure and boilerplate file creation
|
|
4
4
|
*/
|
|
5
5
|
import { EnvFileBackfill } from '../env/EnvFileBackfill.js';
|
|
6
|
+
import { EnvData } from '../scaffolding/env.js';
|
|
6
7
|
import { Logger } from '../../config/logger.js';
|
|
7
8
|
import { ErrorFactory } from '../../exceptions/ZintrustError.js';
|
|
8
9
|
import { randomBytes } from '../../node-singletons/crypto.js';
|
|
@@ -99,45 +100,6 @@ const createProjectConfigFile = (projectPath, variables) => {
|
|
|
99
100
|
return false;
|
|
100
101
|
}
|
|
101
102
|
};
|
|
102
|
-
const toSafeDbBasename = (raw) => {
|
|
103
|
-
const trimmed = raw.trim();
|
|
104
|
-
if (trimmed === '')
|
|
105
|
-
return 'zintrust';
|
|
106
|
-
const lower = trimmed.toLowerCase();
|
|
107
|
-
let out = '';
|
|
108
|
-
let prevWasDash = false;
|
|
109
|
-
for (const char of lower) {
|
|
110
|
-
const isAlphaNum = (char >= 'a' && char <= 'z') || (char >= '0' && char <= '9');
|
|
111
|
-
const isContent = isAlphaNum || char === '_';
|
|
112
|
-
if (isContent) {
|
|
113
|
-
out += char;
|
|
114
|
-
prevWasDash = false;
|
|
115
|
-
continue;
|
|
116
|
-
}
|
|
117
|
-
// Treat as separator: collapse dashes and avoid leading dash
|
|
118
|
-
if (out.length > 0 && !prevWasDash) {
|
|
119
|
-
out += '-';
|
|
120
|
-
prevWasDash = true;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
if (out.endsWith('-')) {
|
|
124
|
-
out = out.slice(0, -1);
|
|
125
|
-
}
|
|
126
|
-
return out === '' ? 'zintrust' : out;
|
|
127
|
-
};
|
|
128
|
-
const readEnvScaffoldTemplate = () => {
|
|
129
|
-
const templateUrl = new URL('./templates/env.scaffold.dotenv.tpl', import.meta.url);
|
|
130
|
-
return fs.readFileSync(templateUrl, 'utf8');
|
|
131
|
-
};
|
|
132
|
-
const renderEnvScaffold = (template, vars) => {
|
|
133
|
-
let out = template;
|
|
134
|
-
for (const [key, value] of Object.entries(vars)) {
|
|
135
|
-
out = out.replaceAll(`{{${key}}}`, value);
|
|
136
|
-
}
|
|
137
|
-
// Normalize: if a placeholder resolves to empty, prevent excessive blank blocks.
|
|
138
|
-
out = out.replaceAll('\n\n\n', '\n\n');
|
|
139
|
-
return out;
|
|
140
|
-
};
|
|
141
103
|
const buildDbOverrides = (dbConnection) => {
|
|
142
104
|
const normalized = dbConnection.trim().toLowerCase();
|
|
143
105
|
if (normalized === 'mysql') {
|
|
@@ -176,6 +138,31 @@ const buildDbOverrides = (dbConnection) => {
|
|
|
176
138
|
// sqlite/d1/d1-remote/etc: no overrides here (DB_PATH is handled via SQLITE_DB_PATH placeholder)
|
|
177
139
|
return { dbLines: [] };
|
|
178
140
|
};
|
|
141
|
+
const toSafeDbBasename = (raw) => {
|
|
142
|
+
const trimmed = raw.trim();
|
|
143
|
+
if (trimmed === '')
|
|
144
|
+
return 'zintrust';
|
|
145
|
+
const lower = trimmed.toLowerCase();
|
|
146
|
+
let out = '';
|
|
147
|
+
let prevWasDash = false;
|
|
148
|
+
for (const char of lower) {
|
|
149
|
+
const isAlphaNum = (char >= 'a' && char <= 'z') || (char >= '0' && char <= '9');
|
|
150
|
+
const isContent = isAlphaNum || char === '_';
|
|
151
|
+
if (isContent) {
|
|
152
|
+
out += char;
|
|
153
|
+
prevWasDash = false;
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
if (out.length > 0 && !prevWasDash) {
|
|
157
|
+
out += '-';
|
|
158
|
+
prevWasDash = true;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
if (out.endsWith('-')) {
|
|
162
|
+
out = out.slice(0, -1);
|
|
163
|
+
}
|
|
164
|
+
return out === '' ? 'zintrust' : out;
|
|
165
|
+
};
|
|
179
166
|
const createEnvFile = (projectPath, variables) => {
|
|
180
167
|
try {
|
|
181
168
|
if (!fs.existsSync(projectPath)) {
|
|
@@ -204,17 +191,7 @@ const createEnvFile = (projectPath, variables) => {
|
|
|
204
191
|
// Keep consistent with `zin key:generate` output.
|
|
205
192
|
const appKey = `base64:${appKeyBytes.toString('base64')}`;
|
|
206
193
|
const { dbLines } = buildDbOverrides(dbConnection);
|
|
207
|
-
const
|
|
208
|
-
const template = readEnvScaffoldTemplate();
|
|
209
|
-
const content = renderEnvScaffold(template, {
|
|
210
|
-
APP_NAME: name,
|
|
211
|
-
PORT: String(port),
|
|
212
|
-
BASE_URL: baseUrl,
|
|
213
|
-
APP_KEY: appKey,
|
|
214
|
-
DB_CONNECTION: dbConnection,
|
|
215
|
-
SQLITE_DB_PATH: sqliteDbPath,
|
|
216
|
-
DB_LINES: dbLinesBlock,
|
|
217
|
-
});
|
|
194
|
+
const content = EnvData(name, port, baseUrl, appKey, dbConnection, dbLines, sqliteDbPath).join('\n');
|
|
218
195
|
fs.writeFileSync(fullPath, content.endsWith('\n') ? content : content + '\n');
|
|
219
196
|
return true;
|
|
220
197
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../../../src/cli/scaffolding/env.ts"],"names":[],"mappings":"AAuiBA,eAAO,MAAM,OAAO,GAClB,MAAM,MAAM,EACZ,MAAM,MAAM,EACZ,SAAS,MAAM,EACf,QAAQ,MAAM,EACd,oBAAoB,MAAM,EAC1B,SAAS,MAAM,EAAE,EACjB,cAAc,MAAM,KACnB,MAAM,EAWR,CAAC"}
|
|
@@ -0,0 +1,549 @@
|
|
|
1
|
+
const HeaderAndApp = (name, port, baseUrl, appKey) => [
|
|
2
|
+
'# ZinTrust — Project Environment (.env)',
|
|
3
|
+
'#',
|
|
4
|
+
'# Generated by: zin new / ProjectScaffolder',
|
|
5
|
+
'#',
|
|
6
|
+
'# Notes:',
|
|
7
|
+
'# - No ${VAR} interpolation: compatible with standard Node dotenv behavior.',
|
|
8
|
+
'# - Secrets are intentionally empty unless auto-generated (APP_KEY).',
|
|
9
|
+
'# - For the complete key list (auto-generated), see: -envexample.generated',
|
|
10
|
+
'',
|
|
11
|
+
'# ============================================================================',
|
|
12
|
+
'# APP',
|
|
13
|
+
'# ============================================================================',
|
|
14
|
+
'',
|
|
15
|
+
'NODE_ENV=development',
|
|
16
|
+
`APP_NAME=${name}`,
|
|
17
|
+
'HOST=localhost',
|
|
18
|
+
`PORT=${port}`,
|
|
19
|
+
`BASE_URL=${baseUrl}`,
|
|
20
|
+
'',
|
|
21
|
+
'# Runtime override (optional): auto | nodejs | cloudflare | deno | lambda',
|
|
22
|
+
'RUNTIME=',
|
|
23
|
+
'',
|
|
24
|
+
'DEBUG=true',
|
|
25
|
+
'METRICS_ENABLED=false',
|
|
26
|
+
'',
|
|
27
|
+
'# Cloudflare Workers (TCP sockets) — set true if using TCP adapters on Workers.',
|
|
28
|
+
'ENABLE_CLOUDFLARE_SOCKETS=false',
|
|
29
|
+
'',
|
|
30
|
+
'# CLI / tooling',
|
|
31
|
+
'ZINTRUST_RUN_FROM_SOURCE=0',
|
|
32
|
+
'ZINTRUST_VERSION_CHECK=true',
|
|
33
|
+
'ZINTRUST_VERSION_CHECK_INTERVAL=24',
|
|
34
|
+
'ZINTRUST_CLI_DEBUG_ARGS=0',
|
|
35
|
+
'',
|
|
36
|
+
'# Optional debug output (local only)',
|
|
37
|
+
'ZIN_DEBUG_VALIDATION_BODY=false',
|
|
38
|
+
'ZIN_DEBUG_BODY_PARSING=false',
|
|
39
|
+
'ZIN_DEBUG_FILE_UPLOAD=false',
|
|
40
|
+
'',
|
|
41
|
+
'# ============================================================================',
|
|
42
|
+
'# STARTUP (boot-time checks)',
|
|
43
|
+
'# ============================================================================',
|
|
44
|
+
'',
|
|
45
|
+
'STARTUP_HEALTH_CHECKS=true',
|
|
46
|
+
'STARTUP_VALIDATE_SECRETS=true',
|
|
47
|
+
'',
|
|
48
|
+
'# Strict required-env validation. Recommended for new projects.',
|
|
49
|
+
'STARTUP_REQUIRE_ENV=true',
|
|
50
|
+
'',
|
|
51
|
+
'STARTUP_CHECK_DB=false',
|
|
52
|
+
'STARTUP_CHECK_CACHE=false',
|
|
53
|
+
'STARTUP_HEALTH_TIMEOUT_MS=2500',
|
|
54
|
+
'STARTUP_CONTINUE_ON_FAILURE=false',
|
|
55
|
+
'',
|
|
56
|
+
'# ============================================================================',
|
|
57
|
+
'# SECURITY (keys, auth, headers)',
|
|
58
|
+
'# ============================================================================',
|
|
59
|
+
'',
|
|
60
|
+
'# Auto-generated secure APP_KEY for encryption interoperability (32 bytes, base64).',
|
|
61
|
+
`APP_KEY=${appKey}`,
|
|
62
|
+
'',
|
|
63
|
+
];
|
|
64
|
+
const SecurityAndDeployment = () => [
|
|
65
|
+
'# Optional: key rotation support (comma-separated OR JSON array of base64 keys)',
|
|
66
|
+
'APP_PREVIOUS_KEYS=',
|
|
67
|
+
'',
|
|
68
|
+
'# Supported: aes-256-cbc | aes-256-gcm',
|
|
69
|
+
'ENCRYPTION_CIPHER=aes-256-cbc',
|
|
70
|
+
'',
|
|
71
|
+
'JWT_ENABLED=true',
|
|
72
|
+
'# If empty, JWT uses APP_KEY in dev. For production, set a dedicated JWT_SECRET.',
|
|
73
|
+
'JWT_SECRET=',
|
|
74
|
+
'JWT_ALGORITHM=HS256',
|
|
75
|
+
'JWT_EXPIRES_IN=3600',
|
|
76
|
+
'JWT_REFRESH_EXPIRES_IN=7d',
|
|
77
|
+
'JWT_ISSUER=zintrust',
|
|
78
|
+
'JWT_AUDIENCE=zintrust-api',
|
|
79
|
+
'',
|
|
80
|
+
'API_KEY_ENABLED=false',
|
|
81
|
+
'API_KEY_HEADER=x-api-key',
|
|
82
|
+
'API_KEY_SECRET=',
|
|
83
|
+
'',
|
|
84
|
+
'CSRF_ENABLED=true',
|
|
85
|
+
'CSRF_HEADER_NAME=x-csrf-token',
|
|
86
|
+
'CSRF_TOKEN_NAME=_csrf',
|
|
87
|
+
'CSRF_COOKIE_NAME=XSRF-TOKEN',
|
|
88
|
+
'CSRF_COOKIE_SECURE=false',
|
|
89
|
+
'CSRF_COOKIE_HTTP_ONLY=true',
|
|
90
|
+
'CSRF_COOKIE_SAME_SITE=lax',
|
|
91
|
+
'CSRF_SKIP_PATHS=/api/*,/queue-monitor/*,/api/_sys/queue/*,/api/_sys/schedule/*',
|
|
92
|
+
'',
|
|
93
|
+
'CORS_ENABLED=true',
|
|
94
|
+
'CORS_ORIGINS=*',
|
|
95
|
+
'CORS_METHODS=GET,POST,PUT,PATCH,DELETE',
|
|
96
|
+
'CORS_ALLOWED_HEADERS=Content-Type,Authorization',
|
|
97
|
+
'CORS_EXPOSED_HEADERS=',
|
|
98
|
+
'CORS_CREDENTIALS=false',
|
|
99
|
+
'CORS_MAX_AGE=86400',
|
|
100
|
+
'',
|
|
101
|
+
'RATE_LIMIT_ENABLED=true',
|
|
102
|
+
'RATE_LIMIT_WINDOW_MS=900000',
|
|
103
|
+
'RATE_LIMIT_MAX_REQUESTS=100',
|
|
104
|
+
'RATE_LIMIT_MESSAGE=Too many requests, please try again later',
|
|
105
|
+
'',
|
|
106
|
+
'HELMET_ENABLED=true',
|
|
107
|
+
'CSP_ENABLED=false',
|
|
108
|
+
'HSTS_ENABLED=false',
|
|
109
|
+
'HSTS_MAX_AGE=31536000',
|
|
110
|
+
'HSTS_INCLUDE_SUBDOMAINS=true',
|
|
111
|
+
'XSS_ENABLED=true',
|
|
112
|
+
'XSS_REPORT_URI=',
|
|
113
|
+
'',
|
|
114
|
+
'SESSION_NAME=zintrust_session',
|
|
115
|
+
'SESSION_SECRET=',
|
|
116
|
+
'SESSION_EXPIRES_IN=1800000',
|
|
117
|
+
'SESSION_SECURE=false',
|
|
118
|
+
'SESSION_HTTP_ONLY=true',
|
|
119
|
+
'SESSION_SAME_SITE=lax',
|
|
120
|
+
'',
|
|
121
|
+
'PASSWORD_MIN_LENGTH=8',
|
|
122
|
+
'PASSWORD_REQUIRE_UPPERCASE=true',
|
|
123
|
+
'PASSWORD_REQUIRE_NUMBERS=true',
|
|
124
|
+
'PASSWORD_REQUIRE_SPECIAL_CHARS=true',
|
|
125
|
+
'BCRYPT_ROUNDS=10',
|
|
126
|
+
'',
|
|
127
|
+
'# ============================================================================',
|
|
128
|
+
'# DEPLOYMENT / LIMITS',
|
|
129
|
+
'# ============================================================================',
|
|
130
|
+
'',
|
|
131
|
+
'ENVIRONMENT=development',
|
|
132
|
+
'REQUEST_TIMEOUT=30000',
|
|
133
|
+
'APP_TIMEZONE=UTC',
|
|
134
|
+
'MAX_BODY_SIZE=10485760',
|
|
135
|
+
'SHUTDOWN_TIMEOUT=10000',
|
|
136
|
+
'',
|
|
137
|
+
];
|
|
138
|
+
const DatabaseAndCloudflare = (databaseNormalized, dbLines, sqliteDbPath) => [
|
|
139
|
+
'# ============================================================================',
|
|
140
|
+
'# DATABASE',
|
|
141
|
+
'# ============================================================================',
|
|
142
|
+
'',
|
|
143
|
+
'# Options: sqlite | postgresql | mysql | sqlserver | d1 | d1-remote',
|
|
144
|
+
`DB_CONNECTION=${databaseNormalized}`,
|
|
145
|
+
'',
|
|
146
|
+
...(databaseNormalized === 'sqlite' ? [`DB_PATH=${sqliteDbPath}`, ''] : []),
|
|
147
|
+
...dbLines,
|
|
148
|
+
'',
|
|
149
|
+
'# Generic SQL defaults (used by some adapters)',
|
|
150
|
+
'DB_HOST=localhost',
|
|
151
|
+
'DB_PORT=5432',
|
|
152
|
+
'DB_DATABASE=',
|
|
153
|
+
'DB_USERNAME=postgres',
|
|
154
|
+
'DB_PASSWORD=',
|
|
155
|
+
'DB_READ_HOSTS=',
|
|
156
|
+
'',
|
|
157
|
+
'# PostgreSQL (optional)',
|
|
158
|
+
'DB_PORT_POSTGRESQL=5432',
|
|
159
|
+
'DB_DATABASE_POSTGRESQL=postgres',
|
|
160
|
+
'DB_USERNAME_POSTGRESQL=postgres',
|
|
161
|
+
'DB_PASSWORD_POSTGRESQL=',
|
|
162
|
+
'DB_READ_HOSTS_POSTGRESQL=',
|
|
163
|
+
'',
|
|
164
|
+
'# SQL Server (MSSQL) (optional)',
|
|
165
|
+
'DB_HOST_MSSQL=localhost',
|
|
166
|
+
'DB_PORT_MSSQL=1433',
|
|
167
|
+
'DB_DATABASE_MSSQL=zintrust',
|
|
168
|
+
'DB_USERNAME_MSSQL=sa',
|
|
169
|
+
'DB_PASSWORD_MSSQL=',
|
|
170
|
+
'DB_READ_HOSTS_MSSQL=',
|
|
171
|
+
'',
|
|
172
|
+
'# Pooling / logging (optional)',
|
|
173
|
+
'DB_POOLING=true',
|
|
174
|
+
'DB_POOL_MIN=5',
|
|
175
|
+
'DB_POOL_MAX=20',
|
|
176
|
+
'DB_IDLE_TIMEOUT=30000',
|
|
177
|
+
'DB_CONNECTION_TIMEOUT=10000',
|
|
178
|
+
'DB_SSL=false',
|
|
179
|
+
'DB_LOG_QUERIES=false',
|
|
180
|
+
'DB_LOG_LEVEL=info',
|
|
181
|
+
'DB_MIGRATION_EXT=ts',
|
|
182
|
+
'',
|
|
183
|
+
'# ============================================================================',
|
|
184
|
+
'# CLOUDFLARE (D1 / KV)',
|
|
185
|
+
'# ============================================================================',
|
|
186
|
+
'',
|
|
187
|
+
'D1_DATABASE_ID=',
|
|
188
|
+
'KV_NAMESPACE_ID=',
|
|
189
|
+
'',
|
|
190
|
+
'# Remote D1 (outside Cloudflare) via proxy',
|
|
191
|
+
'D1_REMOTE_URL=',
|
|
192
|
+
'D1_REMOTE_KEY_ID=',
|
|
193
|
+
'D1_REMOTE_SECRET=',
|
|
194
|
+
'D1_REMOTE_MODE=registry',
|
|
195
|
+
'',
|
|
196
|
+
'# Remote KV (outside Cloudflare) via proxy',
|
|
197
|
+
'KV_REMOTE_URL=',
|
|
198
|
+
'KV_REMOTE_KEY_ID=',
|
|
199
|
+
'KV_REMOTE_SECRET=',
|
|
200
|
+
'KV_REMOTE_NAMESPACE=',
|
|
201
|
+
'',
|
|
202
|
+
'# Cloudflare API (only needed for CLI provisioning)',
|
|
203
|
+
'CLOUDFLARE_ACCOUNT_ID=',
|
|
204
|
+
'CLOUDFLARE_API_TOKEN=',
|
|
205
|
+
'CLOUDFLARE_KV_NAMESPACE_ID=',
|
|
206
|
+
'',
|
|
207
|
+
];
|
|
208
|
+
const HttpProxies = () => [
|
|
209
|
+
'# ============================================================================',
|
|
210
|
+
'# HTTP PROXIES (for Workers compatibility)',
|
|
211
|
+
'# ============================================================================',
|
|
212
|
+
'',
|
|
213
|
+
'ZT_PROXY_TIMEOUT_MS=30000',
|
|
214
|
+
'ZT_PROXY_SIGNING_WINDOW_MS=60000',
|
|
215
|
+
'',
|
|
216
|
+
'USE_MYSQL_PROXY=false',
|
|
217
|
+
'MYSQL_PROXY_URL=',
|
|
218
|
+
'MYSQL_PROXY_HOST=127.0.0.1',
|
|
219
|
+
'MYSQL_PROXY_PORT=8789',
|
|
220
|
+
'MYSQL_PROXY_MAX_BODY_BYTES=131072',
|
|
221
|
+
'MYSQL_PROXY_POOL_LIMIT=10',
|
|
222
|
+
'MYSQL_PROXY_KEY_ID=',
|
|
223
|
+
'MYSQL_PROXY_SECRET=',
|
|
224
|
+
'MYSQL_PROXY_TIMEOUT_MS=30000',
|
|
225
|
+
'MYSQL_PROXY_REQUIRE_SIGNING=true',
|
|
226
|
+
'MYSQL_PROXY_SIGNING_WINDOW_MS=60000',
|
|
227
|
+
'',
|
|
228
|
+
'USE_POSTGRES_PROXY=false',
|
|
229
|
+
'POSTGRES_PROXY_URL=',
|
|
230
|
+
'POSTGRES_PROXY_HOST=127.0.0.1',
|
|
231
|
+
'POSTGRES_PROXY_PORT=8790',
|
|
232
|
+
'POSTGRES_PROXY_MAX_BODY_BYTES=131072',
|
|
233
|
+
'POSTGRES_PROXY_POOL_LIMIT=10',
|
|
234
|
+
'POSTGRES_PROXY_KEY_ID=',
|
|
235
|
+
'POSTGRES_PROXY_SECRET=',
|
|
236
|
+
'POSTGRES_PROXY_TIMEOUT_MS=30000',
|
|
237
|
+
'POSTGRES_PROXY_REQUIRE_SIGNING=true',
|
|
238
|
+
'POSTGRES_PROXY_SIGNING_WINDOW_MS=60000',
|
|
239
|
+
'',
|
|
240
|
+
'USE_REDIS_PROXY=false',
|
|
241
|
+
'REDIS_PROXY_URL=',
|
|
242
|
+
'REDIS_PROXY_HOST=127.0.0.1',
|
|
243
|
+
'REDIS_PROXY_PORT=8791',
|
|
244
|
+
'REDIS_PROXY_MAX_BODY_BYTES=131072',
|
|
245
|
+
'REDIS_PROXY_KEY_ID=',
|
|
246
|
+
'REDIS_PROXY_SECRET=',
|
|
247
|
+
'REDIS_PROXY_TIMEOUT_MS=30000',
|
|
248
|
+
'REDIS_PROXY_REQUIRE_SIGNING=true',
|
|
249
|
+
'REDIS_PROXY_SIGNING_WINDOW_MS=60000',
|
|
250
|
+
'',
|
|
251
|
+
'USE_SMTP_PROXY=false',
|
|
252
|
+
'SMTP_PROXY_URL=',
|
|
253
|
+
'SMTP_PROXY_HOST=127.0.0.1',
|
|
254
|
+
'SMTP_PROXY_PORT=8794',
|
|
255
|
+
'SMTP_PROXY_MAX_BODY_BYTES=131072',
|
|
256
|
+
'SMTP_PROXY_KEY_ID=',
|
|
257
|
+
'SMTP_PROXY_SECRET=',
|
|
258
|
+
'SMTP_PROXY_TIMEOUT_MS=30000',
|
|
259
|
+
'SMTP_PROXY_REQUIRE_SIGNING=true',
|
|
260
|
+
'SMTP_PROXY_SIGNING_WINDOW_MS=60000',
|
|
261
|
+
'',
|
|
262
|
+
'USE_MONGODB_PROXY=false',
|
|
263
|
+
'MONGODB_PROXY_URL=',
|
|
264
|
+
'MONGODB_PROXY_HOST=127.0.0.1',
|
|
265
|
+
'MONGODB_PROXY_PORT=8792',
|
|
266
|
+
'MONGODB_PROXY_MAX_BODY_BYTES=131072',
|
|
267
|
+
'MONGODB_PROXY_KEY_ID=',
|
|
268
|
+
'MONGODB_PROXY_SECRET=',
|
|
269
|
+
'MONGODB_PROXY_TIMEOUT_MS=30000',
|
|
270
|
+
'MONGODB_PROXY_REQUIRE_SIGNING=true',
|
|
271
|
+
'MONGODB_PROXY_SIGNING_WINDOW_MS=60000',
|
|
272
|
+
'',
|
|
273
|
+
'USE_SQLSERVER_PROXY=false',
|
|
274
|
+
'SQLSERVER_PROXY_URL=',
|
|
275
|
+
'SQLSERVER_PROXY_HOST=127.0.0.1',
|
|
276
|
+
'SQLSERVER_PROXY_PORT=8793',
|
|
277
|
+
'SQLSERVER_PROXY_MAX_BODY_BYTES=131072',
|
|
278
|
+
'SQLSERVER_PROXY_POOL_LIMIT=10',
|
|
279
|
+
'SQLSERVER_PROXY_KEY_ID=',
|
|
280
|
+
'SQLSERVER_PROXY_SECRET=',
|
|
281
|
+
'SQLSERVER_PROXY_TIMEOUT_MS=30000',
|
|
282
|
+
'SQLSERVER_PROXY_REQUIRE_SIGNING=true',
|
|
283
|
+
'SQLSERVER_PROXY_SIGNING_WINDOW_MS=60000',
|
|
284
|
+
'',
|
|
285
|
+
];
|
|
286
|
+
const CacheAndRedis = () => [
|
|
287
|
+
'# ============================================================================',
|
|
288
|
+
'# CACHE / REDIS',
|
|
289
|
+
'# ============================================================================',
|
|
290
|
+
'',
|
|
291
|
+
'CACHE_DRIVER=memory',
|
|
292
|
+
'CACHE_CONNECTION=',
|
|
293
|
+
'CACHE_KEY_PREFIX=zintrust:',
|
|
294
|
+
'',
|
|
295
|
+
'CACHE_MEMORY_TTL=3600',
|
|
296
|
+
'CACHE_REDIS_TTL=3600',
|
|
297
|
+
'CACHE_MONGO_TTL=3600',
|
|
298
|
+
'CACHE_KV_TTL=3600',
|
|
299
|
+
'',
|
|
300
|
+
'REDIS_HOST=localhost',
|
|
301
|
+
'REDIS_PORT=6379',
|
|
302
|
+
'REDIS_PASSWORD=',
|
|
303
|
+
'REDIS_DB=0',
|
|
304
|
+
'REDIS_QUEUE_DB=1',
|
|
305
|
+
'REDIS_URL=',
|
|
306
|
+
'',
|
|
307
|
+
'REDIS_HTTPS_ENDPOINT=',
|
|
308
|
+
'REDIS_HTTPS_TOKEN=',
|
|
309
|
+
'',
|
|
310
|
+
'MONGO_URI=',
|
|
311
|
+
'MONGO_DB=zintrust_cache',
|
|
312
|
+
'',
|
|
313
|
+
];
|
|
314
|
+
const QueueConfig = () => [
|
|
315
|
+
'# ============================================================================',
|
|
316
|
+
'# QUEUE',
|
|
317
|
+
'# ============================================================================',
|
|
318
|
+
'',
|
|
319
|
+
'# Options: sync | memory | database | redis | rabbitmq | sqs',
|
|
320
|
+
'QUEUE_DRIVER=sync',
|
|
321
|
+
'QUEUE_CONNECTION=',
|
|
322
|
+
'',
|
|
323
|
+
'QUEUE_TABLE=jobs',
|
|
324
|
+
'QUEUE_DB_CONNECTION=default',
|
|
325
|
+
'',
|
|
326
|
+
'FAILED_JOBS_DB_CONNECTION=default',
|
|
327
|
+
'FAILED_JOBS_TABLE=failed_jobs',
|
|
328
|
+
'',
|
|
329
|
+
'QUEUE_JOB_TIMEOUT=60',
|
|
330
|
+
'QUEUE_JOB_RETRIES=3',
|
|
331
|
+
'QUEUE_JOB_BACKOFF=0',
|
|
332
|
+
'QUEUE_WORKERS=1',
|
|
333
|
+
'QUEUE_MEMORY_TTL=3600000',
|
|
334
|
+
'',
|
|
335
|
+
'QUEUE_MONITOR_ENABLED=true',
|
|
336
|
+
'QUEUE_MONITOR_BASE_PATH=/queue-monitor',
|
|
337
|
+
'QUEUE_MONITOR_MIDDLEWARE=',
|
|
338
|
+
'QUEUE_MONITOR_AUTO_REFRESH=true',
|
|
339
|
+
'QUEUE_MONITOR_REFRESH_MS=5000',
|
|
340
|
+
'',
|
|
341
|
+
'QUEUE_HTTP_PROXY_ENABLED=false',
|
|
342
|
+
'QUEUE_HTTP_PROXY_GATEWAY_ENABLED=true',
|
|
343
|
+
'QUEUE_HTTP_PROXY_URL=',
|
|
344
|
+
'QUEUE_HTTP_PROXY_PATH=/api/_sys/queue/rpc',
|
|
345
|
+
'QUEUE_HTTP_PROXY_KEY_ID=',
|
|
346
|
+
'QUEUE_HTTP_PROXY_KEY=',
|
|
347
|
+
'QUEUE_HTTP_PROXY_TIMEOUT_MS=30000',
|
|
348
|
+
'QUEUE_HTTP_PROXY_MAX_SKEW_MS=60000',
|
|
349
|
+
'QUEUE_HTTP_PROXY_NONCE_TTL_MS=120000',
|
|
350
|
+
'QUEUE_HTTP_PROXY_MIDDLEWARE=',
|
|
351
|
+
'',
|
|
352
|
+
];
|
|
353
|
+
const WorkersSchedulingAndSSE = () => [
|
|
354
|
+
'# ============================================================================',
|
|
355
|
+
'# WORKERS / SCHEDULER',
|
|
356
|
+
'# ============================================================================',
|
|
357
|
+
'',
|
|
358
|
+
'WORKER_ENABLED=true',
|
|
359
|
+
'WORKER_AUTO_START=false',
|
|
360
|
+
'WORKER_CONCURRENCY=5',
|
|
361
|
+
'WORKER_TIMEOUT=60',
|
|
362
|
+
'WORKER_RETRIES=3',
|
|
363
|
+
'WORKER_PRIORITY=1',
|
|
364
|
+
'WORKER_HEALTH_CHECK_INTERVAL=60',
|
|
365
|
+
'WORKER_CLUSTER_MODE=true',
|
|
366
|
+
'WORKER_REGION=us-east-1',
|
|
367
|
+
'',
|
|
368
|
+
'WORKER_PERSISTENCE_DRIVER=memory',
|
|
369
|
+
'WORKER_PERSISTENCE_TABLE=zintrust_workers',
|
|
370
|
+
'WORKER_PERSISTENCE_DB_CONNECTION=default',
|
|
371
|
+
'WORKER_PERSISTENCE_REDIS_DB=',
|
|
372
|
+
'WORKER_PERSISTENCE_REDIS_KEY_PREFIX=',
|
|
373
|
+
'',
|
|
374
|
+
'WORKER_SHUTDOWN_ON_APP_EXIT=true',
|
|
375
|
+
'',
|
|
376
|
+
'SCHEDULES_ENABLED=false',
|
|
377
|
+
'SCHEDULE_SHUTDOWN_TIMEOUT_MS=30000',
|
|
378
|
+
'SCHEDULE_OVERLAP_LOCK_TTL_MS=300000',
|
|
379
|
+
'SCHEDULE_OVERLAP_LOCK_ACQUIRE_TIMEOUT_MS=2000',
|
|
380
|
+
'',
|
|
381
|
+
'SCHEDULE_LEADER_ENABLED=false',
|
|
382
|
+
'SCHEDULE_LEADER_LOCK_PROVIDER=redis',
|
|
383
|
+
'SCHEDULE_LEADER_LOCK_KEY=scheduler:leader',
|
|
384
|
+
'SCHEDULE_LEADER_LOCK_TTL_MS=30000',
|
|
385
|
+
'SCHEDULE_LEADER_LOCK_RENEW_MS=15000',
|
|
386
|
+
'SCHEDULE_LEADER_LOCK_RETRY_MS=5000',
|
|
387
|
+
'SCHEDULE_LEADER_LOCK_ACQUIRE_TIMEOUT_MS=2000',
|
|
388
|
+
'',
|
|
389
|
+
'SCHEDULE_HTTP_PROXY_PATH=/api/_sys/schedule/rpc',
|
|
390
|
+
'SCHEDULE_HTTP_PROXY_KEY_ID=',
|
|
391
|
+
'SCHEDULE_HTTP_PROXY_KEY=',
|
|
392
|
+
'SCHEDULE_HTTP_PROXY_MAX_SKEW_MS=60000',
|
|
393
|
+
'SCHEDULE_HTTP_PROXY_NONCE_TTL_MS=120000',
|
|
394
|
+
'SCHEDULE_HTTP_PROXY_MIDDLEWARE=',
|
|
395
|
+
'',
|
|
396
|
+
'JOB_TRACKING_CLEANUP_ENABLED=false',
|
|
397
|
+
'JOB_TRACKING_CLEANUP_INTERVAL_MS=21600000',
|
|
398
|
+
'JOB_TRACKING_CLEANUP_RETENTION_DAYS=30',
|
|
399
|
+
'JOB_TRACKING_CLEANUP_RETENTION_HOURS=',
|
|
400
|
+
'JOB_TRACKING_CLEANUP_BATCH_SIZE=5000',
|
|
401
|
+
'JOB_TRACKING_CLEANUP_MAX_BATCHES=1',
|
|
402
|
+
'JOB_TRACKING_CLEANUP_LOCK_PROVIDER=redis',
|
|
403
|
+
'',
|
|
404
|
+
'# ============================================================================',
|
|
405
|
+
'# SSE',
|
|
406
|
+
'# ============================================================================',
|
|
407
|
+
'',
|
|
408
|
+
'SSE_HEARTBEAT_INTERVAL=15000',
|
|
409
|
+
'SSE_SNAPSHOT_INTERVAL=5000',
|
|
410
|
+
'',
|
|
411
|
+
];
|
|
412
|
+
const LoggingAndMail = () => [
|
|
413
|
+
'# ============================================================================',
|
|
414
|
+
'# LOGGING',
|
|
415
|
+
'# ============================================================================',
|
|
416
|
+
'',
|
|
417
|
+
'LOG_LEVEL=debug',
|
|
418
|
+
'LOG_FORMAT=text',
|
|
419
|
+
'LOG_CHANNEL=file',
|
|
420
|
+
'DISABLE_LOGGING=false',
|
|
421
|
+
'LOG_HTTP_REQUEST=false',
|
|
422
|
+
'LOG_TO_FILE=false',
|
|
423
|
+
'LOG_ROTATION_SIZE=10485760',
|
|
424
|
+
'LOG_ROTATION_DAYS=7',
|
|
425
|
+
'DOCKER_WORKER=false',
|
|
426
|
+
'',
|
|
427
|
+
'# ============================================================================',
|
|
428
|
+
'# MAIL',
|
|
429
|
+
'# ============================================================================',
|
|
430
|
+
'',
|
|
431
|
+
'MAIL_DRIVER=disabled',
|
|
432
|
+
'MAIL_CONNECTION=',
|
|
433
|
+
'MAIL_FROM_ADDRESS=',
|
|
434
|
+
'MAIL_FROM_NAME=',
|
|
435
|
+
'MAIL_HOST=',
|
|
436
|
+
'MAIL_PORT=587',
|
|
437
|
+
'MAIL_USERNAME=',
|
|
438
|
+
'MAIL_PASSWORD',
|
|
439
|
+
'MAIL_SECURE=starttls',
|
|
440
|
+
'SENDGRID_API_KEY=',
|
|
441
|
+
'MAILGUN_API_KEY=',
|
|
442
|
+
'MAILGUN_DOMAIN=',
|
|
443
|
+
'MAILGUN_BASE_URL=https://api.mailgun.net',
|
|
444
|
+
'',
|
|
445
|
+
];
|
|
446
|
+
const StorageAndBroadcast = () => [
|
|
447
|
+
'# ============================================================================',
|
|
448
|
+
'# STORAGE',
|
|
449
|
+
'# ============================================================================',
|
|
450
|
+
'',
|
|
451
|
+
'STORAGE_CONNECTION=local',
|
|
452
|
+
'STORAGE_PATH=storage',
|
|
453
|
+
'STORAGE_URL=/storage',
|
|
454
|
+
'STORAGE_VISIBILITY=private',
|
|
455
|
+
'TEMP_PATH=storage/temp',
|
|
456
|
+
'TEMP_FILE_MAX_AGE=86400',
|
|
457
|
+
'MAX_UPLOAD_SIZE=100mb',
|
|
458
|
+
'ALLOWED_UPLOAD_MIMES=jpg,jpeg,png,pdf,doc,docx',
|
|
459
|
+
'UPLOADS_PATH=storage/uploads',
|
|
460
|
+
'BACKUP_DRIVER=s3',
|
|
461
|
+
'BACKUPS_PATH=storage/backups',
|
|
462
|
+
'',
|
|
463
|
+
'AWS_REGION=us-east-1',
|
|
464
|
+
'AWS_DEFAULT_REGION=',
|
|
465
|
+
'AWS_ACCESS_KEY_ID=',
|
|
466
|
+
'AWS_SECRET_ACCESS_KEY=',
|
|
467
|
+
'AWS_SESSION_TOKEN=',
|
|
468
|
+
'AWS_S3_BUCKET=',
|
|
469
|
+
'AWS_S3_ENDPOINT=',
|
|
470
|
+
'AWS_S3_URL=',
|
|
471
|
+
'AWS_S3_USE_PATH_STYLE_URL=false',
|
|
472
|
+
'AWS_SQS_QUEUE_URL=',
|
|
473
|
+
'',
|
|
474
|
+
'R2_ACCESS_KEY_ID=',
|
|
475
|
+
'R2_SECRET_ACCESS_KEY=',
|
|
476
|
+
'R2_REGION=',
|
|
477
|
+
'R2_BUCKET=',
|
|
478
|
+
'R2_ENDPOINT=',
|
|
479
|
+
'R2_URL=',
|
|
480
|
+
'R2_BINDING=',
|
|
481
|
+
'',
|
|
482
|
+
'GCS_PROJECT_ID=',
|
|
483
|
+
'GCS_KEY_FILE=',
|
|
484
|
+
'GCS_BUCKET=',
|
|
485
|
+
'GCS_URL=',
|
|
486
|
+
'',
|
|
487
|
+
'# ============================================================================',
|
|
488
|
+
'# BROADCAST',
|
|
489
|
+
'# ============================================================================',
|
|
490
|
+
'',
|
|
491
|
+
'BROADCAST_CONNECTION=inmemory',
|
|
492
|
+
'PUSHER_APP_ID=',
|
|
493
|
+
'PUSHER_APP_KEY=',
|
|
494
|
+
'PUSHER_APP_SECRET=',
|
|
495
|
+
'PUSHER_APP_CLUSTER=',
|
|
496
|
+
'PUSHER_USE_TLS=true',
|
|
497
|
+
'BROADCAST_REDIS_HOST=',
|
|
498
|
+
'BROADCAST_REDIS_PORT=',
|
|
499
|
+
'BROADCAST_REDIS_PASSWORD=',
|
|
500
|
+
'BROADCAST_CHANNEL_PREFIX=broadcast:',
|
|
501
|
+
'',
|
|
502
|
+
];
|
|
503
|
+
const NotificationsAndObservability = () => [
|
|
504
|
+
'# ============================================================================',
|
|
505
|
+
'# NOTIFICATIONS',
|
|
506
|
+
'# ============================================================================',
|
|
507
|
+
'',
|
|
508
|
+
'NOTIFICATION_CONNECTION=console',
|
|
509
|
+
'TERMII_API_KEY=',
|
|
510
|
+
'TERMII_SENDER=ZinTrust',
|
|
511
|
+
'TERMII_ENDPOINT=https://api.termii.com/sms/send',
|
|
512
|
+
'TWILIO_ACCOUNT_SID=',
|
|
513
|
+
'TWILIO_AUTH_TOKEN=',
|
|
514
|
+
'TWILIO_FROM_NUMBER=',
|
|
515
|
+
'SLACK_WEBHOOK_URL=',
|
|
516
|
+
'',
|
|
517
|
+
'# ============================================================================',
|
|
518
|
+
'# OBSERVABILITY (optional)',
|
|
519
|
+
'# ============================================================================',
|
|
520
|
+
'',
|
|
521
|
+
'OTEL_ENABLED=false',
|
|
522
|
+
'OTEL_EXPORTER_OTLP_ENDPOINT=',
|
|
523
|
+
'TRACING_EXPORT_INTERVAL=',
|
|
524
|
+
'JAEGER_AGENT_HOST=',
|
|
525
|
+
'',
|
|
526
|
+
'# ============================================================================',
|
|
527
|
+
'# CI / SCANNING (optional)',
|
|
528
|
+
'# ============================================================================',
|
|
529
|
+
'',
|
|
530
|
+
'SNYK_TOKEN=',
|
|
531
|
+
'SONAR_ORGANIZATION=',
|
|
532
|
+
'SONAR_PROJECT_ID=',
|
|
533
|
+
'SONAR_HOST_URL=',
|
|
534
|
+
'SONAR_TOKEN=',
|
|
535
|
+
'CODECOV_TOKEN=',
|
|
536
|
+
'',
|
|
537
|
+
];
|
|
538
|
+
export const EnvData = (name, port, baseUrl, appKey, databaseNormalized, dbLines, sqliteDbPath) => [
|
|
539
|
+
...HeaderAndApp(name, port, baseUrl, appKey),
|
|
540
|
+
...SecurityAndDeployment(),
|
|
541
|
+
...DatabaseAndCloudflare(databaseNormalized, dbLines, sqliteDbPath),
|
|
542
|
+
...HttpProxies(),
|
|
543
|
+
...CacheAndRedis(),
|
|
544
|
+
...QueueConfig(),
|
|
545
|
+
...WorkersSchedulingAndSSE(),
|
|
546
|
+
...LoggingAndMail(),
|
|
547
|
+
...StorageAndBroadcast(),
|
|
548
|
+
...NotificationsAndObservability(),
|
|
549
|
+
];
|
|
@@ -166,7 +166,7 @@ const load = (options = {}) => {
|
|
|
166
166
|
cached = { loadedFiles: files, mode };
|
|
167
167
|
return cached;
|
|
168
168
|
};
|
|
169
|
-
const ensureLoaded = () => load({ overrideExisting:
|
|
169
|
+
const ensureLoaded = () => load({ overrideExisting: false });
|
|
170
170
|
const applyCliOverrides = (overrides) => {
|
|
171
171
|
// Ensure base env is loaded first.
|
|
172
172
|
ensureLoaded();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../src/config/logger.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../src/config/logger.ts"],"names":[],"mappings":"AAUA,UAAU,OAAO;IACf,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAChE,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/D,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/D,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACjE,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAClE;AA8aD,eAAO,MAAM,aAAa,QAAa,OAAO,CAAC,MAAM,EAAE,CAYtD,CAAC;AAEF,eAAO,MAAM,MAAM;qBA5JQ,MAAM,SAAS,OAAO,aAAa,MAAM,KAAG,IAAI;oBAqBjD,MAAM,SAAS,OAAO,aAAa,MAAM,KAAG,IAAI;oBAqBhD,MAAM,SAAS,OAAO,aAAa,MAAM,KAAG,IAAI;qBAqB/C,MAAM,UAAU,OAAO,aAAa,MAAM,KAAG,IAAI;qBA2BjD,MAAM,UAAU,OAAO,aAAa,MAAM,KAAG,IAAI;yBAoDrC,OAAO,CAAC,MAAM,EAAE,CAAC;mBArBtB,MAAM,KAAG,OAAO;EA2ChD,CAAC;AAEH,eAAe,MAAM,CAAC"}
|
package/src/config/logger.js
CHANGED
|
@@ -3,10 +3,38 @@
|
|
|
3
3
|
* Sealed namespace pattern - all exports through Logger namespace
|
|
4
4
|
* Replaces console.* calls throughout the codebase
|
|
5
5
|
*/
|
|
6
|
+
import { isNonEmptyString } from '../helper/index.js';
|
|
6
7
|
import { appConfig } from './app.js';
|
|
7
8
|
import { Env } from './env.js';
|
|
8
9
|
const isProduction = () => appConfig.isProduction();
|
|
9
|
-
const
|
|
10
|
+
const getEnvString = (key, fallback) => {
|
|
11
|
+
const envGet = Env.get;
|
|
12
|
+
if (typeof envGet !== 'function')
|
|
13
|
+
return fallback;
|
|
14
|
+
try {
|
|
15
|
+
const value = envGet(key, fallback);
|
|
16
|
+
if (typeof value === 'string')
|
|
17
|
+
return value;
|
|
18
|
+
if (value === null || value === undefined)
|
|
19
|
+
return fallback;
|
|
20
|
+
return String(value);
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
return fallback;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
const getEnvBool = (key, fallback) => {
|
|
27
|
+
const envGetBool = Env.getBool;
|
|
28
|
+
if (typeof envGetBool !== 'function')
|
|
29
|
+
return fallback;
|
|
30
|
+
try {
|
|
31
|
+
return envGetBool(key, fallback);
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
return fallback;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
const getLogFormat = () => getEnvString('LOG_FORMAT', 'text');
|
|
10
38
|
const isJsonFormat = (value) => value === 'json';
|
|
11
39
|
// Log level priority: lower means more verbose
|
|
12
40
|
const levelPriority = {
|
|
@@ -17,7 +45,7 @@ const levelPriority = {
|
|
|
17
45
|
fatal: 4,
|
|
18
46
|
};
|
|
19
47
|
const getConfiguredLogLevel = () => {
|
|
20
|
-
const raw =
|
|
48
|
+
const raw = getEnvString('LOG_LEVEL', Env.LOG_LEVEL ?? 'debug')
|
|
21
49
|
.trim()
|
|
22
50
|
.toLowerCase();
|
|
23
51
|
if (raw === 'debug')
|
|
@@ -32,7 +60,7 @@ const getConfiguredLogLevel = () => {
|
|
|
32
60
|
};
|
|
33
61
|
const shouldEmit = (level) => {
|
|
34
62
|
// If global disable, never emit
|
|
35
|
-
if (
|
|
63
|
+
if (getEnvBool('DISABLE_LOGGING', false))
|
|
36
64
|
return false;
|
|
37
65
|
// Respect configured LOG_LEVEL
|
|
38
66
|
const configured = getConfiguredLogLevel();
|
|
@@ -40,8 +68,7 @@ const shouldEmit = (level) => {
|
|
|
40
68
|
const configuredLp = levelPriority[configured] ?? levelPriority['info'];
|
|
41
69
|
return lp >= configuredLp;
|
|
42
70
|
};
|
|
43
|
-
|
|
44
|
-
const SENSITIVE_FIELDS = new Set([
|
|
71
|
+
const BASE_SENSITIVE_FIELDS = Object.freeze([
|
|
45
72
|
'password',
|
|
46
73
|
'token',
|
|
47
74
|
'authorization',
|
|
@@ -51,7 +78,27 @@ const SENSITIVE_FIELDS = new Set([
|
|
|
51
78
|
'jwt',
|
|
52
79
|
'bearer',
|
|
53
80
|
]);
|
|
81
|
+
const SENSITIVE_FIELD_KEY_PATTERN = /^[a-z0-9_.-]+$/;
|
|
82
|
+
const parseSensitiveFields = (rawValue) => {
|
|
83
|
+
try {
|
|
84
|
+
return rawValue
|
|
85
|
+
.split(',')
|
|
86
|
+
.map((value) => value.trim().toLowerCase())
|
|
87
|
+
.filter((value) => isNonEmptyString(value) && SENSITIVE_FIELD_KEY_PATTERN.test(value));
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
return [];
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
const getSensitiveFields = () => {
|
|
94
|
+
const configuredFieldsRaw = getEnvString('SENSITIVE_FIELDS', '');
|
|
95
|
+
const configuredFields = isNonEmptyString(configuredFieldsRaw)
|
|
96
|
+
? parseSensitiveFields(configuredFieldsRaw)
|
|
97
|
+
: [];
|
|
98
|
+
return new Set([...BASE_SENSITIVE_FIELDS, ...configuredFields]);
|
|
99
|
+
};
|
|
54
100
|
const redactSensitiveData = (data) => {
|
|
101
|
+
const sensitiveFields = getSensitiveFields();
|
|
55
102
|
const seen = new WeakSet();
|
|
56
103
|
const walk = (value) => {
|
|
57
104
|
if (Array.isArray(value)) {
|
|
@@ -67,7 +114,7 @@ const redactSensitiveData = (data) => {
|
|
|
67
114
|
seen.add(asObj);
|
|
68
115
|
const out = {};
|
|
69
116
|
for (const [key, inner] of Object.entries(asObj)) {
|
|
70
|
-
if (
|
|
117
|
+
if (sensitiveFields.has(key.toLowerCase())) {
|
|
71
118
|
out[key] = '[REDACTED]';
|
|
72
119
|
}
|
|
73
120
|
else {
|
|
@@ -111,12 +158,12 @@ const getFileWriter = () => {
|
|
|
111
158
|
};
|
|
112
159
|
const shouldLogToFile = () => {
|
|
113
160
|
// Respect global disable
|
|
114
|
-
if (
|
|
161
|
+
if (getEnvBool('DISABLE_LOGGING', false))
|
|
115
162
|
return false;
|
|
116
163
|
// Prefer dynamic lookup so late-bound env (tests, some runtimes) is respected.
|
|
117
|
-
const channel =
|
|
164
|
+
const channel = getEnvString('LOG_CHANNEL', '').trim().toLowerCase();
|
|
118
165
|
const channelWantsFile = channel === 'file' || channel === 'all';
|
|
119
|
-
if (!
|
|
166
|
+
if (!getEnvBool('LOG_TO_FILE', false) && !channelWantsFile)
|
|
120
167
|
return false;
|
|
121
168
|
if (typeof process === 'undefined')
|
|
122
169
|
return false;
|
package/src/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @zintrust/core v0.1.
|
|
2
|
+
* @zintrust/core v0.1.52
|
|
3
3
|
*
|
|
4
4
|
* ZinTrust Framework - Production-Grade TypeScript Backend
|
|
5
5
|
* Built for performance, type safety, and exceptional developer experience
|
|
6
6
|
*
|
|
7
7
|
* Build Information:
|
|
8
|
-
* Built: 2026-02-
|
|
8
|
+
* Built: 2026-02-27T08:07:36.891Z
|
|
9
9
|
* Node: >=20.0.0
|
|
10
10
|
* License: MIT
|
|
11
11
|
*
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* Available at runtime for debugging and health checks
|
|
22
22
|
*/
|
|
23
23
|
export const ZINTRUST_VERSION = '0.1.41';
|
|
24
|
-
export const ZINTRUST_BUILD_DATE = '2026-02-
|
|
24
|
+
export const ZINTRUST_BUILD_DATE = '2026-02-27T08:07:36.860Z'; // Replaced during build
|
|
25
25
|
export { Application } from './boot/Application.js';
|
|
26
26
|
export { AwsSigV4 } from './common/index.js';
|
|
27
27
|
export { SignedRequest } from './security/SignedRequest.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ZintrustD1Proxy.d.ts","sourceRoot":"","sources":["../../../../src/proxy/d1/ZintrustD1Proxy.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ZintrustD1Proxy.d.ts","sourceRoot":"","sources":["../../../../src/proxy/d1/ZintrustD1Proxy.ts"],"names":[],"mappings":"AA2BA,eAAO,MAAM,eAAe,EAyBZ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAExC,eAAe,eAAe,CAAC"}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { isUndefinedOrNull } from '../../helper/index.js';
|
|
2
2
|
import { Logger } from '../../config/logger.js';
|
|
3
|
-
const MODULE_ID = '@zintrust/' + 'cloudflare-d1-proxy';
|
|
4
3
|
let cached = null;
|
|
5
4
|
const load = async () => {
|
|
6
5
|
if (cached !== null)
|
|
7
6
|
return cached;
|
|
8
7
|
try {
|
|
9
8
|
// Non-literal specifier to avoid tsconfig path alias rewriting in dist builds.
|
|
10
|
-
|
|
9
|
+
const pkgName = '@zintrust/cloudflare-d1-proxy';
|
|
10
|
+
cached = (await import(pkgName));
|
|
11
11
|
return cached;
|
|
12
12
|
}
|
|
13
13
|
catch (error) {
|
|
14
|
-
Logger.error(`Optional dependency not installed:
|
|
14
|
+
Logger.error(`Optional dependency not installed: @zintrust/cloudflare-d1-proxy. Install it to use ZintrustD1Proxy.`, { error: error instanceof Error ? error.message : String(error) });
|
|
15
15
|
}
|
|
16
16
|
return undefined;
|
|
17
17
|
};
|
|
@@ -26,7 +26,7 @@ export const ZintrustD1Proxy = new Proxy({}, {
|
|
|
26
26
|
return undefined;
|
|
27
27
|
const target = mod.ZintrustD1Proxy ?? mod.default;
|
|
28
28
|
if (!target || typeof target !== 'object') {
|
|
29
|
-
Logger.error(`Invalid module export from
|
|
29
|
+
Logger.error(`Invalid module export from @zintrust/cloudflare-d1-proxy: missing ZintrustD1Proxy`);
|
|
30
30
|
return undefined;
|
|
31
31
|
}
|
|
32
32
|
const value = target[prop];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isUndefinedOrNull } from '../../helper/index.js';
|
|
2
2
|
import { Logger } from '../../config/logger.js';
|
|
3
|
-
const MODULE_ID = '@zintrust/
|
|
3
|
+
const MODULE_ID = '@zintrust/cloudflare-kv-proxy';
|
|
4
4
|
let cached = null;
|
|
5
5
|
const load = async () => {
|
|
6
6
|
if (cached !== null)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { pathToFileURL } from '../node-singletons/url.js';
|
|
2
1
|
import { readEnvString } from '../common/ExternalServiceUtils.js';
|
|
3
2
|
import { Logger } from '../config/logger.js';
|
|
4
3
|
import { existsSync, readFile } from '../node-singletons/fs.js';
|
|
5
4
|
import * as path from '../node-singletons/path.js';
|
|
5
|
+
import { pathToFileURL } from '../node-singletons/url.js';
|
|
6
6
|
const getProjectCwd = () => process.cwd();
|
|
7
7
|
const getProjectRootEnv = () => readEnvString('ZINTRUST_PROJECT_ROOT');
|
|
8
8
|
const resolveProjectRoot = () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WorkersModule.d.ts","sourceRoot":"","sources":["../../../src/runtime/WorkersModule.ts"],"names":[],"mappings":"AAOA,KAAK,aAAa,GAAG,cAAc,mBAAmB,CAAC,CAAC;AACxD,KAAK,kBAAkB,GAAG,cAAc,yBAAyB,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"WorkersModule.d.ts","sourceRoot":"","sources":["../../../src/runtime/WorkersModule.ts"],"names":[],"mappings":"AAOA,KAAK,aAAa,GAAG,cAAc,mBAAmB,CAAC,CAAC;AACxD,KAAK,kBAAkB,GAAG,cAAc,yBAAyB,CAAC,CAAC;AA+TnE,eAAO,MAAM,iBAAiB,QAAa,OAAO,CAAC,aAAa,CAwB/D,CAAC;AA2CF,eAAO,MAAM,sBAAsB,QAAa,OAAO,CAAC,kBAAkB,CAiBzE,CAAC"}
|
|
@@ -6,6 +6,44 @@ import * as path from '../node-singletons/path.js';
|
|
|
6
6
|
import { pathToFileURL } from '../node-singletons/url.js';
|
|
7
7
|
const KNOWN_EXTENSIONS = ['.js', '.mjs', '.cjs', '.json', '.node'];
|
|
8
8
|
const isNodeRuntime = () => typeof process !== 'undefined' && Boolean(process.versions?.node);
|
|
9
|
+
const readFlag = (name) => {
|
|
10
|
+
if (!isNodeRuntime())
|
|
11
|
+
return '';
|
|
12
|
+
return String(process.env?.[name] ?? '')
|
|
13
|
+
.trim()
|
|
14
|
+
.toLowerCase();
|
|
15
|
+
};
|
|
16
|
+
const isTruthy = (value) => value === '1' || value === 'true';
|
|
17
|
+
const isFalsy = (value) => value === '0' || value === 'false';
|
|
18
|
+
const shouldDisableWorkerModules = () => {
|
|
19
|
+
const dockerWorker = readFlag('DOCKER_WORKER');
|
|
20
|
+
if (isTruthy(dockerWorker))
|
|
21
|
+
return true;
|
|
22
|
+
const workerEnabled = readFlag('WORKER_ENABLED');
|
|
23
|
+
if (isFalsy(workerEnabled))
|
|
24
|
+
return true;
|
|
25
|
+
return false;
|
|
26
|
+
};
|
|
27
|
+
const createDisabledWorkersModule = () => {
|
|
28
|
+
return {
|
|
29
|
+
WorkerInit: {
|
|
30
|
+
initialize: async () => {
|
|
31
|
+
await Promise.resolve();
|
|
32
|
+
},
|
|
33
|
+
autoStartPersistedWorkers: async () => {
|
|
34
|
+
await Promise.resolve();
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
WorkerShutdown: {
|
|
38
|
+
shutdown: async () => {
|
|
39
|
+
await Promise.resolve();
|
|
40
|
+
},
|
|
41
|
+
isShuttingDown: () => false,
|
|
42
|
+
getShutdownState: () => ({ isShuttingDown: false, completedAt: null }),
|
|
43
|
+
},
|
|
44
|
+
registerWorkerRoutes: () => undefined,
|
|
45
|
+
};
|
|
46
|
+
};
|
|
9
47
|
const listJsFilesRecursive = (dir) => {
|
|
10
48
|
const out = [];
|
|
11
49
|
const stack = [dir];
|
|
@@ -161,6 +199,28 @@ let patchAttempted = false;
|
|
|
161
199
|
let patchAfterFailureAttempted = false;
|
|
162
200
|
let queueMonitorModulePromise;
|
|
163
201
|
let queueMonitorPatchAfterFailureAttempted = false;
|
|
202
|
+
let workersResolverDiagnosticLogged = false;
|
|
203
|
+
const resolvePackageEntryForDebug = (packageName) => {
|
|
204
|
+
if (!isNodeRuntime())
|
|
205
|
+
return null;
|
|
206
|
+
try {
|
|
207
|
+
const require = createRequire(import.meta.url);
|
|
208
|
+
return require.resolve(packageName);
|
|
209
|
+
}
|
|
210
|
+
catch {
|
|
211
|
+
return null;
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
const logWorkersResolverDiagnostics = () => {
|
|
215
|
+
if (workersResolverDiagnosticLogged)
|
|
216
|
+
return;
|
|
217
|
+
workersResolverDiagnosticLogged = true;
|
|
218
|
+
Logger.warn('Workers module resolver diagnostics', {
|
|
219
|
+
cwd: process.cwd(),
|
|
220
|
+
workersEntry: resolvePackageEntryForDebug('@zintrust/workers'),
|
|
221
|
+
coreEntry: resolvePackageEntryForDebug('@zintrust/core'),
|
|
222
|
+
});
|
|
223
|
+
};
|
|
164
224
|
const applyInitialPatches = () => {
|
|
165
225
|
if (patchAttempted)
|
|
166
226
|
return;
|
|
@@ -210,6 +270,11 @@ const tryLocalFallback = async () => {
|
|
|
210
270
|
return null;
|
|
211
271
|
};
|
|
212
272
|
export const loadWorkersModule = async () => {
|
|
273
|
+
if (shouldDisableWorkerModules()) {
|
|
274
|
+
Logger.info('Skipping @zintrust/workers module import (workers disabled by env).');
|
|
275
|
+
workersModulePromise ??= Promise.resolve(createDisabledWorkersModule());
|
|
276
|
+
return workersModulePromise;
|
|
277
|
+
}
|
|
213
278
|
applyInitialPatches();
|
|
214
279
|
if (workersModulePromise === undefined) {
|
|
215
280
|
const localFallback = await tryLocalFallback();
|
|
@@ -217,6 +282,7 @@ export const loadWorkersModule = async () => {
|
|
|
217
282
|
return localFallback;
|
|
218
283
|
}
|
|
219
284
|
}
|
|
285
|
+
logWorkersResolverDiagnostics();
|
|
220
286
|
workersModulePromise ??= import('@zintrust/workers');
|
|
221
287
|
try {
|
|
222
288
|
return await workersModulePromise;
|
|
@@ -6,3 +6,25 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
// Intentionally empty by default.
|
|
9
|
+
//
|
|
10
|
+
// Example: pre-register persisted worker processorSpec mappings.
|
|
11
|
+
// Uncomment and adapt to your project as needed.
|
|
12
|
+
//
|
|
13
|
+
// import { ZinTrustProcessor } from '@app/Workers/AdvancEmailWorker';
|
|
14
|
+
// import { WorkerFactory, type WorkerFactoryConfig } from '@zintrust/workers';
|
|
15
|
+
//
|
|
16
|
+
// type PreRegisteredProcessorSpec = {
|
|
17
|
+
// processorSpec: string;
|
|
18
|
+
// processor: WorkerFactoryConfig['processor'];
|
|
19
|
+
// };
|
|
20
|
+
//
|
|
21
|
+
// export const preRegisteredWorkerProcessorSpecs: ReadonlyArray<PreRegisteredProcessorSpec> = [
|
|
22
|
+
// {
|
|
23
|
+
// processorSpec: 'https://wk.zintrust.com/AdvancEmailWorker.js',
|
|
24
|
+
// processor: ZinTrustProcessor,
|
|
25
|
+
// },
|
|
26
|
+
// ];
|
|
27
|
+
//
|
|
28
|
+
// for (const entry of preRegisteredWorkerProcessorSpecs) {
|
|
29
|
+
// WorkerFactory.registerProcessorSpec(entry.processorSpec, entry.processor);
|
|
30
|
+
// }
|
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* side-effect imports (e.g. `@zintrust/db-sqlite/register`) that register
|
|
6
|
-
* optional adapters/drivers into core registries.
|
|
7
|
-
*
|
|
8
|
-
* In the ZinTrust monorepo/dev workspace, we import a local bundle of plugin
|
|
9
|
-
* registrations so `zin s` works out-of-the-box (database adapters, queue, mail).
|
|
2
|
+
* Auto-generated fallback module.
|
|
3
|
+
* This file is created by scripts/ensure-worker-plugins.mjs when missing.
|
|
4
|
+
* It allows optional runtime plugin imports to resolve in CI/scaffolded setups.
|
|
10
5
|
*/
|
|
11
|
-
import './zintrust.comon';
|
|
12
6
|
export declare const __zintrustGeneratedPluginStub = "zintrust.plugins.ts";
|
|
13
7
|
declare const _default: {};
|
|
14
8
|
export default _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zintrust.plugins.d.ts","sourceRoot":"","sources":["../../src/zintrust.plugins.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"zintrust.plugins.d.ts","sourceRoot":"","sources":["../../src/zintrust.plugins.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,eAAO,MAAM,6BAA6B,wBAAwB,CAAC;;AACnE,wBAAkB"}
|
package/src/zintrust.plugins.js
CHANGED
|
@@ -1,14 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* side-effect imports (e.g. `@zintrust/db-sqlite/register`) that register
|
|
6
|
-
* optional adapters/drivers into core registries.
|
|
7
|
-
*
|
|
8
|
-
* In the ZinTrust monorepo/dev workspace, we import a local bundle of plugin
|
|
9
|
-
* registrations so `zin s` works out-of-the-box (database adapters, queue, mail).
|
|
2
|
+
* Auto-generated fallback module.
|
|
3
|
+
* This file is created by scripts/ensure-worker-plugins.mjs when missing.
|
|
4
|
+
* It allows optional runtime plugin imports to resolve in CI/scaffolded setups.
|
|
10
5
|
*/
|
|
11
|
-
/* eslint-disable no-restricted-imports */
|
|
12
|
-
import './zintrust.comon.js';
|
|
13
6
|
export const __zintrustGeneratedPluginStub = 'zintrust.plugins.ts';
|
|
14
7
|
export default {};
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
* This file is created by scripts/ensure-worker-plugins.mjs when missing.
|
|
4
4
|
* It allows optional runtime plugin imports to resolve in CI/scaffolded setups.
|
|
5
5
|
*/
|
|
6
|
-
import './zintrust.comon';
|
|
7
6
|
export declare const __zintrustGeneratedPluginStub = "zintrust.plugins.wg.ts";
|
|
8
7
|
declare const _default: {};
|
|
9
8
|
export default _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zintrust.plugins.wg.d.ts","sourceRoot":"","sources":["../../src/zintrust.plugins.wg.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,
|
|
1
|
+
{"version":3,"file":"zintrust.plugins.wg.d.ts","sourceRoot":"","sources":["../../src/zintrust.plugins.wg.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,eAAO,MAAM,6BAA6B,2BAA2B,CAAC;;AACtE,wBAAkB"}
|
|
@@ -3,6 +3,5 @@
|
|
|
3
3
|
* This file is created by scripts/ensure-worker-plugins.mjs when missing.
|
|
4
4
|
* It allows optional runtime plugin imports to resolve in CI/scaffolded setups.
|
|
5
5
|
*/
|
|
6
|
-
import './zintrust.comon.js';
|
|
7
6
|
export const __zintrustGeneratedPluginStub = 'zintrust.plugins.wg.ts';
|
|
8
7
|
export default {};
|
package/src/zintrust.comon.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import '../packages/db-d1/src/register.js';
|
|
2
|
-
import '../packages/db-mysql/src/register.js';
|
|
3
|
-
import '../packages/db-postgres/src/register.js';
|
|
4
|
-
import '../packages/db-sqlite/src/register.js';
|
|
5
|
-
import '../packages/db-sqlserver/src/register.js';
|
|
6
|
-
import '../packages/mail-sendgrid/src/register.js';
|
|
7
|
-
import '../packages/mail-smtp/src/register.js';
|
|
8
|
-
import '../packages/queue-redis/src/register.js';
|
|
9
|
-
//# sourceMappingURL=zintrust.comon.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"zintrust.comon.d.ts","sourceRoot":"","sources":["../../src/zintrust.comon.ts"],"names":[],"mappings":"AAQA,OAAO,mCAAmC,CAAC;AAC3C,OAAO,sCAAsC,CAAC;AAC9C,OAAO,yCAAyC,CAAC;AACjD,OAAO,uCAAuC,CAAC;AAC/C,OAAO,0CAA0C,CAAC;AAClD,OAAO,2CAA2C,CAAC;AACnD,OAAO,uCAAuC,CAAC;AAC/C,OAAO,yCAAyC,CAAC"}
|
package/src/zintrust.comon.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-restricted-imports */
|
|
2
|
-
// /**
|
|
3
|
-
// * ZinTrust comon plugin auto-imports
|
|
4
|
-
// *
|
|
5
|
-
// * This file is managed by `zin plugin install` and contains side-effect
|
|
6
|
-
// * imports that register optional adapters/drivers into core registries.
|
|
7
|
-
// */
|
|
8
|
-
import '../packages/db-d1/src/register.js';
|
|
9
|
-
import '../packages/db-mysql/src/register.js';
|
|
10
|
-
import '../packages/db-postgres/src/register.js';
|
|
11
|
-
import '../packages/db-sqlite/src/register.js';
|
|
12
|
-
import '../packages/db-sqlserver/src/register.js';
|
|
13
|
-
import '../packages/mail-sendgrid/src/register.js';
|
|
14
|
-
import '../packages/mail-smtp/src/register.js';
|
|
15
|
-
import '../packages/queue-redis/src/register.js';
|