summaryrefslogtreecommitdiff
path: root/packages/integrations/netlify/src/netlify-edge-functions.ts
blob: 1bb8e2c3ab344cb0e61c6fb7620d2fb9c03fd03a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import './edge-shim.js';
import { SSRManifest } from 'astro';
import { App } from 'astro/app';

export function createExports(manifest: SSRManifest) {
	const app = new App(manifest);

	const handler = async (request: Request): Promise<Response> => {
		if (app.match(request)) {
			return app.render(request);
		}

		return new Response(null, {
			status: 404,
			statusText: 'Not found',
		});
	};

	return { default: handler };
}