comparison benchmark/bun-http-framework-benchmark/src/node/koa.js @ 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 const Koa = require('koa')
2 const Router = require('koa-router')
3 const bodyParser = require('koa-bodyparser')
4
5 const app = new Koa()
6 const router = new Router()
7
8 app.use(bodyParser())
9
10 router
11 .get('/', (ctx) => {
12 ctx.body = 'Hi'
13 })
14 .get('/id/:id', (ctx) => {
15 ctx.body = `${ctx.params.id} ${ctx.query.name}`
16 ctx.set('x-powered-by', 'benchmark')
17 })
18 .post('/json', (ctx) => {
19 ctx.body = ctx.request.body
20 })
21
22 app.use(router.routes())
23 app.use(router.allowedMethods())
24 app.listen(3000)