Git Product home page Git Product logo

greenlight's Introduction

Greenlight API

APIs

GET /v1/healthcheck -> Show application information || - GET /v1/movies -> Show details of all movies || movies:read POST /v1/movies -> Create movie || movies:write GET /v1/movies/:id -> Get movie by id || movies:read PATH /v1/movies/:id -> Update movie || movies:write DELETE /v1/movies/:id -> Delete movie || movies:write POST /v1/users -> Register a new user || - PUT /v1/users/activated -> Activate a specific user || - POST /v1/tokens/authentication -> Generate a new authentication token || -

Running the application locally

$ exprt GREENLIGHT_DB_DSN='postgres://greenlight:<password>@localhost/greenlight?sslmode=disable'

Create database commands

$ docker exec -it pid_id /bin/bash
root@aebae6d87e96:/# psql -U postgres -h localhost
postgres=# SELECT current_user;
postgres=# CREATE DATABASE greenlight;
postgres=# CREATE ROLE greenlight WITH LOGIN PASSWORD '<password>';
postgres=# CREATE EXTENSION IF NOT EXISTS citext;
postgres=# grant all privileges on database greenlight to greenlight;
postgres=# alter database greenlight owner to greenlight;

Migrations

Install golang migrate

$ go install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@latest

Run migrations

$ export GREENLIGHT_DB_DSN='postgres://greenlight:<password>@localhost/greenlight?sslmode=disable'
$ migrate -path=./migrations -database=$GREENLIGHT_DB_DSN up

Create migration files

$ migrate create -seq -ext .sql -dir ./migrations add_movies_indexes

Testing commands

Testing optimistic locking

$ xargs -I % -P8 curl -X PATCH -d '{"runtime": "97 mins"}' "localhost:4000/v1/movies/1" < <(printf '%s\n' {1..8})

Measure the response time

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

greenlight's People

Contributors

povarna avatar

Watchers

 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.