This API is designed for library systems. There are User,Book and Borrow endpoints.
Fiber framework, Goose, POSTGRESQL DB, SQLC and Docker was used by developing this API. Also Clean architecture has been used.
-
-
Clone the repo
git clone https://github.com/melikesenacakir/GoLibraryAPI.git -
Go to this file
cd GoLibraryAPI -
Run the system in your terminal
docker-compose up
-
POST /api/v1/loginRequired:
| Parameter | Type | Explanation |
|---|---|---|
role |
string |
Enter role(admin/user) |
username |
string |
Enter username |
password |
string |
Enter password |
-Default Admin Login Informations:
{
"role":"admin",
"username":"admin121",
"password":"123456"
}
{
"role":"admin",
"username":"admin121",
"password":"123456"
}
GET /api/v1/userRequired:
Logged into an existing Admin account
[
{
"role": "admin",
"username": "admin121"
}
]
GET /api/v1/user/idRequired:
- Logged into an existing Admin account
| Parameter | Type | Explanation |
|---|---|---|
id |
int |
Enter id |
[
{
"role": "admin",
"username": "admin121"
}
]
POST /api/v1/user/createRequired:
- Logged into an existing Admin account
| Parameter | Type | Explanation |
|---|---|---|
role |
string |
Enter role(admin/user) |
username |
string |
Enter username |
password |
string |
Enter password |
{
"message": "user successfully created"
}
DELETE /api/v1/user/delete/idRequired:
- Logged into an existing Admin account
| Parameter | Type | Explanation |
|---|---|---|
id |
int |
Enter id to url |
{
"message": "user successfully deleted"
}
PUT /api/v1/user/update/idRequired:
- Logged into an existing Admin account
| Parameter | Type | Explanation |
|---|---|---|
id |
int |
Enter id to url |
role |
string |
Enter role(admin/user) |
username |
string |
Enter username |
password |
string |
Enter password |
{
"message": "user successfully updated"
}
GET /api/v1/book [
{
"id": 1,
"name": "tanios kayası",
"author": "amin maalouf",
"stock": 5
}
]
GET /api/v1/book/idRequired:
| Parameter | Type | Explanation |
|---|---|---|
id |
int |
Enter id to url |
[
{
"id": 1,
"name": "tanios kayası",
"author": "amin maalouf",
"stock": 5
}
]
POST /api/v1/book/createRequired:
- Logged into an existing Admin or User account
| Parameter | Type | Explanation |
|---|---|---|
id |
int |
Enter id to url |
[
{
"id": 1,
"name": "tanios kayası",
"author": "amin maalouf",
"stock": 5
}
]
DELETE /api/v1/book/delete/idRequired:
- Logged into an existing Admin or User account
| Parameter | Type | Explanation |
|---|---|---|
id |
int |
Enter id to url |
{
"message": "book successfully deleted"
}
PUT /api/v1/book/update/idRequired:
- Logged into an existing Admin or User account
| Parameter | Type | Explanation |
|---|---|---|
id |
int |
Enter id to url |
name |
string |
Enter name |
author |
string |
Enter author |
stock |
int |
Enter stock |
{
"message": "book successfully updated"
}
GET /api/v1/borrows/historyRequired:
- Logged into an existing Admin or User account
[
{
"borrow_id": 1,
"borrowdate": "2024-04-28T23:24:35.212264Z",
"returndate": "2024-05-08T23:24:35.212265Z",
"status": "borrowed",
"username": "admin121",
"book_name": "tanios kayası"
},
{
"borrow_id": 2,
"borrowdate": "2024-04-28T23:24:35.212264Z",
"returndate": "2024-05-08T23:24:35.212265Z",
"status": "returned",
"username": "user",
"book_name": "tanios kayası"
}
]
PUT /api/v1/borrows/return/idRequired:
- Logged into an existing Admin or User account
| Parameter | Type | Explanation |
|---|---|---|
id |
int |
Enter id to url |
{
"message": "book returned"
}
POST /api/v1/borrows/newRequired:
- Logged into an existing Admin or User account
| Parameter | Type | Explanation |
|---|---|---|
user_id |
int |
Enter user id |
book_id |
int |
Enter book id |
{
"message": "books successfully borrowed. Please return on time!"
}
GET /api/v1/borrows/oldborrowsRequired:
- Logged into an existing Admin or User account
[
{
"borrow_id": 1,
"borrowdate": "2024-04-28T23:24:35.212264Z",
"returndate": "2024-05-08T23:24:35.212265Z",
"status": "returned",
"username": "admin121",
"book_name": "tanios kayası"
}
]