ajomadlabs / node-backend

Node Backend

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Node Backend App

Description

This project aims at creating stateless microservice using Node.js

It contains mainly three services:

  • Authentication Service This service accepts an username which is an email and password and returns a jwt token.

  • JSON Patching Service This service accepts a json object and json patch object and returns an object after patching.

  • Image Resize Service This service accepts an image URL, downloads the image, resize to 50x50 and returns the resized thumbnail.

Project Structure

Contains three services:

  • AuthenticationService

  • ImageThumbnailService

  • JSONPatchService

AuthenticationService

  • server.js:  Runs Authentication Service
  • routes contains
  •   index.js:  Handles the '/login' route
  • test contains
  •   login.spec.js:  Contains tests for login route
  • config contains
  •   auth.js:  Contains configurations
  •   winston.js:  Contains winston setup for the service
  • Dockerfile
  • swagger.yaml:  Contains swagger specs for Authentication Service API

JSONPatchService

  • server.js:  Runs JSON Patch Service
  • routes contains
  •   index.js:  Handles the '/applyjsonpatch' route
  • test contains
  •   jsonpatch.spec.js:  Contains tests for applyjsonpatch route
  • config contains
  •   auth.js:  Contains configurations
  •   winston.js:  Contains winston setup for the service
  • Dockerfile
  • swagger.yaml:  Contains swagger specs for JSON Patch Service API

ImageThumbnailService

  • server.js:  Runs ImageThumbnail Service
  • routes contains
  •   index.js:  Handles the '/createthumb' route
  • test contains
  •   createThumbnail.spec.js:  Contains tests for createthumb route
  • config contains
  •   auth.js:  Contains configurations
  •   winston.js:  Contains winston setup for the service
  • Dockerfile
  • swagger.yaml:  Contains swagger specs for Image Thumbnail Service API

Config contains

  •   nginx contains
  •      default.conf: Contains nginx configurations to handle requests to different services

Makefile

Docker-compose-prod-yaml:  For production

Docker-compose:  For development

Project Architecture

  • Client makes a request
  • Request hits the api server which is a ngnix container
  • API server routes the requests to the respective services

Pre-requisites

  • Nodejs >8
  • Docker
  • NPM

Installation

  • Clone the repository
  • Run make build-dev for developement
  • Run make build-prod for production

Test

  • Run make test -> This will run the linting, tests and gets the code coverage for all the services

Base URL

http://localhost

Running Services


AuthenticationService


JSONPatchService


ImageThumbnailService


About

Node Backend


Languages

Language:JavaScript 94.4%Language:Makefile 3.9%Language:Dockerfile 1.7%