Fix: Use standard Vercel serverless function format (req, res)

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>
This commit is contained in:
Paul Bakaus
2025-12-16 15:00:08 -08:00
co-authored by Claude Opus 4.5
parent 13f4714b5d
commit 73a3367e0a
5 changed files with 128 additions and 35 deletions
+4 -7
View File
@@ -6,19 +6,16 @@ const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const PROJECT_ROOT = join(__dirname, "..");
export default function handler(request) {
export default function handler(req, res) {
try {
const sourceDir = join(PROJECT_ROOT, "source");
const filePath = join(sourceDir, "patterns.md");
console.log("Reading patterns from:", filePath);
const content = readFileSync(filePath, "utf-8");
console.log("File read, length:", content.length);
const frontmatterMatch = content.match(/^---\n([\s\S]+?)\n---/);
if (!frontmatterMatch) {
return Response.json({ patterns: [], antipatterns: [] });
return res.status(200).json({ patterns: [], antipatterns: [] });
}
const frontmatterText = frontmatterMatch[1];
@@ -69,9 +66,9 @@ export default function handler(request) {
}
}
return Response.json({ patterns, antipatterns });
res.status(200).json({ patterns, antipatterns });
} catch (error) {
console.error("Error in /api/patterns:", error);
return Response.json({ error: error.message, stack: error.stack }, { status: 500 });
res.status(500).json({ error: error.message, stack: error.stack });
}
}