summaryrefslogtreecommitdiff
path: root/packages/integrations/node/src/server.ts
blob: 90bf8c44c46f9b13bc4f37e2919aaf59a4e64a99 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import type { SSRManifest } from 'astro';
import { NodeApp, applyPolyfills } from 'astro/app/node';
import middleware from './nodeMiddleware.js';
import startServer from './standalone.js';
import type { Options } from './types.js';

applyPolyfills();
export function createExports(manifest: SSRManifest, options: Options) {
	const app = new NodeApp(manifest);
	return {
		handler: middleware(app, options.mode),
		startServer: () => startServer(app, options),
	};
}

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);
}