@zintrust/core 0.4.16 → 0.4.18

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zintrust/core",
3
- "version": "0.4.16",
3
+ "version": "0.4.18",
4
4
  "description": "Production-grade TypeScript backend framework for JavaScript",
5
5
  "homepage": "https://zintrust.com",
6
6
  "repository": {
@@ -1 +1 @@
1
- {"version":3,"file":"StartCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/StartCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoC,KAAK,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAs4BvF,eAAO,MAAM,YAAY;cACb,YAAY;EAmCtB,CAAC"}
1
+ {"version":3,"file":"StartCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/StartCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoC,KAAK,YAAY,EAAE,MAAM,kBAAkB,CAAC;AA26BvF,eAAO,MAAM,YAAY;cACb,YAAY;EAmCtB,CAAC"}
@@ -62,7 +62,28 @@ const resolveMode = (options) => {
62
62
  }
63
63
  return resolveModeFromAppMode();
64
64
  };
65
- const resolvePort = (options) => {
65
+ const resolveStandaloneServicePortEnvValue = (cwd) => {
66
+ const normalizedCwd = path.resolve(cwd);
67
+ const serviceRootMarker = `${path.sep}src${path.sep}services${path.sep}`;
68
+ if (!normalizedCwd.includes(serviceRootMarker))
69
+ return '';
70
+ const serviceName = path.basename(normalizedCwd).trim();
71
+ const servicePortKey = serviceName
72
+ .replaceAll(/[^A-Za-z0-9]+/g, '_')
73
+ .replaceAll(/^_+|_+$/g, '')
74
+ .toUpperCase();
75
+ const candidateKeys = [
76
+ servicePortKey === '' ? '' : `${servicePortKey}_PORT`,
77
+ 'SERVICE_PORT',
78
+ ].filter((key) => key !== '');
79
+ for (const key of candidateKeys) {
80
+ const value = process.env[key];
81
+ if (typeof value === 'string' && value.trim() !== '')
82
+ return value.trim();
83
+ }
84
+ return '';
85
+ };
86
+ const resolvePort = (options, cwd) => {
66
87
  const cliPort = typeof options.port === 'string' ? options.port.trim() : '';
67
88
  if (cliPort !== '') {
68
89
  const parsed = Number.parseInt(cliPort, 10);
@@ -71,7 +92,19 @@ const resolvePort = (options) => {
71
92
  }
72
93
  return parsed;
73
94
  }
74
- const envPortRaw = process.env['APP_PORT'] ?? process.env['PORT'] ?? '';
95
+ const standalonePort = resolveStandaloneServicePortEnvValue(cwd);
96
+ const appPort = process.env['APP_PORT'];
97
+ const port = process.env['PORT'];
98
+ let envPortRaw = '';
99
+ if (standalonePort !== '') {
100
+ envPortRaw = standalonePort;
101
+ }
102
+ else if (appPort !== undefined && appPort.trim() !== '') {
103
+ envPortRaw = appPort;
104
+ }
105
+ else if (port !== undefined && port.trim() !== '') {
106
+ envPortRaw = port;
107
+ }
75
108
  if (envPortRaw === '')
76
109
  return undefined;
77
110
  const parsed = Number.parseInt(String(envPortRaw), 10);
@@ -621,7 +654,7 @@ const executeStart = async (options, cmd) => {
621
654
  ensureStartEnvLoaded(context, options);
622
655
  await preloadManifestServiceEnv(context, options);
623
656
  const mode = resolveMode(options);
624
- const port = resolvePort(options);
657
+ const port = resolvePort(options, context.cwd);
625
658
  const runtime = resolveRuntime(options);
626
659
  const configuredRuntime = resolveConfiguredRuntime(options);
627
660
  const variant = resolveStartVariant(options);
@@ -1 +1 @@
1
- {"version":3,"file":"ServiceScaffolder.d.ts","sourceRoot":"","sources":["../../../../src/cli/scaffolding/ServiceScaffolder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,QAAQ,GAAG,UAAU,CAAC;IACjC,IAAI,CAAC,EAAE,SAAS,GAAG,KAAK,GAAG,MAA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AAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;CACjB;AAaD;;GAEG;AAEH;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,cAAc,GAAG;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,CAuB7F;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,GAAG,MAAM,CAGnF;AAED;;GAEG;AAEH,wBAAgB,QAAQ,CACtB,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,qBAAqB,CAAC,CAiDhC;AAycD,eAAO,MAAM,iBAAiB;;;;EAI5B,CAAC"}
@@ -420,10 +420,14 @@ export const Example = Model.define({
420
420
  * Generate service .env file
421
421
  */
422
422
  function generateServiceEnv(options) {
423
+ const servicePort = options.port ?? 3001;
423
424
  return `# ${options.name} Service Configuration
424
425
 
425
426
  # Service Port
426
- ${options.name?.toUpperCase()}_PORT=${options.port ?? 3001}
427
+ APP_PORT=${servicePort}
428
+ PORT=${servicePort}
429
+ SERVICE_PORT=${servicePort}
430
+ ${options.name?.toUpperCase()}_PORT=${servicePort}
427
431
 
428
432
  # Database
429
433
  DATABASE_CONNECTION=${options.database === 'isolated' ? 'postgresql' : 'shared'}
package/src/index.js CHANGED
@@ -1,11 +1,11 @@
1
1
  /**
2
- * @zintrust/core v0.4.16
2
+ * @zintrust/core v0.4.18
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-03-24T13:49:16.905Z
8
+ * Built: 2026-03-24T17:44:59.102Z
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-03-24T13:49:16.870Z'; // Replaced during build
24
+ export const ZINTRUST_BUILD_DATE = '2026-03-24T17:44:59.068Z'; // 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":"ErrorHandlerMiddleware.d.ts","sourceRoot":"","sources":["../../../src/middleware/ErrorHandlerMiddleware.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAU9D,eAAO,MAAM,sBAAsB;cACvB,UAAU;EAsCpB,CAAC;AAEH,eAAe,sBAAsB,CAAC"}
1
+ {"version":3,"file":"ErrorHandlerMiddleware.d.ts","sourceRoot":"","sources":["../../../src/middleware/ErrorHandlerMiddleware.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AA0B9D,eAAO,MAAM,sBAAsB;cACvB,UAAU;EAsCpB,CAAC;AAEH,eAAe,sBAAsB,CAAC"}
@@ -13,6 +13,14 @@ const isWritableEnded = (res) => {
13
13
  return false;
14
14
  return Boolean(raw.writableEnded);
15
15
  };
16
+ const shouldHideStackFromResponse = (error) => {
17
+ if (typeof error !== 'object' || error === null)
18
+ return false;
19
+ const candidate = error;
20
+ return (candidate.name === 'NotFoundError' ||
21
+ candidate.code === 'NOT_FOUND' ||
22
+ candidate.statusCode === 404);
23
+ };
16
24
  export const ErrorHandlerMiddleware = Object.freeze({
17
25
  create() {
18
26
  return async (req, res, next) => {
@@ -22,7 +30,7 @@ export const ErrorHandlerMiddleware = Object.freeze({
22
30
  catch (error) {
23
31
  Logger.error('Unhandled request error:', error);
24
32
  const requestId = RequestContext.get(req)?.requestId ?? req.context['requestId'];
25
- const includeStack = Env.NODE_ENV !== 'production';
33
+ const includeStack = Env.NODE_ENV !== 'production' && !shouldHideStackFromResponse(error);
26
34
  if (!isWritableEnded(res)) {
27
35
  const errorMode = Env.get('ERROR_MODE', 'html');
28
36
  res.setStatus(500);