https://github.com/billykirk01/verse
A lightweight tool for serving http built on top of the Deno standard library.
https://github.com/billykirk01/verse
deno http-server typescript
Last synced: about 1 month ago
JSON representation
A lightweight tool for serving http built on top of the Deno standard library.
- Host: GitHub
- URL: https://github.com/billykirk01/verse
- Owner: billykirk01
- Created: 2021-12-02T19:24:58.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-03-04T14:22:26.000Z (over 4 years ago)
- Last Synced: 2025-01-20T23:48:21.160Z (over 1 year ago)
- Topics: deno, http-server, typescript
- Language: TypeScript
- Homepage:
- Size: 15.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ✨ verse
A lightweight tool for serving http built on top of the Deno standard library.
This project takes much inspiration from the
[sift](https://github.com/satyarohith/sift) Deno project so thank you
[@satyarohith](https://github.com/satyarohith) for that work.
## 📦 Importing
```typescript
import {
serveJson,
serveMarkdown,
serveRemote,
serveStatic,
} from "https://deno.land/x/verse/mod.ts";
```
## 📖 Example Usage
This package can be nicley paired with something like
[Router](https://crux.land/router@0.0.5) by
[Denosaurs](https://github.com/denosaurs)
```typescript
import { serve } from "https://deno.land/std@0.114.0/http/server.ts";
import { router } from "https://crux.land/router@0.0.5";
import { serveJson, serveMarkdown, serveRemote, serveStatic } from "./mod.ts";
const handler = router({
// a single file
"/": serveStatic("./public/index.html"),
// a directory of files (browsing to /public will present a directory listing page)
// note: must include :filename? at end of the path as below
"/public/:filename?": serveStatic("./public"),
// json
"/json": serveJson({ "Hello": "world" }),
// a remote resource
"/todos/:id": serveRemote("https://jsonplaceholder.typicode.com/todos/:id"),
// a markdown file rendered in Github flavored html
"/markdown": serveMarkdown(
"https://raw.githubusercontent.com/billykirk01/verse/master/README.md",
),
});
console.log("Listening on http://localhost:8000");
await serve(handler);
```