Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wobsoriano/siopao
A minimal routing library designed to sit on top of Bun's fast HTTP server.
https://github.com/wobsoriano/siopao
bun http router
Last synced: 29 days ago
JSON representation
A minimal routing library designed to sit on top of Bun's fast HTTP server.
- Host: GitHub
- URL: https://github.com/wobsoriano/siopao
- Owner: wobsoriano
- License: mit
- Created: 2022-07-09T02:38:10.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-06-21T18:01:00.000Z (7 months ago)
- Last Synced: 2024-12-17T10:05:49.947Z (about 1 month ago)
- Topics: bun, http, router
- Language: TypeScript
- Homepage:
- Size: 204 KB
- Stars: 88
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-bun - siopao - A minimal routing library designed to sit on top of Bun's fast HTTP server (Frameworks & Libraries)
- awesome-bun - Siopao - Minimal routing library. Based on Radix Tree. (Extensions / Libraries)
README
# siopao
[![npm (tag)](https://img.shields.io/npm/v/siopao?style=flat&colorA=000000&colorB=000000)](https://www.npmjs.com/package/siopao) ![NPM](https://img.shields.io/npm/l/siopao?style=flat&colorA=000000&colorB=000000)
A minimal routing library designed to sit on top of [Bun](https://github.com/Jarred-Sumner/bun)'s [fast HTTP server](https://bun.sh/docs/api/http). Based on [Radix Tree](https://github.com/unjs/radix3).
Sio=Hot Pao=Bun
## Installation
```bash
bun add siopao
```## Usage
```ts
import { Siopao } from 'siopao'const app = new Siopao()
app.get('/ping', () => new Response('pong'))
// Named route
app.get('/path/:name', (request) => {
return Response.json({
name: request.params.name
})
})// Wildcard route
app.use('/path/foo/**', (request) => {
return new Response('Wildcard route')
})// Named Wildcard route
app.use('/path/foo/**:name', (request) => {
return new Response('Named Wildcard route')
})app.serve({ port: 3000 }, () => {
console.log('Listening on port 3000...')
})
```If you have custom logic to add inside Bun's fetch option, you can use the `fetch` method instead:
```ts
const app = new Siopao()app.get('/ping', () => new Response('pong'))
Bun.serve({
port: 3000,
fetch: (request) => {
// Custom logic herereturn app.fetch(request)
}
})
```For a more complete fully type-safe web framework, check out [Elysia](https://elysiajs.com/).
## License
MIT