Greenlight API

Greenlight is an api, i implemented by following the book Let’s Go Further by Alex Edwards

If you like what you see please consider buying the book, it was my first hands on book and i absolutely loved it and i recommend it strongly.

Requeriments

If you are in Mac OS environment you can use brew to install the tools:

Get Started

  1. Make sure you have the requeriments working correctly

  2. Clone the repo

git clone https://github.com/ricardonunosr/greenlight.git
  1. Create Database,User and install extension to database

psql postgres
CREATE DATABASE greenlight;
\c greenlight
CREATE ROLE greenlight WITH LOGIN PASSWORD 'pa55word';
CREATE EXTENSION IF NOT EXISTS citext;
  1. Add this to your .zshrc or bashrc and then source it

export GREENLIGHT_DB_DSN='postgres://greenlight:[email protected]/greenlight?sslmode=disable'

source ~/.zshrc
  1. Executing the migrations

migrate -path=./migrations -database=$GREENLIGHT_DB_DSN up
  1. Run the api

go run ./cmd/api
  1. Make a POST,GET and DELETE requests to check if its working correctly

BODY='{"title":"Black Panther","year":2018,"runtime":"134 mins","genres":["sci-fi","action","adventure"]}'

curl -i -d "$BODY" localhost:4000/v1/movies
curl -i localhost:4000/v1/movies/1
curl -X DELETE localhost:4000/v1/movies/1

GitHub

View Github