var express = require('express');
var router = express.Router();
const os = require('os');

//
// Postgresql
//
var Pool = require('pg').Pool;
var config = {
  user: 'matjaz',
  password: 'mesnjak',
  database: 'supervizor',
  host: 'server.dev',
  port: 5432,
  max: 10,
  idleTimeoutMillis: 30000,
};
var pool = new Pool(config);

/* GET home page. */
router.get('/', function(req, res, next) {
  pool.query('SELECT version();', [], function(err, result) {
    if(err) {
      res.redirect('/');
    }
    else {
      res.render('streznik', { title: 'Naš denar', os: os, nodever: process.versions, process: process, psql: result.rows[0]});
    }
  })
});

module.exports = router;   

