mirror of
https://github.com/pbakaus/impeccable.git
synced 2026-09-20 01:56:37 +03:00
Migrate from Vercel to Cloudflare Pages, fix distill command symbol
Replace Vercel serverless functions with Cloudflare Pages static rewrites and lightweight download functions. Pre-generate all API JSON data at build time for zero-invocation static serving. Also fix stale simplify→distill rename in framework-viz periodic table. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
98d16686dc
commit
7d2d42da96
@@ -0,0 +1,29 @@
|
||||
const ALLOWED_PROVIDERS = ['universal', 'universal-prefixed'];
|
||||
|
||||
export async function onRequestGet(context) {
|
||||
const { provider } = context.params;
|
||||
|
||||
if (!provider || !ALLOWED_PROVIDERS.includes(provider)) {
|
||||
return Response.json({ error: "Invalid provider" }, { status: 400 });
|
||||
}
|
||||
|
||||
const url = new URL(context.request.url);
|
||||
url.pathname = `/_data/dist/${provider}.zip`;
|
||||
|
||||
const response = await context.env.ASSETS.fetch(url);
|
||||
|
||||
if (!response.ok) {
|
||||
return Response.json({ error: "Bundle not found" }, { status: 404 });
|
||||
}
|
||||
|
||||
const content = await response.arrayBuffer();
|
||||
const safeProvider = provider.replace(/[^a-zA-Z0-9._-]/g, '');
|
||||
|
||||
return new Response(content, {
|
||||
headers: {
|
||||
'Content-Type': 'application/zip',
|
||||
'Content-Disposition': `attachment; filename="impeccable-style-${safeProvider}.zip"`,
|
||||
'Cache-Control': 'public, s-maxage=86400, stale-while-revalidate=3600',
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user