Giter VIP home page Giter VIP logo

books's Introduction

books

This project is a simple RESTful API built with Express.js for managing a collection of books.

Table of Contents

Introduction

This is an API built for managing a collection of books. It allows adding books to the database, updating the loan status of the book, getting all the books in the database or just one particular book and it also allows for the deletion of a book. It is useful in a library setting where one has to keep track of all the books available

Installation

Provide step-by-step instructions on how to set up the project locally. To set up the project locally:

  1. Clone the repository using this link https://github.com/Hephzy-1/books.git
  2. Navigate to the cloned repository
  3. Download the dependencies using npm install
# Clone the repository
git clone https://github.com/Hephzy-1/books.git

# Navigate to the project directory
cd books

# Install dependencies
npm install 

Usage

You can run the project using nodemon

# Start the server
npm start

Your output should be similar to

Server is running on port 3000

API Endpoints

Here are the available API endpoints:

GET /books

This endpoint retrieves all the books in the database.

GET /api/books

Responses

200 OK - Returns all books 400 Bad Request - Invalid Request

GET /books/:title

This endpoint retrieves a single book by its id.

GET /api/books/{title}

Path Parameter

title - The title of the book

Responses

200 OK - Returns the book with the specified title 404 Not Found - Book not found

POST /books

This endpoint adds a new book to the database. The request body should contain the book details in JSON

POST /api/books

Request Body

{
  "title": "Book Title",
  "author": "Author Name"
}

Responses

201 Created - Book added successfully 400 Bad Request - Invalid input

PUT /books/:title

This endpoint updates a single book by its id. The request body should contain the updated book details in JSON

PUT /api/books/{title}

Path Parameter

title - The title of the book

Request Body

{
  "title": "Book Title",
  "loan": true
}

Responses

200 OK - Book updated successfully 404 Not Found - Book not found

DELETE /books/:title

This endpoint deletes a single book by its id.

DELETE /api/books/{title}

Path Parameter

title - The title of the book

Request Body

{
  "title": "Book Title"
}

Responses

200 OK - Book deleted successfully 404 Not Found - Book not found

books's People

Contributors

hephzy-1 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.