server/file_fact_fetcher.ts

Filesystem-backed FactExternalFetcher.

Resolves file:<shard>/<rest> external URLs against a configured facts directory. The URL shape is the canonical relative-path scheme: 2 hex chars for the shard subdir + 62 hex chars for the rest of the blake3 hash (64 hex chars total). Files live at <facts_dir>/<shard>/<rest> after the writer atomically temp+renames them in.

Pre-filter regex: ^file:[0-9a-f]{2}/[0-9a-f]{62}$. A .. segment can't match (. isn't in [0-9a-f]); neither can absolute paths, query strings, or any non-hex character. Defense-in-depth in front of path.join — the fetcher never trusts the URL came from a fact row, even though it always does in practice.

The fetcher does NOT verify hash content — PgFactStore.get calls fact_hash_verify(hash, bytes) after the fetch and returns null on mismatch.

Runtime: uses node:fs/promises + node:fs createReadStream so the same code works under Deno (via node compat) and vitest.

view source

Declarations
#

2 declarations

create_file_fact_fetcher
#

server/file_fact_fetcher.ts view source

(options: FileFactFetcherOptions): FactExternalFetcher import {create_file_fact_fetcher} from '@fuzdev/fuz_app/server/file_fact_fetcher.js';

Build a FactExternalFetcher that resolves file: URLs against the filesystem. Throws on a malformed URL before touching the disk so PgFactStore.get logs the warning + returns null without an I/O round-trip on bad data.

options

returns

FactExternalFetcher

FileFactFetcherOptions
#

server/file_fact_fetcher.ts view source

FileFactFetcherOptions import type {FileFactFetcherOptions} from '@fuzdev/fuz_app/server/file_fact_fetcher.js';

Construction options.

facts_dir

Absolute path to the facts directory. Files resolve to <facts_dir>/<shard>/<rest>.

type string

Depends on
#