Giter Club home page Giter Club logo

loco's Introduction

Requirements

  • Node 8 ++
  • Git

Setup

Clone the repo and install the dependencies.

git clone https://github.com/yogeshwar607/remotepanda.git
cd remotepanda
npm install

Open envConfig.json and inject your credentials , as of now i have added my credential for testing purpose.

To start the express server, run the following

npm start 

Test cases are written for api testing at /test/apiTest.js using supertest and mocha Install supertest

npm install supertest --save-dev

To test api, run the following

npm test 

test cases

For testing and verification

Postman Collection - https://www.getpostman.com/collections/b840a6f8f5337ede1bbf

Approach for apis

Note:

All the apis are validated using Joi schema (npm package).

Boom (npm package) is used for error handling.

For in-memory implementation , transaction array is defined in at /models/index.js below format

transaction array = [{"type":"debit","amount":121,"parent_id":46564}];
  1. /web/api/transaction/create

    After basic sanitization check below function is called transactionList.addTxn(txnObj) defined at /models/index

    This function will check whether transaction exits with same transaction id , if yes then throws error otherwise adds record to transaction list array

  2. /web/api/transaction/get

    Based on request url , this is handling get requests After checking url , 3 request types are defined in logic based on url inputs

     * transaction
     * types
     * sum
    

    transaction request type - transactionList().getTxnById(transactionId) is called which is defined at /models/index

    It will find transaction detail based on transaction_id as input response is returned if valid transaction is found.

    types request type - transactionList().getTxnByType(type) is called which is defined at /models/index It will filter and return transactions id in array with have same type - debit/credit

    sum request type - transactionList().getSumByParentId(transactionId) is called which is defined at /models/index

    It will find parent_id based on transaction_id as input. After finding parent_id , it will return all the transaction linked to parent_id.

    Sum of these filtered transaction is calculated using Array.reduce() and response is returned

loco's People

Contributors

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