Function: publishRoute()
publishRoute(
store,route,hash):Promise<void>
Defined in: publishRoute.ts:37
Points a route at an artifact and invalidates that one page, in that order — the body of the
POST /api/nubbin/publish handler an application exposes, which is where nubbin publish --origin <url> sends { route, hash }.
revalidatePath reaches only the cache of the process that runs it, so this has to run inside
the server that serves the page. Moving the pointer from a terminal instead leaves that server
answering from its cache until it restarts.
Parameters
store
ArtifactStore
The store serving the application. publish is the only method called.
route
string
The route to serve, exactly as it was compiled — resolveArtifact matches a
pointer by its route string, so a route published under a different spelling never resolves.
hash
string
The artifact to serve there. Write it first: this moves a pointer and never stores anything, and a pointer at a hash nothing has written is a live 404.
Returns
Promise<void>
Nothing. Publishing the same route and hash twice is a no-op in the store and invalidates the page again, so a retried publish is safe.
Throws
Whatever store.publish raises, before anything is invalidated — a store rejecting an
unwritten hash or an unaddressable route leaves the page that is live untouched.
Example
export async function POST(request: Request) {
const { route, hash } = (await request.json()) as { route: string; hash: string };
await publishRoute(store, route, hash);
return Response.json({ ok: true, route, hash });
}