10LOC

#static-files

Bunintermediate

A static file router that falls back to Bun.file

import { serve, file } from "bun";

const PUBLIC_DIR = `${import.meta.dir}/public`;

const server = serve({

A fetch handler can serve API routes first and fall back to Bun.file for anything else, building a static file server without a separate static-file middleware.