Fix Vercel runtime: use Node.js-compatible file APIs

- 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 <noreply@anthropic.com>
This commit is contained in:
Paul Bakaus
2025-12-16 14:24:01 -08:00
co-authored by Claude Opus 4.5
parent 7aefe19b2a
commit 851b5f6c7a
2 changed files with 17 additions and 23 deletions
+16 -14
View File
@@ -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"`,
+1 -9
View File
@@ -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"
}