Complete CRUD API with authentication, validation, error handling, and documentation.
Prompt
Build a REST API using Express.js for a bookstore:
- CRUD endpoints: GET /books, GET /books/:id, POST /books, PUT /books/:id, DELETE /books/:id
- Book model: title, author, isbn, price, category, description
- Input validation with meaningful error messages
- Simple JWT authentication (register/login endpoints)
- Protected routes (only authenticated users can create/update/delete)
- Pagination, sorting, and filtering on GET /books
- Error handling middleware
- CORS enabled
- Store data in a JSON file (no database needed)
Include a README.md with API documentation. Put everything in ~/data/
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.