setup a basket to send back, convert to https

This commit is contained in:
Paul Trowbridge 2019-03-18 17:27:01 -04:00
parent 50c5054e12
commit ecaef0ae4b
3 changed files with 37 additions and 11 deletions

1
.gitignore vendored
View File

@ -5,3 +5,4 @@ npm-debug.log
/.vscode /.vscode
logs.html logs.html
stat.html stat.html
*.pem

View File

@ -1,5 +1,6 @@
require('dotenv').config(); require('dotenv').config();
const express = require('express'); const express = require('express');
var https = require('https');
var bodyParser = require('body-parser'); var bodyParser = require('body-parser');
const server = express(); const server = express();
const pg = require('pg'); const pg = require('pg');
@ -9,6 +10,15 @@ var fs = require('fs');
var readline = require('readline'); var readline = require('readline');
//------------------------------------------------------- //-------------------------------------------------------
var options = {
key: fs.readFileSync('./key.pem'),
cert: fs.readFileSync('./cert.pem'),
passprase: []
};
https.createServer(options,server).listen(3000, () => console.log('started'));
//server.listen(3000, () => console.log('started'))
var Postgres = new pg.Client({ var Postgres = new pg.Client({
user: process.env.user, user: process.env.user,
password: process.env.password, password: process.env.password,
@ -353,4 +363,3 @@ function build_where(req, c, w, d, args) {
return { c, w, d }; return { c, w, d };
} }
server.listen(3000, () => console.log('started'))

View File

@ -23,10 +23,10 @@ mseq AS (
--select * from mseq --select * from mseq
,base AS ( ,base AS (
SELECT SELECT
--order_season order_season
--,order_month ,order_month
--,version ,version
--,iter ,iter
,part_descr ,part_descr
,bill_cust_descr ,bill_cust_descr
,ship_cust_descr ,ship_cust_descr
@ -37,14 +37,30 @@ FROM
WHERE WHERE
where_clause where_clause
GROUP BY GROUP BY
--order_season order_season
--,order_month ,order_month
--,version ,version
--,iter ,iter
,part_descr ,part_descr
,bill_cust_descr ,bill_cust_descr
,ship_cust_descr ,ship_cust_descr
) )
, basket AS (
SELECT
part_descr
,bill_cust_descr
,ship_cust_descr
,SUM(units) units
,SUM(value_usd) value_usd
FROM
base
GROUP BY
part_descr
,bill_cust_descr
,ship_cust_descr
ORDER BY
value_usd desc
)
,months AS ( ,months AS (
SELECT SELECT
order_season order_season
@ -123,8 +139,8 @@ SELECT
,(SELECT jsonb_agg(row_to_json(months)::jsonb) FROM months) ,(SELECT jsonb_agg(row_to_json(months)::jsonb) FROM months)
,'mpvt' ,'mpvt'
,(SELECT jsonb_agg(row_to_json(mlist)::jsonb) FROM mlist) ,(SELECT jsonb_agg(row_to_json(mlist)::jsonb) FROM mlist)
,'base' ,'basket'
,(SELECT jsonb_agg(row_to_json(base)::jsonb) FROM base) ,(SELECT jsonb_agg(row_to_json(basket)::jsonb) FROM basket)
,'totals' ,'totals'
,(SELECT jsonb_agg(row_to_json(totals)::jsonb) FROM totals) ,(SELECT jsonb_agg(row_to_json(totals)::jsonb) FROM totals)
) package ) package