GithubHelp home page GithubHelp logo

hackerbay-backend's Introduction

HackerBay Backend

A Microservice with 2 main functions of patching JSON and generating thumbnail.

Prerequisites

This project requires nodejs installed on your local machine.

Getting started

The following instructions would get this project up and running on you local machine for development and testing purpose

Cloning

  mkdir project-directory
  cd project-directory
  git clone https://github.com/kennyose/hackerbay-backend

Installing

  cd project-directory
  # run the command
  npm install

Directory Tree

project-directory
├── node_modules
├── public
│ └── css
│ │ └── style.css
│ └── js
│ └── custom.js
├── src
│ └── app.js
│ └── controllers.js
│ └── index.js
│ └── middleware.js
│ └── routes.js
| └── utils.js
├── test
│ └── index.test.js
├── views
│ └── error.ejs
│ └── errorPage.ejs
│ └── index.ejs
│ └── login.ejs
├── .dockerignore
├── .editorconfig
├── .env
├── .gitignore
├── access.log
├── Dockerfile
├── LICENSE.md
├── .package-lock.json
├── .package.json
├── README.md

Env

  • Create a .env file
  • write your secret JWT_SECRET=yoursecret

Starting server

 npm start

Open http://localhost:8080 to view it in the browser.

Test

  • Don't forget to hardcode a resently signed jwt token for use in index.test.js Ln 9 Col 1 while testing.
  npm test

Test Coverage

  npm run cover

Coding Style

This Project uses EsLint for coding guide

Built with

This Project is built with:

  • NodeJS - Javascript runtime engine
  • ExpressJS - Web Server Framework
  • Chai and chaiHttp - Unit test

API route

  • POST http://localhost:8080/login:
    • Request - username and password in body of request.
    • Response - a JSON containing signed JWT under token.
  • POST http://localhost:8080/patch:
    • Request - json[should be an object] and patch[should be an array of object(s) containing op, path & value] both strigified in body of request.
    • Response - a JSON containing result of patch operation under patchedObj
  • POST http://localhost:8080/thumbnail:
    • Request - url[containing a URI of public image] in query of request.
    • Response - a binary data in chunks.

Docker

  • Make sure you have Docker installed Locally
  • DockerHub - Pull this project docker image by running this command docker pull kennyose/hackerbay-node
  • Check container's image id by running $ sudo docker ps -l
  • Start project in docker container by running $ sudo docker run -p 8080:8080 -it ${IMAGE} - replace ${IMAGE} with container's image id.

Caveats

  • Test - JWT is unable to sign when testing,
    • Fix - expose process.env.JWT_SECRET in controller.js Ln 27 Col 31 and in middleware.js Ln 9 Col 25

hackerbay-backend's People

Contributors

kennyose 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.