mirror of
https://github.com/pbakaus/impeccable.git
synced 2026-09-15 23:56:29 +03:00
Response.json() is for Edge Functions, not Node.js serverless functions. Switched all API handlers to use res.status().json() format which is the standard for Vercel Node.js functions. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
29 lines
915 B
JavaScript
29 lines
915 B
JavaScript
import { readFileSync, existsSync } from "fs";
|
|
import { join, dirname } from "path";
|
|
import { fileURLToPath } from "url";
|
|
|
|
const __filename = fileURLToPath(import.meta.url);
|
|
const __dirname = dirname(__filename);
|
|
const PROJECT_ROOT = join(__dirname, "../../..");
|
|
|
|
export default function handler(req, res) {
|
|
try {
|
|
const { provider } = req.query;
|
|
const distDir = join(PROJECT_ROOT, "dist");
|
|
const zipPath = join(distDir, `${provider}.zip`);
|
|
|
|
if (!existsSync(zipPath)) {
|
|
return res.status(404).json({ error: "Bundle not found" });
|
|
}
|
|
|
|
const content = readFileSync(zipPath);
|
|
res.setHeader("Content-Type", "application/zip");
|
|
res.setHeader("Content-Disposition", `attachment; filename="impeccable-style-${provider}.zip"`);
|
|
res.send(content);
|
|
} catch (error) {
|
|
console.error("Error downloading bundle:", error);
|
|
res.status(500).json({ error: error.message });
|
|
}
|
|
}
|
|
|