diff --git a/README.md b/README.md index e609e98..0b53198 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,12 @@ Minimum TypeScript compiler options: An example app: ```tsx -import { MageApp, StatusCode, useSecurityHeaders } from "@mage/server"; +import { + MageApp, + StatusCode, + useSecurityHeaders, + useServeFiles, +} from "@mage/server"; const app = new MageApp(); @@ -53,6 +58,8 @@ app.get("/render", async (context) => { ); }); +app.get("/public/*", useServeFiles({ directory: "./public" })); + app.run({ port: 8000, onListen({ hostname, port }) { @@ -129,7 +136,7 @@ A collection of prebuilt middleware is available to use. | `useNotFound` | Responds with 404, ignores preflight (OPTIONS) requests | | `useOptions` | Responds to preflight (OPTIONS) requests | | `useSecurityHeaders` | Adds recommended security headers to the response | -| `serveFiles` | Serve files from a durectory based on the wildcard on context | +| `useServeFiles` | Serve files from a durectory based on the wildcard on context | ## Context @@ -229,6 +236,16 @@ await context.rewrite("/new-location"); await context.rewrite("https://example.com"); ``` +#### `serveFile` + +Serve a file from the file system. + +```tsx +await context.serveFile("path/to/file"); +``` + +#### + ### Cookies You can read cookies from the request. diff --git a/deno.json b/deno.json index a9b1a67..bc25117 100644 --- a/deno.json +++ b/deno.json @@ -1,6 +1,6 @@ { "name": "@mage/server", - "version": "0.8.0", + "version": "0.8.1", "license": "MIT", "exports": "./mod.ts", "tasks": {