Giter Club home page Giter Club logo

interview-backend-task's Introduction

About the program

This program is developed for a technical interview. It's a RESTFul application that provides three routes.

  1. POST /login expects a username and a password, and returns a JWT token for future requests.
  2. POST /thumbnails protected route that expects a json payload {"url":"http://link"}, and return the relative path to the resized image. Example of a response
{
  "path": "/images/ff61ab0b-74c7-4144-a173-22935256d6d7"
}
  1. POST /jsonpatch protected route that expects a json payload containing a document and a patch, and returns the result of applying the patch on the document. An example of request
{
  "doc": {
    "baz": "qux",
    "foo": "bar"
  },
  "patch": [{ "op": "replace", "path": "/baz", "value": "boo" }]
}

the answer will be

{
  "baz": "boo",
  "foo": "bar"
}

Installation

To install the application, you'll need to have node.js in your computer.

$ git clone [email protected]:abdellani/interview-backend-task.git
$ npm install

The application is also available in docker

docker pull abdellani/interview-backend-task

Configuration

You'll need to adapt the configurations file in config/

  • developement.js
{
  "PORT": "3000",
  "JWT_LIFE_TIME": "JWT Life time",
  "JWT_SECRET": "SUPER SUCRET KEY",
  "IMAGE_DIR": "ABSOLUTE PATH TO THE RESIZE IMAGES "
}

After an image is resized, it'll be store in "IMAGE_DIR".

  • test.js
{
  "PORT": "3001",
  "JWT_LIFE_TIME": "JWT Life time",
  "JWT_SECRET": "SUPER SUCRET KEY",
  "IMAGE_DIR": "should be different from the value in developement.json ",
  "IMAGE_SERVER_PORT": "8080",
  "HASH_RESIZE_IMAGE":"7a700bc715eda72d192b1c934547424e8ab69815026f24ead81a27122cf042f511df22b840c0e5438db0cb60d03e35d14d9289cd822ce0646068574438ec5fe0"
}
  • IMAGE_SERVER_PORT is the port number for the server used in the integration tests. That server will send a valid images to the application.
  • HASH_RESIZE_IMAGE after an image is resized, its hash will be compared to this value.

Run the code

npm start

Run in development mode

npm run dev

Run tests

npm run test:unit # will run  unit tests
npm run test:integration # will run  integration tests
npm run test # will run both unit and integration tests

Run linter

npm run linter

Author

Mohamed ABDELLANI

interview-backend-task's People

Contributors

abdellani avatar

Watchers

James Cloos avatar  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.