astro/packages/integrations/cloudflare/src/getAdapter.ts
Alexander Niebuhr f6ba533df6
chore(cloudflare): refactor structure, optimize patterns (#8654)
---------

Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
Co-authored-by: 100gle <loogle.space@gmail.com>
2023-09-28 18:04:49 +02:00

40 lines
944 B
TypeScript

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