Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Book-API CRUD with PostgreSQL

Table of contents 👀

General info

BAPI or Book-API is a Golang REST API made to show some detail book for person.

The BAPI Object 🍵

Properties Description Type
judul_buku the identity title book String
penulis author book String
tgl_publikasi date of publication String

Routes ⚡

Routes HTTP Methods Description
/api/book/ GET Displays all book
/api/book/ POST Creates a new book
/api/book/{id} GET Displays a specific book, given its name
/api/book/{id} PUT Update identitiy book
/api/user/{id}} DELETE Deletes a specific book, given its id

Technologies

Project is created with:

  • Golang
  • gorilla/mux
  • lib/pq
  • joho/godotenv
  • PostgreSQL

How I built it

👉 Check out the series here!

Setup

To run this project locally, clone repo and add an .env file in the root:

POSTGRES_URL="Postgres connection string"

Then execute in command prompt:

$ cd go-postgres
$ go mod tidy
$ go run main.go

API Reference

These are the endpoints available from the app

GET /api/book/

Returns result identity

Response

Show example response

{
  "data": [
    {
     "judul_buku":"Al Wajiz",
     "penulis": "Imam Ibnu Taimiyah",
     "tgl_publikasi":"2020-10-11",
    }
  ]
}


POST /api/book/

Creates a new identity book

Request

This request requires body payload, you can find the example below.

Show example payload

{
    "judul_buku":"Al Wajiz",
     "penulis": "Imam Ibnu Taimiyah",
     "tgl_publikasi":"2020-10-11",
}

GET /api/book/:id

Returns a book by id

Response

Show example response

{
  "meta": {
    "code": 200
  },
  "data": {
    "id": 1,
    "judul_buku":"Al Wajiz",
     "penulis": "Imam Ibnu Taimiyah",
     "tgl_publikasi":"2020-10-11",
  }
}


UPDATE /api/book/:ID

Update value of identity book

Response

Show example response

{
    "judul_buku":"Al Wajiz",
    "penulis": "Imam Ibnu Taimiyah",
    "tgl_publikasi":"2020-10-11", 
}


DELETE /api/book/:ID

Delete team by id

About

Book-API was made using Golang and PostgreSQL with technique CRUD with mux and pq

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages