A RESTful API for managing a collection of books. The API supports basic CRUD (Create, Read, Update, Delete) operations.
- URL:
localhost:port/api/books
- Method:
GET
- Description: Retrieve a list of all books.
- Response:
200 OK
: Returns a list of all books.
- URL:
localhost:port/api/books
- Method:
POST
- Description: Create a new book.
- Request Body:
title
(string, required): The title of the book.author
(string, required): The author of the book.publishedYear
(number, required): The year the book was published.ISBN
(string, required): The ISBN number of the book.
- Response:
201 Created
: Returns the created book.
- URL:
localhost:port/api/books/:id
- Method:
GET
- Description: Retrieve details of a specific book by ID.
- Response:
200 OK
: Returns the book details.
- URL:
localhost:port/api/books/:id
- Method:
PATCH
- Description: Update the details of a specific book by ID.
- Request Body: Any book field that needs to be updated.
- Response:
200 OK
: Returns the updated book.
- URL:
localhost:port/api/books/:id
- Method:
DELETE
- Description: Delete a specific book by its ID.
- Response:
204 No Content
: Indicates successful deletion.
- URL:
localhost:port/api/books/cover-image/:id
- Method:
PATCH
- Description: Update the cover image of a specific book.
- Request: Multipart form data with the key
photo
and the image file. - Response:
200 OK
: Returns the book with the updated cover image.
$ git clone https://github.com/gitEricsson/Books-API.git
cd books-api
After cloning book-management-api, install the dependencies by running:
$ npm install
To start the server, run:
$ npm start
To run the tests, use the following command:
$ npm test