Coder Social home page Coder Social logo

nodejs-task-movies-api's Introduction

Movies API - Recruitment Task

Techstack

  • Server: Express.JS
  • Database: MongoDb
  • Tests Framework: Jest
  • Code Versioning: git
  • Code Repository: github
  • Container System: Docker, docker-compose
  • CI: Github Actions
  • IDE: Local VSCode

Architecture

Current app architecture exposes 2 basic bearer token protected, endpoints for movies. Initialy the server starts with getting the mongoDB connection.

  • When request comes from the client for geting the movies, it queries the mongoDB for user's added movies and respond back.
  • When request comes from the client for add the movie, it will first check whether the user role is basic and exceed the allowed limit of 5 movies per calendar month or not. Based on the decision further request send OMDB database for the serach. For successfull movie response, its stored to movies database along with userId of the requested user.
  • Simple CI through github Actions has been implemented. This CI workflow will execute on master branch push or pull requests targeting the master branch.
  • Directories Explained
    • routes
      • All the routes for movies service has been defined here with v1 versioning structure. The routes are initialized with init function in routes/index.js file.
    • services
      • Contains the business logic to process the endpoint requests.
    • models
      • Contains the model files used in the app.
    • handlers
      • Each resource route ex. /movies provided a dedicated route handler. Here all the verbs get, put, post... has been defined for the resource. And each verb for the route has been given a separate service file that contain the business logic of the endpoint.
    • middlewares
      • Contains the middlerware functions we need to leverage. ex. authGate.js
    • utils
      • Contains the basic app wide util feature reated files like axios.js, constants.js, auth.js, db-config.js.

Configuration

  • sample ENV. variables for ref.
    • external API
    • Database
      • MONGODB_USER=root
      • MONGODB_PASSWORD=123456
      • MONGODB_DATABASE=movies_db
      • MONGODB_LOCAL_PORT=7017
      • MONGODB_DOCKER_PORT=27017
      • APP_PORT=4000

Documentation

  • API docs
  • Postman
    • Collection:
      • docs/postman/dev-nodejs-recruitment-task-collection.json
    • Environment variables:
      • docs/postman/dev-nodejs-recruitment-task.postman_environment.json

Setup / Usage

  • Step1:
    • In order to prevent providing multiple env. variables at the time of starting the app, all the variables are added to .env.sample file except the sensitive OMDB_API_KEY.
    • Please rename the .env.sample to .env in order for app to receive the required env. variables.
  • Step2:
    • spin up the docker containers by following docker-compose command at the root of the directory where Dockerfile and docker-compose exists.

Note: Mostly all the required env. variables will be referenced from .env (except the sensitive OMDB_API_KEY and JWT_SECRET) available at the root along with Dockerfile and docker-compose.yml. Since the OMDB_API_KEY, JWT_SECRET is sensitive, it will be sent on different medium

OMDB_API_KEY=<api_key> JWT_SECRET=<jwt_secret> docker-compose up
  • Spin down the service

    execute following command
docker-compose down

nodejs-task-movies-api's People

Contributors

tejasmob avatar tejasrsuthar 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.