Backend API for sharing happy thoughts. Users can post thoughts, like others' thoughts, and manage their own content.
API: https://js-project-api-cathi.onrender.com
- Node.js & Express
- MongoDB with Mongoose
- JWT authentication
- bcrypt for passwords
POST /auth/register- Register userPOST /auth/login- Login user
GET /thoughts- Get all thoughtsPOST /thoughts- Create thoughtPATCH /thoughts/:id- Update thought (own only)DELETE /thoughts/:id- Delete thought (own only)PATCH /thoughts/:id/like- Like thoughtPATCH /thoughts/:id/unlike- Unlike thought
- Clone repo and install dependencies:
npm install- Create
.envfile:
MONGO_URL=mongodb://localhost/happy-thoughts
JWT_SECRET=your-secret-key
PORT=8080
- Start development server:
npm run dev- ✅ Anonymous and authenticated posting
- ✅ User authentication with JWT
- ✅ CRUD operations for thoughts
- ✅ Like/unlike functionality
- ✅ Input validation and error handling
- ✅ Pagination and filtering
Deployed on Render with MongoDB Atlas database.