From 851b5f6c7a5fb6b37b418f6a96f9efde275366e1 Mon Sep 17 00:00:00 2001 From: Paul Bakaus Date: Tue, 16 Dec 2025 14:24:01 -0800 Subject: [PATCH] Fix Vercel runtime: use Node.js-compatible file APIs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Remove invalid functions.runtime config from vercel.json - Replace Bun.file() with Node.js fs/promises APIs - Vercel's Bun runtime only supports Next.js/Express/Hono/Nitro frameworks 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- server/lib/api-handlers.js | 30 ++++++++++++++++-------------- vercel.json | 10 +--------- 2 files changed, 17 insertions(+), 23 deletions(-) diff --git a/server/lib/api-handlers.js b/server/lib/api-handlers.js index 53f77affd..168113257 100644 --- a/server/lib/api-handlers.js +++ b/server/lib/api-handlers.js @@ -1,5 +1,11 @@ -import { readdir } from "fs/promises"; +import { readdir, readFile } from "fs/promises"; import { basename, join } from "path"; +import { existsSync } from "fs"; + +// Helper to read file content (works in both Node.js and Bun) +async function readFileContent(filePath) { + return readFile(filePath, "utf-8"); +} // Read all skills from source directory export async function getSkills() { @@ -10,7 +16,7 @@ export async function getSkills() { for (const file of files) { if (file.endsWith(".md")) { - const content = await Bun.file(join(skillsDir, file)).text(); + const content = await readFileContent(join(skillsDir, file)); const frontmatterMatch = content.match(/^---\n([\s\S]+?)\n---/); if (frontmatterMatch) { @@ -39,7 +45,7 @@ export async function getCommands() { for (const file of files) { if (file.endsWith(".md")) { - const content = await Bun.file(join(commandsDir, file)).text(); + const content = await readFileContent(join(commandsDir, file)); const frontmatterMatch = content.match(/^---\n([\s\S]+?)\n---/); if (frontmatterMatch) { @@ -100,15 +106,13 @@ export async function handleFileDownload(type, provider, id) { } try { - const file = Bun.file(filePath); - const exists = await file.exists(); - - if (!exists) { + if (!existsSync(filePath)) { return new Response("File not found", { status: 404 }); } + const content = await readFile(filePath); const fileName = basename(filePath); - return new Response(file, { + return new Response(content, { headers: { "Content-Type": "application/octet-stream", "Content-Disposition": `attachment; filename="${fileName}"`, @@ -126,7 +130,7 @@ export async function getPatterns() { const filePath = join(sourceDir, "patterns.md"); try { - const content = await Bun.file(filePath).text(); + const content = await readFileContent(filePath); const frontmatterMatch = content.match(/^---\n([\s\S]+?)\n---/); if (!frontmatterMatch) { @@ -203,14 +207,12 @@ export async function handleBundleDownload(provider) { const zipPath = join(distDir, `${provider}.zip`); try { - const file = Bun.file(zipPath); - const exists = await file.exists(); - - if (!exists) { + if (!existsSync(zipPath)) { return new Response("Bundle not found", { status: 404 }); } - return new Response(file, { + const content = await readFile(zipPath); + return new Response(content, { headers: { "Content-Type": "application/zip", "Content-Disposition": `attachment; filename="impeccable-style-${provider}.zip"`, diff --git a/vercel.json b/vercel.json index cfc841af2..c2823844c 100644 --- a/vercel.json +++ b/vercel.json @@ -1,14 +1,6 @@ { "$schema": "https://openapi.vercel.sh/vercel.json", "buildCommand": "bun run build", - "outputDirectory": "public", - "functions": { - "api/**/*.js": { - "runtime": "bun@1" - } - }, - "rewrites": [ - { "source": "/api/(.*)", "destination": "/api/$1" } - ] + "outputDirectory": "public" }