0.4.3 • Published 1 year ago

siopao v0.4.3

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year 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.3

1 year ago

0.4.2

1 year ago

0.3.0

2 years ago

0.4.0

2 years ago

0.2.7

3 years ago

0.2.8

3 years ago

0.2.6

3 years ago

0.2.5

3 years ago

0.2.4

3 years ago

0.2.3

3 years ago

0.2.2

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago