blob: cef262b4793a0c4d39ce27789f875bd1c9e0abd0 (
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
24
25
26
27
28
29
30
31
32
|
// Keep at the top
import './polyfill.js';
import type { SSRManifest } from 'astro';
import { NodeApp } from 'astro/app/node';
import { setGetEnv } from 'astro/env/setup';
import createMiddleware from './middleware.js';
import { createStandaloneHandler } from './standalone.js';
import startServer from './standalone.js';
import type { Options } from './types.js';
setGetEnv((key) => process.env[key]);
export function createExports(manifest: SSRManifest, options: Options) {
const app = new NodeApp(manifest);
options.trailingSlash = manifest.trailingSlash;
return {
options: options,
handler:
options.mode === 'middleware' ? createMiddleware(app) : createStandaloneHandler(app, options),
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);
}
|