The Books Management System is a RESTful API built using Node.js, Express, and MongoDB. It provides user authentication and CRUD operations for managing books. Only authenticated users can perform book-related operations.
- User Registration & Login
- Token-based Authentication using JWT
- CRUD Operations for Books
- Input Validation with Joi
- Secure Password Handling with bcryptjs
- Environment Variables with dotenv
- Logging with Morgan
- Error Handling & Data Integrity Checks
- Node.js
- Express.js
- MongoDB (Mongoose ODM)
- JWT (jsonwebtoken)
- bcryptjs
- Joi (Input validation)
- Morgan (Logging)
- Compression (Performance optimization)
Ensure you have the following installed:
git clone https://github.com/HassanEssam0110/Task-3-Books-Management-System.git
cd Task-3-Books-Management-Systemnpm installCreate a .env file in the project root and add the following:
# Server
PORT=3000
NODE_ENV="development"
# Database
MONGO_DB_URI="mongodb://127.0.0.1:27017/DB_books_management"
# JWT Authentication
JWT_SECRET="secret"
JWT_EXPIRES_IN="30d"
JWT_COOKIES_EXPIRES_IN=30
# Password Hashing
SALT_ROUNDS=10npm run start:devnpm run start:prodPOST /api/v1/register
{
"username": "user1",
"password": "password123",
"repeat_password": "password123"
}POST /api/v1/login
{
"username": "user1",
"password": "password123"
}POST /api/v1/books
{
"title": "The Great Gatsby",
"author": "F. Scott Fitzgerald",
"publishedDate": "1925-04-10"
}GET /api/v1/books
GET /api/v1/books/:id
PUT /api/v1/books/:id
{
"title": "The Great Gatsby",
"author": "F. Scott Fitzgerald",
"publishedDate": "1925-04-10"
}DELETE /api/v1/books/:id
DELETE /api/v1/books/:id?softDelete=false