From a821e88fc698ec7d4a1135fdd79fe818ea813843 Mon Sep 17 00:00:00 2001 From: Thomas FORGIONE Date: Mon, 18 May 2015 10:48:37 +0200 Subject: [PATCH] Modified server to test db connection --- server.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/server.js b/server.js index 7ff5594..e2a8c22 100644 --- a/server.js +++ b/server.js @@ -1,6 +1,10 @@ var http = require('http'); var express = require('express'); var jade = require('jade'); +var pg = require('pg'); + +// pg conf +var pgc = require('./private'); var app = express(); var urls = require('./urls'); @@ -51,3 +55,12 @@ if ( app.get('env') === 'development' ) { console.log("Starting server on " + server_ip_address + ":" + server_port); app.listen(server_port, server_ip_address); + +console.log("Trying to connect to the db..."); +pg.connect(pgc.url, function(err, client, done) { + if (err) { + return console.error('error fetching client from pool', err); + } + + client.query('INSERT INTO Users(name) VALUES(\'Hello\')'); +});