feat(bench): green-tea/express/fastify/raw-http servers with parity controls

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
This commit is contained in:
chrnx committed 2026-07-06 22:39:35 -05:00
1 parent 67133ca4ce
commit 92ca5f96da
4 files changed
+101

No files matched your search

+19
View File
@@ -0,0 +1,19 @@
import Fastify from 'fastify';
const app = Fastify({ logger: false });
app.get('/hello', async () => ({ hello: 'world' }));
app.get('/users/:id', async (req: any) => ({ id: req.params.id }));
const hook = (n: number) => (req: any, _res: any, done: any) => { req[`s${n}`] = n; done(); };
app.get('/pipeline', { preHandler: [hook(1), hook(2), hook(3)] }, async (req: any) => ({ hello: 'world', s3: req.s3 }));
app.post('/validate', {
schema: { body: { type: 'object', required: ['email'], properties: { email: { type: 'string' } } } },
}, async (req: any, reply) => {
const b = req.body;
if (!b.email.includes('@')) { reply.code(422); return { error: 'invalid' }; }
return { email: b.email };
});
app.listen({ port: 0 }, (err, addr) => {
if (err) { console.error(err); process.exit(1); }
(app.server as any).keepAliveTimeout = 5000;
console.log(`READY ${Number(new URL(addr).port)}`);
});