mirror of
https://github.com/withastro/astro.git
synced 2024-12-23 21:53:55 -05:00
26 lines
713 B
TypeScript
26 lines
713 B
TypeScript
import { polyfill } from '@astrojs/webapi';
|
|
import type { SSRManifest } from 'astro';
|
|
import { NodeApp } from 'astro/app/node';
|
|
import middleware from './middleware.js';
|
|
import startServer from './standalone.js';
|
|
import type { Options } from './types';
|
|
|
|
polyfill(globalThis, {
|
|
exclude: 'window document',
|
|
});
|
|
|
|
export function createExports(manifest: SSRManifest, options: Options) {
|
|
const app = new NodeApp(manifest);
|
|
return {
|
|
handler: middleware(app, options.mode),
|
|
};
|
|
}
|
|
|
|
export function start(manifest: SSRManifest, options: Options) {
|
|
if (options.mode !== 'standalone' || process.env.ASTRO_NODE_AUTOSTART === 'disabled') {
|
|
return;
|
|
}
|
|
|
|
const app = new NodeApp(manifest);
|
|
startServer(app, options);
|
|
}
|