A RESTful API for managing blogs and users, built with Node.js, Express, and MongoDB. This project was built as part of the Full Stack Open course (Part 4).
- User registration and authentication (JWT)
- CRUD operations for blogs
- Blog ownership and authorization
- Password hashing with bcrypt
- MongoDB data modeling with Mongoose
- Comprehensive integration and unit tests
- Logging and error handling
POST /api/login
Authenticate a user and receive a JWT token.
GET /api/users
List all users with their blogs.POST /api/users
Register a new user.- Requires a unique username (min 3 chars) and password (min 3 chars).
GET /api/blogs
List all blogs.POST /api/blogs
Create a new blog.- Requires authentication (JWT).
- Fields:
title,author,url,likes(default 0).
PUT /api/blogs/:id
Update a blog.DELETE /api/blogs/:id
Delete a blog.- Only the creator can delete.
POST /api/testing/reset
Reset the database (for automated tests).
- Node.js (v22+ recommended)
- MongoDB instance (local or cloud)
-
Clone the repository:
git clone https://github.com/jakariyaa/fullstackopen-bloglist cd fullstackopen-bloglist -
Install dependencies:
npm install
-
Create a
.envfile in the project root:MONGODB_URI=your_mongodb_uri TEST_MONGODB_URI=your_test_mongodb_uri SECRET=your_jwt_secret PORT=3001
- Start the server:
The server will run on the port specified in
npm run dev
.env(default: 3001).
- Run all tests:
npm test
app.js– Express app setup and middlewareindex.js– Entry pointcontrollers/– Route handlers for blogs, users, login, and testingmodels/– Mongoose schemas for Blog and Userutils/– Middleware, logger, config, and helper functionstests/– Integration and unit tests
MIT License © 2025 Jakariya Abbas