nw-classic-integration

Classic DB Integration

Usage no npm install needed!

<script type="module">
  import nwClassicIntegration from 'https://cdn.skypack.dev/nw-classic-integration';
</script>

README

nw-classic-integration

Classic Integration Microservice is series of API endpoints used by Classic to push Events to New Wave.

List of events can be found here: https://confluence.nw.adesa.com/display/NW/Business+Events+Payload

Logic Flow

  1. Classic calls API and passes information
  2. This service searches for mapping for classic ids against Redis/DynamoDB(eventually Postgres)
  3. If found - get it. If not - generate uuid and put to mappings table (DynamoDB - eventually Postgres)
  4. Map Classic values to New Wave Event
  5. In Event we put our ids (uuids) and don't put classicids
  6. Serialize Event using ProtoBufs
  7. Put Event on Kinesis stream

TODO

  1. Error Handling

RUN LOCALLY

Prepare

Run the following once per dev environment

  • Install localstack
    • Make sure you have .nprmrc in your home folder (mac) with the following line @nw:registry=http://nexus.nw.adesa.com/repository/npm-group/
    • Run the command npm i -g @nw/localstack to install localstack globally
  • Run the command localstack kinesis topic create -n nw-auction-local to create kinesis topic. Repeat for every topic you need
  • View "dev:test:bdd" in package.json for localstack commands

Execute

Run the following command for every new terminal you open

  • export KINESIS_ENDPOINT=http://localhost:4567
    sets the kinesis endpoint to be local (port fits localstack)
  • export AWS_REGION=us-east-1
    provides default region for kinesis client (for aws sdk)
  • export AUCTION_STREAM_NAME='nw-auction-local'
    provides default stream name for auctions
  • export WATCHLIST_STREAM_NAME='nw-watchlist-local'
    provides default stream name for auctions
  • npm run localstack:all:up
    runs all localstack components
  • localstack kinesis topic create -n nw-auction-local
    creates required topic on kinesis
  • npm run dev:test:bdd
    to actually execute the tests

DEPLOY TO AWS


   {
       "eventType": "vehicle_added_watchlist",
       "body": {
           "origin_vehicle_id" : "220308777",
           "vin": "12345678901234567",
           "model": "Accord",
           "make": "Honda",
           "year": 2016,
           "origin_login_id": "209019",
           "first_name": "Kitty",
           "last_name": "Luo",
           "login_name": "kluo_atco",
           "origin_private_label_id": "1",
           "private_label_name": "ADESA Auction",
           "site_name": "www.adesa.com",
           "origin_consignor_organization_id": "434660",
           "consignor_organization_name": "Bob's AutoHaus",
           "origin_timestamp": 1495227243992,
           "origin_created_by": "209019",
           "origin_modified_by": "209019"
       }
   }
  • Sample CURL Request:

  • HTTP Codes:

    • 200 - Success. Event was posted to kinesis
    • 500 - Server Error. Server wasn't able to process event (check error message)
    • 501 - Event is not implemented
    • 504 - Gateway Timeout. Server times out due to lambda cold start time, network connectivity, etc.