From c85994b606a949585855ea029aab583dfc21d1fb Mon Sep 17 00:00:00 2001 From: Trowbridge Date: Fri, 22 Mar 2019 04:49:35 -0400 Subject: [PATCH] correct log stmt and add route --- index.js | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 5d09a36..1e8799a 100644 --- a/index.js +++ b/index.js @@ -348,7 +348,49 @@ server.post('/new_part', bodyParser.json(), function (req, res) { res.send("no body was sent"); return; } - console.log("--------------------scale volume & price:-------------------"); + console.log("--------------------new part:-------------------"); + console.log(req.body); + //console.log(args); + sql = sql.replace(new RegExp("where_clause",'g'),w); + sql = sql.replace(new RegExp("target_vol",'g'),req.body.qty); + sql = sql.replace(new RegExp("target_prc",'g'),req.body.amount); + sql = sql.replace(new RegExp("replace_request",'g'),JSON.stringify(req.body)); + sql = sql.replace(new RegExp("replace_version",'g'),req.body.scenario.version); + sql = sql.replace(new RegExp("replace_source",'g'),req.body.source); + sql = sql.replace(new RegExp("replace_iterdef",'g'),JSON.stringify(req.body)); + console.log(sql); + Postgres.FirstRow(sql,[],res) + } + + fs.readFile(path, 'utf8', function(err, data){ + if (!err){ + callback(data); + } else { + console.log("fatal error pulling sql file") + callback(err); + } + }); +}) + +server.post('/new_basket', bodyParser.json(), function (req, res) { + + var sql = ""; + var w = ""; + var c = 1; + var d = 1; + var args = []; + var path = './route_sql/new_basket.sql'; + + var callback = function(arg){ + sql = arg; + + ({ c, w, d } = build_where(req, c, w, d, args)); + + if (c == 1) { + res.send("no body was sent"); + return; + } + console.log("--------------------new basket:-------------------"); console.log(req.body); //console.log(args); sql = sql.replace(new RegExp("where_clause",'g'),w);