From 9d2d31b1089d3ec8a02e73785cd99df88be6bf29 Mon Sep 17 00:00:00 2001 From: Paul Bakaus Date: Wed, 7 Jan 2026 20:20:13 -0800 Subject: [PATCH] Add missing /api/command-source Vercel endpoint This endpoint was in the local server but missing from Vercel serverless functions, causing "Source not available" on the deployed site. Co-Authored-By: Claude Opus 4.5 --- api/command-source/[id].js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 api/command-source/[id].js diff --git a/api/command-source/[id].js b/api/command-source/[id].js new file mode 100644 index 000000000..4a74caaf6 --- /dev/null +++ b/api/command-source/[id].js @@ -0,0 +1,25 @@ +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 { id } = req.query; + const sourceDir = join(PROJECT_ROOT, "source"); + const commandPath = join(sourceDir, "commands", `${id}.md`); + + if (!existsSync(commandPath)) { + return res.status(404).json({ error: "Command not found" }); + } + + const content = readFileSync(commandPath, "utf-8"); + res.status(200).json({ content }); + } catch (error) { + console.error("Error in /api/command-source:", error); + res.status(500).json({ error: error.message }); + } +}