/NodeJS-Book-CRUD

Primary LanguageJavaScriptMIT LicenseMIT

NodeJS Book CRUD API (Node.js + Express + MongoDB)

Table of Contents

Introduction

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.

Features

  • 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.

Requirements

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)

Installation

  1. Clone this repository or download the source code.
git clone https://github.com/rahulranjan937/NodeJS-Book-CRUD.git
cd NodeJS-Book-CRUD
  1. Install dependencies.
npm install

Configuration

  1. Create a .env file in the project root directory based on the .env.example file provided.

  2. Update the .env file with your configuration settings, including database connection details, JWT secret, and other environment-specific variables.

Usage

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.

API Endpoints

  • 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.

Testing (Coming Soon)

To run the sample test cases, use the following command:

npm test

You can add more test cases in the test directory as needed.

Deployment

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.

Contributing

Contributions are welcome! If you'd like to contribute to this project, please follow these guidelines:

  1. Fork the repository.
  2. Create a new branch for your feature or bug fix.
  3. Make your changes and test thoroughly.
  4. Submit a pull request.

License

This project is licensed under the MIT License - see the LICENSE file for details.