https://github.com/backendstack21/0http-bun
Bun-based HTTP framework inspired by 0http
https://github.com/backendstack21/0http-bun
Last synced: 9 months ago
JSON representation
Bun-based HTTP framework inspired by 0http
- Host: GitHub
- URL: https://github.com/backendstack21/0http-bun
- Owner: BackendStack21
- License: mit
- Created: 2022-11-18T14:33:40.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2025-03-22T09:39:28.000Z (10 months ago)
- Last Synced: 2025-04-18T20:49:19.632Z (9 months ago)
- Language: JavaScript
- Size: 86.9 KB
- Stars: 5
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Introduction
Experimental, bun-based HTTP framework inspired by [0http](https://0http.21no.de/#/)

> MacBook Pro (13-inch, 2020)
## Usage
```js
const http = require('0http-bun')
const { router } = http({
port: 3000
})
router.use((req, next) => {
req.ctx = {
engine: 'bun'
}
return next()
})
router.get('/:id', async (req) => {
return Response.json(req.params)
})
router.post('/', async (req) => {
return new Response('POST')
})
router.delete('/:id', async (req) => {
return Response.json(req.params, {
status: 200
})
})
export default router
```
# Benchmarks
## 0http-bun (bun v0.2.2)
```
% wrk -t4 -c50 -d10s --latency http://127.0.0.1:3000/hi
Running 10s test @ http://127.0.0.1:3000/hi
4 threads and 50 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 463.26us 99.23us 4.28ms 96.62%
Req/Sec 25.98k 1.10k 27.48k 76.73%
Latency Distribution
50% 442.00us
75% 466.00us
90% 485.00us
99% 0.91ms
1044377 requests in 10.10s, 127.49MB read
Requests/sec: 103397.66
Transfer/sec: 12.62MB
```
## 0http (node v18.2.0)
```
% wrk -t4 -c50 -d10s --latency http://127.0.0.1:3000/hi
Running 10s test @ http://127.0.0.1:3000/hi
4 threads and 50 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 0.98ms 251.77us 13.04ms 95.09%
Req/Sec 12.31k 771.37 16.96k 95.29%
Latency Distribution
50% 0.95ms
75% 0.96ms
90% 0.98ms
99% 1.88ms
493899 requests in 10.10s, 63.59MB read
Requests/sec: 48893.32
Transfer/sec: 6.29MB
```
## express (node v18.2.0)
```
% wrk -t4 -c50 -d10s --latency http://127.0.0.1:3000/hi
Running 10s test @ http://127.0.0.1:3000/hi
4 threads and 50 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 4.99ms 0.90ms 20.31ms 89.52%
Req/Sec 2.42k 154.52 2.66k 82.25%
Latency Distribution
50% 4.67ms
75% 4.83ms
90% 6.03ms
99% 8.43ms
96296 requests in 10.01s, 21.95MB read
Requests/sec: 9622.74
Transfer/sec: 2.19MB
```
# Support / Donate 💚
You can support the maintenance of this project:
- PayPal: https://www.paypal.me/kyberneees