Its a Library Management Rest API Express Application.The Database i have used to store Books is MongoDB with a collection name as Books. The 4 Methods i have used are GET, POST , PUT , DELETE to get book/books , add a new Book , Update the Fields of a book or add New one in the Existing Document and to Delete a Existing Book from the Collection.
This API provides basic functionality for managing books in a library.
GET /api/getbook
Retrieves information about books based on the provided parameters.
bookId
(optional): The unique identifier of the book.
- Retrieve information about a specific book by providing the
bookId
. - Retrieve information about all books in the library by not providing a
bookId
.
- 200 OK: Returns information about the requested book(s).
- 400 Bad Request: Indicates that the book(s) don't exist.
POST /api/addbooks
Adds a new book to the library.
title
(required): The title of the book.author
(optional): The author of the book.genre
(optional): The genre of the book.pageCount
(optional): The page count of the book.
- Add a book with only the required
title
. - Add a book with additional information such as
author
,genre
, andpageCount
.
- 201 Created: Returns the newly added book.
- 400 Bad Request: Indicates missing required fields.
PUT /api/updatebooks
Updates information about a book in the library.
bookId
(required): The unique identifier of the book.title
(optional): The new title of the book.author
(optional): The new author of the book.genre
(optional): The new genre of the book.pageCount
(optional): The new page count of the book.
- Update the
title
of a book. - Update multiple fields of a book such as
author
,genre
, andpageCount
.
- 200 OK: Returns the updated information about the book.
- 400 Bad Request: Indicates missing required
bookId
.
DELETE /api/deletebooks
Removes a book from the library.
bookId
(optional): The unique identifier of the book.title
(optional): The title of the book.
- Remove a book by providing its unique
bookId
. - Remove a book by providing its
title
.
- 200 OK: Returns the removed book.
- 400 Bad Request: Indicates missing both
bookId
andtitle
.