This is a simple RESTful API for managing books, built with Express.js and MongoDB (using Mongoose).
- Add a new book
- Get all books
- Get a book by ID
- Update a book by ID
- Delete a book by ID
.
├── .env
├── .gitignore
├── index.js
├── package.json
├── Models/
│ └── bookModel.js
└── Routes/
└── bookRoutes.js
- Node.js
- MongoDB database (local or Atlas)
- Clone the repository.
- Run
npm install
to install dependencies. - Create a
.env
file with your MongoDB URI and desired port:MONGODB_URI=your_mongodb_connection_string PORT=3000
- Start the server:
node index.js
POST /books
- Create a new bookGET /books
- Get all booksGET /books/:id
- Get a book by IDPUT /books/:id
- Update a book by IDDELETE /books/:id
- Delete a book by ID