Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/suvam720/book-store
book-store restApi
https://github.com/suvam720/book-store
gin mysql
Last synced: about 2 months ago
JSON representation
book-store restApi
- Host: GitHub
- URL: https://github.com/suvam720/book-store
- Owner: suvam720
- Created: 2022-05-16T17:16:33.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2022-06-06T08:57:05.000Z (over 2 years ago)
- Last Synced: 2024-11-14T14:39:32.419Z (about 2 months ago)
- Topics: gin, mysql
- Language: Go
- Homepage:
- Size: 21.5 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# book-store
### A simple CRUD api using gin and mysql
## How to run:
- clone project
- add .env file and update the database connection string in DB_STRING key.
- run the command `make run`## Endpoints: usage:
- post /books (add a book)
- get /books (get all books)
- get /books/:id (get one book by id)
- put /books/:id (update a book)
- delete /books/:id (delete a book)## Routes:
### POST /books : _adding a book_
- request:
```
{
"name":"Autobiography og a yogi",
"author":"Paramhansa Yogananda",
"publisher":"Yogoda Satsanga Society of india",
"published_date":"2016",
"rating": 4.9
}
```- response:
- 201 created```
{
"data": {
"ID": 1,
"CreatedAt": "2022-05-27T23:09:34.37+05:30",
"UpdatedAt": "2022-05-27T23:11:09.275+05:30",
"DeletedAt": null,
"name": "Autobiography og a yogi",
"author": "Paramhansa Yogananda",
"publisher": "Yogoda Satsanga Society of india",
"published_date": "2016",
"rating": 4.9
}
}
```### GET /books : _get all books_
- response
- 200 ok```
{
"data": {
"ID": 1,
"CreatedAt": "2022-05-27T23:09:34.37+05:30",
"UpdatedAt": "2022-05-27T23:11:09.275+05:30",
"DeletedAt": null,
"name": "Autobiography og a yogi",
"author": "Paramhansa Yogananda",
"publisher": "Yogoda Satsanga Society of india",
"published_date": "2016",
"rating": 4.9
}
}
```### GET /books/:id : _get a book by id_
- Param path:
- id: 1
- response:
- 200 ok```
{
"data": {
"ID": 1,
"CreatedAt": "2022-05-27T23:09:34.37+05:30",
"UpdatedAt": "2022-05-27T23:11:09.275+05:30",
"DeletedAt": null,
"name": "Autobiography og a yogi",
"author": "Paramhansa Yogananda",
"publisher": "Yogoda Satsanga Society of india",
"published_date": "2016",
"rating": 4.9
}
}
```### PUT /books/:id : _updating a book_
- request:
```
{
"name":"Autobiography Of A Yogi",
"author":"Paramhansa Yogananda",
"publisher":"Yogoda Satsanga Society of india",
"published_date":"2016",
"rating": 5
}
```- response:
- 200 ok```
{
"data": {
"ID": 1,
"CreatedAt": "2022-05-27T23:09:34.37+05:30",
"UpdatedAt": "2022-05-27T23:21:28.865+05:30",
"DeletedAt": null,
"name": "Autobiography Of A Yogi",
"author": "Paramhansa Yogananda",
"publisher": "Yogoda Satsanga Society of india",
"published_date": "2016",
"rating": 5
}
}
```### DELETE /books/:id : _deleting a book_
- Param path:
- id: 1
- response:
- 200 ok```
{
"message": "item deleted"
}
```