Skip to content
This repository has been archived by the owner on Jul 14, 2021. It is now read-only.

Latest commit

 

History

History
102 lines (70 loc) · 2.14 KB

README.md

File metadata and controls

102 lines (70 loc) · 2.14 KB

internet-movie-database-api

Build Status

Live app: https://internet-movie-database-api.herokuapp.com/movies

Api endpoints

  • POST /movies
  • GET /movies
  • POST /comments
  • GET /comments

More details here.

Requirements

  • Postgres (ver. 9.4 or newer)
  • node.js
  • Omdb api key

Instalation

1. Install dependencies and copy .env files:

yarn install
cp .env.development.example .env.development
cp .env.test.example .env.test

2. Edit .env files to match your enviroment settings:

By default app will use variables from file .env.development if it exists. App is picking .env files based on NODE_ENV enviroment variable, ex. .env.[NODE_ENV].

Example .env.development file:

DB_USERNAME=docker
DB_PASSWORD=password
DB_DATABASE=internet_movie_database_api_test
DB_HOST=127.0.0.1
DB_PORT=5432

DB_MAX_CONNECTIONS=20 // optional
DB_MAX_IDLE_TIME=10000 // optional

LOG_SAVE=true // optional
LOG_FILE=combined.log // optional
LOG_LEVEL=info // optional, more about levels here https://www.npmjs.com/package/winston#logging-levels

OMDB_API_KEY=[your api key]

PORT=5000 // optional, default 5000

Save api key in .env.development and .env.test files

4. Run app:

yarn start

Running app in docker

Requirements:

Instalation:

Edit file docker-compose.yml and paste your omdb api key

sudo docker-compose up

Testing

# Test code styles and app:
yarn test 

# Test only app:
yarn run mocha

Code style:

Eslint uses Airbnb style guide:

# Test code style:
yarn run lint

Database migration and seeding

App is using sequelize cli to menage database seeding and migrations:

  • sequelize db:migrate - migrate tables
  • sequelize db:seed:all - seed tables
  • sequelize db:migrate:undo:all - drop migrated tables