Packages
Static File Handling Package
A guide to static file handling in Raptor
Installation
To start using the static file handling, simply install into an existing Raptor application via the CLI or, if you are using Deno, import it directly from JSR.
deno add jsr:@raptor/staticbunx jsr add @raptor/staticnpx jsr add @raptor/staticyarn dlx jsr add @raptor/staticpnpm dlx jsr add @raptor/staticUsage
The static handler supports a configurable path, relative to the current working directory.
import static from "@raptor/static";
import { Kernel, Context } from "@raptor/kernel";
const app = new Kernel();
app.use(static({
staticFileDirectory: "public"
}));
app.use(() => `
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="/css/style.css">
</head>
<body>
<h1>It's a UNIX System! I know this!</h1>
</body>
</html>
`);
app.serve();The code above will render an HTML page and load in the stylesheet with the correct headers.