slice-it-api

module
v0.0.0-...-61649fe Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 8, 2022 License: MIT

README

sliced piece of pie

Welcome to the Slice It API 👋

Using go version 1.14 Using go version 1.14 Go Report Card godoc

Dependencies

  • Be sure to have Go (1.14+)
  • Be sure to have postgres running locally

Database

  • Set up development db with
    createdb slice_it_api_dev
    
  • Run migration:
    psql -U slice_it_user -d slice_it_api_dev -a -f internal/storage/migrations/schema.sql
    

Usage

Development

go run cmd/server/main.go

Testing

Standard:

go test ./...

For some nice color output:

make test

Deployment

Build docker image after code changes:

docker build \
  --build-arg SLICE_IT_API_SERVER_PORT={server_port} \
  --build-arg SLICE_IT_API_DB_HOST={host} \
  --build-arg SLICE_IT_API_DB_PORT={db_port} \
  --build-arg SLICE_IT_API_DB_USER={db_username} \
  --build-arg SLICE_IT_API_DB_PASSWORD={db_password} \
  --build-arg SLICE_IT_API_DB_NAME={db_name} \
  --build-arg SLICE_IT_API_SSL_MODE={ssl_mode} \
  -t bradfordhamilton/slice-it-api:latest .

Push image:

docker push bradfordhamilton/slice-it-api:latest

Then cd into build/terraform and run the following commands.

terraform plan -out=tfplan -input=false .
terraform apply -input=false tfplan

Directories

Path Synopsis
cmd
internal
server
Package server provides a New func for spinning up a new API server.
Package server provides a New func for spinning up a new API server.
storage
Package storage describes the interface for interacting with our datastore, and provides a PostgreSQL implementation for the slice-it-api.
Package storage describes the interface for interacting with our datastore, and provides a PostgreSQL implementation for the slice-it-api.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL