Skip to content

Commit

Permalink
docs: updated readme (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
LeeCheneler authored Nov 22, 2024
1 parent 0ece8ce commit 5727db6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
21 changes: 19 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -53,6 +58,8 @@ app.get("/render", async (context) => {
);
});

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

app.run({
port: 8000,
onListen({ hostname, port }) {
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion deno.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mage/server",
"version": "0.8.0",
"version": "0.8.1",
"license": "MIT",
"exports": "./mod.ts",
"tasks": {
Expand Down

0 comments on commit 5727db6

Please sign in to comment.