Files
ai-taxonomy-literature-anal…/pages/api/articles/[slug].ts
T
claude-bot 9ffe734275
Deploy / deploy (push) Successful in 7m40s
Write APIs for articles and tool taxonomy; taxonomy table replaces the tools table
- /api/articles[/slug]: GET/PUT/POST/DELETE, article JSON stored in PostgreSQL (schema analysis)
- /api/tool-taxonomy: categories (tree), per-paper tools, each tool in one or more categories
- /contents/tools-of-agents: category table with roll-up and links to the papers; removed
  "By kind of contribution" and "Recent papers"
- content moves out of the repo: removed content/articles, load-articles.js, agent-tools.ts

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FbMbJPadPzVwvt9rU9GBNo
2026-10-23 19:55:21 +08:00

19 lines
780 B
TypeScript

import { route, bodyObject, bigBody, HttpError } from '../../../lib/api';
import { deleteArticle, exportArticle, saveArticle } from '../../../lib/article-store';
export const config = bigBody;
// GET /api/articles/:slug the article as JSON (same shape PUT accepts)
// PUT /api/articles/:slug create or replace the whole article
// DELETE /api/articles/:slug
export default route({
GET: (req) => exportArticle(String(req.query.slug)),
PUT: (req) => {
const body = bodyObject(req);
const slug = String(req.query.slug);
if (body.slug && body.slug !== slug) throw new HttpError(400, `slug in body (${body.slug}) differs from the URL (${slug})`);
return saveArticle({ ...body, slug });
},
DELETE: (req) => deleteArticle(String(req.query.slug)),
});