comparison benchmark/bun-http-framework-benchmark/src/bun/bunrest.ts @ 185:dfdd66825396

Merged in keep alive changes and mrjunejune changes.
author MrJuneJune <me@mrjunejune.com>
date Fri, 23 Jan 2026 22:22:30 -0800
parents a8976a008a9d
children
comparison
equal deleted inserted replaced
182:d6ab5921fedc 185:dfdd66825396
1 import Server from 'bunrest'
2
3 const app = Server()
4 const xPoweredBy = 'benchmark'
5
6 app.get('/', (req, res) => {
7 res.send('Hi')
8 })
9
10 // ? Can't read body
11 app.post('/json', async (req, res) => {
12 res.send(await req.json())
13 })
14
15 // ? Named parameter not implemented?
16 app.get('/id/:id', ({ params: { id }, query: { name } }, res) => {
17 const headers = new Headers()
18 headers.set('x-powered-by', xPoweredBy)
19
20 res.headers(headers)
21 res.send(`${id} ${name}`)
22 })
23
24 app.listen(3000)