setup a basket to send back, convert to https
This commit is contained in:
		
							parent
							
								
									50c5054e12
								
							
						
					
					
						commit
						ecaef0ae4b
					
				
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@ -5,3 +5,4 @@ npm-debug.log
 | 
			
		||||
/.vscode
 | 
			
		||||
logs.html
 | 
			
		||||
stat.html
 | 
			
		||||
*.pem
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										11
									
								
								index.js
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								index.js
									
									
									
									
									
								
							@ -1,5 +1,6 @@
 | 
			
		||||
require('dotenv').config();
 | 
			
		||||
const express = require('express');
 | 
			
		||||
var https = require('https');
 | 
			
		||||
var bodyParser = require('body-parser');
 | 
			
		||||
const server = express();
 | 
			
		||||
const pg = require('pg');
 | 
			
		||||
@ -9,6 +10,15 @@ var fs = require('fs');
 | 
			
		||||
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({
 | 
			
		||||
    user: process.env.user,
 | 
			
		||||
    password: process.env.password,
 | 
			
		||||
@ -353,4 +363,3 @@ function build_where(req, c, w, d, args) {
 | 
			
		||||
    return { c, w, d };
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
server.listen(3000, () => console.log('started'))
 | 
			
		||||
 | 
			
		||||
@ -23,10 +23,10 @@ mseq AS (
 | 
			
		||||
--select * from mseq
 | 
			
		||||
,base AS (
 | 
			
		||||
SELECT
 | 
			
		||||
    --order_season
 | 
			
		||||
    --,order_month
 | 
			
		||||
    --,version
 | 
			
		||||
    --,iter
 | 
			
		||||
    order_season
 | 
			
		||||
    ,order_month
 | 
			
		||||
    ,version
 | 
			
		||||
    ,iter
 | 
			
		||||
    ,part_descr
 | 
			
		||||
    ,bill_cust_descr
 | 
			
		||||
    ,ship_cust_descr
 | 
			
		||||
@ -37,14 +37,30 @@ FROM
 | 
			
		||||
WHERE
 | 
			
		||||
    where_clause
 | 
			
		||||
GROUP BY
 | 
			
		||||
    --order_season
 | 
			
		||||
    --,order_month
 | 
			
		||||
    --,version
 | 
			
		||||
    --,iter
 | 
			
		||||
    order_season
 | 
			
		||||
    ,order_month
 | 
			
		||||
    ,version
 | 
			
		||||
    ,iter
 | 
			
		||||
    ,part_descr
 | 
			
		||||
    ,bill_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 (
 | 
			
		||||
    SELECT
 | 
			
		||||
        order_season
 | 
			
		||||
@ -123,8 +139,8 @@ SELECT
 | 
			
		||||
        ,(SELECT jsonb_agg(row_to_json(months)::jsonb) FROM months)
 | 
			
		||||
        ,'mpvt'
 | 
			
		||||
        ,(SELECT jsonb_agg(row_to_json(mlist)::jsonb) FROM mlist)
 | 
			
		||||
        ,'base'
 | 
			
		||||
        ,(SELECT jsonb_agg(row_to_json(base)::jsonb) FROM base)
 | 
			
		||||
        ,'basket'
 | 
			
		||||
        ,(SELECT jsonb_agg(row_to_json(basket)::jsonb) FROM basket)
 | 
			
		||||
        ,'totals'
 | 
			
		||||
        ,(SELECT jsonb_agg(row_to_json(totals)::jsonb) FROM totals)
 | 
			
		||||
    ) package
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user