A lightweight mock API built using modern tools like Express.js, Zod, Zustand, and Faker.js โ perfect for rapid prototyping, frontend integration, and demos without relying on a real database.
โ Check server availability or test endpoints using the deployed API:
Live Demo: https://express-zod-zustand-faker.onrender.com
This backend simulates a user database and provides three API endpoints:
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/users |
Fetch paginated user list (searchable) |
| GET | /api/users/:id |
Fetch a single user by ID |
| POST | /api/logs |
Log user actions (e.g., search, clicks) |
The system is designed with:
- Zod: To validate and type-check input parameters
- Zustand (vanilla): To hold in-memory mock data
- Faker.js: To generate 50 randomized mock users
- Express.js + TypeScript: For a robust and strongly-typed server
| Tool | Purpose |
|---|---|
| Express.js | Web framework |
| TypeScript | Static typing |
| Zod | Input validation |
| Zustand | State management (used as mock DB) |
| Faker.js | Fake data generation |
| Morgan | Logging requests |
| CORS | API access from other origins |
Query parameters:
q(optional): search string (matchesname,email,bio)page(optional): page number (default: 1)limit(optional): items per page (default: 10)
Example:
GET /api/users?q=john&page=2&limit=5