A Node.js and MongoDB application for managing books in a library. Users can create, view, update, and delete book records efficiently.
- Add, update, and delete books.
- View a list of all available books.
- RESTful APIs for easy integration.
- MongoDB database for efficient storage.
- Backend: Node.js, Express.js
- Database: MongoDB
- Version Control: Git
- Tools: REST Client(VS code Extension),Postman (for API testing)
Follow these steps to set up the project locally:
-
Clone the Repository:
git clone <repository-url> cd books-library
-
Install Dependencies: Make sure you have Node.js and npm installed, then run:
npm install
-
Set Up MongoDB:
- Install and run MongoDB locally or connect to MongoDB Atlas.
- Update the database connection string in
.env:MONGODB_URI=mongodb://127.0.0.1:27017/booksLibrary
-
Run the Application: Start the server with:
npm start
The app will be available at: http://localhost:3000
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/books |
Fetch all books |
| GET | /api/books/:id |
Get a single book |
| POST | /api/books |
Add a new book |
| PUT | /api/books/:id |
Update a book |
| DELETE | /api/books/:id |
Delete a book |
books-library/
│
├── models/
│ └── Book.js # Mongoose model for books
├── routes/
│ └── books.js # Routes for book APIs
├── controllers/
│ └── booksController.js # Logic for handling API requests
├── config/
│ └── db.js # MongoDB connection
│
├── .gitignore # Ignore node_modules
├── package.json # Project metadata
└── server.js # Main application file
Contributions are welcome! Feel free to submit a pull request.
- Fork the project.
- Create your feature branch:
git checkout -b feature/my-feature
- Commit your changes:
git commit -m "Add my feature" - Push to the branch:
git push origin feature/my-feature
- Open a pull request.