@takazudo/zudo-doc-history-server 0.2.0 → 0.2.1

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
@@ -17,12 +17,15 @@ pnpm dev -- \
17
17
  --port 4322
18
18
  ```
19
19
 
20
- | Flag | Required | Default | Description |
21
- | ------------------ | -------- | ------- | --------------------------------------------- |
22
- | `--content-dir` | Yes | — | Primary content directory to scan |
23
- | `--locale <k>:<d>` | No | — | Extra locale directory (repeatable) |
24
- | `--port` | No | `4322` | HTTP port |
25
- | `--max-entries` | No | `50` | Max commits to include per file |
20
+ | Flag | Required | Default | Description |
21
+ | ------------------ | -------- | ------------- | --------------------------------------------- |
22
+ | `--content-dir` | Yes | — | Primary content directory to scan |
23
+ | `--locale <k>:<d>` | No | — | Extra locale directory (repeatable) |
24
+ | `--port` | No | `4322` | HTTP port |
25
+ | `--host` | No | `127.0.0.1` | Network interface to bind (see note below) |
26
+ | `--max-entries` | No | `50` | Max commits to include per file |
27
+
28
+ > **Security note — `--host`:** The server exposes full git revision history including file content at every commit. It binds to `127.0.0.1` (loopback only) by default so it is not reachable from the LAN. The zfb dev plugin proxies `/doc-history/*` requests server-side, so both `pnpm dev` and `pnpm dev:network` work without LAN exposure. Pass `--host 0.0.0.0` only when you have a specific reason to accept remote connections.
26
29
 
27
30
  #### Endpoints
28
31
 
@@ -30,7 +33,7 @@ pnpm dev -- \
30
33
  - `GET /doc-history/{locale}/{slug}.json` — History for a localized document
31
34
  - `GET /health` — Health check
32
35
 
33
- The file index is refreshed every 10 seconds so newly added or renamed files are picked up without restarting the server. All responses include CORS headers for cross-origin dev access.
36
+ The file index is refreshed every 10 seconds so newly added or renamed files are picked up without restarting the server. All responses include CORS headers.
34
37
 
35
38
  ### CLI mode (CI builds)
36
39
 
@@ -50,9 +53,9 @@ pnpm generate -- \
50
53
  | `--out-dir` | Yes | — | Output directory for the generated JSONs |
51
54
  | `--max-entries` | No | `50` | Max commits to include per file |
52
55
 
53
- ## Astro integration
56
+ ## zfb integration
54
57
 
55
- In dev mode, the Astro integration at `src/integrations/doc-history.ts` proxies `/doc-history/*` requests to this server. In build mode, the integration falls back to inline generation unless `SKIP_DOC_HISTORY=1` is set — which is the case in the CI `build-site` job so that the Astro build completes fast while the CLI `build-history` job generates the JSONs in parallel.
58
+ In dev mode, the zfb integration at `packages/zudo-doc/src/integrations/doc-history/` proxies `/doc-history/*` requests to this server. In build mode, the integration falls back to inline generation unless `SKIP_DOC_HISTORY=1` is set — which is the case in the CI `build-site` job so that the zfb build completes fast while the CLI `build-history` job generates the JSONs in parallel.
56
59
 
57
60
  ## Build
58
61
 
@@ -64,7 +67,7 @@ Uses `tsup` to emit ESM output + DTS into `dist/`.
64
67
 
65
68
  ## Design notes
66
69
 
67
- - **Synchronous git** — uses `execFileSync` for `git log` calls. The dev server is single-user and CI is inherently sequential, so async streaming is not needed.
70
+ - **Async git** — all git calls use `execFile` / `spawn` (non-blocking). The CLI batch generator wraps each file in a semaphore-bounded Promise, so the async variant genuinely parallelizes across files (#1986). The server also uses the same async path so the event loop is never blocked.
68
71
  - **Repo-relative paths** — responses use relative file paths to avoid leaking absolute server paths.
69
72
  - **`--follow` for renames** — file history is tracked across renames with multiple fallback strategies.
70
- - **pnpm --filter CWD** — when run via `pnpm --filter`, the CWD is this package dir, so content paths passed from CI need `../../` prefix for repo-relative resolution.
73
+ - **pnpm --filter CWD** — when run via `pnpm --filter`, the CWD is this package dir. pnpm sets `INIT_CWD` to the repo root, so pass repo-root-relative content paths (e.g. `src/content/docs`) without any `../../` prefix.
@@ -0,0 +1,35 @@
1
+ // src/concurrency.ts
2
+ import { cpus } from "os";
3
+ function makeSemaphore(concurrency) {
4
+ let running = 0;
5
+ const queue = [];
6
+ function next() {
7
+ if (queue.length > 0 && running < concurrency) {
8
+ queue.shift()();
9
+ }
10
+ }
11
+ return function acquire() {
12
+ return new Promise((resolve) => {
13
+ function tryRun() {
14
+ if (running < concurrency) {
15
+ running++;
16
+ resolve(() => {
17
+ running--;
18
+ next();
19
+ });
20
+ } else {
21
+ queue.push(tryRun);
22
+ }
23
+ }
24
+ tryRun();
25
+ });
26
+ };
27
+ }
28
+ function defaultGitConcurrency() {
29
+ return Math.min(8, Math.max(2, cpus().length));
30
+ }
31
+
32
+ export {
33
+ makeSemaphore,
34
+ defaultGitConcurrency
35
+ };
@@ -81,62 +81,6 @@ function getCommitInfo(hash, filePath) {
81
81
  return { hash, date: "", author: "", message: "" };
82
82
  }
83
83
  }
84
- function getFileAtCommit(hash, filePath) {
85
- const isAbsolute = filePath.startsWith("/");
86
- const relPath = isAbsolute ? toRepoRelative(filePath) : filePath;
87
- try {
88
- return execFileSync("git", ["show", `${hash}:${relPath}`], gitOpts());
89
- } catch {
90
- try {
91
- const oldPath = execFileSync(
92
- "git",
93
- [
94
- "log",
95
- "-1",
96
- "--follow",
97
- "--diff-filter=R",
98
- "--format=",
99
- "--name-only",
100
- hash,
101
- "--",
102
- relPath
103
- ],
104
- gitOpts()
105
- ).trim();
106
- if (oldPath) {
107
- return execFileSync("git", ["show", `${hash}:${oldPath}`], gitOpts());
108
- }
109
- } catch {
110
- }
111
- try {
112
- const followOutput = execFileSync(
113
- "git",
114
- [
115
- "log",
116
- "--follow",
117
- "--format=%H",
118
- "--name-only",
119
- "--diff-filter=AMRC",
120
- "--",
121
- relPath
122
- ],
123
- gitOpts()
124
- ).trim();
125
- const lines = followOutput.split("\n").filter(Boolean);
126
- for (let i = 0; i < lines.length - 1; i += 2) {
127
- if (lines[i] === hash && lines[i + 1]) {
128
- return execFileSync(
129
- "git",
130
- ["show", `${hash}:${lines[i + 1]}`],
131
- gitOpts()
132
- );
133
- }
134
- }
135
- } catch {
136
- }
137
- return "";
138
- }
139
- }
140
84
  function parseCommitLog(output) {
141
85
  const records = [];
142
86
  const blocks = output.split(/\n\n+/).filter(Boolean);
@@ -153,19 +97,6 @@ function parseCommitLog(output) {
153
97
  }
154
98
  return records;
155
99
  }
156
- function buildHashToPathMap(filePath, maxEntries) {
157
- const relPath = filePath.startsWith("/") ? toRepoRelative(filePath) : filePath;
158
- try {
159
- const output = execFileSync(
160
- "git",
161
- hashToPathArgs(relPath, maxEntries),
162
- gitOpts()
163
- ).trim();
164
- return parseHashToPathMap(output);
165
- } catch {
166
- return /* @__PURE__ */ new Map();
167
- }
168
- }
169
100
  function hashToPathArgs(relPath, maxEntries) {
170
101
  return [
171
102
  "log",
@@ -212,26 +143,6 @@ async function buildHashToPathMapAsync(filePath, maxEntries) {
212
143
  return /* @__PURE__ */ new Map();
213
144
  }
214
145
  }
215
- function batchFetchContents(pairs) {
216
- if (pairs.length === 0) return /* @__PURE__ */ new Map();
217
- try {
218
- const rawBuf = execFileSync(
219
- "git",
220
- ["cat-file", "--batch"],
221
- // encoding must be omitted (or "buffer") to get a raw Buffer so that
222
- // byte offsets from the <size> field stay accurate across UTF-8 content.
223
- // cwd = repo root for the same reason as gitOpts() (see #1907 above).
224
- {
225
- stdio: ["pipe", "pipe", "pipe"],
226
- input: catFileBatchInput(pairs),
227
- cwd: getRepoRoot()
228
- }
229
- );
230
- return parseBatchContents(rawBuf, pairs);
231
- } catch {
232
- return /* @__PURE__ */ new Map();
233
- }
234
- }
235
146
  function catFileBatchInput(pairs) {
236
147
  return Buffer.from(
237
148
  pairs.map(({ hash, path }) => `${hash}:${path}`).join("\n"),
@@ -282,39 +193,6 @@ function batchFetchContentsAsync(pairs) {
282
193
  child.stdin.end();
283
194
  });
284
195
  }
285
- function getDocHistory(filePath, slug, maxEntries = 50) {
286
- const relPath = filePath.startsWith("/") ? toRepoRelative(filePath) : filePath;
287
- let metaRecords = [];
288
- try {
289
- const logOutput = execFileSync(
290
- "git",
291
- commitMetaArgs(relPath, maxEntries),
292
- gitOpts()
293
- ).trim();
294
- if (logOutput) {
295
- metaRecords = parseCommitLog(logOutput);
296
- }
297
- } catch {
298
- }
299
- if (metaRecords.length === 0) {
300
- return { slug, filePath: relPath, entries: [] };
301
- }
302
- const hashToPath = buildHashToPathMap(relPath, maxEntries);
303
- const pairs = metaRecords.map((rec) => ({
304
- hash: rec.hash,
305
- path: hashToPath.get(rec.hash) ?? relPath
306
- }));
307
- const contentMap = batchFetchContents(pairs);
308
- const entries = metaRecords.map((rec, i) => {
309
- const pair = pairs[i];
310
- if (contentMap.has(rec.hash)) {
311
- return { ...rec, content: contentMap.get(rec.hash) };
312
- }
313
- const content = getFileAtCommit(rec.hash, filePath);
314
- return { ...rec, content };
315
- });
316
- return { slug, filePath: relPath, entries };
317
- }
318
196
  function commitMetaArgs(relPath, maxEntries) {
319
197
  return [
320
198
  "log",
@@ -496,15 +374,15 @@ function collectContentFiles(dir) {
496
374
  walk(dir, dir);
497
375
  return results;
498
376
  }
377
+ var getDocHistory = getDocHistoryAsync;
499
378
 
500
379
  export {
501
380
  getFileCommits,
502
381
  getFirstCommit,
503
382
  getCommitInfo,
504
- getFileAtCommit,
505
- getDocHistory,
506
383
  getDocHistoryAsync,
507
384
  getFileCommitsMeta,
508
385
  getFileCommitsMetaAsync,
509
- collectContentFiles
386
+ collectContentFiles,
387
+ getDocHistory
510
388
  };
@@ -88,6 +88,7 @@ function parseCommonArgs(args, extra) {
88
88
  }
89
89
  function parseServerArgs(args) {
90
90
  let port = 4322;
91
+ let host = "127.0.0.1";
91
92
  const common = parseCommonArgs(args, {
92
93
  onFlag: (flag, next) => {
93
94
  if (flag === "--port") {
@@ -99,10 +100,14 @@ function parseServerArgs(args) {
99
100
  port = n;
100
101
  return true;
101
102
  }
103
+ if (flag === "--host") {
104
+ host = next();
105
+ return true;
106
+ }
102
107
  return false;
103
108
  }
104
109
  });
105
- return { ...common, port };
110
+ return { ...common, port, host };
106
111
  }
107
112
  function parseCliArgs(args) {
108
113
  let outDir = "";
package/dist/cli.js CHANGED
@@ -1,42 +1,20 @@
1
1
  #!/usr/bin/env node
2
+ import {
3
+ defaultGitConcurrency,
4
+ makeSemaphore
5
+ } from "./chunk-D7ABPNW2.js";
2
6
  import {
3
7
  getContentDirEntries,
4
8
  parseCliArgs
5
- } from "./chunk-JP2STGQX.js";
9
+ } from "./chunk-S2IER563.js";
6
10
  import {
7
11
  collectContentFiles,
8
12
  getDocHistoryAsync
9
- } from "./chunk-OP6QXSUZ.js";
13
+ } from "./chunk-FYNTYCJD.js";
10
14
 
11
15
  // src/cli.ts
12
16
  import { mkdirSync, writeFileSync } from "fs";
13
17
  import { dirname, join } from "path";
14
- import { cpus } from "os";
15
- function makeSemaphore(concurrency) {
16
- let running = 0;
17
- const queue = [];
18
- function next() {
19
- if (queue.length > 0 && running < concurrency) {
20
- queue.shift()();
21
- }
22
- }
23
- return function acquire() {
24
- return new Promise((resolve2) => {
25
- function tryRun() {
26
- if (running < concurrency) {
27
- running++;
28
- resolve2(() => {
29
- running--;
30
- next();
31
- });
32
- } else {
33
- queue.push(tryRun);
34
- }
35
- }
36
- tryRun();
37
- });
38
- };
39
- }
40
18
  async function generate(options2) {
41
19
  const { contentDir, locales, outDir, maxEntries } = options2;
42
20
  const startTime = performance.now();
@@ -44,7 +22,7 @@ async function generate(options2) {
44
22
  mkdirSync(outDir, { recursive: true });
45
23
  let totalFiles = 0;
46
24
  let errorCount = 0;
47
- const concurrency = Math.min(8, Math.max(2, cpus().length));
25
+ const concurrency = defaultGitConcurrency();
48
26
  const acquire = makeSemaphore(concurrency);
49
27
  const tasks = [];
50
28
  for (const [localeKey, dir] of dirEntries) {
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Tiny semaphore for bounded parallelism — avoids a p-limit dependency.
3
+ * Limits concurrent async tasks to `concurrency` at a time.
4
+ */
5
+ declare function makeSemaphore(concurrency: number): () => Promise<() => void>;
6
+ /**
7
+ * Default concurrency for git-history tasks: CPU count clamped to [2, 8].
8
+ * Each getFileCommitsMetaAsync / getDocHistoryAsync issues one git process,
9
+ * so this saturates git without spawning excessively on many-core machines.
10
+ */
11
+ declare function defaultGitConcurrency(): number;
12
+
13
+ export { defaultGitConcurrency, makeSemaphore };
@@ -0,0 +1,8 @@
1
+ import {
2
+ defaultGitConcurrency,
3
+ makeSemaphore
4
+ } from "./chunk-D7ABPNW2.js";
5
+ export {
6
+ defaultGitConcurrency,
7
+ makeSemaphore
8
+ };
@@ -27,35 +27,17 @@ declare function getFirstCommit(filePath: string): string | null;
27
27
  * Returns { hash, date, author, message } with full hash for unique identification.
28
28
  */
29
29
  declare function getCommitInfo(hash: string, filePath: string): Omit<DocHistoryEntry, "content">;
30
- /**
31
- * Get the file content at a specific commit.
32
- * Accepts absolute paths and converts to repo-relative for git show.
33
- * Handles renamed files by falling back to the old path via git log --follow.
34
- */
35
- declare function getFileAtCommit(hash: string, filePath: string): string;
36
30
  /**
37
31
  * Get the complete history for a document file.
38
32
  *
39
33
  * Optimised: uses ONE `git log --follow` for commit metadata and ONE
40
34
  * `git log --follow --name-only` for the hash→path map, then a single
41
- * `git cat-file --batch` for all content fetches. Falls back to the
42
- * original per-commit logic only for batch misses (renamed-path entries
43
- * where the current path didn't exist at that commit).
35
+ * `git cat-file --batch` for all content fetches. Falls back to
36
+ * per-commit logic only for batch misses (renamed-path entries where the
37
+ * current path didn't exist at that commit).
44
38
  *
45
- * Returns DocHistoryData with all entries populated.
46
- */
47
- declare function getDocHistory(filePath: string, slug: string, maxEntries?: number): DocHistoryData;
48
- /**
49
- * Async variant of getDocHistory.
50
- *
51
- * Byte-for-byte equivalent to the sync version (shares every parser and the
52
- * same git invocations) but issues each git command via execFile / spawn
53
- * instead of execFileSync. This matters for the CLI batch generator
54
- * (`cli.ts`): its semaphore wraps each file in a Promise, but the sync
55
- * getDocHistory's execFileSync blocks the event loop, so the "concurrency"
56
- * cap was a no-op and all files ran serially — blowing zfb's 120s postBuild
57
- * budget on large corpora (issue #1986). With genuine async git calls the
58
- * semaphore actually parallelizes the work.
39
+ * Issues all git commands via execFile / spawn (non-blocking) so the CLI's
40
+ * semaphore-bounded concurrency actually parallelizes across files (#1986).
59
41
  */
60
42
  declare function getDocHistoryAsync(filePath: string, slug: string, maxEntries?: number): Promise<DocHistoryData>;
61
43
  /**
@@ -65,10 +47,10 @@ declare function getDocHistoryAsync(filePath: string, slug: string, maxEntries?:
65
47
  */
66
48
  declare function getFileCommitsMeta(filePath: string): Array<Omit<DocHistoryEntry, "content">>;
67
49
  /**
68
- * Async variant of getFileCommitsMeta. Runs the same `git log --follow`
69
- * via execFile (non-blocking) so callers can issue multiple git spawns
70
- * concurrently. Returns an array of records newest-first (no -n limit).
71
- * Used by the pre-build parallelization path.
50
+ * Get commit metadata for a file using a single `git log --follow` walk
51
+ * (async variant). Runs via execFile (non-blocking) so callers can issue
52
+ * multiple git spawns concurrently. Returns an array of records newest-first
53
+ * (no -n limit). Used by the pre-build parallelization path.
72
54
  */
73
55
  declare function getFileCommitsMetaAsync(filePath: string): Promise<Array<Omit<DocHistoryEntry, "content">>>;
74
56
  /**
@@ -79,5 +61,12 @@ declare function collectContentFiles(dir: string): Array<{
79
61
  filePath: string;
80
62
  slug: string;
81
63
  }>;
64
+ /**
65
+ * Back-compat alias for the public `./git-history` subpath: the sync
66
+ * `getDocHistory` was removed when the duplicated sync orchestration
67
+ * family was deleted (#2011). The alias keeps the exported name resolving
68
+ * for existing consumers — note it is now async (returns a Promise).
69
+ */
70
+ declare const getDocHistory: typeof getDocHistoryAsync;
82
71
 
83
- export { collectContentFiles, getCommitInfo, getDocHistory, getDocHistoryAsync, getFileAtCommit, getFileCommits, getFileCommitsMeta, getFileCommitsMetaAsync, getFirstCommit };
72
+ export { collectContentFiles, getCommitInfo, getDocHistory, getDocHistoryAsync, getFileCommits, getFileCommitsMeta, getFileCommitsMetaAsync, getFirstCommit };
@@ -3,18 +3,16 @@ import {
3
3
  getCommitInfo,
4
4
  getDocHistory,
5
5
  getDocHistoryAsync,
6
- getFileAtCommit,
7
6
  getFileCommits,
8
7
  getFileCommitsMeta,
9
8
  getFileCommitsMetaAsync,
10
9
  getFirstCommit
11
- } from "./chunk-OP6QXSUZ.js";
10
+ } from "./chunk-FYNTYCJD.js";
12
11
  export {
13
12
  collectContentFiles,
14
13
  getCommitInfo,
15
14
  getDocHistory,
16
15
  getDocHistoryAsync,
17
- getFileAtCommit,
18
16
  getFileCommits,
19
17
  getFileCommitsMeta,
20
18
  getFileCommitsMetaAsync,
package/dist/index.js CHANGED
@@ -2,23 +2,26 @@
2
2
  import {
3
3
  getContentDirEntries,
4
4
  parseServerArgs
5
- } from "./chunk-JP2STGQX.js";
5
+ } from "./chunk-S2IER563.js";
6
6
  import {
7
7
  collectContentFiles,
8
- getDocHistory
9
- } from "./chunk-OP6QXSUZ.js";
8
+ getDocHistoryAsync
9
+ } from "./chunk-FYNTYCJD.js";
10
10
 
11
11
  // src/server.ts
12
12
  import { createServer } from "http";
13
13
  import { resolve } from "path";
14
14
  var FILE_INDEX_REFRESH_MS = 1e4;
15
- function setCorsHeaders(res) {
16
- res.setHeader("Access-Control-Allow-Origin", "*");
17
- res.setHeader("Access-Control-Allow-Methods", "GET, OPTIONS");
18
- res.setHeader("Access-Control-Allow-Headers", "Content-Type");
15
+ function setCorsHeaders(res, origin) {
16
+ const isLocalhost = origin !== void 0 && /^https?:\/\/(localhost|127\.0\.0\.1)(:\d+)?$/.test(origin);
17
+ if (isLocalhost) {
18
+ res.setHeader("Access-Control-Allow-Origin", origin);
19
+ res.setHeader("Access-Control-Allow-Methods", "GET, OPTIONS");
20
+ res.setHeader("Access-Control-Allow-Headers", "Content-Type");
21
+ }
19
22
  }
20
- function sendJson(res, status, data) {
21
- setCorsHeaders(res);
23
+ function sendJson(res, status, data, origin) {
24
+ setCorsHeaders(res, origin);
22
25
  res.writeHead(status, { "Content-Type": "application/json" });
23
26
  res.end(JSON.stringify(data));
24
27
  }
@@ -33,17 +36,17 @@ function buildFileIndex(dirEntries) {
33
36
  }
34
37
  return index;
35
38
  }
36
- function handleDocHistory(requestedSlug, fileIndex, maxEntries, res) {
39
+ async function handleDocHistory(requestedSlug, fileIndex, maxEntries, res, origin) {
37
40
  const found = fileIndex.get(requestedSlug);
38
41
  if (found) {
39
- const history = getDocHistory(found.filePath, found.slug, maxEntries);
40
- sendJson(res, 200, history);
42
+ const history = await getDocHistoryAsync(found.filePath, found.slug, maxEntries);
43
+ sendJson(res, 200, history, origin);
41
44
  return;
42
45
  }
43
- sendJson(res, 404, { error: `No doc found for slug: ${requestedSlug}` });
46
+ sendJson(res, 404, { error: `No doc found for slug: ${requestedSlug}` }, origin);
44
47
  }
45
48
  function startServer(options2) {
46
- const { port, contentDir, locales, maxEntries } = options2;
49
+ const { port, host, contentDir, locales, maxEntries } = options2;
47
50
  const dirEntries = getContentDirEntries(contentDir, locales);
48
51
  let fileIndex = buildFileIndex(dirEntries);
49
52
  console.log(`Indexed ${fileIndex.size} documents`);
@@ -55,33 +58,38 @@ function startServer(options2) {
55
58
  }, FILE_INDEX_REFRESH_MS);
56
59
  const server = createServer((req, res) => {
57
60
  const url = req.url ?? "";
61
+ const origin = req.headers.origin;
58
62
  if (req.method === "OPTIONS") {
59
- setCorsHeaders(res);
63
+ setCorsHeaders(res, origin);
60
64
  res.writeHead(204);
61
65
  res.end();
62
66
  return;
63
67
  }
64
68
  const pathname = url.split(/[?#]/, 1)[0] ?? "";
65
69
  if (pathname === "/health") {
66
- sendJson(res, 200, { status: "ok" });
70
+ sendJson(res, 200, { status: "ok" }, origin);
67
71
  return;
68
72
  }
69
73
  const match = pathname.match(/^\/doc-history\/(.+)\.json$/);
70
74
  if (match) {
75
+ let requestedSlug;
71
76
  try {
72
- const requestedSlug = decodeURIComponent(match[1] ?? "");
73
- handleDocHistory(requestedSlug, fileIndex, maxEntries, res);
74
- } catch (err) {
77
+ requestedSlug = decodeURIComponent(match[1] ?? "");
78
+ } catch {
79
+ sendJson(res, 400, { error: "Malformed percent-encoding in slug" }, origin);
80
+ return;
81
+ }
82
+ handleDocHistory(requestedSlug, fileIndex, maxEntries, res, origin).catch((err) => {
75
83
  sendJson(res, 500, {
76
84
  error: err instanceof Error ? err.message : "Internal error"
77
- });
78
- }
85
+ }, origin);
86
+ });
79
87
  return;
80
88
  }
81
- sendJson(res, 404, { error: "Not found" });
89
+ sendJson(res, 404, { error: "Not found" }, origin);
82
90
  });
83
- server.listen(port, () => {
84
- console.log(`Doc history server listening on http://localhost:${port}`);
91
+ server.listen(port, host, () => {
92
+ console.log(`Doc history server listening on http://${host}:${port}`);
85
93
  console.log(`Content dir: ${resolve(contentDir)}`);
86
94
  for (const locale of locales) {
87
95
  console.log(`Locale ${locale.key}: ${resolve(locale.dir)}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@takazudo/zudo-doc-history-server",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "type": "module",
5
5
  "description": "Standalone doc git-history service for zudo-doc — HTTP server + CLI batch generator. Decouples expensive `git log --follow` calls from the main build pipeline.",
6
6
  "license": "MIT",
@@ -41,6 +41,10 @@
41
41
  "types": "./dist/types.d.ts",
42
42
  "default": "./dist/types.js"
43
43
  },
44
+ "./concurrency": {
45
+ "types": "./dist/concurrency.d.ts",
46
+ "default": "./dist/concurrency.js"
47
+ },
44
48
  "./package.json": "./package.json"
45
49
  },
46
50
  "files": [
@@ -55,7 +59,7 @@
55
59
  "vitest": "^4.1.0"
56
60
  },
57
61
  "scripts": {
58
- "build": "tsup src/index.ts src/cli.ts src/git-history.ts src/types.ts --format esm --dts",
62
+ "build": "tsup src/index.ts src/cli.ts src/git-history.ts src/types.ts src/concurrency.ts --format esm --dts",
59
63
  "dev": "tsx src/index.ts",
60
64
  "generate": "tsx src/cli.ts",
61
65
  "test": "vitest run",