Skip to main content

@nubbin/store-fs

The reference artifact store for Nubbin, on the filesystem. One file per artifact, one pointer file per route, and no aggregate document — so two publishes to different routes cannot lose each other's write, because there is no shared file to read and rewrite.

npm install @nubbin/store-fs
import { createFsArtifactStore } from "@nubbin/store-fs";

const store = createFsArtifactStore("./.nubbin");
await store.write(artifact);
await store.publish("/promotions/summer", artifact.hash);
.nubbin/
artifacts/<hash>.json
routes/%2Fpromotions%2Fsummer.json
history/%2Fpromotions%2Fsummer.jsonl

Writes are temp-then-rename, so a concurrent reader sees the old pointer or the new one and never half of either. manifest() reads the pointer directory rather than a stored file, so there is nothing to keep in step.

Each publish also appends one line to the route's history log — after the pointer has moved, so a failed publish is never recorded as live. Appending writes only the new line, never reading the log back to rewrite it, so concurrent publishes of one route cannot lose each other's entry either. history(route) reads it back oldest first, and unpublish leaves it where it is.

It passes a shared ArtifactStore contract suite, which is how a replacement adapter proves itself equivalent — by execution rather than by inspection.

Read the Nubbin documentation for the complete artifact store reference. MIT.

Functions