{"id":18152050,"url":"https://github.com/muhdhanish/blog_api_json_server","last_synced_at":"2026-04-20T05:34:10.705Z","repository":{"id":258496051,"uuid":"874039621","full_name":"MuhdHanish/blog_api_json_server","owner":"MuhdHanish","description":"Node.js Express server acting as a proxy for a JSON Server, providing a RESTful API for managing blog posts.","archived":false,"fork":false,"pushed_at":"2024-10-17T15:40:01.000Z","size":35,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-06T23:45:29.944Z","etag":null,"topics":["api","api-rest","blogs","chalk","error-handling","express-middleware","expressjs","fetch-api","json","json-server","nodejs","nodemon","nodemon-express","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MuhdHanish.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-17T06:41:02.000Z","updated_at":"2024-10-24T18:46:14.000Z","dependencies_parsed_at":"2024-10-20T11:54:17.046Z","dependency_job_id":null,"html_url":"https://github.com/MuhdHanish/blog_api_json_server","commit_stats":null,"previous_names":["muhdhanish/blog_api_json_server"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MuhdHanish%2Fblog_api_json_server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MuhdHanish%2Fblog_api_json_server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MuhdHanish%2Fblog_api_json_server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MuhdHanish%2Fblog_api_json_server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MuhdHanish","download_url":"https://codeload.github.com/MuhdHanish/blog_api_json_server/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247569130,"owners_count":20959758,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","api-rest","blogs","chalk","error-handling","express-middleware","expressjs","fetch-api","json","json-server","nodejs","nodemon","nodemon-express","typescript"],"created_at":"2024-11-02T02:05:28.555Z","updated_at":"2026-04-20T05:34:10.667Z","avatar_url":"https://github.com/MuhdHanish.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Blog API JSON Server\n\n## Table of Contents\n1. [Introduction](#introduction)\n2. [Features](#features)\n3. [Prerequisites](#prerequisites)\n4. [Installation](#installation)\n5. [Usage](#usage)\n6. [API Endpoints](#api-endpoints)\n7. [Request \u0026 Response Examples](#request--response-examples)\n8. [Error Handling](#error-handling)\n9. [Feedback](#feedback)\n10. [Support](#support)\n\n## Introduction\n\nThis project is a Node.js Express server acting as a proxy for a JSON Server, providing a RESTful API for managing blog posts. It offers a robust solution for creating, reading, updating, and deleting blog entries with custom error handling and logging.\n\n## Features\n\n- Full CRUD operations for blog posts\n- Custom error handling with detailed error messages\n- Error logging with stack traces for debugging\n- CORS support for cross-origin requests\n- TypeScript for type safety and better developer experience\n- Integration with JSON Server for easy data persistence\n\n## Prerequisites\n\n- Node.js (version 14 or later recommended)\n- npm (comes with Node.js)\n\n## Installation\n\n1. Clone the repository:\n   ```bash\n   git clone https://github.com/MuhdHanish/blog_api_json_server.git\n   cd blog_api_json_server\n   ```\n\n2. Install dependencies:\n   ```bash\n   npm install\n   ```\n\n3. Start the JSON Server and Express server together:\n   ```bash\n   npm start\n   ```\n\n## Usage\n\n1. If running JSON Server separately:\n   ```bash\n   json-server --watch db.json --port 3000\n   ```\n\n2. Start the Express server:\n   ```bash\n   npm run start:server\n   ```\n\nThe server will run on `http://localhost:8000`.\n\n## API Endpoints\n\n- `/`: Server status\n- `GET /api/blogs`: Retrieve all blogs\n- `GET /api/blogs/:id`: Retrieve a specific blog\n- `POST /api/blogs`: Create a new blog\n- `PUT /api/blogs/:id`: Update an existing blog\n- `DELETE /api/blogs/:id`: Delete a blog\n- `*`: Catch all route for handling undefined routes\n\n## Request \u0026 Response Examples\n\n### GET /api/blogs\n\nResponse body:\n```json\n[\n  {\n    \"id\": \"cf73\",\n    \"title\": \"Introduction to Express.js\",\n    \"content\": \"Express.js is a minimal and flexible Node.js web application framework...\",\n    \"author\": \"John Doe\",\n    \"createdAt\": \"2023-06-01T10:00:00Z\",\n    \"updatedAt\": \"2023-06-01T10:00:00Z\"\n  }\n]\n```\n\n### POST /api/blogs\n\nRequest body:\n```json\n{\n  \"title\": \"Getting Started with TypeScript\",\n  \"content\": \"TypeScript is a typed superset of JavaScript that compiles to plain JavaScript...\",\n  \"author\": \"Jane Smith\"\n}\n```\n\nResponse body:\n```json\n{\n  \"id\": \"cf74\",\n  \"title\": \"Getting Started with TypeScript\",\n  \"content\": \"TypeScript is a typed superset of JavaScript that compiles to plain JavaScript...\",\n  \"author\": \"Jane Smith\",\n  \"createdAt\": \"2023-06-02T15:30:00Z\",\n  \"updatedAt\": \"2023-06-02T15:30:00Z\"\n}\n```\n\n### PUT /api/blogs/:id\n\nRequest body:\n```json\n{\n  \"title\": \"Updated: Getting Started with TypeScript\",\n  \"content\": \"TypeScript is a powerful typed superset of JavaScript...\",\n  \"author\": \"Jane Smith\"\n}\n```\n\nResponse body:\n```json\n{\n  \"id\": \"cf74\",\n  \"title\": \"Updated: Getting Started with TypeScript\",\n  \"content\": \"TypeScript is a powerful typed superset of JavaScript...\",\n  \"author\": \"Jane Smith\",\n  \"createdAt\": \"2023-06-02T15:30:00Z\",\n  \"updatedAt\": \"2023-06-02T16:45:00Z\"\n}\n```\n\n### DELETE /api/blogs/:id\n\nRequest:\n```\nDELETE /api/blogs/cf74\n```\n\nResponse:\n```\nStatus: 204 No Content\n```\n\n## Error Handling\n\nThe API uses custom error handling. If an error occurs, the response will be in the following format:\n\n```json\n{\n  \"status\": \"error\",\n  \"message\": \"Error message here\"\n}\n```\n\nErrors are also logged to the console with stack traces for debugging purposes.\n\n## Feedback\n\nIf you have any feedback, please reach me at [muhammedhanish11@gmail.com](mailto:muhammedhanish11@gmail.com) or connect with me on [LinkedIn](https://www.linkedin.com/in/muhdhanish/).\n\n## Support\n\nShow your support by 🌟 starring the project!!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmuhdhanish%2Fblog_api_json_server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmuhdhanish%2Fblog_api_json_server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmuhdhanish%2Fblog_api_json_server/lists"}