Node.js Specific Instructions

Setting up your Development Environment

npm i
npm start

You'll require node (tested on v15.6.0) and npm (v7.6.3). We recommend nvm for node version management, and setup takes just a few minutes.

We also recommend a desktop client for making local test requests. Postman is optional, and we have a Postman collection with an example POST. At the top you can change the language from curl (which you can run in your terminal) to javascript.

You will NOT need to be familiar with OpenAPI or Swagger. Implementing an API contract for endpoint definition is not in the scope of the JS problem.

The code base uses Express to handle a very lightweight frontend at http://localhost:3000/. Updating the frontend is also not in the scope of the problem.

Tests can be run on port 5678 with npm test. If you have a daemon process running on that port (Error: listen EADDRINUSE: address already in use :::5678) you may be able to force kill by

lsof -i tcp:5678  
kill -9 $PID

As a headsup, Jest sets NODE_ENV=test, and sequelize logging is suppressed in this case.

API

Recommended: pre-defined Postman configuration

You will be working on creating a new endpoint, POST /api/merchant_config/.

An example loan application endpoint has been set up: POST /api/loan_application/.

POST /api/loan_application

The only Merchant seeded has merchant_id = 1. You will need the merchant_id to hit the "Init Loan Application" endpoint:

Headers {
    Content-Type: application/json
}

Body {
    "data": {
        "requested_amount_cents": 10000,
        "currency": "USD",
        "merchant_id": 1
    }
}

Using CURL:

curl --location --request POST 'http://localhost:3000/api/loan_application' \
--header 'Content-Type: application/json' \
--data-raw '{
    "data": {
        "requested_amount_cents": 10000,
        "currency": "USD",
        "merchant_id": 1
    }
}
'