Mercurial
comparison benchmark/bun-http-framework-benchmark/src/node/hapi.js @ 183:a8976a008a9d
[BenchMark] Added bun bench mark to test seoboe vs other popular benchmarks.
| author | MrJuneJune <me@mrjunejune.com> |
|---|---|
| date | Fri, 23 Jan 2026 21:19:08 -0800 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 179:8d17f6e6e290 | 183:a8976a008a9d |
|---|---|
| 1 const Hapi = require("@hapi/hapi") | |
| 2 | |
| 3 const init = async () => { | |
| 4 const server = Hapi.server({ | |
| 5 port: 3000, | |
| 6 host: "localhost" | |
| 7 }) | |
| 8 | |
| 9 server.route([ | |
| 10 { | |
| 11 method: "GET", | |
| 12 path: "/", | |
| 13 handler: (request, h) => "Hi" | |
| 14 }, | |
| 15 { | |
| 16 method: "POST", | |
| 17 path: "/json", | |
| 18 handler: (request, h) => h.response(request.payload) | |
| 19 }, | |
| 20 { | |
| 21 method: "GET", | |
| 22 path: "/id/{id}", | |
| 23 handler: (request, h) => { | |
| 24 response.header("x-powered-by", "benchmark") | |
| 25 return h.response(`${request.params.id} ${request.query.name}`) | |
| 26 } | |
| 27 } | |
| 28 ]) | |
| 29 | |
| 30 await server.start() | |
| 31 console.log("Server running on %s", server.info.uri) | |
| 32 } | |
| 33 | |
| 34 init().catch((error) => { | |
| 35 console.error(error) | |
| 36 process.exit(1) | |
| 37 }) |