4acd245d8f
* refactor: remove Deno shim to esbuild "banner" * refactor: move shim to const * refactor: add shim to netlify edge * chore: changeset
26 lines
624 B
TypeScript
26 lines
624 B
TypeScript
import type { 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 | void> => {
|
|
const url = new URL(request.url);
|
|
|
|
// If this matches a static asset, just return and Netlify will forward it
|
|
// to its static asset handler.
|
|
if (manifest.assets.has(url.pathname)) {
|
|
return;
|
|
}
|
|
if (app.match(request)) {
|
|
return app.render(request);
|
|
}
|
|
|
|
return new Response(null, {
|
|
status: 404,
|
|
statusText: 'Not found',
|
|
});
|
|
};
|
|
|
|
return { default: handler };
|
|
}
|