@t0.labs/daxta 1.1.0 → 1.1.2

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 CHANGED
@@ -30,7 +30,7 @@ DAxTA captures that real traffic while your tests run and turns it into interact
30
30
  ```ts
31
31
  import { apiDocs } from '@t0.labs/daxta';
32
32
 
33
- apiDocs(app); // NestJS — mount /api-docs when DAXTA_DOCS=true
33
+ apiDocs(app); // NestJS — mount /docs when DAXTA_DOCS=on
34
34
  ```
35
35
 
36
36
  Generation happens when Jest finishes (reporter) or when you run `daxta generate`. You do not call `generateApiDocs()` in `main.ts`.
@@ -139,7 +139,7 @@ These examples come from **actual test executions**, not manually maintained doc
139
139
 
140
140
  3. **When Jest finishes**, DAxTA performs a single documentation build.
141
141
 
142
- 4. `apiDocs(app)` mounts the generated documentation on your NestJS application when `DAXTA_DOCS=true`.
142
+ 4. `apiDocs(app)` mounts the generated documentation on your NestJS application when `DAXTA_DOCS=on`.
143
143
 
144
144
  ---
145
145
 
@@ -200,7 +200,7 @@ When Jest finishes, your documentation is ready.
200
200
  Start your application with DAxTA enabled:
201
201
 
202
202
  ```bash
203
- DAXTA_DOCS=true pnpm start:dev
203
+ DAXTA_DOCS=on pnpm start:dev
204
204
  ```
205
205
 
206
206
  Open:
@@ -290,20 +290,20 @@ Your tests remain the source of truth.
290
290
 
291
291
  ## `DAXTA_DOCS`
292
292
 
293
- DAxTA requires an explicit decision about whether `/api-docs` should be mounted.
293
+ DAxTA requires an explicit decision about whether `/docs` should be mounted. Only `on` and `off` are accepted.
294
294
 
295
295
  ```bash
296
- DAXTA_DOCS=true # mount /api-docs
297
- DAXTA_DOCS=false # do not mount /api-docs
296
+ DAXTA_DOCS=on # mount /docs
297
+ DAXTA_DOCS=off # do not mount /docs
298
298
 
299
- # unset / empty → throws
299
+ # unset / empty / any other value → throws
300
300
  ```
301
301
 
302
302
  This makes exposing API documentation an explicit application decision.
303
303
 
304
- `DAXTA_DOCS=false` does not remove `@t0.labs/daxta` from your Node image. It only prevents `/api-docs` from being mounted.
304
+ `DAXTA_DOCS=off` does not remove `@t0.labs/daxta` from your Node image. It only prevents `/docs` from being mounted.
305
305
 
306
- The path is configurable via `docsPath` in `daxta.config.ts` (default `/api-docs`).
306
+ The path defaults to `/docs`. Override with `DAXTA_DOCS_PATH` or `docsPath` in `daxta.config.ts`.
307
307
 
308
308
  ---
309
309
 
package/assets/empty.html CHANGED
@@ -139,7 +139,7 @@
139
139
  </head>
140
140
  <body>
141
141
  <header class="topnav">
142
- <span class="nav-meta">/api-docs</span>
142
+ <span class="nav-meta">/docs</span>
143
143
  </header>
144
144
  <main class="stage">
145
145
  <div class="panel">
@@ -563,9 +563,12 @@
563
563
  grid-column: 3;
564
564
  grid-row: 1;
565
565
  min-height: 0;
566
- overflow: auto;
566
+ height: 100%;
567
+ overflow: hidden;
567
568
  padding: 14px 18px 16px;
568
569
  background: var(--paper);
570
+ display: flex;
571
+ flex-direction: column;
569
572
  }
570
573
  .sidebar {
571
574
  position: relative;
@@ -1123,6 +1126,7 @@
1123
1126
  gap: 8px;
1124
1127
  align-items: stretch;
1125
1128
  margin-bottom: 12px;
1129
+ flex: none;
1126
1130
  }
1127
1131
  .url {
1128
1132
  flex: 1;
@@ -1199,8 +1203,11 @@
1199
1203
  display: grid;
1200
1204
  grid-template-columns: 1fr 1fr;
1201
1205
  gap: 12px;
1202
- margin-bottom: 20px;
1203
- align-items: start;
1206
+ margin-bottom: 0;
1207
+ align-items: stretch;
1208
+ flex: 1;
1209
+ min-height: 0;
1210
+ overflow: hidden;
1204
1211
  }
1205
1212
  .card {
1206
1213
  background: var(--white);
@@ -1208,9 +1215,12 @@
1208
1215
  border: 1px solid var(--hairline);
1209
1216
  box-shadow: none;
1210
1217
  min-width: 0;
1218
+ min-height: 0;
1219
+ height: 100%;
1211
1220
  display: flex;
1212
1221
  flex-direction: column;
1213
1222
  max-width: 100%;
1223
+ overflow: hidden;
1214
1224
  }
1215
1225
  .card.response-card {
1216
1226
  overflow: hidden;
@@ -1252,12 +1262,15 @@
1252
1262
  padding: 0;
1253
1263
  display: flex;
1254
1264
  flex-direction: column;
1265
+ flex: 1;
1255
1266
  min-height: 0;
1267
+ overflow-x: hidden;
1268
+ overflow-y: auto;
1256
1269
  }
1257
- #response-body {
1258
- overflow: auto;
1270
+ .json-pane {
1271
+ min-height: 0;
1259
1272
  }
1260
- #response-body pre {
1273
+ .json-pane pre {
1261
1274
  max-height: none;
1262
1275
  }
1263
1276
  .meta-block {
@@ -1412,6 +1425,9 @@
1412
1425
  .foot-bar { position: sticky; bottom: 0; }
1413
1426
  .sidebar-resizer { display: none; }
1414
1427
  .pair, .schemas { grid-template-columns: 1fr; }
1428
+ .workbench { overflow: auto; height: auto; }
1429
+ .pair { flex: none; height: auto; overflow: visible; }
1430
+ .card { height: auto; max-height: 70vh; }
1415
1431
  .search-wrap { width: min(280px, 70vw); }
1416
1432
  }
1417
1433
 
@@ -1527,7 +1543,7 @@
1527
1543
  const viewer = spec["x-viewer"] || {};
1528
1544
  const workspace = (spec.info && spec.info["x-workspace"]) || viewer.workspace || "";
1529
1545
  const defaultBaseUrlFromSpec = String((viewer.baseUrl || (spec.servers && spec.servers[0] && spec.servers[0].url) || "http://localhost:3000")).replace(/\/$/, "");
1530
- const docsPathSuffix = String(viewer.docsPath || "/api-docs").replace(/\/$/, "") || "/api-docs";
1546
+ const docsPathSuffix = String(viewer.docsPath || "/docs").replace(/\/$/, "") || "/docs";
1531
1547
 
1532
1548
  const inferBaseUrlFromLocation = () => {
1533
1549
  if (typeof location === "undefined") return null;
@@ -3546,7 +3562,7 @@
3546
3562
  ${metaBlock("Headers", headersHtml, requiredAuthHint(item.op), { always: true })}
3547
3563
  ${metaBlock("Path", pathParamsHtml)}
3548
3564
  ${metaBlock("Query", queryHtml)}
3549
- ${metaBlock("Body", bodyHtml, "", { always: true })}
3565
+ ${metaBlock("Body", `<div class="json-pane">${bodyHtml}</div>`, "", { always: true })}
3550
3566
  ${schemas.request}
3551
3567
  </div>
3552
3568
  </section>
@@ -3567,7 +3583,7 @@
3567
3583
  </div>
3568
3584
  </div>
3569
3585
  <div class="card-body">
3570
- <div id="response-body">${resHtml}</div>
3586
+ ${metaBlock("Body", `<div class="json-pane" id="response-body">${resHtml}</div>`, "", { always: true })}
3571
3587
  ${schemas.response}
3572
3588
  </div>
3573
3589
  </section>
@@ -3626,23 +3642,6 @@
3626
3642
  };
3627
3643
  });
3628
3644
 
3629
- const syncResponseHeight = () => {
3630
- const requestCard = document.getElementById("request-card");
3631
- const responseCard = document.getElementById("response-card");
3632
- const responseBody = document.getElementById("response-body");
3633
- if (!requestCard || !responseCard || !responseBody) return;
3634
- responseCard.style.maxHeight = "";
3635
- responseBody.style.maxHeight = "";
3636
- const requestHeight = requestCard.offsetHeight;
3637
- const head = responseCard.querySelector(".card-head");
3638
- const headHeight = head ? head.offsetHeight : 0;
3639
- const maxBody = Math.max(0, requestHeight - headHeight);
3640
- responseCard.style.maxHeight = requestHeight + "px";
3641
- responseBody.style.maxHeight = maxBody + "px";
3642
- };
3643
- syncResponseHeight();
3644
- requestAnimationFrame(syncResponseHeight);
3645
-
3646
3645
  document.getElementById("copy-curl").onclick = (event) => copy(toCurl(item, scenario), event.currentTarget, "Copy cURL");
3647
3646
  const copyReq = document.getElementById("copy-req");
3648
3647
  if (copyReq && reqCopyText) copyReq.onclick = (event) => copy(reqCopyText, event.currentTarget, "Copy body");
@@ -408,9 +408,12 @@
408
408
  grid-column: 3;
409
409
  grid-row: 1;
410
410
  min-height: 0;
411
- overflow: auto;
411
+ height: 100%;
412
+ overflow: hidden;
412
413
  padding: 14px 18px 16px;
413
414
  background: var(--paper);
415
+ display: flex;
416
+ flex-direction: column;
414
417
  }
415
418
  .sidebar {
416
419
  position: relative;
@@ -964,6 +967,7 @@
964
967
  gap: 8px;
965
968
  align-items: stretch;
966
969
  margin-bottom: 12px;
970
+ flex: none;
967
971
  }
968
972
  .url {
969
973
  flex: 1;
@@ -1040,8 +1044,11 @@
1040
1044
  display: grid;
1041
1045
  grid-template-columns: 1fr 1fr;
1042
1046
  gap: 12px;
1043
- margin-bottom: 20px;
1044
- align-items: start;
1047
+ margin-bottom: 0;
1048
+ align-items: stretch;
1049
+ flex: 1;
1050
+ min-height: 0;
1051
+ overflow: hidden;
1045
1052
  }
1046
1053
  .card {
1047
1054
  background: var(--white);
@@ -1049,9 +1056,12 @@
1049
1056
  border: 1px solid var(--hairline);
1050
1057
  box-shadow: none;
1051
1058
  min-width: 0;
1059
+ min-height: 0;
1060
+ height: 100%;
1052
1061
  display: flex;
1053
1062
  flex-direction: column;
1054
1063
  max-width: 100%;
1064
+ overflow: hidden;
1055
1065
  }
1056
1066
  .card.response-card {
1057
1067
  overflow: hidden;
@@ -1093,12 +1103,15 @@
1093
1103
  padding: 0;
1094
1104
  display: flex;
1095
1105
  flex-direction: column;
1106
+ flex: 1;
1096
1107
  min-height: 0;
1108
+ overflow-x: hidden;
1109
+ overflow-y: auto;
1097
1110
  }
1098
- #response-body {
1099
- overflow: auto;
1111
+ .json-pane {
1112
+ min-height: 0;
1100
1113
  }
1101
- #response-body pre {
1114
+ .json-pane pre {
1102
1115
  max-height: none;
1103
1116
  }
1104
1117
  .meta-block {
@@ -1249,6 +1262,9 @@
1249
1262
  .ex-dock { position: sticky; bottom: 0; }
1250
1263
  .sidebar-resizer { display: none; }
1251
1264
  .pair, .schemas { grid-template-columns: 1fr; }
1265
+ .workbench { overflow: auto; height: auto; }
1266
+ .pair { flex: none; height: auto; overflow: visible; }
1267
+ .card { height: auto; max-height: 70vh; }
1252
1268
  .search-wrap { width: min(280px, 70vw); }
1253
1269
  }
1254
1270
  </style>
@@ -1320,7 +1336,7 @@
1320
1336
  const viewer = spec["x-viewer"] || {};
1321
1337
  const workspace = (spec.info && spec.info["x-workspace"]) || viewer.workspace || "";
1322
1338
  const defaultBaseUrlFromSpec = String((viewer.baseUrl || (spec.servers && spec.servers[0] && spec.servers[0].url) || "http://localhost:3000")).replace(/\/$/, "");
1323
- const docsPathSuffix = String(viewer.docsPath || "/api-docs").replace(/\/$/, "") || "/api-docs";
1339
+ const docsPathSuffix = String(viewer.docsPath || "/docs").replace(/\/$/, "") || "/docs";
1324
1340
 
1325
1341
  const inferBaseUrlFromLocation = () => {
1326
1342
  if (typeof location === "undefined") return null;
@@ -3271,7 +3287,7 @@
3271
3287
  ${metaBlock("Headers", headersHtml, requiredAuthHint(item.op), { always: true })}
3272
3288
  ${metaBlock("Path", pathParamsHtml)}
3273
3289
  ${metaBlock("Query", queryHtml)}
3274
- ${metaBlock("Body", bodyHtml, "", { always: true })}
3290
+ ${metaBlock("Body", `<div class="json-pane">${bodyHtml}</div>`, "", { always: true })}
3275
3291
  ${schemas.request}
3276
3292
  </div>
3277
3293
  </section>
@@ -3292,7 +3308,7 @@
3292
3308
  </div>
3293
3309
  </div>
3294
3310
  <div class="card-body">
3295
- <div id="response-body">${resHtml}</div>
3311
+ ${metaBlock("Body", `<div class="json-pane" id="response-body">${resHtml}</div>`, "", { always: true })}
3296
3312
  ${schemas.response}
3297
3313
  </div>
3298
3314
  </section>
@@ -3351,23 +3367,6 @@
3351
3367
  };
3352
3368
  });
3353
3369
 
3354
- const syncResponseHeight = () => {
3355
- const requestCard = document.getElementById("request-card");
3356
- const responseCard = document.getElementById("response-card");
3357
- const responseBody = document.getElementById("response-body");
3358
- if (!requestCard || !responseCard || !responseBody) return;
3359
- responseCard.style.maxHeight = "";
3360
- responseBody.style.maxHeight = "";
3361
- const requestHeight = requestCard.offsetHeight;
3362
- const head = responseCard.querySelector(".card-head");
3363
- const headHeight = head ? head.offsetHeight : 0;
3364
- const maxBody = Math.max(0, requestHeight - headHeight);
3365
- responseCard.style.maxHeight = requestHeight + "px";
3366
- responseBody.style.maxHeight = maxBody + "px";
3367
- };
3368
- syncResponseHeight();
3369
- requestAnimationFrame(syncResponseHeight);
3370
-
3371
3370
  document.getElementById("copy-curl").onclick = (event) => copy(toCurl(item, scenario), event.currentTarget, "Copy cURL");
3372
3371
  const copyReq = document.getElementById("copy-req");
3373
3372
  if (copyReq && reqCopyText) copyReq.onclick = (event) => copy(reqCopyText, event.currentTarget, "Copy body");
@@ -118,7 +118,7 @@ export default defineConfig({
118
118
  baseUrl: 'http://localhost:3000',
119
119
  controllersRoot: 'src',
120
120
  outDir: '.daxta/out',
121
- docsPath: '/api-docs',
121
+ docsPath: '/docs',
122
122
  treeLayout: 'role-resource',
123
123
  treeSkipParams: true,
124
124
  exampleLabelStyle: 'status-title-case',
@@ -158,7 +158,7 @@ function ensureGitignore(cwd, dryRun) {
158
158
  return added.map((e) => `.gitignore += ${e}`);
159
159
  }
160
160
  const ENV_CANDIDATES = ['.env', '.env.local', '.env.development', '.env.development.local'];
161
- /** Ensure DAXTA_DOCS is present (default true). Mirrors uninstall strip. */
161
+ /** Ensure DAXTA_DOCS is present (default on). Mirrors uninstall strip. */
162
162
  function ensureEnvDaxtaDocs(cwd, dryRun) {
163
163
  for (const name of ENV_CANDIDATES) {
164
164
  const filePath = path.join(cwd, name);
@@ -171,7 +171,7 @@ function ensureEnvDaxtaDocs(cwd, dryRun) {
171
171
  const targetName = ENV_CANDIDATES.find((name) => (0, fs_1.existsSync)(path.join(cwd, name))) ?? '.env';
172
172
  const targetPath = path.join(cwd, targetName);
173
173
  const created = !(0, fs_1.existsSync)(targetPath);
174
- const line = 'DAXTA_DOCS=true';
174
+ const line = 'DAXTA_DOCS=on';
175
175
  if (!dryRun) {
176
176
  if (created) {
177
177
  (0, fs_1.writeFileSync)(targetPath, `${line}\n`);
@@ -182,7 +182,7 @@ function ensureEnvDaxtaDocs(cwd, dryRun) {
182
182
  (0, fs_1.writeFileSync)(targetPath, next);
183
183
  }
184
184
  }
185
- return created ? `created ${targetName} (+ DAXTA_DOCS=true)` : `${targetName} += DAXTA_DOCS=true`;
185
+ return created ? `created ${targetName} (+ DAXTA_DOCS=on)` : `${targetName} += DAXTA_DOCS=on`;
186
186
  }
187
187
  function runPackageInstall(cwd, pm, version, dryRun) {
188
188
  if (dryRun)
@@ -344,7 +344,7 @@ async function installDaxta(options = {}) {
344
344
  }
345
345
  (0, ui_1.box)('Ready', [
346
346
  `${ui_1.c.mint('✔')} ${ui_1.c.bold(project)} · DAxTA ${ui_1.c.gold(`v${version}`)}`,
347
- `${ui_1.c.dim('api docs')} ${ui_1.c.ice('/api-docs')} · ${ui_1.c.ice('DAXTA_DOCS=true')}`,
347
+ `${ui_1.c.dim('api docs')} ${ui_1.c.ice('/docs')} · ${ui_1.c.ice('DAXTA_DOCS=on')}`,
348
348
  `${ui_1.c.dim('tests')} same script — titles first, spec after`,
349
349
  `${ui_1.c.dim('retune')} ${ui_1.c.ice('daxta tree')} · ${ui_1.c.ice('daxta titles')}`,
350
350
  ]);
@@ -356,7 +356,7 @@ async function installDaxta(options = {}) {
356
356
  },
357
357
  {
358
358
  cmd: `${pm} start:dev`,
359
- why: 'open /api-docs (DAXTA_DOCS already in .env)',
359
+ why: 'open /docs (DAXTA_DOCS=on already in .env)',
360
360
  },
361
361
  ]);
362
362
  }
package/dist/config.d.ts CHANGED
@@ -47,6 +47,10 @@ export type DaxtaConfig = {
47
47
  exampleLabelStyle?: ExampleLabelStyle;
48
48
  port?: number;
49
49
  fieldsFile?: string;
50
+ /**
51
+ * URL prefix for the viewer. Default `/docs`.
52
+ * Override with env `DAXTA_DOCS_PATH` (e.g. `/docs` or `docs`).
53
+ */
50
54
  docsPath?: string;
51
55
  /**
52
56
  * Persisted Try-it env/header store (survives rebuild). Default `.daxta/viewer-store.json`.
@@ -67,6 +71,8 @@ export type DaxtaConfig = {
67
71
  treePathSegments?: (pathTemplate: string) => string[] | undefined;
68
72
  };
69
73
  export type ResolvedDaxtaConfig = Required<Pick<DaxtaConfig, 'workspace' | 'baseUrl' | 'controllersRoot' | 'outDir' | 'treeLayout' | 'treePathOverrides' | 'treeSkipParams' | 'exampleLabelStyle' | 'port' | 'fieldsFile' | 'docsPath' | 'viewerStoreFile'>> & DaxtaConfig;
74
+ export declare const DEFAULT_DOCS_PATH = "/docs";
75
+ export declare function normalizeDocsPath(raw?: string | null): string;
70
76
  export declare function defineConfig(config: DaxtaConfig): DaxtaConfig;
71
77
  export declare function normalizeTreeLayout(layout: TreeLayout | LegacyTreeLayout | undefined): TreeLayout;
72
78
  export declare function resolveConfig(cwd?: string, overrides?: DaxtaConfig): ResolvedDaxtaConfig;
package/dist/config.js CHANGED
@@ -33,6 +33,8 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.DEFAULT_DOCS_PATH = void 0;
37
+ exports.normalizeDocsPath = normalizeDocsPath;
36
38
  exports.defineConfig = defineConfig;
37
39
  exports.normalizeTreeLayout = normalizeTreeLayout;
38
40
  exports.resolveConfig = resolveConfig;
@@ -52,13 +54,19 @@ const DEFAULTS = {
52
54
  exampleLabelStyle: 'status-title-case',
53
55
  port: 5199,
54
56
  fieldsFile: '.daxta/out/fields.json',
55
- docsPath: '/api-docs',
57
+ docsPath: '/docs',
56
58
  viewerStoreFile: '.daxta/viewer-store.json',
57
59
  envPresets: {
58
60
  local: { baseUrl: 'http://localhost:3000' },
59
61
  },
60
62
  };
61
63
  let cached = null;
64
+ exports.DEFAULT_DOCS_PATH = '/docs';
65
+ function normalizeDocsPath(raw) {
66
+ const value = String(raw ?? exports.DEFAULT_DOCS_PATH).trim() || exports.DEFAULT_DOCS_PATH;
67
+ const withSlash = value.startsWith('/') ? value : `/${value}`;
68
+ return withSlash.replace(/\/$/, '') || exports.DEFAULT_DOCS_PATH;
69
+ }
62
70
  function defineConfig(config) {
63
71
  return config;
64
72
  }
@@ -106,6 +114,7 @@ function resolveConfig(cwd = process.cwd(), overrides) {
106
114
  if (merged.exampleLabelStyle == null)
107
115
  merged.exampleLabelStyle = DEFAULTS.exampleLabelStyle;
108
116
  merged.envPresets = normalizeEnvPresets(merged.envPresets, merged.baseUrl);
117
+ merged.docsPath = normalizeDocsPath(process.env.DAXTA_DOCS_PATH || merged.docsPath);
109
118
  merged.controllersRoot = path.isAbsolute(merged.controllersRoot)
110
119
  ? merged.controllersRoot
111
120
  : path.join(cwd, merged.controllersRoot);
@@ -15,10 +15,10 @@ function printDocsReady(hits, operations) {
15
15
  console.log('');
16
16
  console.log(` ${bold('API docs ready')}`);
17
17
  console.log(` ${dim('│')} ${green('✔')} ${cyan(url)} ${dim(`(${hits} hits · ${operations} ops)`)}`);
18
- console.log(` ${dim('│')} ${dim('DAXTA_DOCS=true')} required on app start`);
18
+ console.log(` ${dim('│')} ${dim('DAXTA_DOCS=on')} required on app start`);
19
19
  console.log('');
20
20
  console.log(` ${bold('Next')}`);
21
- console.log(` ${cyan('$')} ${bold('DAXTA_DOCS=true pnpm start:dev')}`);
21
+ console.log(` ${cyan('$')} ${bold('DAXTA_DOCS=on pnpm start:dev')}`);
22
22
  console.log(` ${dim(`open ${url}`)}`);
23
23
  console.log('');
24
24
  }
@@ -1,5 +1,5 @@
1
1
  export type ApiDocsOptions = {
2
- /** URL prefix for the API docs viewer. Default from config (`docsPath`) or `/api-docs`. */
2
+ /** URL prefix for the API docs viewer. Default from config (`docsPath`) / `DAXTA_DOCS_PATH` or `/docs`. */
3
3
  basePath?: string;
4
4
  };
5
5
  type LooseRequest = {
@@ -22,7 +22,7 @@ type LooseResponse = {
22
22
  };
23
23
  export type ApiDocsHandler = (req: LooseRequest, res: LooseResponse, next: (error?: unknown) => void) => void | Promise<void>;
24
24
  /**
25
- * Express / Nest handler that serves generated API docs under `/api-docs`
25
+ * Express / Nest handler that serves generated API docs under `/docs`
26
26
  * (or `basePath`), Try-it proxy at `/__proxy`, and env store at `{base}/env.json`.
27
27
  */
28
28
  export declare function apiDocsHandler(options?: ApiDocsOptions): ApiDocsHandler;
@@ -30,9 +30,11 @@ export declare function apiDocsHandler(options?: ApiDocsOptions): ApiDocsHandler
30
30
  * Mount generated API docs on a Nest / Express app (`app.use(...)`).
31
31
  *
32
32
  * Requires `DAXTA_DOCS` in the environment:
33
- * - missing / empty → throws (app must set it explicitly)
34
- * - `true` | `1` | `yes` | `on` → serve API docs
35
- * - `false` | `0` | `no` | `off` → no-op
33
+ * - missing / empty → throws
34
+ * - `on` → serve docs
35
+ * - `off` → no-op
36
+ *
37
+ * Path defaults to `/docs`. Override with `DAXTA_DOCS_PATH` or `docsPath` in config.
36
38
  */
37
39
  export declare function apiDocs(app: {
38
40
  use: (...handlers: unknown[]) => unknown;
@@ -96,11 +96,11 @@ async function readRequestJson(req) {
96
96
  }
97
97
  }
98
98
  /**
99
- * Express / Nest handler that serves generated API docs under `/api-docs`
99
+ * Express / Nest handler that serves generated API docs under `/docs`
100
100
  * (or `basePath`), Try-it proxy at `/__proxy`, and env store at `{base}/env.json`.
101
101
  */
102
102
  function apiDocsHandler(options = {}) {
103
- const basePath = (options.basePath ?? (0, paths_1.getDocsBasePath)()).replace(/\/$/, '') || '/api-docs';
103
+ const basePath = (options.basePath ?? (0, paths_1.getDocsBasePath)()).replace(/\/$/, '') || '/docs';
104
104
  return async (req, res, next) => {
105
105
  const method = (req.method || 'GET').toUpperCase();
106
106
  const pathname = requestPathname(req);
@@ -193,22 +193,22 @@ function apiDocsHandler(options = {}) {
193
193
  * Mount generated API docs on a Nest / Express app (`app.use(...)`).
194
194
  *
195
195
  * Requires `DAXTA_DOCS` in the environment:
196
- * - missing / empty → throws (app must set it explicitly)
197
- * - `true` | `1` | `yes` | `on` → serve API docs
198
- * - `false` | `0` | `no` | `off` → no-op
196
+ * - missing / empty → throws
197
+ * - `on` → serve docs
198
+ * - `off` → no-op
199
+ *
200
+ * Path defaults to `/docs`. Override with `DAXTA_DOCS_PATH` or `docsPath` in config.
199
201
  */
200
202
  function apiDocs(app, options = {}) {
201
203
  const raw = process.env.DAXTA_DOCS;
202
204
  if (raw == null || String(raw).trim() === '') {
203
- throw new Error('DAxTA: DAXTA_DOCS is not set. Set DAXTA_DOCS=true to enable API docs, or DAXTA_DOCS=false to disable.');
205
+ throw new Error('DAxTA: DAXTA_DOCS is not set. Set DAXTA_DOCS=on or DAXTA_DOCS=off.');
204
206
  }
205
207
  const normalized = String(raw).trim().toLowerCase();
206
- const enabled = ['1', 'true', 'yes', 'on'].includes(normalized);
207
- const disabled = ['0', 'false', 'no', 'off'].includes(normalized);
208
- if (!enabled && !disabled) {
209
- throw new Error(`DAxTA: invalid DAXTA_DOCS="${raw}". Use true/false (or 1/0).`);
208
+ if (normalized !== 'on' && normalized !== 'off') {
209
+ throw new Error(`DAxTA: invalid DAXTA_DOCS="${raw}". Use on or off.`);
210
210
  }
211
- if (!enabled)
211
+ if (normalized === 'off')
212
212
  return;
213
213
  app.use(apiDocsHandler(options));
214
214
  }
@@ -9,7 +9,7 @@ export declare function getEmptyViewerAssetPath(): string;
9
9
  export declare function readEmptyDocsHtml(): Buffer;
10
10
  export declare function getFaviconAssetPath(): string;
11
11
  export declare function getDocsBasePath(): string;
12
- /** App-origin URL where generated API docs are served (e.g. `http://localhost:3000/api-docs`). */
12
+ /** App-origin URL where generated API docs are served (e.g. `http://localhost:3000/docs`). */
13
13
  export declare function getApiDocUrl(): string;
14
14
  /** Paths and URL for the generated API docs artifact. */
15
15
  export declare function getApiDocs(): {
@@ -85,10 +85,9 @@ function getFaviconAssetPath() {
85
85
  return path.join(__dirname, '..', '..', 'assets', 'favicon.png');
86
86
  }
87
87
  function getDocsBasePath() {
88
- const configured = (0, config_1.getConfig)().docsPath ?? '/api-docs';
89
- return configured.startsWith('/') ? configured.replace(/\/$/, '') || '/api-docs' : `/${configured}`.replace(/\/$/, '');
88
+ return (0, config_1.normalizeDocsPath)(process.env.DAXTA_DOCS_PATH || (0, config_1.getConfig)().docsPath || config_1.DEFAULT_DOCS_PATH);
90
89
  }
91
- /** App-origin URL where generated API docs are served (e.g. `http://localhost:3000/api-docs`). */
90
+ /** App-origin URL where generated API docs are served (e.g. `http://localhost:3000/docs`). */
92
91
  function getApiDocUrl() {
93
92
  const config = (0, config_1.getConfig)();
94
93
  return `${String(config.baseUrl || '').replace(/\/$/, '')}${getDocsBasePath()}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@t0.labs/daxta",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "description": "DAxTA — Tested behavior. Trusted API docs. Generate API documentation from observed test execution.",
5
5
  "license": "MIT",
6
6
  "author": {