This project is a backend REST API for CommunityHub built using Node.js and Express.
The goal of this project was to learn backend fundamentals by building a server, creating routes, implementing CRUD operations, using middleware, handling errors, organizing code into modules, and working with environment variables.
The API allows users to:
git clone https://github.com/your-github-username/iyf-s10-week-10-your-github-username.git
cd iyf-s10-week-10-your-github-username
npm install
npm start
OR
node server.js
http://localhost:3000/api/posts
GET /api/posts
GET /api/posts/:id
POST /api/posts
PUT /api/posts/:id
DELETE /api/posts/:id
PATCH /api/posts/:id/like
Through this project I learned:
Initially it was difficult understanding how GET, POST, PUT, and DELETE work together.
Solution:
Practiced each route individually and tested each endpoint.
Separating routes, controllers, middleware, and data was confusing.
Solution:
Used a modular project structure to keep the code organized.
POST requests failed when data was incomplete.
Solution:
Added validation middleware to check request data before saving posts.
Some routes returned errors due to syntax and route mistakes.
Solution:
Used console logging, error middleware, and incremental testing.