Coder Social home page Coder Social logo

nodejsonmicroservice's Introduction

NodeJSONMicroservice

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

  • Authentication
  • JSON patching
  • Image Thumbnail Generation

Public Endpoints

Login
Request body contains an arbitrary username/password pair. (accept any username/password) A signed Json Web Token (https://jwt.io/) will be returned which can be used to validate future requests.

Private Endpoints

Apply Json Patch
Request body contains a JSON object and a JSON patch object (http://jsonpatch.com/). service applies the json patch to the json object, and returns the resulting json object. The service is first authorized with a JWT.

Create Thumbnail
Request contains a public image URL. Service downloads the image, resize to 50x50 pixels, and store the resulting thumbnail in thumbnails folder. The service is first authorized with a JWT.

Setting up

  • use npm install for installing dependencies
  • use npm start for starting server
  • use npx nodemon for starting server with nodemon
  • use npm run test for running all tests
  • use npm run coverage for running all tests and returning coverage as report

Usage

  • Login
    • Request Body -> { "username":"YOUR_USERNAME", "password":"YOUR_PASSWORD" }
    • Returned -> { "token":"YOUR_TOKEN" }
  • JSON Patch
    • Cookie -> Authorization : "Token"
    • Request Body -> { "jsonObject": {JSON_OBJECT} , "jsonPatch": [{JSON_PATCH}] }
    • Returned -> { "Patched":"JSON_OBJECT_WITH_PATCH" }
  • Thumbnail Creation
    • Cookie -> Authorization : "Token"
    • Request Body -> { "url":"IMAGE_URL" }
    • Returned -> { "message":"RESPECTIVE_MESSAGE" }
    • Thumbnail stored in /public/images/thumbnail

Testing

Testing is done with Mocha and Chai. And Istanbul (https://github.com/gotwarlost/istanbul) is used to generate code test coverage reports.

nodejsonmicroservice's People

Contributors

hans-06 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.