astro/benchmark/packages/timer/src/server.ts

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

19 lines
506 B
TypeScript
Raw Normal View History

2023-03-06 22:55:44 +08:00
import type { SSRManifest } from 'astro';
import { NodeApp, applyPolyfills } from 'astro/app/node';
import type { IncomingMessage, ServerResponse } from 'node:http';
2023-03-06 22:55:44 +08:00
applyPolyfills();
2023-03-06 22:55:44 +08:00
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();
},
};
}