A simple and lightweight mock API built with Node.js and Express, designed for testing or frontend development without a real backend.
- 🔑 Login endpoint with mock authentication
- 📰 Article list with pagination
- 📄 Article detail by ID
- 🌐 CORS enabled by default
- 🧱 Standardized API response format (
ApiResponsehelper class)
# Clone the repository
git clone https://github.com/your-username/mock-api.git
cd mock-apinpm installnpm run devnpm start
Server runs at 👉 http://localhost:3000Authenticate user and get a mock token.
{
"email": "[email protected]",
"password": "123456"
}{
"status": "success",
"message": "Login Successful",
"data": {
"token": "ABC123",
"user": {
"id": 1,
"name": "John Doe",
"email": "[email protected]"
}
}
}{
"status": "error",
"message": "Unauthorized",
"data": null
}Fetch a paginated list of articles.
{
"status": "success",
"message": "Fetched successfully",
"data": {
"articles": [
{
"id": 1,
"title": "Article 1",
"image": "https://picsum.photos/seed/article1/400/250"
}
],
"page": 1,
"limit": 10,
"hasMore": true
}
}Fetch details of a specific article by ID.
{
"status": "success",
"message": "Fetched Successfully",
"data": {
"id": 1,
"title": "Article 1",
"image": "https://picsum.photos/seed/article1/400/250",
"content": "This is the content of Article 1."
}
}{
"status": "error",
"message": "Article not found",
"data": null
}All responses follow a consistent structure using the ApiResponse helper:
{
status: "success" | "error",
message: "string",
data: any
}💡 Useful for frontend integration, testing pagination logic, or mocking authentication.