Giter Club home page Giter Club logo

services-app's Introduction

services-app

services-app is a simple stateless microservice app in Nodejs, with three major functionalities -

  • Authentication
  • JSON patching
  • Image Thumbnail Generation

To know more, check out docs and Code Coverage report

Installation

Using npm

Clone the repository, install npm dependencies, build and run

$ git clone https://github.com/shikhardhing/services-app
$ npm install
$ npm run build
$ npm start
Using docker

Clone the repository, build docker image and run

$ git clone https://github.com/shikhardhing/services-app
$ cd services-app
$ docker build -t <username>/services-app
$ docker run -p 3000:3000 -d <username>/services-app

Usage

  • POST /login:

    Provide an arbitrary username/password pair to obtain a JWT token

    $ curl -XPOST -H "Content-Type: application/json" localhost:3000/login -d '{"username": "user", "password": "password"}'
  • POST /api/thumbnail:

    Provide a public image URL in query, with a valid JWT token obtained from /login to get 50*50 pixel thumbnail as response

    curl -XPOST -H "Authorization: JWT <token>" http://localhost:3000/api/thumbnail\?url\=https://cdn.pixabay.com/photo/2017/09/03/17/26/woman-2711279_960_720.jpg
  • POST /api/patch:

    Provide a JSON document and patch object, with a valid JWT token obtained from /login to get a patched json object

    curl -XPOST -H "Authorization: JWT <token>" -H "Content-Type: application/json" http://localhost:3000/api/patch -d '{"document": { "firstName": "Albert", "contactDetails": { "phoneNumbers": [] } },"operation": [{ "op": "replace", "path": "/firstName", "value": "Joachim" },{ "op": "add", "path": "/lastName", "value": "Wester" },{ "op": "add", "path": "/contactDetails/phoneNumbers/0", "value": { "number": "555-123" } }]}'

Testing

  • Run the tests using npm:
$ npm run test
  • For linting (using standard-js)
$ npm run lint
  • Get code coverage
$ cd dist
$ istanbul cover ./node_modules/.bin/_mocha

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.