Giter Site home page Giter Site logo

greenlight's Introduction

Greenlight

Code for "Let's go further" book

How to run?

First you'll need to export following variable to your environment:

export GREENLIGHT_DB_DSN=postgres://greenlight:pa55word@localhost/greenlight?sslmode=disable

Then start the PostgreSQL in docker container with:

docker-compose up -d

and finally start the server with:

go run ./cmd/api

Useful variables for testing

export BODY='{"title":"","year":1000,"runtime":"-123 mins","genres":["sci-fi","sci-fi"]}'

export BODY_OK='{"title":"Moana","year":2016,"runtime":"107 mins","genres":["animation","adventure"]}'
export BODY_OK2='{"title":"Black Panther","year":2018,"runtime":"134 mins","genres":["action","adventure"]}'
export BODY_OK3='{"title":"Deadpool","year":2016, "runtime":"108 mins","genres":["action","comedy"]}'
export BODY_OK4='{"title":"The Breakfast Club","year":1986, "runtime":"96 mins","genres":["drama"]}'

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

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

curl -X DELETE localhost:4000/v1/movies/3

curl -w '\nTime: %{time_total}s \n' localhost:4000/v1/movies/1

BODY_USER='{“name": "Alice Smith", "email": "[email protected]", "password": "pa55word"}'

curl -i -d "$BODY_USER" http://localhost:4000/v1/users

BODY_USER_INVALID='{"name": "", "email": "bob@invalid.", "password": "pass"}'

curl -i -d "$BODY_USER_INVALID" http://localhost:4000/v1/users

BODY_USER_DUPLICATE='{"name": "Alice Jones", "email": "[email protected]", "password": "pa55word"}'

DB Migrations

migrate create -seq -ext=.sql -dir=./migrations create_movies_table

migrate create -seq -ext=.sql -dir=./migrations add_movies_check_constraints

migrate -path=./migrations -database=$GREENLIGHT_DB_DSN up

migrate create -seq -ext .sql -dir ./migrations add_movies_indexes
migrate -path ./migrations -database $GREENLIGHT_DB_DSN up

greenlight's People

Contributors

sekibomazic avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.