The NodeJS Book CRUD API is a simple REST API for managing books. It provides endpoints for creating, reading, updating, and deleting books. The system is built using modern JavaScript and uses popular libraries and frameworks such as Express, MongoDB, and more.
- CRUD Operations: Create, Read, Update, and Delete books.
- Logging: Logging requests using Morgan.
- Error Handling: Handling errors and exceptions gracefully.
- Configuration: Using dotenv for environment variable management.
- Ready for Deployment: Configured for easy deployment to platforms like Heroku or AWS.
Make sure you have the following software installed:
- Node.js (16 or higher)
- MongoDB (or a MongoDB cloud service)
- npm or yarn (package managers)
- Git (optional)
- Clone this repository or download the source code.
git clone https://github.com/rahulranjan937/NodeJS-Book-CRUD.git
cd NodeJS-Book-CRUD
- Install dependencies.
npm install
-
Create a
.env
file in the project root directory based on the.env.example
file provided. -
Update the
.env
file with your configuration settings, including database connection details, JWT secret, and other environment-specific variables.
To start the application, run:
npm start
This will start the Express server, and your authentication system will be accessible at http://localhost:3000
by default. You can customize the port and other settings in the .env
file.
- POST /api/book: Create a new book.
- GET /api/book: Get all books.
- PUT /api/book: Update a book.
- DELETE /api/book: Delete a book.
To run the sample test cases, use the following command:
npm test
You can add more test cases in the test
directory as needed.
The NodeJS Book CRUD API is ready for deployment to a platform of your choice. You can use services like Heroku, AWS, or others to host your application. Be sure to configure the environment variables accordingly for production deployment.
Contributions are welcome! If you'd like to contribute to this project, please follow these guidelines:
- Fork the repository.
- Create a new branch for your feature or bug fix.
- Make your changes and test thoroughly.
- Submit a pull request.
This project is licensed under the MIT License - see the LICENSE file for details.