Mercurial
comparison benchmark/bun-http-framework-benchmark/src/node/koa.js @ 186:8cf4ec5e2191 hg-web
Fixed merge conflict.
| author | MrJuneJune <me@mrjunejune.com> |
|---|---|
| date | Fri, 23 Jan 2026 22:38:59 -0800 |
| parents | a8976a008a9d |
| children |
comparison
equal
deleted
inserted
replaced
| 176:fed99fc04e12 | 186:8cf4ec5e2191 |
|---|---|
| 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) |