$ show hiteshchoudhary/apihub
FreeAPI is an open-source API hub that provides free REST APIs for learning and demonstration purposes. The backend is a monolithic Express.js application with MongoDB, offering a range of endpoints: static public data (cats, dogs, quotes, etc.), kitchen-sink features (HTTP methods, status codes, cookies, redirects), and full-featured CRUD applications (ecommerce, social media, chat, todo) with authentication (JWT, OAuth via Google/GitHub), real-time chat via Socket.IO, file uploads, email notifications, and payment integration (Razorpay, PayPal). The codebase is well-structured with reusable utilities (asyncHandler, ApiError, pagination helpers), modular validators, and seeding scripts. It also includes multiple React/Vite frontend examples (ecommerce with Redux, chat with Socket.IO, todo app, status code quiz) that demonstrate best practices in consuming APIs. The project is clearly a learning resource and demo platform, not a production service.
The LLM identified 4 files worth highlighting for reuse:
Custom error class extending the built-in Error with HTTP statusCode, errors array, and stack trace. Used throughout controllers to throw consistent error responses. This is a self-contained, reusable pattern for any Express or Node.js application that needs standardized error handling.
Higher-order function that wraps async route handlers, automatically catching rejected promises and forwarding them to the Express error middleware. Eliminates repetitive try-catch blocks and is easily extracted for use in other Express projects.
Collection of utility functions including getMongoosePaginationOptions (builds Mongoose pagination query options from request query params), getPaginatedPayload (formats paginated response with metadata), and filterObjectKeys (whitelists/blacklists object keys). These are clean, parameterized helpers that can be reused in any MongoDB/Express backend requiring paginated endpoints.
Validation middleware that executes an array of express-validator validation chains and returns a standardized JSON error response if validation fails. This pattern decouples validation logic from route handlers and is directly reusable in any Express project using express-validator.