2020-11-27 01:05:10 -05:00
|
|
|
require('dotenv').config();
|
|
|
|
const express = require('express');
|
|
|
|
var https = require('https');
|
|
|
|
var bodyParser = require('body-parser');
|
|
|
|
const server = express();
|
|
|
|
var fs = require('fs');
|
|
|
|
var readline = require('readline');
|
2020-11-27 02:34:47 -05:00
|
|
|
const pg = require('pg');
|
2020-11-27 01:05:10 -05:00
|
|
|
|
2020-11-27 02:34:47 -05:00
|
|
|
var options = {
|
|
|
|
key: fs.readFileSync(process.env.wd + 'key.pem'),
|
|
|
|
cert: fs.readFileSync(process.env.wd + 'cert.pem'),
|
|
|
|
passprase: []
|
|
|
|
};
|
2020-11-27 01:02:31 -05:00
|
|
|
|
|
|
|
const client = new pg.Client({
|
2020-11-27 02:34:47 -05:00
|
|
|
user: process.env.user,
|
|
|
|
password: process.env.password,
|
|
|
|
host: process.env.host,
|
|
|
|
port: process.env.port,
|
|
|
|
database: process.env.database,
|
|
|
|
ssl: false,
|
|
|
|
application_name: "osm_api"
|
2020-11-27 00:40:08 -05:00
|
|
|
})
|
|
|
|
client.connect()
|
2020-11-27 02:34:47 -05:00
|
|
|
/*
|
2020-11-27 01:05:10 -05:00
|
|
|
client.query('SELECT 1', (err, res) => {
|
2020-11-27 00:40:08 -05:00
|
|
|
console.log(err, res)
|
|
|
|
client.end()
|
2020-11-27 02:34:47 -05:00
|
|
|
})
|
|
|
|
*/
|
|
|
|
server.get('/pgtest', bodyParser.json(), function(req, res) {
|
|
|
|
client.query('SELECT 1', (err, rslt) => {
|
|
|
|
console.log(err, rslt)
|
|
|
|
res.send(rslt.rows[0]);
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
https.createServer(options, server).listen(process.env.nodeport, () => {
|
|
|
|
console.log('started on ' + process.env.nodeport)
|
|
|
|
});
|