inkan

Static files

The built frontend next to the API, with the fallback a single-page app needs.

import { ,  } from "@vxnsin/inkan";


  .(())
  .(({ : "client/dist", : true, : ["/api"] }));

Serves the files of a folder. Every route of the app wins against them. A hashed asset under /assets/ is cached for a year; everything else, and the page itself, is asked for again (no-cache), with an ETag and a 304 when nothing changed. Nothing outside the folder and no dotfile is ever served.

Options

optiondefault
dirthe folder the files come from
prefix/where they are served
spafalsefor a single-page app: a GET that finds no file gets index.html (or the file named), with no-cache
excludepaths that stay out of the fallback and answer 404, like ["/api"], so a mistyped API call is not handed a page
immutablea path under /assets/files that never change under their name: a regular expression or (path) => boolean
maxAge0max-age in seconds for every other file
indexindex.htmlthe file a folder answers with

On this page