0.4.2 • Published 3 months ago

siopao v0.4.2

Weekly downloads
-
License
MIT
Repository
-
Last release
3 months ago

siopao

npm (tag) NPM

A minimal routing library designed to sit on top of Bun's fast HTTP server. Based on Radix Tree.

Sio=Hot Pao=Bun

Installation

bun add siopao

Usage

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:

const app = new Siopao()

app.get('/ping', () => new Response('pong'))

Bun.serve({
  port: 3000,
  fetch: (request) => {
    // Custom logic here

    return app.fetch(request)
  }
})

For a more complete fully type-safe web framework, check out Elysia.

License

MIT

0.4.2

3 months ago

0.3.0

10 months ago

0.4.0

8 months ago

0.2.7

2 years ago

0.2.8

1 year ago

0.2.6

2 years ago

0.2.5

2 years ago

0.2.4

2 years ago

0.2.3

2 years ago

0.2.2

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago