From 4cf54c60aa63bd614b242da0602790015005673d Mon Sep 17 00:00:00 2001 From: Matthew Phillips Date: Tue, 19 Apr 2022 11:22:15 -0400 Subject: Netlify Edge function support (#3148) * Netlify Edge function support * Update readme with edge function information * Adds a changeset * Disable running edge function test in CI for now --- .../netlify/src/netlify-edge-functions.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 packages/integrations/netlify/src/netlify-edge-functions.ts (limited to 'packages/integrations/netlify/src/netlify-edge-functions.ts') diff --git a/packages/integrations/netlify/src/netlify-edge-functions.ts b/packages/integrations/netlify/src/netlify-edge-functions.ts new file mode 100644 index 000000000..f7000442c --- /dev/null +++ b/packages/integrations/netlify/src/netlify-edge-functions.ts @@ -0,0 +1,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 => { + if(app.match(request)) { + return app.render(request); + } + + return new Response(null, { + status: 404, + statusText: 'Not found' + }); + }; + + return { 'default': handler }; +} -- cgit v1.2.3