Anthor Test - Back-end

  1. Before starting the project, create a github repo and make an initial commit only with a Readme file, answering the following questions:
  2. How do you intend to approach this project? What technologies have you decided to use for each part?
  3. Do you find this to be particularly challenging in any of its requirements?
  4. If you had a lot of time to do this, what would you do differently?

Required dependencies

  • Npm v6.4.1
  • Node v10.11.0 or latest - Obs: you can to use nvm to control it (:
  • Docker v18.09.1
  • Docker-compose v1.17

Framework node

This project uses Adonis (v4.1.0) api scaffold as backend framework.

Application configuration steps

  1. $ git clone https://github.com/rehnan/anthor-test-back-end.git && cd anthor-test-back-end to download the app

  2. $ cp .env.example .env to create application environment variables

  3. Modify only below variables in .env file (if necessary):

     DB_PORT=<PORT>
     DB_USER=<USERNAME>
     DB_PASSWORD=<PASSWORD>
     DB_DATABASE=<DATABASE>
    
  4. Run npm install to install all app dependencies

  5. Run docker volume create --name=anthor-data to create app external volumes

  6. Run docker-compose up to start a virtual machine in a docker containerized environment

  7. Run seed database with docker command: docker exec -it anthor_app_1 adonis seed

  8. So, you can then access the app in localhost:3223

Tests

  1. You can run tests with npm command: npm run test

Api Routes

Authentication

Authentication endpoint routes

  • BASE PATH

    /v1/auth

  • Available Method:

    POST

  • GET /v1/sign-in (Required: user email and password)

    Login user account and return token

  • GET /v1/sign-out (Required: token)

    Logout user account

  • GET /v1/authenticated (Required token)

    Check authentication status from some user account

Default authentication user generated by User Seeder:

email: root@anthor.com.br password: password

Movies

Movie endpoint routes

  • BASE PATH

    /v1/movies

  • Available Method:

    GET | POST | DELETE | PATCH

  • GET /v1/movies (No auth required)

    Return movie list

  • GET /v1/movies/:id> (No auth required)

    Return movie by id

  • POST /v1/movies (Required Auth)

    Create new movie and return it in response

  • PATCH /v1/movies/:id (Required Auth)

    Update movie by id and return it in response

  • DELETE /v1/movies/:id (Required Auth)

    Delete movie by id and return it in response