nfl-looser-pool-api

command module
v0.0.0-...-c877efe Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2022 License: MIT Imports: 12 Imported by: 0

README

NFL Looser Pool REST API

REST API for NFL Looser Pool game

Getting Started

  • Install Postgres, Docker, and Go.

  • Install the Docker app launch it

  • Install the Postgres app and launch it using port 5432

  • You'll need to set up a .env file to store your PostgreSQL information. Here is an example:

POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
POSTGRES_DB=postgres
DB_HOST=host.docker.internal

export POSTGRESQL_URL="postgres://postgres:postgres@localhost:5432/postgres?sslmode=disable"

Note: POSTGRESQL_URL is not being used in the program, but we can reference this variable in our db migration commands

  • create schemas migrate create -ext sql -dir db/migrations -seq create_items_table

  • Run Database Migrations

    • Migrate Up
    migrate -database postgres://postgres:postgres@localhost:5432/postgres?sslmode=disable -path db/migrations up
    

    or

    export POSTGRESQL_URL="postgres://postgres:postgres@localhost:5432/postgres?sslmode=disable"
    migrate -database ${POSTGRESQL_URL} -path db/migrations up
    
    • Migrate Down
    migrate -database postgres://postgres:postgres@localhost:5432/postgres?sslmode=disable -path db/migrations down
    
  • To dig into Postgresql, you can use psql

  • run docker-compose up --build to launch the api server on port 8080

    Before you run this command, be sure your local postgres server is running using the postgres app

  • run docker-compose down to destroy Docker containers

  • Create a sample item

curl -X POST http://localhost:8080/items -H "Content-type: application/json" -d '{ "name": "swim across the River Benue", "description": "ho ho ho"}'
  • Get all items
curl http://localhost:8080/items

Scripts

  • dev - starts the local docker container for local dev
  • kill-postgres kills postgres running ports / servers
  • db:down - drops the database
  • db:up - runs database migrations
  • db:down:up:dev - drops the database, runs migrations and starts the docker container / server

References and Tools

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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