This repository contains the backend for an application that allows users to share books among themselves, users can add books, borrow a book, return a book and see all available books.
DB_USER
- To store username of the mysql user (default = "kali")DB_PASS
- To store password of the mysql user (default = "kali")DB_HOST
- To store hostname of the mysql database (default = "127.0.0.1")DB_PORT
- To store port of the mysql database (default = "3306")DB_NAME
- To store the database name (default = "zolo")
The database by default does not have any lenders so remember to add a few lenders before proceeding.
-
Install and setup go on your system.
-
Create a MySQL database in your machine and store database details in the enviornment
-
Clone the git repository
git clone https://github.com/skushagra/zolo-backend.git
- Get the requirements
go get .
- Run the server
go run .
The server will start running on port 9090 by default.
Greets user and verifies that the server is running.
Returns a list of all the books in the database which are available for sharing.
Adds a new book to the database.
Request Payload
{
book_name string
book_author string
available_till string
genre string
hosted_by int
available int (set to 1)
}
Borrows a book from the database with the given book id.
Request Payload
{
borrower_id int
start_time datetime-string
end_time datetime-string
}
Returns the details of the borrow request with the given borrow id.
A postman collection with sample API calls has been uploaded on the repo.