Serving Files

Mage has multiple mechanisms for serving files from the file system.

Single file

You can serve a single file via a utility method on the context.

await c.file("path/to/file.txt");

A directory

Mage provides a middleware to serve files from a directory based on a wildcard.

import { useServeFiles } from "@mage/app/serve-files"; 

app.get(
  "/public/*",
  useServeFiles({ directory: resolve(Deno.cwd(), "./public") })
);