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
679 B
TypeScript
Raw Normal View History

import type { SSRManifest } from 'astro';
import type { Options } from './types';
import { polyfill } from '@astrojs/webapi';
2022-06-06 16:49:53 +00:00
import { NodeApp } from 'astro/app/node';
import middleware from './middleware.js';
import startServer from './standalone.js';
polyfill(globalThis, {
2022-03-24 11:27:15 +00:00
exclude: 'window document',
});
export function createExports(manifest: SSRManifest) {
const app = new NodeApp(manifest);
return {
handler: middleware(app)
2022-03-24 11:27:15 +00:00
};
}
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);
}