Back to Browse
✍️Prompt
REST API Endpoint Generator
Generate complete REST API endpoints with validation, error handling, and OpenAPI docs. Works with Express, Fastify, or Next.js Route Handlers.
Prompt Content
Generate a complete REST API endpoint with the following requirements:
## Input
- Framework: [express / fastify / next.js-route-handler]
- HTTP Method: [GET/POST/PUT/DELETE]
- Path: [/api/resource]
- Database: [prisma / drizzle / raw-sql]
- Auth: [none / bearer / api-key / session]
## Output Requirements
For each endpoint, generate:
1. **Route Handler** with:
- Input validation using Zod schema
- Proper error handling with typed errors
- Request/response TypeScript types
- Pagination support for list endpoints
- Field selection (sparse fieldsets)
- Filtering and sorting support
2. **Validation Schema**:
```typescript
import { z } from "zod"
export const CreateItemSchema = z.object({
name: z.string().min(1).max(100),
description: z.string().max(500).optional(),
tags: z.array(z.string()).max(10).default([]),
})
```
3. **Error Responses**: Consistent error format with proper HTTP status codes
4. **OpenAPI Documentation**: Auto-generated from the Zod schemas
## Example for: POST /api/users
```typescript
import { z } from "zod"
import { prisma } from "@/lib/db"
import { hash } from "bcryptjs"
const CreateUserSchema = z.object({
email: z.string().email(),
name: z.string().min(2).max(100),
password: z.string().min(8),
})
export async function POST(request: Request) {
try {
const body = await request.json()
const data = CreateUserSchema.parse(body)
const existing = await prisma.user.findUnique({ where: { email: data.email } })
if (existing) {
return Response.json({ error: "Email already registered" }, { status: 409 })
}
const hashedPassword = await hash(data.password, 12)
const user = await prisma.user.create({
data: { email: data.email, name: data.name, password: hashedPassword },
select: { id: true, email: true, name: true, createdAt: true },
})
return Response.json({ data: user }, { status: 201 })
} catch (error) {
if (error instanceof z.ZodError) {
return Response.json({ error: "Validation failed", details: error.errors }, { status: 400 })
}
console.error("Create user error:", error)
return Response.json({ error: "Internal server error" }, { status: 500 })
}
}
```
Now generate an endpoint for: [DESCRIBE_YOUR_ENDPOINT]REST API Endpoint Generator
No variables detected in this prompt.
293 words2291 chars~573 tokens
Live Preview
Generate a complete REST API endpoint with the following requirements:
## Input
- Framework: [express / fastify / next.js-route-handler]
- HTTP Method: [GET/POST/PUT/DELETE]
- Path: [/api/resource]
- Database: [prisma / drizzle / raw-sql]
- Auth: [none / bearer / api-key / session]
## Output Requirements
For each endpoint, generate:
1. **Route Handler** with:
- Input validation using Zod schema
- Proper error handling with typed errors
- Request/response TypeScript types
- Pagination support for list endpoints
- Field selection (sparse fieldsets)
- Filtering and sorting support
2. **Validation Schema**:
```typescript
import { z } from "zod"
export const CreateItemSchema = z.object({
name: z.string().min(1).max(100),
description: z.string().max(500).optional(),
tags: z.array(z.string()).max(10).default([]),
})
```
3. **Error Responses**: Consistent error format with proper HTTP status codes
4. **OpenAPI Documentation**: Auto-generated from the Zod schemas
## Example for: POST /api/users
```typescript
import { z } from "zod"
import { prisma } from "@/lib/db"
import { hash } from "bcryptjs"
const CreateUserSchema = z.object({
email: z.string().email(),
name: z.string().min(2).max(100),
password: z.string().min(8),
})
export async function POST(request: Request) {
try {
const body = await request.json()
const data = CreateUserSchema.parse(body)
const existing = await prisma.user.findUnique({ where: { email: data.email } })
if (existing) {
return Response.json({ error: "Email already registered" }, { status: 409 })
}
const hashedPassword = await hash(data.password, 12)
const user = await prisma.user.create({
data: { email: data.email, name: data.name, password: hashedPassword },
select: { id: true, email: true, name: true, createdAt: true },
})
return Response.json({ data: user }, { status: 201 })
} catch (error) {
if (error instanceof z.ZodError) {
return Response.json({ error: "Validation failed", details: error.errors }, { status: 400 })
}
console.error("Create user error:", error)
return Response.json({ error: "Internal server error" }, { status: 500 })
}
}
```
Now generate an endpoint for: [DESCRIBE_YOUR_ENDPOINT]Related Prompts
Generate stunning cinematic landscape photographs with dramatic lighting, golden hour warmth, and professional composition. Perfect for Midjourney and DALL-E.
photographylandscapecinematicgolden hour+1
midjourney
2847
A comprehensive system prompt that turns any LLM into an expert code reviewer. Catches bugs, security issues, and suggests improvements.
code reviewsystem promptprogrammingbest practices+1
4123
Generate compelling e-commerce product descriptions that convert. Includes SEO keywords, emotional hooks, and benefit-focused copy.
copywritingecommerceproduct descriptionsmarketing+1
1956
Prompt
Create detailed anime-style character designs with consistent style. Works great for game characters, illustrations, and concept art.
animecharacter designillustrationconcept art+1
stable-diffusion
3201
Statistics
Copies2,123
Likes1,045
Added3/31/2026
Author
APIBuilder
Framework
claude_code
Tags
RESTAPIbackendExpressNext.js
Categories
Code GenerationBackend