@zukhruf/nx 0.8.113 → 0.8.115
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare function eslintConfig(projectRoot: string, rootOffset: string): string;
|
|
2
|
-
export declare const appTs = "import { evlog } from 'evlog/hono';\nimport { Hono } from 'hono';\nimport { compress } from 'hono/compress';\nimport { contextStorage } from 'hono/context-storage';\nimport { cors } from 'hono/cors';\nimport { HTTPException } from 'hono/http-exception';\nimport { timing } from 'hono/timing';\n\nimport { evlogMiddlewareOptions, evlogRequestContext } from './logging.ts';\n\nconst app = new Hono();\n\napp.use(\n evlog(evlogMiddlewareOptions),\n evlogRequestContext(),\n timing(),\n // A browser origin gets CORS only when ALLOWED_ORIGINS lists it, in every\n // setup.\n cors({\n origin: (origin) => {\n // A request with no Origin header (a health check, a server call) needs\n // no CORS and never reads ALLOWED_ORIGINS.\n if (!origin) return '';\n const allowed = process.env.ALLOWED_ORIGINS.split(',');\n return allowed.map((entry) => entry.trim()).includes(origin)\n ? origin\n : '';\n },\n credentials: true,\n }),\n // Required by @sdk-it/hono/runtime's `output` helpers.\n contextStorage(),\n);\n\napp.use('/api/*', compress());\n\n// Route modules register on the /api base path. Add new modules to this list;\n// sdk-it only discovers routes that use `validate` and a JSDoc @openapi tag.\nfor await (const route of [import('./routes/healthz.route.ts')]) {\n route.default(app.basePath('/api'));\n}\n\napp.notFound((c) =>\n c.json(\n {\n error: 'Not Found',\n cause: {\n code: 'api/not-found',\n detail: 'The requested resource was not found',\n instance: c.req.path,\n },\n },\n 404,\n ),\n);\n\
|
|
2
|
+
export declare const appTs = "import { evlog } from 'evlog/hono';\nimport { Hono } from 'hono';\nimport { compress } from 'hono/compress';\nimport { contextStorage } from 'hono/context-storage';\nimport { cors } from 'hono/cors';\nimport { HTTPException } from 'hono/http-exception';\nimport { timing } from 'hono/timing';\n\nimport { evlogMiddlewareOptions, evlogRequestContext } from './logging.ts';\n\nconst app = new Hono();\n\napp.use(\n evlog(evlogMiddlewareOptions),\n evlogRequestContext(),\n timing(),\n // A browser origin gets CORS only when ALLOWED_ORIGINS lists it, in every\n // setup.\n cors({\n origin: (origin) => {\n // A request with no Origin header (a health check, a server call) needs\n // no CORS and never reads ALLOWED_ORIGINS.\n if (!origin) return '';\n const allowed = process.env.ALLOWED_ORIGINS.split(',');\n return allowed.map((entry) => entry.trim()).includes(origin)\n ? origin\n : '';\n },\n credentials: true,\n }),\n // Required by @sdk-it/hono/runtime's `output` helpers.\n contextStorage(),\n);\n\napp.use('/api/*', compress());\n\n// Route modules register on the /api base path. Add new modules to this list;\n// sdk-it only discovers routes that use `validate` and a JSDoc @openapi tag.\nfor await (const route of [import('./routes/healthz.route.ts')]) {\n route.default(app.basePath('/api'));\n}\n\napp.notFound((c) =>\n c.json(\n {\n error: 'Not Found',\n cause: {\n code: 'api/not-found',\n detail: 'The requested resource was not found',\n instance: c.req.path,\n },\n },\n 404,\n ),\n);\n\n// The evlog middleware logs the error that reaches here, its cause included,\n// and logging.ts sets the level from the status.\napp.onError((error, c) => {\n if (error instanceof HTTPException) {\n return c.json({ error: error.message, cause: error.cause }, error.status);\n }\n // The log has the error; the response never carries it.\n return c.json(\n {\n error: 'Internal Server Error',\n cause: { code: 'api/internal', detail: 'Unexpected error' },\n },\n 500,\n );\n});\n\nexport default app;\n";
|
|
3
3
|
export declare const appTestTs = "import assert from 'node:assert/strict';\nimport { test } from 'node:test';\n\nimport app from './app.ts';\n\ntest('answers the health check on the API base path, with no build sha outside an image', async () => {\n const response = await app.request('/api/healthz');\n\n assert.equal(response.status, 200);\n assert.deepEqual(await response.json(), { status: 'ok', sha: null });\n});\n\ntest('rejects unknown API routes with a JSON cause', async () => {\n const response = await app.request('/api/nope');\n\n assert.equal(response.status, 404);\n const body: unknown = await response.json();\n assert.ok(typeof body === 'object' && body !== null && 'cause' in body);\n});\n";
|
|
4
4
|
export declare function envTs(port: number): string;
|
|
5
5
|
export declare function loggingTs(name: string): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../../src/generators/node-app/files.ts"],"names":[],"mappings":"AAGA,wBAAgB,YAAY,CAAC,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CA2B5E;AAED,eAAO,MAAM,KAAK,
|
|
1
|
+
{"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../../src/generators/node-app/files.ts"],"names":[],"mappings":"AAGA,wBAAgB,YAAY,CAAC,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CA2B5E;AAED,eAAO,MAAM,KAAK,kmEAyEjB,CAAC;AAEF,eAAO,MAAM,SAAS,8qBAmBrB,CAAC;AAEF,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CA6C1C;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAgI9C;AAED,eAAO,MAAM,cAAc,6sBAqB1B,CAAC;AAEF,eAAO,MAAM,QAAQ,w3CA6CpB,CAAC;AAEF,eAAO,MAAM,SAAS,sLAKrB,CAAC;AAEF,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAiB7D;AAED,MAAM,WAAW,iBAAiB;IAChC,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,wDAAwD;IACxD,GAAG,CAAC,EAAE;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC;CACpD;AAED,wBAAgB,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,MAAM,CA6C7D;AAED,eAAO,MAAM,YAAY,gKAYxB,CAAC;AAEF,wBAAgB,WAAW,CAAC,WAAW,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAa5E;AAED;;;;;GAKG;AACH,eAAO,MAAM,eAAe;IAAK,SAAS;CAAc,CAAC;AAEzD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,MAAM,CAgD3E;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAWzD"}
|
|
@@ -84,18 +84,13 @@ app.notFound((c) =>
|
|
|
84
84
|
),
|
|
85
85
|
);
|
|
86
86
|
|
|
87
|
+
// The evlog middleware logs the error that reaches here, its cause included,
|
|
88
|
+
// and logging.ts sets the level from the status.
|
|
87
89
|
app.onError((error, c) => {
|
|
88
90
|
if (error instanceof HTTPException) {
|
|
89
|
-
if (error.status >= 500) {
|
|
90
|
-
c.get('log')?.error(error);
|
|
91
|
-
} else {
|
|
92
|
-
// A bare \`status: 400\` in telemetry is undiagnosable; keep the cause.
|
|
93
|
-
c.get('log')?.warn(error.message, { cause: error.cause });
|
|
94
|
-
}
|
|
95
91
|
return c.json({ error: error.message, cause: error.cause }, error.status);
|
|
96
92
|
}
|
|
97
93
|
// The log has the error; the response never carries it.
|
|
98
|
-
c.get('log')?.error(error);
|
|
99
94
|
return c.json(
|
|
100
95
|
{
|
|
101
96
|
error: 'Internal Server Error',
|
|
@@ -214,12 +209,23 @@ const fileDrain =
|
|
|
214
209
|
}),
|
|
215
210
|
);
|
|
216
211
|
|
|
217
|
-
// evlog derives
|
|
218
|
-
//
|
|
219
|
-
//
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
212
|
+
// evlog derives the level from the log calls, not from the response status:
|
|
213
|
+
// its Hono middleware logs each error that onError handled at error, and a
|
|
214
|
+
// handler that *returns* a 5xx logs at info. Enrichment runs after emit and
|
|
215
|
+
// before output and drain, with a mutable event. As the OpenTelemetry HTTP
|
|
216
|
+
// conventions treat a server span, a 4xx is the client's error: it logs at
|
|
217
|
+
// warn, and its error keeps the name, message, status and cause, not the
|
|
218
|
+
// stack.
|
|
219
|
+
function levelFromStatus({ event, response }: EnrichContext): void {
|
|
220
|
+
const status = response?.status;
|
|
221
|
+
if (status === undefined) return;
|
|
222
|
+
if (status >= 500) {
|
|
223
|
+
event.level = 'error';
|
|
224
|
+
} else if (status >= 400 && event.level === 'error') {
|
|
225
|
+
event.level = 'warn';
|
|
226
|
+
if (typeof event.error === 'object' && event.error !== null) {
|
|
227
|
+
Reflect.deleteProperty(event.error, 'stack');
|
|
228
|
+
}
|
|
223
229
|
}
|
|
224
230
|
}
|
|
225
231
|
|
|
@@ -242,7 +248,7 @@ const config = defineEvlog({
|
|
|
242
248
|
drain: fileDrain,
|
|
243
249
|
// evlog globs: \`*\` stops at \`/\`, \`**\` crosses it.
|
|
244
250
|
exclude: ['/api/healthz', '/assets/**'],
|
|
245
|
-
enrich:
|
|
251
|
+
enrich: levelFromStatus,
|
|
246
252
|
});
|
|
247
253
|
|
|
248
254
|
initLogger(toLoggerConfig(config));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"files.js","sourceRoot":"","sources":["../../../src/generators/node-app/files.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,+EAA+E;AAE/E,MAAM,UAAU,YAAY,CAAC,WAAmB,EAAE,UAAkB;IAClE,OAAO;;qDAE4C,UAAU;;;;;;;;;;;;;;;;;mCAiB5B,WAAW;;;;;;CAM7C,CAAC;AACF,CAAC;AAED,MAAM,CAAC,MAAM,KAAK,GAAG
|
|
1
|
+
{"version":3,"file":"files.js","sourceRoot":"","sources":["../../../src/generators/node-app/files.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,+EAA+E;AAE/E,MAAM,UAAU,YAAY,CAAC,WAAmB,EAAE,UAAkB;IAClE,OAAO;;qDAE4C,UAAU;;;;;;;;;;;;;;;;;mCAiB5B,WAAW;;;;;;CAM7C,CAAC;AACF,CAAC;AAED,MAAM,CAAC,MAAM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AE,QAAQ,EAAE;QACpE,EAAE,EAAE;YACF,WAAW,EAAE,SAAS;YACtB,oBAAoB,EAAE,CAAC,cAAc,CAAC;YACtC,OAAO,EAAE;gBACP,GAAG,EAAE;oBACH,oEAAoE;oBACpE,OAAO,EAAE,iBAAiB;oBAC1B,OAAO,EAAE;wBACP,GAAG,EAAE,eAAe;wBACpB,GAAG,EAAE,EAAE,QAAQ,EAAE,YAAY,EAAE;qBAChC;oBACD,KAAK,EAAE,IAAI;oBACX,SAAS,EAAE,CAAC,aAAa,CAAC;oBAC1B,MAAM,EAAE;wBACN,aAAa;wBACb,EAAE,yBAAyB,EAAE,SAAS,EAAE,UAAU,EAAE,IAAI,EAAE;wBAC1D,mCAAmC;wBACnC,4BAA4B;qBAC7B;oBACD,OAAO,EAAE;wBACP,mBAAmB;wBACnB,oBAAoB;wBACpB,6BAA6B;qBAC9B;iBACF;aACF;SACF;KACF,CAAC;IACF,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC;AAClD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,UAAkB;IAC/C,MAAM,QAAQ,GAAG;QACf,OAAO,EAAE,MAAM,UAAU,oBAAoB;QAC7C,eAAe,EAAE;YACf,MAAM,EAAE,SAAS;YACjB,eAAe,EAAE,8BAA8B;SAChD;QACD,KAAK,EAAE,EAAE;QACT,OAAO,EAAE,EAAE;KACZ,CAAC;IACF,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC;AAClD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zukhruf/nx",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.115",
|
|
4
4
|
"description": "The Nx part of the monorepo standard: inference plugins for format, test, lint, opentofu and prisma targets, and generators for the root files (preset, init), apps (node-app, react-app, pair, ui-package), a db package (prisma) and delivery (dokploy).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -132,7 +132,7 @@
|
|
|
132
132
|
"@nx/react": ">=24.0.6 <25.0.0",
|
|
133
133
|
"@nx/vite": ">=24.0.6 <25.0.0",
|
|
134
134
|
"@nx/vitest": ">=24.0.6 <25.0.0",
|
|
135
|
-
"@zukhruf/testing": "^0.8.
|
|
135
|
+
"@zukhruf/testing": "^0.8.115",
|
|
136
136
|
"nx": ">=24.0.6 <25.0.0",
|
|
137
137
|
"prettier": "^3.0.0",
|
|
138
138
|
"typescript": ">=5.8.0 <6.1.0"
|
|
@@ -155,9 +155,12 @@
|
|
|
155
155
|
}
|
|
156
156
|
},
|
|
157
157
|
"devDependencies": {
|
|
158
|
-
"@
|
|
159
|
-
"@zukhruf/
|
|
160
|
-
"@zukhruf/
|
|
158
|
+
"@sdk-it/hono": "0.46.11",
|
|
159
|
+
"@zukhruf/eslint": "^0.8.115",
|
|
160
|
+
"@zukhruf/fs": "^0.8.115",
|
|
161
|
+
"@zukhruf/testing": "^0.8.115",
|
|
162
|
+
"evlog": "2.35.1",
|
|
163
|
+
"hono": "4.13.20",
|
|
161
164
|
"semver": "^7.8.5"
|
|
162
165
|
}
|
|
163
166
|
}
|