Giter Site home page Giter Site logo

igbaryya / sdk-datapower Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 21 KB

SDK Data validation Layer between FE to BE

JavaScript 100.00%
datatypes datatype-validation datapower swagger-validator swagger-validating rest-api rest-api-validation json-swagger-validator

sdk-datapower's Introduction

SDK Data types validator

SDK-Datapower is Layer that will sit between FE host to BE host and validate REST request payloads & query params based on Swaggers JSONs. It is very importnant for your server security to validate requests types before it reachs BE, for example if you have POST REST that defined in swagger with object A: { properties: b: type: number }

and FE request from that REST with POST payload as below: A: { b: "123A" }

This request suppose to fail since it is not match swagger type for this REST. Instead of failing on BE and causing different issues.

Overview:

overview

Env Installation

Require:

SDK-DataPower can be ran in your Local Machine or in UNIX envs.

Desktop:

npm install
node .\src\server.js --endpoint ENTER_HOST --branch REPOSITORY_BRANCH
  • "endpoint" is the Server host (BE) server.com is example; Once the validation pass, the call will be passed to BE.
  • "branch" is your workspace branch number

Linux: Download and Install nodeJS in your linux machine: https://nodejs.org/dist/v7.5.0/node-v7.5.0-linux-x64.tar.xz

$ mkdir sdk-datapower
$ cd sdk-datapower
#Download the project inside sdk-datapower
$ nohup node ./src/server.js --endpoint $HOSTNAME > logger.log /dev/null 2>&1 &

Server will Run in with port "40004" - it is configurable port.

Configuration:

You can config your workspace branch and Nexus in package.json file:

# branch: Your workspace branch (If no arg sent for server.js file - See above)
# nexus: Your nexus URL. (or GitHub)

You can see server runtime configuration under: src\configs.js

# whitelistApis: Bypassed URLs
# passAPIOnFailure: Pass the REST even if there was failure (Failures will be logged)
# continueWithInvalidJson: Once JSON is not valid, Fail the REST call. 
# endpoint.port is the port for for the target Env (endpoint env)

You can change the REST base path under: src\validator\http_constants.js

# Example in USCC, all of the RESTs are starting with "my-rests":
# http://<host>:><port>/my-rests/v1/example-rest

You can set the zipped JSONs packages names from nexus under: src\startup\nexus\constants.js

# Example for my package: rest-api-name: 
files: [
        {
            name: 'rest-api-name',
            src: 'rest-api-name-${SNAPSHOT_VERSION}-json.zip',   
            trg: 'rest-api-name.zip'
        }
    ],

sdk-datapower's People

Contributors

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