Skip to content

yumaeda/sakaba-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sakaba-api

API repository for sakaba.link

Build Docker image

docker build --no-cache -t sakaba/api .

 

Launch Docker container

docker run --rm -d \
    -e APP_CONFIG_JSON="{\"db.password\":\"DB_PWD\",\"db.host\":\"DB_HOST\",\"db.name\":\"DB_NAME\",\"db.user\":\"DB_USER\",\"aws.s3.id\":\"S3_ID\",\"aws.s3.secret\":\"S3_SECRET\",\"aws.s3.region\":\"S3_REGION\"}" \
    -p 8080:8080 \
    sakaba/api

 

Login

curl -X POST \
    -H 'Content-Type: application/json' \
    -d '{"email":"example@sakaba.link", "password":"xxxx"}' \
    http://localhost:8080/login

 

Refresh token

curl -X GET \
    -H 'Content-Type: application/json' \
    -H 'Authorization:Bearer xxxxxxxxx' \
    http://localhost:8080/auth/refresh_token

Access

curl -X GET \
    -H 'Content-Type: application/json' \
    -H 'Authorization:Bearer xxxxxxxxx' \
    http://localhost:8080/auth/home

Call add restaurant genre API

curl -X POST \
    -H 'Authorization:Bearer xxxxxxxxx' \
    -H 'Content-Type: application/json; charset=utf-8' \
    -d '{ "restaurant_id": "{RESTAURANT_ID}", "genre_id": "{GENRE_ID}" }' \
    http://localhost:8080/auth/restaurant-genre/

Call add restaurant API

curl -X POST \
    -H 'Authorization:Bearer xxxxxxxxx' \
    -H 'Content-Type: application/json; charset=utf-8' \
    -d '{ "url": "{URL}", "name": "{NAME}", "genre": "{GENRE}", "tel": "{TEL}", "business_day_info": "{BUSINESS_DAY_INFO}", "address": "{ADDRESS}", "latitude": "{LATITUDE}", "longitude": "{LONGITUDE}", "area": "{AREA}" }' \
    http://localhost:8080/auth/restaurant/

 

Reference

 

Misc

Install Go

brew install go

Install golint

go install golang.org/x/lint/golint@latest

Install shadow linter

go install golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow@latest

Linting and Vetting

golint ./...
go vet ./...
shadow ./...

List environment variables for Go

go env

Remove unused modules

go mod tidy -v

 

TODOs

 

Links