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