BookCollection REST API is a simple RESTful API built with Node.js and Hapi.js for managing a collection of books. It allows you to perform CRUD (Create, Read, Update, Delete) operations on book records.
Add a new book (POST /books):
{
"name": "Book Name",
"author": "Author Name",
"year": 2023,
"publisher": "Publisher Name",
"summary": "Summary of the book",
"readPage": 100,
"reading": true,
"pageCount": 200
}
Response:
{
"status": "success",
"message": "Buku berhasil ditambahkan",
"data": {
"bookId": "nanoid"
}
}
Get all books (GET /books):
Query Parameters (optional): name
, reading
, finished
Response:
{
"status": "success",
"data": {
"books": [
{
"id": "nanoid",
"name": "Book Name",
"publisher": "Publisher Name"
}
]
}
}
Get book details by ID (GET /books/bookId):
Response:
{
"status": "success",
"data": {
"book": {
"id": "nanoid",
"name": "Book Name",
"author": "Author Name",
"year": 2023,
"publisher": "Publisher Name",
"summary": "Summary of the book",
"readPage": 100,
"reading": true,
"pageCount": 200,
"finished": false,
"insertedAt": "2023-05-01T00:00:00.000Z",
"updatedAt": "2023-05-01T00:00:00.000Z"
}
}
}
Update book details by ID (PUT /books/bookId):
Request Body:
{
"name": "Updated Book Name",
"author": "Updated Author Name",
"year": 2023,
"publisher": "Updated Publisher Name",
"summary": "Updated summary of the book",
"readPage": 150,
"reading": false,
"pageCount": 200
}
Response:
{
"status": "success",
"message": "Buku berhasil diperbarui"
}
Delete a book by ID (DELETE /books/bookId):
Response:
{
"status": "success",
"message": "Buku berhasil dihapus"
}
Clone the repository from GitHub:
git clone https://github.com/SideeID/API-Bookshelf.git
Navigate to the project directory:
cd API-Bookshelf
Install dependencies:
npm install
Start the development server:
npm run start-dev
Or start the server in production mode:
npm start
Run tests:
npm test
This is a personal learning project and does not accept external contributions.