Skip to content

benschw/books-poc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TODO

  • database migrations instead of fixture schema
  • user input validation
  • test postgres repo

Run the App

# build (for linux since it will be running inside a docker container)
GOOS=linux GOARCH=amd64 go build

# Start a postgres server & the app with docker-compose
docker-compose up -d

Run the UI

https://github.com/benschw/books-ui-poc (this will proxy API requests to localhost:8080 to match the below default service usage)

git clone git@github.com:benschw/books-ui-poc.git
cd books-ui-poc
yarn start

Interact with the API

$ curl -X POST localhost:8080/book -d '{"title": "hello world", "author": "ben schwartz"}'
{"data":{"id":1,"title":"hello world","author":"ben schwartz"}}

$ curl -X POST localhost:8080/book -d '{"title": "hello world", "author": "ben schwartz"}'
{"data":{"id":2,"title":"hello world","author":"ben schwartz"}}

$ curl -X POST localhost:8080/book -d '{"title": "hello world", "author": "ben schwartz"}'
{"data":{"id":3,"title":"hello world","author":"ben schwartz"}

$ curl -s localhost:8080/book | jq .
{
  "data": [
    {
      "id": 1,
      "title": "hello world",
      "author": "ben schwartz"
    },
    {
      "id": 2,
      "title": "hello galaxy",
      "author": "ben schwartz"
    },
    {
      "id": 3,
      "title": "hello world",
      "author": "ben schwartz"
    }
  ]
}}

$ curl -X PUT localhost:8080/book/1 -d '{"title": "hello galaxy", "author": "benjamin schwartz"}'
{"data":{"id":1,"title":"hello galaxy","author":"benjamin schwartz"}}

$ curl -X DELETE localhost:8080/book/2

$ curl -s localhost:8080/book | jq .
{
  "data": [
    {
      "id": 1,
      "title": "hello galaxy",
      "author": "benjamin schwartz"
    },
    {
      "id": 3,
      "title": "hello world",
      "author": "ben schwartz"
    }
  ]
}}

Notes

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published