*Simple Blog API*
A basic RESTful API built with Express.js that serves blog data. This project demonstrates how to create a minimal backend server with routes to fetch blog posts.
Features Get a list of all blog posts (GET /api/blogs)
Built with Express.js and CORS enabled for cross-origin requests
JSON response format for easy integration with frontend applications
Getting Started Prerequisites Node.js (v14 or higher)
npm or yarn package manager
Installation Clone the repository:
bash Copy Edit git clone cd Install dependencies:
bash Copy Edit npm install Start the server:
bash Copy Edit node index.js The server will run at http://localhost:5000.
API Endpoints GET /api/blogs Returns an array of all blog posts.
(Optional) GET /api/blogs/:id Returns a single blog post by ID. (Add if implemented)
Example Response for /api/blogs json Copy Edit [ { "id": "1", "title": "Understanding Time Dilation", "description": "How time slows down near massive objects according to Einstein's theory.", "content": "Time dilation is one of the most fascinating concepts in general relativity. ..." }, { "id": "2", "title": "Bending of Light Around Stars", "description": "Learn how gravity can bend the path of light, an effect called gravitational lensing.", "content": "Gravity not only affects mass but also bends light! ..." } ] Future Improvements Add routes to create, update, and delete blog posts.
Connect to a database to persist data.
Implement input validation and error handling.
Add detailed logging and testing.
License This project is licensed under the MIT License.