Commit a77cdbacc4446265fcd24a9510265e6899e69939

Authored by José Maria Villac Pinheiro
1 parent 7f6f9c69

V. 0.5.2 - Adicionadas mensagens para avisar se ocorreram as conexões com o banco de dados.

Showing 2 changed files with 13 additions and 0 deletions   Show diff stats
routes/mapRoutes.js
  1 +// Here are all mapping routes
  2 +//
1 3 const keys = require("../config/keys");
2 4  
3 5 module.exports = router => {
... ...
services/databases.js
  1 +// Create global connections with SQLServer (comercial) and Postgres (mapping)
  2 +//
1 3 var ms_sql = require("mssql");
2 4 var pg = require("pg");
3 5 const keys = require("../config/keys");
... ... @@ -7,8 +9,17 @@ pg.defaults.poolSize = 25;
7 9  
8 10 // Creates global pool connection with Postgres and MS SqlServer
9 11 global.poolPg = new pg.Pool(keys.pg);
  12 +global.poolPg.connect(function(err, client, done){
  13 + if(err){
  14 + console.error("Error connectin to Postgres Server"+ err.stack);
  15 + } else {
  16 + console.log("Connection estabilished with Postgres Server");
  17 + }
  18 +})
10 19 global.poolMsql = new ms_sql.ConnectionPool(keys.msql, function(err) {
11 20 if (err) {
12 21 console.log("Não conectou com SQLServer:\n" + err);
  22 + } else{
  23 + console.log("Connection estabilished with SQLServer");
13 24 }
14 25 });
15 26 \ No newline at end of file
... ...