include test route, env reference, and self signed certs
This commit is contained in:
parent
8f7f387729
commit
25ad266aef
34
script.js
34
script.js
@ -5,18 +5,38 @@ var bodyParser = require('body-parser');
|
|||||||
const server = express();
|
const server = express();
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
var readline = require('readline');
|
var readline = require('readline');
|
||||||
|
const pg = require('pg');
|
||||||
|
|
||||||
const pg = require('pg')
|
var options = {
|
||||||
|
key: fs.readFileSync(process.env.wd + 'key.pem'),
|
||||||
|
cert: fs.readFileSync(process.env.wd + 'cert.pem'),
|
||||||
|
passprase: []
|
||||||
|
};
|
||||||
|
|
||||||
const client = new pg.Client({
|
const client = new pg.Client({
|
||||||
user: 'api',
|
user: process.env.user,
|
||||||
host: '192.168.1.110',
|
password: process.env.password,
|
||||||
database: 'ubm',
|
host: process.env.host,
|
||||||
password: 'qqqx53!028',
|
port: process.env.port,
|
||||||
port: 5433,
|
database: process.env.database,
|
||||||
|
ssl: false,
|
||||||
|
application_name: "osm_api"
|
||||||
})
|
})
|
||||||
client.connect()
|
client.connect()
|
||||||
|
/*
|
||||||
client.query('SELECT 1', (err, res) => {
|
client.query('SELECT 1', (err, res) => {
|
||||||
console.log(err, res)
|
console.log(err, res)
|
||||||
client.end()
|
client.end()
|
||||||
})
|
})
|
||||||
|
*/
|
||||||
|
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)
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user