0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-30 22:03:56 -05:00
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 16:27:56 -05:00
import type { SSRManifest } from 'astro';
2022-06-06 11:49:53 -05:00
import { NodeApp } from 'astro/app/node';
import middleware from './middleware.js';
import startServer from './standalone.js';
2022-10-12 16:27:56 -05:00
import type { Options } from './types';
polyfill(globalThis, {
2022-03-24 06:27:15 -05: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 06:27:15 -05:00
};
}
export function start(manifest: SSRManifest, options: Options) {
2022-10-12 16:27:56 -05:00
if (options.mode !== 'standalone' || process.env.ASTRO_NODE_AUTOSTART === 'disabled') {
return;
}
const app = new NodeApp(manifest);
startServer(app, options);
}