priceGetter/handler.js
// helper function to save price trend in db
helper function to save price trend in db
helper function to save price trend in db
function process(d, callback) {
  var evald = JSON.parse(d);
  if (typeof evald.last == "undefined") {
    console.log("no last price in object, so not saving");
    callback(null, {
      "result": "nothing saved"
    });
    return;
  }
  savePrice(evald).then(function() {
    const response = {
      statusCode: 200,
      body: JSON.stringify({
        message: 'saved data: ' + d
      })
    };
    callback(null, response);
  });
}
function process ( d , callback ) { var evald = JSON . parse ( d ) ; if ( typeof evald . last == "undefined" ) { console . log ( "no last price in object, so not saving" ) ; callback ( null , { "result" : "nothing saved" } ) ; return ; } savePrice ( evald ) . then ( function ( ) { const response = { statusCode : 200 , body : JSON . stringify ( { message : 'saved data: ' + d } ) } ; callback ( null , response ) ; } ) ; }
helper function to save price trend in db
helper function to save price trend in db
// when the response is malformed (exchange-side error, etc) // terminate the function immediately