Git Product home page Git Product logo

book-store's Introduction

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"
}

book-store's People

Contributors

suvam720 avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.