API Surface
All routes are versioned under /api/v1.
Endpoints
Section titled “Endpoints”GET /api/v1/postslist posts (supports query via Zod schema)GET /api/v1/posts/id/:idget a post by idGET /api/v1/posts/:slugget a post by slugPOST /api/v1/postscreate a post (auth required)PUT /api/v1/posts/:idupdate a post (auth required)DELETE /api/v1/posts/:iddelete a post (auth required)GET /api/v1/categorieslist categoriesGET /api/v1/posts/stats/viewsview statsGET /healthhealth check
Example requests
Section titled “Example requests”List posts:
curl "http://localhost:51214/api/v1/posts?page=1&limit=10"Example response:
{ "data": [ { "id": "1", "title": "Why Fastify", "slug": "why-fastify", "excerpt": "A short case for low-latency APIs.", "authorId": "user_123", "createdAt": "2024-01-12T10:05:00.000Z" } ], "meta": { "page": 1, "limit": 10, "total": 42 }}Create post (auth required):
curl -X POST "http://localhost:51214/api/v1/posts" \ -H "Authorization: Bearer <CLERK_JWT>" \ -H "Content-Type: application/json" \ -d '{ "title": "Typed APIs that scale", "slug": "typed-apis", "content": "Full post body...", "excerpt": "Why type-safe contracts matter.", "category": "engineering" }'Example response:
{ "id": "2", "title": "Typed APIs that scale", "slug": "typed-apis", "authorId": "user_123", "createdAt": "2024-01-12T12:30:00.000Z"}