summaryrefslogtreecommitdiff
path: root/packages/integrations/cloudflare/src/getAdapter.ts
blob: 0cc1263a17f13a1be2f25a47c879b78a44947d08 (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
33
34
35
36
37
38
39
40
import type { AstroAdapter, AstroFeatureMap } from 'astro';

export function getAdapter({
	isModeDirectory,
	functionPerRoute,
}: {
	isModeDirectory: boolean;
	functionPerRoute: boolean;
}): AstroAdapter {
	const astroFeatures = {
		hybridOutput: 'stable',
		staticOutput: 'unsupported',
		serverOutput: 'stable',
		assets: {
			supportKind: 'stable',
			isSharpCompatible: false,
			isSquooshCompatible: false,
		},
	} satisfies AstroFeatureMap;

	if (isModeDirectory) {
		return {
			name: '@astrojs/cloudflare',
			serverEntrypoint: '@astrojs/cloudflare/entrypoints/server.directory.js',
			exports: ['onRequest', 'manifest'],
			adapterFeatures: {
				functionPerRoute,
				edgeMiddleware: false,
			},
			supportedAstroFeatures: astroFeatures,
		};
	}

	return {
		name: '@astrojs/cloudflare',
		serverEntrypoint: '@astrojs/cloudflare/entrypoints/server.advanced.js',
		exports: ['default'],
		supportedAstroFeatures: astroFeatures,
	};
}