0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2025-02-03 22:29:08 -05:00
astro/benchmark/packages/timer/src/server.ts
Emanuele Stoppa 4c9a42c2da [ci] format
2024-11-06 12:34:13 +00:00

18 lines
506 B
TypeScript

import type { IncomingMessage, ServerResponse } from 'node:http';
import type { SSRManifest } from 'astro';
import { NodeApp, applyPolyfills } from 'astro/app/node';
applyPolyfills();
export function createExports(manifest: SSRManifest) {
const app = new NodeApp(manifest);
return {
handler: async (req: IncomingMessage, res: ServerResponse) => {
const start = performance.now();
await app.render(req);
const end = performance.now();
res.write(end - start + '');
res.end();
},
};
}