Skip to content

mohamedfo17/CRUD-Rest-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Book Management API

This is a CRUD REST API for managing books, built with Express.js, Node.js, and MongoDB.

Features

  • Create a new book
  • Retrieve all books
  • Retrieve a single book by ID
  • Update a book's details
  • Delete a book

Technologies Used

  • Node.js
  • Express.js
  • MongoDB
  • Mongoose
  • dotenv

Installation

  1. Clone the repository:

    git clone https://github.com/mohamedfo17/CRUD-Rest-API
    cd CRUD-Rest-API
  2. Install dependencies:

    npm install
  3. Create a .env file and add your MongoDB connection string:

    MONGO_URI=your_mongodb_connection_string
    PORT=3000
  4. Start the server:

    nodemon start

API Endpoints

Create a Book

  • Endpoint: POST /books
  • Description: Adds a new book to the database.
  • Request Body:
    {
      "title": "Book Title",
      "author": "Author Name",
      "publishedYear": 2024
    }

Get All Books

  • Endpoint: GET /books
  • Description: Retrieves a list of all books.

Get a Single Book by ID

  • Endpoint: GET /books/:id
  • Description: Retrieves a book by its ID.

Update a Book

  • Endpoint: PUT /books/:id
  • Description: Updates an existing book's details.
  • Request Body: (Provide the fields you want to update)
    {
      "title": "Updated Title",
      "author": "Updated Author"
    }

Delete a Book

  • Endpoint: DELETE /books/:id
  • Description: Removes a book from the database.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors