Code Monkey home page Code Monkey logo

book-management's Introduction

Book Management API

This is a simple RESTful API for managing a collection of books. It allows you to perform basic CRUD (Create, Read, Update, Delete) operations on books stored in a MongoDB database.

API Endpoints and Their Usage

1. Create a New Book

  • Endpoint: POST /api/books
  • Usage: Create a new book by sending a JSON object with the book's information (title, author, summary) in the request body.

Example Request:

POST /api/books
{
  "title": "Sample Book",
  "author": "John Doe",
  "summary": "A sample book summary."
}

2. Get a List of All Books

  • Endpoint: GET /api/books
  • Usage: Retrieve a list of all books in the database.

Example Request:

GET /api/books

3. Get Details of a Specific Book

  • Endpoint: GET /api/books/:id
  • Usage: Retrieve the details of a specific book by specifying its ID in the URL parameter.

Example Request:

GET /api/books/123456789012345678901234

4. Update a Book's Details

  • Endpoint: PUT /api/books/:id
  • Usage: Update the details of a specific book by specifying its ID in the URL parameter and sending a JSON object with the updated book information in the request body.

Example Request:

PUT /api/books/123456789012345678901234
{
  "title": "Updated Book Title",
  "author": "Jane Smith",
  "summary": "An updated book summary."
}

5. Delete a Book

  • Endpoint: DELETE /api/books/:id
  • Usage: Delete a specific book by specifying its ID in the URL parameter.

Example Request:

DELETE /api/books/123456789012345678901234

Instructions to Set Up and Run the Application Locally

To set up and run this application on your local machine, follow these steps:

1. Clone the repository from GitHub:

git clone <repository_url>

2. Navigate to the project directory:

cd book-management-api

3. Create a .env file in the project root and set the following environment variables:

PORT=3000
MONGO_USERNAME=<YourMongoDBUsername>
MONGO_PASSWORD=<YourMongoDBPassword>

Replace YourMongoDBUsername and YourMongoDBPassword with your MongoDB credentials.

4. Install project dependencies:

npm install

5. Start the application:

npm start

book-management's People

Contributors

theadeshkhanna avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.