astro/packages/integrations/node/src/server.ts

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

27 lines
713 B
TypeScript
Raw Normal View History

import { polyfill } from '@astrojs/webapi';
2022-10-12 21:27:56 +00:00
import type { SSRManifest } from 'astro';
2022-06-06 16:49:53 +00:00
import { NodeApp } from 'astro/app/node';
import middleware from './middleware.js';
import startServer from './standalone.js';
2022-10-12 21:27:56 +00:00
import type { Options } from './types';
polyfill(globalThis, {
2022-03-24 11:27:15 +00:00
exclude: 'window document',
});
export function createExports(manifest: SSRManifest, options: Options) {
const app = new NodeApp(manifest);
return {
handler: middleware(app, options.mode),
2022-03-24 11:27:15 +00:00
};
}
export function start(manifest: SSRManifest, options: Options) {
2022-10-12 21:27:56 +00:00
if (options.mode !== 'standalone' || process.env.ASTRO_NODE_AUTOSTART === 'disabled') {
return;
}
const app = new NodeApp(manifest);
startServer(app, options);
}