@zintrust/core 0.1.17 → 0.1.19
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/README.md +6 -0
- package/package.json +10 -1
- package/public/index.html +1 -1
- package/routes/api.d.ts +7 -0
- package/routes/api.d.ts.map +1 -0
- package/routes/api.js +91 -0
- package/routes/broadcast.d.ts +9 -0
- package/routes/broadcast.d.ts.map +1 -0
- package/routes/broadcast.js +27 -0
- package/routes/health.d.ts +7 -0
- package/routes/health.d.ts.map +1 -0
- package/routes/health.js +127 -0
- package/routes/storage.d.ts +4 -0
- package/routes/storage.d.ts.map +1 -0
- package/routes/storage.js +35 -0
- package/src/boot/Application.js +1 -1
- package/src/boot/bootstrap.js +1 -1
- package/src/cli/CLI.d.ts.map +1 -1
- package/src/cli/CLI.js +2 -0
- package/src/cli/PromptHelper.d.ts.map +1 -1
- package/src/cli/PromptHelper.js +5 -4
- package/src/cli/commands/NewCommand.d.ts +1 -1
- package/src/cli/commands/NewCommand.d.ts.map +1 -1
- package/src/cli/commands/NewCommand.js +27 -10
- package/src/cli/commands/SimulateCommand.js +1 -1
- package/src/cli/commands/StartCommand.d.ts.map +1 -1
- package/src/cli/commands/StartCommand.js +90 -3
- package/src/cli/commands/UpgradeCommand.d.ts +16 -0
- package/src/cli/commands/UpgradeCommand.d.ts.map +1 -0
- package/src/cli/commands/UpgradeCommand.js +107 -0
- package/src/cli/commands/runner/index.d.ts +3 -0
- package/src/cli/commands/runner/index.d.ts.map +1 -0
- package/src/cli/commands/runner/index.js +139 -0
- package/src/cli/config/ConfigSchema.js +1 -1
- package/src/cli/env/EnvFileBackfill.d.ts +10 -0
- package/src/cli/env/EnvFileBackfill.d.ts.map +1 -0
- package/src/cli/env/EnvFileBackfill.js +64 -0
- package/src/cli/scaffolding/ProjectScaffolder.d.ts.map +1 -1
- package/src/cli/scaffolding/ProjectScaffolder.js +53 -23
- package/src/cli/utils/DistPackager.d.ts.map +1 -1
- package/src/cli/utils/DistPackager.js +8 -0
- package/src/config/broadcast.js +1 -1
- package/src/config/database.d.ts +6 -0
- package/src/config/database.d.ts.map +1 -1
- package/src/config/database.js +7 -1
- package/src/config/index.d.ts +7 -1
- package/src/config/index.d.ts.map +1 -1
- package/src/config/middleware.d.ts +2 -1
- package/src/config/middleware.d.ts.map +1 -1
- package/src/config/middleware.js +47 -11
- package/src/config/notification.js +1 -1
- package/src/config/storage.js +1 -1
- package/src/config/type.d.ts +7 -1
- package/src/config/type.d.ts.map +1 -1
- package/src/index.d.ts +1 -0
- package/src/index.d.ts.map +1 -1
- package/src/middleware/RateLimiter.d.ts +35 -0
- package/src/middleware/RateLimiter.d.ts.map +1 -1
- package/src/middleware/RateLimiter.js +213 -16
- package/src/node.d.ts +1 -1
- package/src/node.d.ts.map +1 -1
- package/src/node.js +4 -1
- package/src/orm/DatabaseRuntimeRegistration.d.ts.map +1 -1
- package/src/orm/DatabaseRuntimeRegistration.js +4 -0
- package/src/orm/QueryBuilder.d.ts.map +1 -1
- package/src/orm/QueryBuilder.js +7 -3
- package/src/orm/adapters/SQLiteAdapter.d.ts.map +1 -1
- package/src/orm/adapters/SQLiteAdapter.js +5 -1
- package/src/routes/api.d.ts +2 -0
- package/src/routes/api.d.ts.map +1 -0
- package/src/routes/api.js +1 -0
- package/src/routes/broadcast.d.ts +2 -0
- package/src/routes/broadcast.d.ts.map +1 -0
- package/src/routes/broadcast.js +1 -0
- package/src/routes/health.d.ts +2 -0
- package/src/routes/health.d.ts.map +1 -0
- package/src/routes/health.js +1 -0
- package/src/routes/storage.d.ts +2 -0
- package/src/routes/storage.d.ts.map +1 -0
- package/src/routes/storage.js +1 -0
- package/src/runtime/RuntimeAdapter.d.ts.map +1 -1
- package/src/runtime/RuntimeAdapter.js +20 -1
- package/src/runtime/adapters/DenoAdapter.js +2 -2
- package/src/scripts/TemplateImportsCheck.js +7 -7
- package/src/scripts/TemplateSync.js +6 -0
- package/src/start.d.ts +21 -0
- package/src/start.d.ts.map +1 -0
- package/src/start.js +60 -0
- package/src/templates/features/Queue.ts.tpl +2 -3
- package/src/templates/project/basic/.env.example.tpl +1 -1
- package/src/templates/project/basic/app/Controllers/UserController.ts.tpl +2 -4
- package/src/templates/project/basic/app/Middleware/ProfilerMiddleware.ts.tpl +1 -3
- package/src/templates/project/basic/app/Middleware/index.ts.tpl +3 -8
- package/src/templates/project/basic/app/Models/Post.ts.tpl +2 -3
- package/src/templates/project/basic/app/Models/User.ts.tpl +1 -1
- package/src/templates/project/basic/config/FileLogWriter.ts.tpl +1 -1
- package/src/templates/project/basic/config/SecretsManager.ts.tpl +2 -2
- package/src/templates/project/basic/config/StartupConfigValidator.ts.tpl +2 -2
- package/src/templates/project/basic/config/app.ts.tpl +3 -3
- package/src/templates/project/basic/config/broadcast.ts.tpl +4 -5
- package/src/templates/project/basic/config/cache.ts.tpl +2 -3
- package/src/templates/project/basic/config/cloudflare.ts.tpl +1 -1
- package/src/templates/project/basic/config/database.ts.tpl +9 -3
- package/src/templates/project/basic/config/env.ts.tpl +1 -1
- package/src/templates/project/basic/config/features.ts.tpl +2 -2
- package/src/templates/project/basic/config/index.ts.tpl +38 -20
- package/src/templates/project/basic/config/logger.ts.tpl +5 -381
- package/src/templates/project/basic/config/logging/HttpLogger.ts.tpl +1 -1
- package/src/templates/project/basic/config/logging/KvLogger.ts.tpl +2 -2
- package/src/templates/project/basic/config/logging/SlackLogger.ts.tpl +1 -1
- package/src/templates/project/basic/config/mail.ts.tpl +2 -3
- package/src/templates/project/basic/config/microservices.ts.tpl +1 -1
- package/src/templates/project/basic/config/middleware.ts.tpl +40 -13
- package/src/templates/project/basic/config/notification.ts.tpl +3 -4
- package/src/templates/project/basic/config/queue.ts.tpl +2 -2
- package/src/templates/project/basic/config/security.ts.tpl +3 -3
- package/src/templates/project/basic/config/startup.ts.tpl +1 -1
- package/src/templates/project/basic/config/storage.ts.tpl +3 -4
- package/src/templates/project/basic/config/type.ts.tpl +12 -2
- package/src/templates/project/basic/package.json.tpl +1 -1
- package/src/templates/project/basic/routes/api.ts.tpl +4 -4
- package/src/templates/project/basic/routes/health.ts.tpl +1 -6
- package/src/templates/project/basic/src/index.ts.tpl +7 -80
- package/src/templates/project/basic/tsconfig.json.tpl +0 -2
package/src/node.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/node.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/node.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAEvE,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAEjE,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AACvF,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,OAAO,EACL,aAAa,IAAI,yBAAyB,EAC1C,YAAY,IAAI,wBAAwB,EACxC,cAAc,IAAI,0BAA0B,GAC7C,MAAM,kCAAkC,CAAC"}
|
package/src/node.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
// Runtime marker to make this re-export-only module coverable in V8 coverage.
|
|
2
|
+
const __coverageMarker = true;
|
|
3
|
+
void __coverageMarker;
|
|
1
4
|
export { default, default as process } from './node-singletons/process.js';
|
|
2
|
-
export {
|
|
5
|
+
export { FileLogWriter, cleanOnce } from './config/FileLogWriter.js';
|
|
3
6
|
export { listTemplates, loadTemplate, renderTemplate } from './tools/mail/templates/markdown/index.js';
|
|
4
7
|
export { MailFake } from './tools/mail/testing.js';
|
|
5
8
|
export { FakeStorage } from './tools/storage/testing.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatabaseRuntimeRegistration.d.ts","sourceRoot":"","sources":["../../../src/orm/DatabaseRuntimeRegistration.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,mBAAmB,EAGpB,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"DatabaseRuntimeRegistration.d.ts","sourceRoot":"","sources":["../../../src/orm/DatabaseRuntimeRegistration.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,mBAAmB,EAGpB,MAAM,cAAc,CAAC;AA4CtB;;;;;;;GAOG;AACH,wBAAgB,kCAAkC,CAAC,MAAM,EAAE,mBAAmB,GAAG,IAAI,CAWpF"}
|
|
@@ -10,6 +10,10 @@ const toOrmConfig = (cfg) => {
|
|
|
10
10
|
switch (cfg.driver) {
|
|
11
11
|
case 'sqlite':
|
|
12
12
|
return { driver: 'sqlite', database: cfg.database };
|
|
13
|
+
case 'd1':
|
|
14
|
+
return { driver: 'd1' };
|
|
15
|
+
case 'd1-remote':
|
|
16
|
+
return { driver: 'd1-remote' };
|
|
13
17
|
case 'postgresql':
|
|
14
18
|
return {
|
|
15
19
|
driver: 'postgresql',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryBuilder.d.ts","sourceRoot":"","sources":["../../../src/orm/QueryBuilder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE1C,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,SAAS,GAAG,MAAM,CAAC;AAE5D,MAAM,WAAW,mBAAmB;IAClC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,cAAc,CAAC,EAAE,cAAc,CAAC;CACjC;AAED,MAAM,WAAW,aAAa;IAC5B,MAAM,CAAC,GAAG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G;aACY,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;EAIxC,CAAC"}
|
package/src/orm/QueryBuilder.js
CHANGED
|
@@ -6,7 +6,10 @@ import { ErrorFactory } from '../exceptions/ZintrustError.js';
|
|
|
6
6
|
/**
|
|
7
7
|
* Escape SQL identifier
|
|
8
8
|
*/
|
|
9
|
-
const escapeIdentifier = (id) =>
|
|
9
|
+
const escapeIdentifier = (id) => id
|
|
10
|
+
.split('.')
|
|
11
|
+
.map((part) => `"${part.replaceAll('"', '""')}"`)
|
|
12
|
+
.join('.');
|
|
10
13
|
const SAFE_IDENTIFIER_PATH = /^[A-Za-z_]\w*(?:\.[A-Za-z_]\w*)*$/;
|
|
11
14
|
const assertSafeIdentifierPath = (id, label) => {
|
|
12
15
|
const trimmed = id.trim();
|
|
@@ -143,12 +146,13 @@ const buildOrderByClause = (orderBy) => {
|
|
|
143
146
|
if (!orderBy)
|
|
144
147
|
return '';
|
|
145
148
|
const col = orderBy.column.trim();
|
|
149
|
+
let columnSql = col;
|
|
146
150
|
if (!isNumericLiteral(col)) {
|
|
147
151
|
assertSafeIdentifierPath(col, 'order by column');
|
|
152
|
+
columnSql = escapeIdentifier(col);
|
|
148
153
|
}
|
|
149
154
|
const dir = normalizeOrderDirection(orderBy.direction);
|
|
150
|
-
|
|
151
|
-
return ` ORDER BY ${col} ${dir}`;
|
|
155
|
+
return ` ORDER BY ${columnSql} ${dir}`;
|
|
152
156
|
};
|
|
153
157
|
/**
|
|
154
158
|
* Build LIMIT and OFFSET clause
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SQLiteAdapter.d.ts","sourceRoot":"","sources":["../../../../src/orm/adapters/SQLiteAdapter.ts"],"names":[],"mappings":"AACA;;;GAGG;AAMH,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAe,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"SQLiteAdapter.d.ts","sourceRoot":"","sources":["../../../../src/orm/adapters/SQLiteAdapter.ts"],"names":[],"mappings":"AACA;;;GAGG;AAMH,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAe,MAAM,sBAAsB,CAAC;AA6KrF,iBAAS,mBAAmB,CAAC,MAAM,EAAE,cAAc,GAAG,gBAAgB,CAoDrE;AAED,eAAO,MAAM,aAAa;;EAExB,CAAC"}
|
|
@@ -25,7 +25,11 @@ function isMissingEsmPackage(error, packageName) {
|
|
|
25
25
|
}
|
|
26
26
|
async function importSqliteDatabaseConstructor() {
|
|
27
27
|
try {
|
|
28
|
-
|
|
28
|
+
// Avoid a literal dynamic import so bundlers (e.g. Wrangler/esbuild) don't
|
|
29
|
+
// try to bundle the native sqlite driver into non-Node targets.
|
|
30
|
+
const pkg = globalThis
|
|
31
|
+
.__zintrustSqliteDriver;
|
|
32
|
+
const mod = (await import(pkg ?? 'better-sqlite3'));
|
|
29
33
|
const ctor = mod.default;
|
|
30
34
|
if (typeof ctor === 'function')
|
|
31
35
|
return ctor;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/routes/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { registerRoutes } from '../../routes/api.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"broadcast.d.ts","sourceRoot":"","sources":["../../../src/routes/broadcast.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { registerBroadcastRoutes } from '../../routes/broadcast.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"health.d.ts","sourceRoot":"","sources":["../../../src/routes/health.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { registerHealthRoutes } from '../../routes/health.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../../src/routes/storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default, registerStorageRoutes } from '../../routes/storage.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RuntimeAdapter.d.ts","sourceRoot":"","sources":["../../../src/runtime/RuntimeAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE7E,KAAK,KAAK,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;AAEpC;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC;AAElC;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC;IAC3C,IAAI,CAAC,EAAE,KAAK,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC;IAC1C,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC;IAC3C,IAAI,CAAC,EAAE,KAAK,CAAC;IACb,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,QAAQ,EAAE,QAAQ,GAAG,QAAQ,G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wBAAgB,qBAAqB,CAAC,OAAO,EAAE,eAAe,GAAG;IAC/D,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC7B,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC7B,YAAY,EAAE;QACZ,UAAU,EAAE,MAAM,CAAC;QACnB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC;QAC3C,IAAI,EAAE,KAAK,CAAC;KACb,CAAC;CACH,CA+DA"}
|
|
@@ -86,6 +86,19 @@ export const ErrorResponse = Object.freeze({
|
|
|
86
86
|
* Create mock Node.js request/response objects for platform compatibility
|
|
87
87
|
*/
|
|
88
88
|
export function createMockHttpObjects(request) {
|
|
89
|
+
const coerceFirstForwardedFor = (value) => {
|
|
90
|
+
if (Array.isArray(value)) {
|
|
91
|
+
const first = value[0];
|
|
92
|
+
return typeof first === 'string' && first.trim() !== '' ? first.trim() : undefined;
|
|
93
|
+
}
|
|
94
|
+
if (typeof value === 'string' && value.trim() !== '')
|
|
95
|
+
return value.trim();
|
|
96
|
+
return undefined;
|
|
97
|
+
};
|
|
98
|
+
const forwardedFor = coerceFirstForwardedFor(request.headers?.['x-forwarded-for']);
|
|
99
|
+
const remoteAddress = typeof request.remoteAddr === 'string' && request.remoteAddr.trim() !== ''
|
|
100
|
+
? request.remoteAddr.trim()
|
|
101
|
+
: (forwardedFor?.split(',')[0]?.trim() ?? '') || '0.0.0.0';
|
|
89
102
|
const responseData = {
|
|
90
103
|
statusCode: 200,
|
|
91
104
|
headers: { 'Content-Type': 'application/json' },
|
|
@@ -96,7 +109,13 @@ export function createMockHttpObjects(request) {
|
|
|
96
109
|
method: request.method,
|
|
97
110
|
url: request.path,
|
|
98
111
|
headers: request.headers,
|
|
99
|
-
remoteAddress
|
|
112
|
+
remoteAddress,
|
|
113
|
+
socket: {
|
|
114
|
+
remoteAddress,
|
|
115
|
+
},
|
|
116
|
+
connection: {
|
|
117
|
+
remoteAddress,
|
|
118
|
+
},
|
|
100
119
|
};
|
|
101
120
|
const res = {
|
|
102
121
|
statusCode: 200,
|
|
@@ -90,7 +90,7 @@ async function handleDenoRequest(adapter, config, logger, event, _context) {
|
|
|
90
90
|
? await denoRequest.arrayBuffer()
|
|
91
91
|
: null;
|
|
92
92
|
// Create mock Node.js request/response for compatibility
|
|
93
|
-
const { res, responseData } = createMockHttpObjects(request);
|
|
93
|
+
const { req, res, responseData } = createMockHttpObjects(request);
|
|
94
94
|
// Set request timeout
|
|
95
95
|
const timeout = config.timeout ?? 30000;
|
|
96
96
|
const timeoutHandle = setTimeout(() => {
|
|
@@ -104,7 +104,7 @@ async function handleDenoRequest(adapter, config, logger, event, _context) {
|
|
|
104
104
|
// Process through handler with mock Node.js objects
|
|
105
105
|
// Note: In a real implementation, we'd use the handler from the adapter config
|
|
106
106
|
// For compatibility with the existing code structure
|
|
107
|
-
await config.handler(
|
|
107
|
+
await config.handler(req, res, body === null ? null : Buffer.from(body));
|
|
108
108
|
}
|
|
109
109
|
finally {
|
|
110
110
|
clearTimeout(timeoutHandle);
|
|
@@ -2,7 +2,6 @@ import * as fs from 'node:fs';
|
|
|
2
2
|
import * as path from 'node:path';
|
|
3
3
|
const TEMPLATES_ROOT = path.resolve(process.cwd(), 'src/templates');
|
|
4
4
|
const bannedPrefixes = [
|
|
5
|
-
'@config/',
|
|
6
5
|
'@exceptions/',
|
|
7
6
|
'@orm/',
|
|
8
7
|
'@routing/',
|
|
@@ -19,10 +18,10 @@ const bannedPrefixes = [
|
|
|
19
18
|
'@mail/',
|
|
20
19
|
'@storage/',
|
|
21
20
|
'@node-singletons/',
|
|
22
|
-
'@app/',
|
|
23
|
-
'@routes/',
|
|
24
21
|
'@common/',
|
|
25
22
|
'@/',
|
|
23
|
+
'./',
|
|
24
|
+
'../',
|
|
26
25
|
];
|
|
27
26
|
function listFilesRecursive(root) {
|
|
28
27
|
const out = [];
|
|
@@ -47,12 +46,13 @@ function checkFile(filePath) {
|
|
|
47
46
|
const offenses = [];
|
|
48
47
|
const addIfBanned = (lineNo, spec, lineText) => {
|
|
49
48
|
const trimmed = spec.trim();
|
|
50
|
-
if (trimmed === '@zintrust/core' ||
|
|
49
|
+
if (trimmed === '@zintrust/core' ||
|
|
50
|
+
trimmed === '@zintrust/core/node' ||
|
|
51
|
+
trimmed === '@zintrust/core/start') {
|
|
51
52
|
return;
|
|
53
|
+
}
|
|
52
54
|
if (trimmed.startsWith('node:'))
|
|
53
55
|
return;
|
|
54
|
-
if (trimmed.startsWith('./') || trimmed.startsWith('../'))
|
|
55
|
-
return;
|
|
56
56
|
for (const prefix of bannedPrefixes) {
|
|
57
57
|
if (trimmed.startsWith(prefix)) {
|
|
58
58
|
offenses.push({ line: lineNo, spec: trimmed, text: lineText });
|
|
@@ -103,7 +103,7 @@ function main() {
|
|
|
103
103
|
process.stderr.write(`- ${o.file}:${o.line} -> ${o.spec}\n`);
|
|
104
104
|
process.stderr.write(` ${o.text.trim()}\n`);
|
|
105
105
|
}
|
|
106
|
-
process.stderr.write("\nAllowed: '@zintrust/core', '@zintrust/core/node', 'node:*'
|
|
106
|
+
process.stderr.write("\nAllowed: '@zintrust/core', '@zintrust/core/node', '@zintrust/core/start', 'node:*'\n");
|
|
107
107
|
process.exit(1);
|
|
108
108
|
}
|
|
109
109
|
process.stdout.write(`✓ Template import check passed (${files.length} templates)\n`);
|
|
@@ -126,6 +126,12 @@ const rewriteStarterTemplateImports = (relPath, content) => {
|
|
|
126
126
|
// Starter templates should import framework APIs from the public package surface,
|
|
127
127
|
// not from internal path-alias modules that only exist in the framework repo.
|
|
128
128
|
return (content
|
|
129
|
+
// Starter templates should not rely on local config/env wrappers.
|
|
130
|
+
// Normalize Env imports to come from the public package surface.
|
|
131
|
+
.replaceAll("from '../env';", "from '@zintrust/core';")
|
|
132
|
+
.replaceAll('from "../env";', 'from "@zintrust/core";')
|
|
133
|
+
.replaceAll("from './env';", "from '@zintrust/core';")
|
|
134
|
+
.replaceAll('from "./env";', 'from "@zintrust/core";')
|
|
129
135
|
// Node-singletons are internal to this repo; starter templates should use Node built-ins.
|
|
130
136
|
.replaceAll("'@node-singletons/fs'", "'node:fs'")
|
|
131
137
|
.replaceAll('"@node-singletons/fs"', '"node:fs"')
|
package/src/start.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare const isNodeMain: (importMetaUrl: string) => boolean;
|
|
2
|
+
/**
|
|
3
|
+
* Start the Node server (dev/prod) by delegating to the framework bootstrap.
|
|
4
|
+
*
|
|
5
|
+
* This uses a non-literal dynamic import so Worker bundlers don't pull Node-only modules.
|
|
6
|
+
*/
|
|
7
|
+
export declare const start: () => Promise<void>;
|
|
8
|
+
/**
|
|
9
|
+
* Cloudflare Workers entry (module worker style).
|
|
10
|
+
*/
|
|
11
|
+
export { default } from './functions/cloudflare';
|
|
12
|
+
export { default as cloudflareWorker } from './functions/cloudflare';
|
|
13
|
+
/**
|
|
14
|
+
* Deno fetch handler.
|
|
15
|
+
*/
|
|
16
|
+
export { default as deno } from './functions/deno';
|
|
17
|
+
/**
|
|
18
|
+
* AWS Lambda handler.
|
|
19
|
+
*/
|
|
20
|
+
export { handler } from './functions/lambda';
|
|
21
|
+
//# sourceMappingURL=start.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"start.d.ts","sourceRoot":"","sources":["../../src/start.ts"],"names":[],"mappings":"AAqBA,eAAO,MAAM,UAAU,GAAI,eAAe,MAAM,KAAG,OAYlD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,KAAK,QAAa,OAAO,CAAC,IAAI,CAS1C,CAAC;AAEF;;GAEG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAEhD,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEpE;;GAEG;AACH,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAElD;;GAEG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC"}
|
package/src/start.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
const isNodeRuntime = () => {
|
|
2
|
+
// Avoid importing any `node:*` modules so this file remains Worker-safe.
|
|
3
|
+
// In Workers/Deno, `process` is typically undefined.
|
|
4
|
+
return (typeof process !== 'undefined' &&
|
|
5
|
+
typeof process === 'object' &&
|
|
6
|
+
process !== null &&
|
|
7
|
+
typeof process.versions === 'object');
|
|
8
|
+
};
|
|
9
|
+
const fileUrlToPathLike = (value) => {
|
|
10
|
+
if (!value.startsWith('file://'))
|
|
11
|
+
return value;
|
|
12
|
+
// Basic file URL decoding (sufficient for macOS/Linux paths).
|
|
13
|
+
try {
|
|
14
|
+
return decodeURIComponent(value.slice('file://'.length));
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
return value.slice('file://'.length);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
export const isNodeMain = (importMetaUrl) => {
|
|
21
|
+
if (!isNodeRuntime())
|
|
22
|
+
return false;
|
|
23
|
+
const argv1 = process.argv;
|
|
24
|
+
const scriptPath = Array.isArray(argv1) ? String(argv1[1] ?? '') : '';
|
|
25
|
+
if (scriptPath === '')
|
|
26
|
+
return false;
|
|
27
|
+
const here = fileUrlToPathLike(importMetaUrl);
|
|
28
|
+
if (scriptPath === here)
|
|
29
|
+
return true;
|
|
30
|
+
// Best-effort: handle relative argv paths and runner wrappers.
|
|
31
|
+
return scriptPath.endsWith(here);
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Start the Node server (dev/prod) by delegating to the framework bootstrap.
|
|
35
|
+
*
|
|
36
|
+
* This uses a non-literal dynamic import so Worker bundlers don't pull Node-only modules.
|
|
37
|
+
*/
|
|
38
|
+
export const start = async () => {
|
|
39
|
+
/* c8 ignore start */
|
|
40
|
+
if (!isNodeRuntime())
|
|
41
|
+
return;
|
|
42
|
+
// Compiled output places bootstrap at `dist/src/boot/bootstrap.js`.
|
|
43
|
+
// This file compiles to `dist/src/start.js`, so relative import is stable.
|
|
44
|
+
// In unit tests, importing bootstrap has heavy side effects (starts server + exits).
|
|
45
|
+
await import('./boot/' + 'bootstrap.js');
|
|
46
|
+
/* c8 ignore stop */
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Cloudflare Workers entry (module worker style).
|
|
50
|
+
*/
|
|
51
|
+
export { default } from './functions/cloudflare.js';
|
|
52
|
+
export { default as cloudflareWorker } from './functions/cloudflare.js';
|
|
53
|
+
/**
|
|
54
|
+
* Deno fetch handler.
|
|
55
|
+
*/
|
|
56
|
+
export { default as deno } from './functions/deno.js';
|
|
57
|
+
/**
|
|
58
|
+
* AWS Lambda handler.
|
|
59
|
+
*/
|
|
60
|
+
export { handler } from './functions/lambda.js';
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// TEMPLATE_START
|
|
2
2
|
|
|
3
|
-
import { generateSecureJobId } from '@
|
|
4
|
-
import { Logger } from '@config/logger';
|
|
3
|
+
import { generateSecureJobId, Logger } from '@zintrust/core';
|
|
5
4
|
|
|
6
5
|
export interface QueueJob {
|
|
7
6
|
id: string;
|
|
@@ -44,4 +43,4 @@ export const Queue = Object.freeze({
|
|
|
44
43
|
},
|
|
45
44
|
});
|
|
46
45
|
|
|
47
|
-
// TEMPLATE_END
|
|
46
|
+
// TEMPLATE_END
|
|
@@ -3,10 +3,8 @@
|
|
|
3
3
|
* Example controller demonstrating request handling
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { User } from '
|
|
7
|
-
import { Logger } from '@zintrust/core';
|
|
8
|
-
import { IRequest } from '@zintrust/core';
|
|
9
|
-
import { IResponse } from '@zintrust/core';
|
|
6
|
+
import { User } from '@app/Models/User';
|
|
7
|
+
import { IRequest, Logger, IResponse } from '@zintrust/core';
|
|
10
8
|
|
|
11
9
|
/**
|
|
12
10
|
* User Controller Interface
|
|
@@ -4,9 +4,7 @@
|
|
|
4
4
|
* Enables request profiling when ENABLE_PROFILER environment variable is set
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import { Logger } from '@zintrust/core';
|
|
8
|
-
import { Middleware } from '@zintrust/core';
|
|
9
|
-
import { RequestProfiler } from '@zintrust/core';
|
|
7
|
+
import { Middleware, Logger , RequestProfiler} from '@zintrust/core';
|
|
10
8
|
|
|
11
9
|
/**
|
|
12
10
|
* ProfilerMiddleware wraps request execution with performance profiling
|
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
import type { CsrfTokenManagerType, ICsrfTokenManager } from '@zintrust/core';
|
|
2
|
-
import type { IJwtManager, JwtAlgorithm, JwtManagerType } from '@zintrust/core';
|
|
3
1
|
/**
|
|
4
2
|
* Example Middleware
|
|
5
3
|
* Common middleware patterns for Zintrust
|
|
6
4
|
*/
|
|
7
5
|
|
|
8
|
-
import {
|
|
9
|
-
import { IRequest } from '@zintrust/core';
|
|
10
|
-
|
|
11
|
-
import { XssProtection } from '@zintrust/core';
|
|
12
|
-
import type { ISchema, SchemaType } from '@zintrust/core';
|
|
13
|
-
import { Validator } from '@zintrust/core';
|
|
6
|
+
import type { IJwtManager, JwtAlgorithm, JwtManagerType, ISchema, SchemaType, CsrfTokenManagerType, ICsrfTokenManager } from '@zintrust/core';
|
|
7
|
+
import { Logger , Validator, IRequest, IResponse, XssProtection} from '@zintrust/core';
|
|
8
|
+
|
|
14
9
|
|
|
15
10
|
type JwtManagerInput = IJwtManager | JwtManagerType;
|
|
16
11
|
type CsrfManagerInput = ICsrfTokenManager | CsrfTokenManagerType;
|
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
* Example Post Model
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { IModel, Model, ModelConfig } from '@zintrust/core';
|
|
5
|
+
import { User } from '@app/Models/User';
|
|
6
|
+
import { IModel, Model, ModelConfig, IRelationship } from '@zintrust/core';
|
|
8
7
|
|
|
9
8
|
export const PostConfig: ModelConfig = {
|
|
10
9
|
table: 'posts',
|
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
* Supports: AWS Secrets Manager, Parameter Store, Cloudflare KV, Deno env
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import { Logger } from '
|
|
7
|
+
import { Logger } from '@zintrust/core';
|
|
8
8
|
import type {
|
|
9
9
|
GetSecretOptions,
|
|
10
10
|
SecretConfig,
|
|
11
11
|
SecretsManagerInstance,
|
|
12
12
|
SetSecretOptions,
|
|
13
|
-
} from '
|
|
13
|
+
} from '@zintrust/core';
|
|
14
14
|
import { ErrorFactory } from '@zintrust/core';
|
|
15
15
|
|
|
16
16
|
let instance: SecretsManagerInstance | undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { appConfig } from '
|
|
2
|
-
import type { StartupConfigValidationError, StartupConfigValidationResult } from '
|
|
1
|
+
import { appConfig } from '@zintrust/core';
|
|
2
|
+
import type { StartupConfigValidationError, StartupConfigValidationResult } from '@zintrust/core';
|
|
3
3
|
import { ErrorFactory } from '@zintrust/core';
|
|
4
4
|
|
|
5
5
|
const isSensitiveKey = (key: string): boolean => {
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* Sealed namespace for immutability
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import { Env } from '
|
|
8
|
-
import type { Environment, ProcessLike, StartMode } from '
|
|
7
|
+
import { Env } from '@zintrust/core';
|
|
8
|
+
import type { Environment, ProcessLike, StartMode } from '@zintrust/core';
|
|
9
9
|
|
|
10
10
|
const getProcessLike = (): ProcessLike | undefined => {
|
|
11
11
|
return typeof process === 'undefined' ? undefined : (process as unknown as ProcessLike);
|
|
@@ -99,7 +99,7 @@ const appConfigObj = {
|
|
|
99
99
|
port:
|
|
100
100
|
typeof (Env as unknown as { PORT?: unknown }).PORT === 'number'
|
|
101
101
|
? (Env as unknown as { PORT: number }).PORT
|
|
102
|
-
: readEnvInt('APP_PORT', 3000),
|
|
102
|
+
: readEnvInt('PORT', readEnvInt('APP_PORT', 3000)),
|
|
103
103
|
|
|
104
104
|
/**
|
|
105
105
|
* Application host
|
|
@@ -5,8 +5,7 @@
|
|
|
5
5
|
* Driver selection must be dynamic (tests may mutate process.env).
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
8
|
+
import type{
|
|
10
9
|
BroadcastConfigInput,
|
|
11
10
|
BroadcastDrivers,
|
|
12
11
|
InMemoryBroadcastDriverConfig,
|
|
@@ -14,13 +13,13 @@ import {
|
|
|
14
13
|
PusherBroadcastDriverConfig,
|
|
15
14
|
RedisBroadcastDriverConfig,
|
|
16
15
|
RedisHttpsBroadcastDriverConfig,
|
|
17
|
-
} from '
|
|
18
|
-
import { ErrorFactory } from '@zintrust/core';
|
|
16
|
+
} from '@zintrust/core';
|
|
17
|
+
import { ErrorFactory,Env } from '@zintrust/core';
|
|
19
18
|
|
|
20
19
|
const normalizeDriverName = (value: string): string => value.trim().toLowerCase();
|
|
21
20
|
|
|
22
21
|
const hasOwn = (obj: Record<string, unknown>, key: string): boolean => {
|
|
23
|
-
return Object.
|
|
22
|
+
return Object.hasOwn(obj, key);
|
|
24
23
|
};
|
|
25
24
|
|
|
26
25
|
const getDefaultBroadcaster = (drivers: BroadcastDrivers): string => {
|
|
@@ -4,9 +4,8 @@
|
|
|
4
4
|
* Sealed namespace for immutability
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { ErrorFactory } from '@zintrust/core';
|
|
7
|
+
import type { CacheConfigInput, CacheDriverConfig } from '@zintrust/core';
|
|
8
|
+
import { ErrorFactory , Env} from '@zintrust/core';
|
|
10
9
|
|
|
11
10
|
const getCacheDriver = (config: CacheConfigInput, name?: string): CacheDriverConfig => {
|
|
12
11
|
const selected = String(name ?? config.default).trim();
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* This keeps runtime-specific globals out of adapters/drivers.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { KVNamespace, WorkersEnv } from '
|
|
8
|
+
import type { KVNamespace, WorkersEnv } from '@zintrust/core';
|
|
9
9
|
import type { DatabaseConfig, ID1Database } from '@zintrust/core';
|
|
10
10
|
|
|
11
11
|
const getWorkersEnv = (): WorkersEnv | null => {
|
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
* Sealed namespace for immutability
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import { Env } from '
|
|
8
|
-
import { DatabaseConfigShape, DatabaseConnectionConfig, DatabaseConnections } from '
|
|
7
|
+
import { Env } from '@zintrust/core';
|
|
8
|
+
import type { DatabaseConfigShape, DatabaseConnectionConfig, DatabaseConnections } from '@zintrust/core';
|
|
9
9
|
import { ErrorFactory } from '@zintrust/core';
|
|
10
10
|
|
|
11
11
|
const hasOwn = (obj: Record<string, unknown>, key: string): boolean => {
|
|
12
|
-
return Object.
|
|
12
|
+
return Object.hasOwn(obj, key);
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
const getDefaultConnection = (connections: DatabaseConnections): string => {
|
|
@@ -48,6 +48,12 @@ const connections = {
|
|
|
48
48
|
database: Env.DB_DATABASE,
|
|
49
49
|
migrations: 'database/migrations',
|
|
50
50
|
},
|
|
51
|
+
d1: {
|
|
52
|
+
driver: 'd1' as const,
|
|
53
|
+
},
|
|
54
|
+
'd1-remote': {
|
|
55
|
+
driver: 'd1-remote' as const,
|
|
56
|
+
},
|
|
51
57
|
postgresql: {
|
|
52
58
|
driver: 'postgresql' as const,
|
|
53
59
|
host: Env.DB_HOST,
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* Safe for both Node.js and serverless runtimes (Cloudflare Workers, Deno, Lambda)
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { ProcessLike } from '
|
|
9
|
+
import type { ProcessLike } from '@zintrust/core';
|
|
10
10
|
|
|
11
11
|
const getProcessLike = (): ProcessLike | undefined => {
|
|
12
12
|
return typeof process === 'undefined' ? undefined : (process as unknown as ProcessLike);
|