Build a REST API using Express.js for a bookstore called "PageTurn API".
- CRUD endpoints: GET /books, GET /books/:id, POST /books, PUT /books/:id, DELETE /books/:id
- Book schema: title, author, isbn, genre, price, published_year, in_stock
- Input validation with helpful error messages
- Pagination: ?page=1&limit=10 with total count in response
- Search: ?q=keyword across title and author
- Filter: ?genre=fiction&in_stock=true
- Simple token auth: X-API-Key header
- Auto-generated API docs page at GET /docs with all endpoints listed
- Seed data: 20 sample books
- Error handling middleware with consistent JSON error format.
1
Copy the prompt above
2
Paste in Claude Code terminal
3
Your project is live
apiexpressnodejsrestauth
About this prompt
Building a REST API with proper authentication, validation, error handling, and documentation is typically a multi-day project. This prompt generates a complete, production-quality API in about 10 minutes. It includes JWT authentication, input validation, pagination, sorting, filtering, CORS configuration, and a README with full API documentation. The data is stored in a JSON file — no database setup required to get started.
What you get
✓ Full CRUD endpoints (GET, POST, PUT, DELETE)
✓ Book model with title, author, ISBN, price, category
✓ JWT authentication with register and login
✓ Protected routes for create, update, and delete
✓ Input validation with clear error messages
✓ Pagination, sorting, and filtering on list endpoint
✓ Error handling middleware
✓ CORS enabled
✓ JSON file storage (no database needed)
✓ README.md with complete API documentation
Frequently asked questions
Can I switch from JSON file to a real database?
Yes. Ask Claude to replace the JSON storage with MongoDB, PostgreSQL, or SQLite. The API structure stays the same.
Is the JWT implementation secure?
It uses standard JWT with bcrypt password hashing. For production, add refresh tokens and token expiration as a follow-up.
Can I deploy this on host4.ai?
Yes. The API runs on your host4.ai environment. It is accessible at your subdomain on the port you configure.