@zukhruf/nx 0.8.39 → 0.8.41

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.
Files changed (76) hide show
  1. package/README.md +54 -32
  2. package/dist/generators/auth/files.d.ts +2 -2
  3. package/dist/generators/auth/files.d.ts.map +1 -1
  4. package/dist/generators/auth/files.js +21 -20
  5. package/dist/generators/auth/files.js.map +1 -1
  6. package/dist/generators/auth/generator.d.ts.map +1 -1
  7. package/dist/generators/auth/generator.js +13 -17
  8. package/dist/generators/auth/generator.js.map +1 -1
  9. package/dist/generators/dokploy/files.d.ts.map +1 -1
  10. package/dist/generators/dokploy/files.js +16 -1
  11. package/dist/generators/dokploy/files.js.map +1 -1
  12. package/dist/generators/env-file.d.ts +8 -0
  13. package/dist/generators/env-file.d.ts.map +1 -0
  14. package/dist/generators/env-file.js +13 -0
  15. package/dist/generators/env-file.js.map +1 -0
  16. package/dist/generators/init/files.js +2 -2
  17. package/dist/generators/init/nx-json.d.ts +7 -0
  18. package/dist/generators/init/nx-json.d.ts.map +1 -1
  19. package/dist/generators/init/nx-json.js +19 -1
  20. package/dist/generators/init/nx-json.js.map +1 -1
  21. package/dist/generators/node-app/files.d.ts +3 -3
  22. package/dist/generators/node-app/files.d.ts.map +1 -1
  23. package/dist/generators/node-app/files.js +48 -35
  24. package/dist/generators/node-app/files.js.map +1 -1
  25. package/dist/generators/node-app/generator.d.ts.map +1 -1
  26. package/dist/generators/node-app/generator.js +32 -36
  27. package/dist/generators/node-app/generator.js.map +1 -1
  28. package/dist/generators/pair/files.d.ts +11 -2
  29. package/dist/generators/pair/files.d.ts.map +1 -1
  30. package/dist/generators/pair/files.js +51 -34
  31. package/dist/generators/pair/files.js.map +1 -1
  32. package/dist/generators/pair/generator.d.ts.map +1 -1
  33. package/dist/generators/pair/generator.js +22 -8
  34. package/dist/generators/pair/generator.js.map +1 -1
  35. package/dist/generators/portless-env.d.ts +14 -0
  36. package/dist/generators/portless-env.d.ts.map +1 -0
  37. package/dist/generators/portless-env.js +26 -0
  38. package/dist/generators/portless-env.js.map +1 -0
  39. package/dist/generators/prisma/files.d.ts.map +1 -1
  40. package/dist/generators/prisma/files.js +2 -0
  41. package/dist/generators/prisma/files.js.map +1 -1
  42. package/dist/generators/prisma/generator.d.ts +35 -1
  43. package/dist/generators/prisma/generator.d.ts.map +1 -1
  44. package/dist/generators/prisma/generator.js +57 -36
  45. package/dist/generators/prisma/generator.js.map +1 -1
  46. package/dist/generators/react-app/generator.js +10 -20
  47. package/dist/generators/react-app/generator.js.map +1 -1
  48. package/dist/generators/ui-package/files.d.ts.map +1 -1
  49. package/dist/generators/ui-package/files.js +7 -8
  50. package/dist/generators/ui-package/files.js.map +1 -1
  51. package/dist/generators/ui-package/generator.d.ts.map +1 -1
  52. package/dist/generators/ui-package/generator.js +3 -1
  53. package/dist/generators/ui-package/generator.js.map +1 -1
  54. package/dist/migrations/update-0-8-40/add-local-postgres.d.ts +14 -0
  55. package/dist/migrations/update-0-8-40/add-local-postgres.d.ts.map +1 -0
  56. package/dist/migrations/update-0-8-40/add-local-postgres.js +125 -0
  57. package/dist/migrations/update-0-8-40/add-local-postgres.js.map +1 -0
  58. package/dist/migrations/update-0-8-40/add-portless-proxy-env.d.ts +9 -0
  59. package/dist/migrations/update-0-8-40/add-portless-proxy-env.d.ts.map +1 -0
  60. package/dist/migrations/update-0-8-40/add-portless-proxy-env.js +21 -0
  61. package/dist/migrations/update-0-8-40/add-portless-proxy-env.js.map +1 -0
  62. package/dist/migrations/update-0-8-40/add-prisma-client-inputs.d.ts +11 -0
  63. package/dist/migrations/update-0-8-40/add-prisma-client-inputs.d.ts.map +1 -0
  64. package/dist/migrations/update-0-8-40/add-prisma-client-inputs.js +20 -0
  65. package/dist/migrations/update-0-8-40/add-prisma-client-inputs.js.map +1 -0
  66. package/dist/migrations/update-0-8-40/node-env-production.d.ts +13 -0
  67. package/dist/migrations/update-0-8-40/node-env-production.d.ts.map +1 -0
  68. package/dist/migrations/update-0-8-40/node-env-production.js +189 -0
  69. package/dist/migrations/update-0-8-40/node-env-production.js.map +1 -0
  70. package/dist/migrations/workspace.d.ts +31 -0
  71. package/dist/migrations/workspace.d.ts.map +1 -0
  72. package/dist/migrations/workspace.js +53 -0
  73. package/dist/migrations/workspace.js.map +1 -0
  74. package/migrations.json +24 -0
  75. package/package.json +51 -3
  76. package/release.json +30 -0
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Adds `KEY=value` to an env file that has no line for the key. A line that is
3
+ * there keeps its value. A missing file gets the one line. The prisma and auth
4
+ * generators and the migrations use it (ADR 0014 decision 12, ADR 0017).
5
+ */
6
+ export function addEnvEntry(tree, path, key, value) {
7
+ const content = tree.read(path, 'utf-8') ?? '';
8
+ if (new RegExp(`^${key}=`, 'm').test(content))
9
+ return;
10
+ const separator = content === '' || content.endsWith('\n') ? '' : '\n';
11
+ tree.write(path, `${content}${separator}${key}=${value}\n`);
12
+ }
13
+ //# sourceMappingURL=env-file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env-file.js","sourceRoot":"","sources":["../../src/generators/env-file.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,UAAU,WAAW,CACzB,IAAU,EACV,IAAY,EACZ,GAAW,EACX,KAAa;IAEb,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC;IAC/C,IAAI,IAAI,MAAM,CAAC,IAAI,GAAG,GAAG,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC;QAAE,OAAO;IACtD,MAAM,SAAS,GAAG,OAAO,KAAK,EAAE,IAAI,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IACvE,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,GAAG,OAAO,GAAG,SAAS,GAAG,GAAG,IAAI,KAAK,IAAI,CAAC,CAAC;AAC9D,CAAC"}
@@ -226,8 +226,8 @@ await preCommit([
226
226
  `,
227
227
  '.husky/pre-push.ts': `#!/usr/bin/env node
228
228
  // .husky/pre-push is a link to this file. Build builds each pushed commit in
229
- // its own snapshot, never the working tree. NODE_ENV is set because Vite sets
230
- // production only when NODE_ENV is not set.
229
+ // its own snapshot, never the working tree. NODE_ENV is set for the tools, so a
230
+ // shell that sets another value builds the same.
231
231
  import { Build, prePush } from '@zukhruf/git-hooks';
232
232
 
233
233
  await prePush([new Build({ env: { NODE_ENV: 'production' } })]);
@@ -16,5 +16,12 @@ export declare function updateTargetDefault(nxJson: NxJsonConfiguration, target:
16
16
  * other keys. A list gets the entries that it does not have.
17
17
  */
18
18
  export declare function mergeNxJson(tree: Tree): void;
19
+ /**
20
+ * Every setup runs under production (ADR 0016): the test and serve defaults
21
+ * set NODE_ENV=production, and a NODE_ENV that is there stays. A project
22
+ * target's own env replaces this one, so the web keeps its development and
23
+ * test. init and the node-env-production migration call it.
24
+ */
25
+ export declare function addProductionNodeEnvDefaults(nxJson: NxJsonConfiguration): void;
19
26
  export {};
20
27
  //# sourceMappingURL=nx-json.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"nx-json.d.ts","sourceRoot":"","sources":["../../../src/generators/init/nx-json.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACxB,KAAK,IAAI,EAEV,MAAM,YAAY,CAAC;AA+CpB,eAAO,MAAM,UAAU,GAAI,OAAO,mBAAmB,WACH,CAAC;AAEnD,eAAO,MAAM,MAAM,GAAI,CAAC,EAAE,QAAQ,CAAC,EAAE,QAQpC,CAAC;AAEF,KAAK,iBAAiB,GAAG,WAAW,CAAC,mBAAmB,CAAC,YAAY,CAAC,CAAC,CAAC;AAExE;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,UAAU,EAAE,iBAAiB,GAAG,SAAS,EACzC,UAAU,EAAE,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a,GAC9C,IAAI,CAON;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAuD5C;AAED;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,mBAAmB,GAC1B,IAAI,CAUN"}
@@ -3,7 +3,7 @@ import { addMissingKeys } from "../add-keys.js";
3
3
  const namedInputs = {
4
4
  default: ['{projectRoot}/**/*', 'sharedGlobals'],
5
5
  // The hash of a task does not read the environment, so NODE_ENV is an input:
6
- // else a cached development build can ship to production.
6
+ // a build under another value is never served from the cache.
7
7
  production: [
8
8
  'default',
9
9
  '!{projectRoot}/eslint.config.mjs',
@@ -119,8 +119,26 @@ export function mergeNxJson(tree) {
119
119
  continuous: false,
120
120
  }));
121
121
  }
122
+ addProductionNodeEnvDefaults(nxJson);
122
123
  nxJson.sync = { ...nxJson.sync, applyChanges: true };
123
124
  return nxJson;
124
125
  });
125
126
  }
127
+ /**
128
+ * Every setup runs under production (ADR 0016): the test and serve defaults
129
+ * set NODE_ENV=production, and a NODE_ENV that is there stays. A project
130
+ * target's own env replaces this one, so the web keeps its development and
131
+ * test. init and the node-env-production migration call it.
132
+ */
133
+ export function addProductionNodeEnvDefaults(nxJson) {
134
+ for (const target of ['test', 'serve']) {
135
+ updateTargetDefault(nxJson, target, (entry) => ({
136
+ ...entry,
137
+ options: {
138
+ ...entry.options,
139
+ env: addMissingKeys(entry.options?.env, { NODE_ENV: 'production' }),
140
+ },
141
+ }));
142
+ }
143
+ }
126
144
  //# sourceMappingURL=nx-json.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"nx-json.js","sourceRoot":"","sources":["../../../src/generators/init/nx-json.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,UAAU,GACX,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAMhD,MAAM,WAAW,GAAsC;IACrD,OAAO,EAAE,CAAC,oBAAoB,EAAE,eAAe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AAE,CAAC;QACvC,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;YAC9C,GAAG,KAAK;YACR,OAAO,EAAE;gBACP,GAAG,KAAK,CAAC,OAAO;gBAChB,GAAG,EAAE,cAAc,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,EAAE,EAAE,QAAQ,EAAE,YAAY,EAAE,CAAC;aACpE;SACF,CAAC,CAAC,CAAC;IACN,CAAC;AACH,CAAC"}
@@ -1,12 +1,12 @@
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 cors({\n origin: (origin) => {\n if (process.env.NODE_ENV === 'development') return origin;\n if (!origin) return '';\n const allowed = process.env.ALLOWED_ORIGINS.split(',').map((o) => o.trim());\n return allowed.includes(origin) ? origin : '';\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\napp.onError((error, c) => {\n if (error instanceof HTTPException) {\n if (error.status >= 500) {\n c.get('log')?.error(error);\n } else {\n // A bare `status: 400` in telemetry is undiagnosable; keep the cause.\n c.get('log')?.warn(error.message, { cause: error.cause });\n }\n return c.json({ error: error.message, cause: error.cause }, error.status);\n }\n c.get('log')?.error(error);\n return c.json(\n {\n error: 'Internal Server Error',\n cause: {\n code: 'api/internal',\n detail:\n process.env.NODE_ENV === 'development'\n ? String(error)\n : 'Unexpected error',\n },\n },\n 500,\n );\n});\n\nexport default app;\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\napp.onError((error, c) => {\n if (error instanceof HTTPException) {\n if (error.status >= 500) {\n c.get('log')?.error(error);\n } else {\n // A bare `status: 400` in telemetry is undiagnosable; keep the cause.\n c.get('log')?.warn(error.message, { cause: error.cause });\n }\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 c.get('log')?.error(error);\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;
6
6
  export declare const healthzRouteTs = "import { validate } from '@sdk-it/hono/runtime';\nimport type { Hono } from 'hono';\n\n// sdk-it discovers a route only when: the path is a string literal, an\n// argument is a call literally named `validate` whose selector is an arrow\n// function, the last argument is an arrow function, and the JSDoc block sits\n// directly above the statement.\nexport default function (router: Hono): void {\n /**\n * @openapi getHealthz\n * @tags health\n * @description Report whether the API is up, and the commit it was built from.\n */\n router.get(\n '/healthz',\n validate(() => ({})),\n async (c) => {\n return c.json({ status: 'ok', sha: process.env.BUILD_SHA ?? null });\n },\n );\n}\n";
7
- export declare const serverTs = "#!/usr/bin/env tsx\n// @nx-target-name: serve\nimport './startup.ts';\n\nimport { createTerminus } from '@godaddy/terminus';\nimport { serve } from '@hono/node-server';\nimport { log } from 'evlog';\n\nimport app from './app.ts';\nimport { flushLogs, logError } from './logging.ts';\n\nconst port = Number.parseInt(process.env.PORT ?? '3000', 10);\n// In development claim 127.0.0.1 explicitly: the dual-stack wildcard leaves\n// the IPv4 address free for a stray local server to capture proxy traffic.\nconst hostname =\n process.env.HOST ??\n (process.env.NODE_ENV === 'development' ? '127.0.0.1' : undefined);\n\nconst server = serve({ fetch: app.fetch, port, hostname }, (info) => {\n log.info({\n event: 'server.started',\n port: info.port,\n address: info.address,\n });\n});\n\n// terminus answers /healthz before Hono sees the request and turns SIGTERM\n// into a drained shutdown.\ncreateTerminus(server, {\n healthChecks: { '/healthz': async () => ({ status: 'ok' }) },\n async onSignal() {\n log.info({ event: 'server.shutdown.started' });\n await flushLogs();\n },\n useExit0: true,\n});\n\nprocess.on('uncaughtException', (error) => {\n logError({ event: 'server.uncaught-exception' }, error);\n process.kill(process.pid, 'SIGTERM');\n});\n\nprocess.on('unhandledRejection', (reason) => {\n logError({ event: 'server.unhandled-rejection' }, reason);\n process.kill(process.pid, 'SIGTERM');\n});\n";
7
+ export declare const serverTs = "#!/usr/bin/env tsx\n// @nx-target-name: serve\nimport './startup.ts';\n\nimport { createTerminus } from '@godaddy/terminus';\nimport { serve } from '@hono/node-server';\nimport { log } from 'evlog';\n\nimport app from './app.ts';\nimport { flushLogs, logError } from './logging.ts';\n\nconst port = Number.parseInt(process.env.PORT ?? '3000', 10);\n// HOST is required (env.ts). .env binds 127.0.0.1: the dual-stack wildcard\n// leaves the IPv4 address free for a stray local server to capture proxy\n// traffic. The image binds 0.0.0.0.\nconst hostname = process.env.HOST;\n\nconst server = serve({ fetch: app.fetch, port, hostname }, (info) => {\n log.info({\n event: 'server.started',\n port: info.port,\n address: info.address,\n });\n});\n\n// terminus answers /healthz before Hono sees the request and turns SIGTERM\n// into a drained shutdown.\ncreateTerminus(server, {\n healthChecks: { '/healthz': async () => ({ status: 'ok' }) },\n async onSignal() {\n log.info({ event: 'server.shutdown.started' });\n await flushLogs();\n },\n useExit0: true,\n});\n\nprocess.on('uncaughtException', (error) => {\n logError({ event: 'server.uncaught-exception' }, error);\n process.kill(process.pid, 'SIGTERM');\n});\n\nprocess.on('unhandledRejection', (reason) => {\n logError({ event: 'server.unhandled-rejection' }, reason);\n process.kill(process.pid, 'SIGTERM');\n});\n";
8
8
  export declare const startupTs = "import './env.ts';\n\n// Boot module: connect stores, run migrations, and start queues or workers here\n// before the app serves. Empty until the product needs it.\nexport {};\n";
9
- export declare function envExample(port: number): string;
9
+ export declare function envExample(port: number, name: string): string;
10
10
  export interface DockerfileOptions {
11
11
  projectRoot: string;
12
12
  projectName: 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,6mEA8EjB,CAAC;AAEF,eAAO,MAAM,SAAS,8qBAmBrB,CAAC;AAEF,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CA2C1C;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAmH9C;AAED,eAAO,MAAM,cAAc,6sBAqB1B,CAAC;AAEF,eAAO,MAAM,QAAQ,i6CA8CpB,CAAC;AAEF,eAAO,MAAM,SAAS,sLAKrB,CAAC;AAEF,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAY/C;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,CA2C7D;AAED,eAAO,MAAM,YAAY,gKAYxB,CAAC;AAEF,wBAAgB,WAAW,CAAC,WAAW,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAa5E;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,M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wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAWzD"}
@@ -44,12 +44,17 @@ app.use(
44
44
  evlog(evlogMiddlewareOptions),
45
45
  evlogRequestContext(),
46
46
  timing(),
47
+ // A browser origin gets CORS only when ALLOWED_ORIGINS lists it, in every
48
+ // setup.
47
49
  cors({
48
50
  origin: (origin) => {
49
- if (process.env.NODE_ENV === 'development') return origin;
51
+ // A request with no Origin header (a health check, a server call) needs
52
+ // no CORS and never reads ALLOWED_ORIGINS.
50
53
  if (!origin) return '';
51
- const allowed = process.env.ALLOWED_ORIGINS.split(',').map((o) => o.trim());
52
- return allowed.includes(origin) ? origin : '';
54
+ const allowed = process.env.ALLOWED_ORIGINS.split(',');
55
+ return allowed.map((entry) => entry.trim()).includes(origin)
56
+ ? origin
57
+ : '';
53
58
  },
54
59
  credentials: true,
55
60
  }),
@@ -89,17 +94,12 @@ app.onError((error, c) => {
89
94
  }
90
95
  return c.json({ error: error.message, cause: error.cause }, error.status);
91
96
  }
97
+ // The log has the error; the response never carries it.
92
98
  c.get('log')?.error(error);
93
99
  return c.json(
94
100
  {
95
101
  error: 'Internal Server Error',
96
- cause: {
97
- code: 'api/internal',
98
- detail:
99
- process.env.NODE_ENV === 'development'
100
- ? String(error)
101
- : 'Unexpected error',
102
- },
102
+ cause: { code: 'api/internal', detail: 'Unexpected error' },
103
103
  },
104
104
  500,
105
105
  );
@@ -133,11 +133,9 @@ export function envTs(port) {
133
133
  import { logError } from './logging.ts';
134
134
 
135
135
  const env = z.object({
136
- NODE_ENV: z
137
- .enum(['development', 'test', 'production'])
138
- .default('development'),
139
136
  PORT: z.string().optional().default('${port}'),
140
- HOST: z.string().optional(),
137
+ // The bind address: 127.0.0.1 in .env, 0.0.0.0 in the image.
138
+ HOST: z.string().min(1),
141
139
  // Kept a string: process.env stays string-valued so the ProcessEnv
142
140
  // augmentation below remains compatible with every Node API typed against
143
141
  // it (child_process env, etc.). Parse lists at the use site.
@@ -146,6 +144,10 @@ const env = z.object({
146
144
  // Dockerfile). /api/healthz reports it, so a deploy can tell the new
147
145
  // container from the old one. A process that is not an image has none.
148
146
  BUILD_SHA: z.string().min(1).optional(),
147
+ // logging.ts reads these two before this check runs. The folder of the log
148
+ // files (unset: no file), and \`true\` for readable logs (unset: JSON lines).
149
+ LOG_DIR: z.string().min(1).optional(),
150
+ LOG_PRETTY: z.enum(['true', 'false']).optional(),
149
151
  });
150
152
 
151
153
  const parsed = env.safeParse(process.env);
@@ -198,18 +200,19 @@ declare module 'hono' {
198
200
  }
199
201
 
200
202
  // This module is imported by env.ts (to report validation failures), so it
201
- // runs before the environment is validated and reads the raw variable.
202
- const environment = process.env.NODE_ENV ?? 'development';
203
+ // runs before the environment is validated and reads the raw variables. The
204
+ // log files go to LOG_DIR when it is set.
205
+ const logDir = process.env.LOG_DIR;
203
206
  const fileDrain =
204
- process.env.NODE_ENV === 'development'
205
- ? createDrainPipeline<DrainContext>({ batch: { size: 1 } })(
207
+ logDir === undefined
208
+ ? undefined
209
+ : createDrainPipeline<DrainContext>({ batch: { size: 1 } })(
206
210
  createFsDrain({
207
- dir: '.evlog/logs/${name}',
211
+ dir: logDir,
208
212
  maxFiles: 7,
209
213
  maxSizePerFile: 10 * 1024 * 1024,
210
214
  }),
211
- )
212
- : undefined;
215
+ );
213
216
 
214
217
  // evlog derives no level from the response status, so a handler that
215
218
  // *returns* a 5xx (rather than throwing) would log at info. Enrichment runs
@@ -222,7 +225,8 @@ function promoteServerErrors(context: EnrichContext): void {
222
225
 
223
226
  const config = defineEvlog({
224
227
  service: '${name}',
225
- environment,
228
+ // Readable logs when LOG_PRETTY is true, JSON lines otherwise.
229
+ pretty: process.env.LOG_PRETTY === 'true',
226
230
  redact: {
227
231
  paths: [
228
232
  'authorization',
@@ -321,11 +325,10 @@ import app from './app.ts';
321
325
  import { flushLogs, logError } from './logging.ts';
322
326
 
323
327
  const port = Number.parseInt(process.env.PORT ?? '3000', 10);
324
- // In development claim 127.0.0.1 explicitly: the dual-stack wildcard leaves
325
- // the IPv4 address free for a stray local server to capture proxy traffic.
326
- const hostname =
327
- process.env.HOST ??
328
- (process.env.NODE_ENV === 'development' ? '127.0.0.1' : undefined);
328
+ // HOST is required (env.ts). .env binds 127.0.0.1: the dual-stack wildcard
329
+ // leaves the IPv4 address free for a stray local server to capture proxy
330
+ // traffic. The image binds 0.0.0.0.
331
+ const hostname = process.env.HOST;
329
332
 
330
333
  const server = serve({ fetch: app.fetch, port, hostname }, (info) => {
331
334
  log.info({
@@ -362,17 +365,22 @@ export const startupTs = `import './env.ts';
362
365
  // before the app serves. Empty until the product needs it.
363
366
  export {};
364
367
  `;
365
- export function envExample(port) {
368
+ export function envExample(port, name) {
366
369
  return `# Copy to \`.env\` (gitignored). Nx loads this project's \`.env\`, \`.env.<target>\`
367
370
  # and \`.env.<target>.<configuration>\` into every task it runs here, so
368
- # \`nx run <project>:serve\` needs no dotenv. NODE_ENV is deliberately absent:
369
- # the serve target sets it to development, and the Dockerfile to production.
371
+ # \`nx run <project>:serve\` needs no dotenv.
372
+ # Every setup runs under production; no code reads NODE_ENV (ADR 0016).
373
+ NODE_ENV=production
370
374
  PORT=${port}
371
- # Bind address. Unset binds the dual-stack wildcard; development defaults to
372
- # 127.0.0.1 so portless and the web dev proxy can always reach the server.
375
+ # Bind address, required. 127.0.0.1, so portless and the web dev proxy always
376
+ # reach the server; the image binds 0.0.0.0.
373
377
  HOST=127.0.0.1
374
- # Comma-separated browser origins allowed outside development (CORS).
378
+ # Comma-separated browser origins allowed to call the API (CORS).
375
379
  ALLOWED_ORIGINS=
380
+ # The folder of the log files. Unset writes no log file.
381
+ LOG_DIR=.evlog/logs/${name}
382
+ # true prints readable logs; unset prints JSON lines.
383
+ LOG_PRETTY=true
376
384
  `;
377
385
  }
378
386
  export function dockerfile(options) {
@@ -381,6 +389,8 @@ export function dockerfile(options) {
381
389
  const spaCopy = spa
382
390
  ? `COPY --from=build /workspace/${spa.projectRoot}/dist ./${spa.projectRoot}/dist\n`
383
391
  : '';
392
+ // The backend serves the web build that UI_ROOT names (pair).
393
+ const uiRoot = spa ? ` UI_ROOT=/app/${spa.projectRoot}/dist` : '';
384
394
  return `# syntax=docker/dockerfile:1
385
395
  # @zukhruf/nx:node-app writes this file, and @zukhruf/nx:pair writes it again.
386
396
  # Build from the workspace root: \`nx run ${projectName}:docker:build\`.
@@ -403,7 +413,7 @@ FROM node:lts-alpine AS runtime
403
413
  # The commit this image is built from; /api/healthz reports it. docker:build
404
414
  # passes it, and an image built without it does not start (env.ts).
405
415
  ARG BUILD_SHA
406
- ENV NODE_ENV=production HOST=0.0.0.0 PORT=${port} BUILD_SHA=$BUILD_SHA
416
+ ENV NODE_ENV=production HOST=0.0.0.0 PORT=${port} BUILD_SHA=$BUILD_SHA${uiRoot}
407
417
  RUN npm install -g npm@latest
408
418
  WORKDIR /app
409
419
  # prune-lockfile writes the runtime manifest (type: module, runtime deps only)
@@ -482,7 +492,10 @@ export function clientManifest(name, apiProjectName) {
482
492
  sdk: {
483
493
  // Config discovery walks up from cwd to the api's sdk-it.config.ts.
484
494
  command: 'sdk-it generate',
485
- options: { cwd: '{projectRoot}' },
495
+ options: {
496
+ cwd: '{projectRoot}',
497
+ env: { NODE_ENV: 'production' },
498
+ },
486
499
  cache: true,
487
500
  inputs: [
488
501
  { projects: [apiProjectName], input: 'production' },
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8Ep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,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"}
@@ -1 +1 @@
1
- {"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../../src/generators/node-app/generator.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,iBAAiB,EAEtB,KAAK,IAAI,EAMV,MAAM,YAAY,CAAC;AAoCpB,MAAM,WAAW,cAAc;IAC7B,oDAAoD;IACpD,SAAS,EAAE,MAAM,CAAC;IAClB,uFAAuF;IACvF,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAYD,eAAO,MAAM,mBAAmB,0HACyF,CAAC;AAO1H;;;;GAIG;AACH,wBAA8B,gBAAgB,CAC5C,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,iBAAiB,CAAC,CA+F5B;AA8CD,uGAAuG;AACvG,wBAAgB,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAOvD"}
1
+ {"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../../src/generators/node-app/generator.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,iBAAiB,EAEtB,KAAK,IAAI,EAOV,MAAM,YAAY,CAAC;AAqCpB,MAAM,WAAW,cAAc;IAC7B,oDAAoD;IACpD,SAAS,EAAE,MAAM,CAAC;IAClB,uFAAuF;IACvF,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAqBD,eAAO,MAAM,mBAAmB,0HACyF,CAAC;AAO1H;;;;GAIG;AACH,wBAA8B,gBAAgB,CAC5C,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,iBAAiB,CAAC,CAkG5B;AA8CD,uGAAuG;AACvG,wBAAgB,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAOvD"}
@@ -1,10 +1,11 @@
1
- import { formatFiles, installPackagesTask, runTasksInSerial, updateJson, writeJson, } from '@nx/devkit';
1
+ import { formatFiles, installPackagesTask, readJson, runTasksInSerial, updateJson, writeJson, } from '@nx/devkit';
2
2
  import { addMissingKeys } from "../add-keys.js";
3
3
  import { addLines } from "../add-lines.js";
4
4
  import { appDirectory, projectNameOf } from "../app-directory.js";
5
5
  import initGenerator from "../init/generator.js";
6
6
  import { mergeGeneratorDefaults, unique, updateTargetDefault, } from "../init/nx-json.js";
7
7
  import { nxPlugin } from "../nx-plugin.js";
8
+ import { addPortlessProxyEnv } from "../portless-env.js";
8
9
  import { fseventsScript, rootDependencyNames, settleRootDependencies, } from "../root-dependencies.js";
9
10
  import { appPackageVersions as versions } from "../versions.js";
10
11
  import { workspaceScope } from "../workspace-scope.js";
@@ -28,6 +29,11 @@ export default async function nodeAppGenerator(tree, options) {
28
29
  const { applicationGenerator } = nxPlugin('@nx/node');
29
30
  // @nx/node adds a VS Code launch configuration; the one that was there stays.
30
31
  const launchJson = tree.read('.vscode/launch.json');
32
+ // @nx/node writes its own serve over the one that is there (#4868).
33
+ const previousServe = tree.exists(`${projectRoot}/package.json`)
34
+ ? readJson(tree, `${projectRoot}/package.json`).nx
35
+ ?.targets?.serve
36
+ : undefined;
31
37
  const appTask = await applicationGenerator(tree, {
32
38
  directory: projectRoot,
33
39
  framework: 'none',
@@ -51,13 +57,7 @@ export default async function nodeAppGenerator(tree, options) {
51
57
  tree.delete(`${projectRoot}/src/main.ts`);
52
58
  tree.delete(`${projectRoot}/src/assets/.gitkeep`);
53
59
  writeTsconfigs(tree, projectRoot, rootOffset);
54
- writeProjectPackageJson(tree, {
55
- projectRoot,
56
- name,
57
- projectName,
58
- port,
59
- scope,
60
- });
60
+ writeProjectPackageJson(tree, { projectRoot, name, projectName, port, scope }, previousServe);
61
61
  tree.write(`${projectRoot}/eslint.config.mjs`, eslintConfig(projectRoot, rootOffset));
62
62
  tree.write(`${projectRoot}/src/app.ts`, appTs);
63
63
  tree.write(`${projectRoot}/src/app.test.ts`, appTestTs);
@@ -67,9 +67,9 @@ export default async function nodeAppGenerator(tree, options) {
67
67
  tree.write(`${projectRoot}/src/server.ts`, serverTs);
68
68
  tree.write(`${projectRoot}/src/startup.ts`, startupTs);
69
69
  // .env.example is the generator's; .env is the developer's copy.
70
- tree.write(`${projectRoot}/.env.example`, envExample(port));
70
+ tree.write(`${projectRoot}/.env.example`, envExample(port, name));
71
71
  if (!tree.exists(`${projectRoot}/.env`)) {
72
- tree.write(`${projectRoot}/.env`, envExample(port));
72
+ tree.write(`${projectRoot}/.env`, envExample(port, name));
73
73
  }
74
74
  wireSdk(tree, { projectRoot, name, projectName, rootOffset, scope });
75
75
  tree.write(`${projectRoot}/Dockerfile`, dockerfile({ projectRoot, projectName, port }));
@@ -154,12 +154,31 @@ export function imageTagFor(projectName) {
154
154
  .replace(/-+/g, '-')
155
155
  .replace(/^-|-$/g, '');
156
156
  }
157
+ /**
158
+ * The serve of a backend. @nx/js/tsx infers its command from the header of
159
+ * src/server.ts, and @nx/node writes serve as continuous, which a project
160
+ * value overrides over the discrete target default. NODE_ENV is production,
161
+ * as in every setup (ADR 0016). A serve that node-app wrote before has no
162
+ * executor, and keeps what other generators added to it, such as the `^up`
163
+ * of prisma (#4868). The serve of @nx/node, with its executor, is replaced.
164
+ */
165
+ function serveTarget(previous) {
166
+ const own = previous?.executor === undefined ? previous : undefined;
167
+ return {
168
+ ...own,
169
+ dependsOn: unique([...(own?.dependsOn ?? []), '^build']),
170
+ options: {
171
+ ...own?.options,
172
+ env: addMissingKeys(own?.options?.env, { NODE_ENV: 'production' }),
173
+ },
174
+ };
175
+ }
157
176
  /**
158
177
  * The app manifest is its deploy manifest: `prune-lockfile` copies its
159
178
  * dependencies into dist/package.json, and @nx/dependency-checks keeps them
160
179
  * right, because the bundle leaves each npm package external.
161
180
  */
162
- function writeProjectPackageJson(tree, app) {
181
+ function writeProjectPackageJson(tree, app, previousServe) {
163
182
  const imageTag = imageTagFor(app.projectName);
164
183
  updateJson(tree, `${app.projectRoot}/package.json`, (packageJson) => {
165
184
  const targets = { ...packageJson.nx?.targets };
@@ -187,14 +206,7 @@ function writeProjectPackageJson(tree, app) {
187
206
  targets: {
188
207
  ...targets,
189
208
  build: buildTarget(app.projectRoot),
190
- // @nx/js/tsx infers the command from the header of src/server.ts.
191
- // @nx/node writes serve as continuous, and a project value wins
192
- // over the discrete target default. The app turns on its
193
- // development log drain only when NODE_ENV is development.
194
- serve: {
195
- dependsOn: ['^build'],
196
- options: { env: { NODE_ENV: 'development' } },
197
- },
209
+ serve: serveTarget(previousServe),
198
210
  portless: {
199
211
  command: `portless --name ${app.name}.${app.scope} --app-port ${app.port} -- nx run ${app.projectName}:serve --output-style=stream-without-prefixes`,
200
212
  },
@@ -300,23 +312,7 @@ function mergeNodeNxJson(tree) {
300
312
  dependsOn: unique([...inferred, ...(entry.dependsOn ?? []), '^sdk']),
301
313
  }));
302
314
  }
303
- // One portless proxy serves every app on the machine, and the target that
304
- // starts it sets its mode. PORTLESS_UNPRIVILEGED starts it without sudo,
305
- // so an agent with no TTY can. PORTLESS_HTTPS keeps it on HTTPS: a
306
- // stopped unprivileged proxy otherwise restarts on plain HTTP, and the
307
- // portless origin in ALLOWED_ORIGINS and the HMR of the web are https. No
308
- // PORTLESS_TLD: localhost is the default, and a set TLD replaces the TLDs
309
- // that another repo's proxy saved. Copy in react-app (docs/copied-code.md).
310
- updateTargetDefault(nxJson, 'portless', (entry) => ({
311
- ...entry,
312
- options: {
313
- ...entry.options,
314
- env: addMissingKeys(entry.options?.env, {
315
- PORTLESS_UNPRIVILEGED: '1',
316
- PORTLESS_HTTPS: '1',
317
- }),
318
- },
319
- }));
315
+ addPortlessProxyEnv(nxJson);
320
316
  // sdk-it.config.ts imports the root CLI. Outside production, its closure
321
317
  // stays out of the pruned runtime lockfile of the app.
322
318
  nxJson.namedInputs ??= {};
@@ -1 +1 @@
1
- {"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../src/generators/node-app/generator.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,WAAW,EACX,mBAAmB,EACnB,gBAAgB,EAChB,UAAU,EACV,SAAS,GACV,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,aAAa,MAAM,sBAAsB,CAAC;AACjD,OAAO,EACL,sBAAsB,EACtB,MAAM,EACN,mBAAmB,GACpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,kBAAkB,IAAI,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EACL,SAAS,EACT,KAAK,EACL,cAAc,EACd,cAAc,EACd,UAAU,EACV,YAAY,EACZ,UAAU,EACV,KAAK,EACL,YAAY,EACZ,cAAc,EACd,SAAS,EACT,WAAW,EACX,QAAQ,EACR,SAAS,GACV,MAAM,YAAY,CAAC;AAmBpB,MAAM,CAAC,MAAM,mBAAmB,GAC9B,uHAAuH,CAAC;AAE1H,MAAM,uBAAuB,GAAG;IAC9B,IAAI,EAAE,+BAA+B;IACrC,MAAM,EAAE,CAAC,SAAS,EAAE,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CAAC;aACH;SACF,CAAC,CAAC,CAAC;QACJ,yEAAyE;QACzE,uDAAuD;QACvD,MAAM,CAAC,WAAW,KAAK,EAAE,CAAC;QAC1B,MAAM,CAAC,WAAW,CAAC,YAAY,CAAC,GAAG,MAAM,CAAC;YACxC,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YACpD,8CAA8C;SAC/C,CAAC,CAAC;QACH,MAAM,CAAC,UAAU,GAAG,sBAAsB,CAAC,MAAM,CAAC,UAAU,EAAE,UAAU,EAAE;YACxE,WAAW,EAAE;gBACX,SAAS,EAAE,MAAM;gBACjB,OAAO,EAAE,SAAS;gBAClB,MAAM,EAAE,QAAQ;gBAChB,cAAc,EAAE,MAAM;gBACtB,aAAa,EAAE,MAAM;gBACrB,MAAM,EAAE,KAAK;aACd;SACF,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC,CAAC;AACL,CAAC"}
1
+ {"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../src/generators/node-app/generator.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,WAAW,EACX,mBAAmB,EACnB,QAAQ,EACR,gBAAgB,EAChB,UAAU,EACV,SAAS,GACV,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,aAAa,MAAM,sBAAsB,CAAC;AACjD,OAAO,EACL,sBAAsB,EACtB,MAAM,EACN,mBAAmB,GACpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,s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AAE,KAAK;aACd;SACF,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -1,4 +1,13 @@
1
1
  export declare function apiTs(clientName: string): string;
2
- /** `webDist` is the web build relative to the api build, for example `../../web/dist`. */
3
- export declare function uiRouteTs(webDist: string): string;
2
+ /** The first line of the UI mount in app.ts; auth inserts its routes above it. */
3
+ export declare const uiMountComment = "// pair: the backend serves the web build that UI_ROOT names.";
4
+ /** The import of the UI route, in the mount of each version of pair. */
5
+ export declare const uiRouteImport = "import('./routes/ui.route.ts')";
6
+ /** The lines of app.ts that mount the UI route of pair. */
7
+ export declare const uiMount = "// pair: the backend serves the web build that UI_ROOT names. Unset, as in\n// development, where Vite serves the web, there is no UI route.\nconst uiRoot = process.env.UI_ROOT;\nif (uiRoot !== undefined) {\n await (await import('./routes/ui.route.ts')).default(app, uiRoot);\n}";
8
+ /** The mount that pair wrote before UI_ROOT; a second run replaces it. */
9
+ export declare const legacyUiMount = "// pair fixed the path of the web build; development enters through the Vite proxy.\n(await import('./routes/ui.route.ts')).default(app);";
10
+ /** The line of env.ts that declares UI_ROOT. */
11
+ export declare const uiRootEnvTs = " // The folder of the web build that the backend serves (ui.route.ts). Unset,\n // the backend serves no UI.\n UI_ROOT: z.string().min(1).optional(),\n";
12
+ export declare const uiRouteTs = "import { readFile } from 'node:fs/promises';\nimport { join } from 'node:path';\n\nimport { serveStatic } from '@hono/node-server/serve-static';\nimport type { Hono } from 'hono';\nimport { compress } from 'hono/compress';\nimport { etag } from 'hono/etag';\n\nimport { logError } from '../logging.ts';\n\n// Same-origin SPA shell from the web build in `root` (UI_ROOT): hashed\n// assets are immutable (served precompressed when the web build emitted\n// .br/.gz), and every other GET returns index.html so the client router owns\n// the URL. A GET under /api/ goes on to the API routes and their notFound.\n// It reads index.html once, at startup, and the process stops there when\n// UI_ROOT names no web build.\nexport default async function (router: Hono, root: string): Promise<void> {\n const indexHtml = join(root, 'index.html');\n const html = await readIndexHtml(indexHtml);\n router.use(\n '/assets/*',\n serveStatic({\n root,\n precompressed: true,\n onFound: (_path, c) => {\n c.header('Cache-Control', 'public, max-age=31536000, immutable');\n },\n }),\n );\n router.get('*', compress(), etag(), async (c, next) => {\n if (c.req.path.startsWith('/api/')) {\n await next();\n return;\n }\n return c.html(html);\n });\n}\n\nasync function readIndexHtml(path: string): Promise<string> {\n try {\n return await readFile(path, 'utf-8');\n } catch (error) {\n if (!(Error.isError(error) && 'code' in error && error.code === 'ENOENT')) {\n throw error;\n }\n logError(\n {\n event: 'ui.build.missing',\n message: `UI_ROOT names no web build: ${path} does not exist. Build the web app, or unset UI_ROOT.`,\n },\n error,\n );\n process.exit(1);\n }\n}\n";
4
13
  //# sourceMappingURL=files.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../../src/generators/pair/files.ts"],"names":[],"mappings":"AAGA,wBAAgB,KAAK,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAWhD;AAED,0FAA0F;AAC1F,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAwDjD"}
1
+ {"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../../src/generators/pair/files.ts"],"names":[],"mappings":"AAGA,wBAAgB,KAAK,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAWhD;AAED,kFAAkF;AAClF,eAAO,MAAM,cAAc,kEACsC,CAAC;AAElE,wEAAwE;AACxE,eAAO,MAAM,aAAa,mCAAmC,CAAC;AAE9D,2DAA2D;AAC3D,eAAO,MAAM,OAAO,4RAKlB,CAAC;AAEH,0EAA0E;AAC1E,eAAO,MAAM,aAAa,8IACa,CAAC;AAExC,gDAAgD;AAChD,eAAO,MAAM,WAAW,+JAGvB,CAAC;AAEF,eAAO,MAAM,SAAS,mvDAuDrB,CAAC"}