diff --git a/script.js b/script.js index efb6d07..552b23d 100644 --- a/script.js +++ b/script.js @@ -5,18 +5,38 @@ var bodyParser = require('body-parser'); const server = express(); var fs = require('fs'); 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({ - user: 'api', - host: '192.168.1.110', - database: 'ubm', - password: 'qqqx53!028', - port: 5433, + 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" }) client.connect() +/* client.query('SELECT 1', (err, res) => { console.log(err, res) client.end() -}) \ No newline at end of file +}) +*/ +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) +}); \ No newline at end of file