diff --git a/services/mailer/application/config.js b/services/mailer/application/config.js index 1442e85ed..c46f236f8 100644 --- a/services/mailer/application/config.js +++ b/services/mailer/application/config.js @@ -1,15 +1,20 @@ var path = require('path'); -var fs = require('fs'); -var config = {}; +let defaultFile = 'datasources.json'; -let devConfigPath = path.join(__dirname, '/config/datasources.development.json'); -let configPath = path.join(__dirname, '/config/datasources.json'); +function getFile(fileName) { + return require(path.join(__dirname, `/config/${fileName}`)); +} try { - config = Object.assign(require(configPath), require(devConfigPath)); + let envFile = 'datasources.development.json'; + + if (process.env.NODE_ENV === 'test') + envFile = 'datasources.test.json'; + + config = getFile(envFile); } catch (e) { if (e.code == 'MODULE_NOT_FOUND') - config = require(configPath); + config = getFile(defaultFile); } config.proxy = require('../../nginx/config.json'); diff --git a/services/mailer/application/config/datasources.test.json b/services/mailer/application/config/datasources.test.json index 69943439d..d3a2d8b33 100644 --- a/services/mailer/application/config/datasources.test.json +++ b/services/mailer/application/config/datasources.test.json @@ -4,14 +4,14 @@ "debug": false, "defaultLanguage": "es", "senderMail": "noreply@localhost", - "senderName": "" + "senderName": "VerdNatura" }, "mysql": { "host": "localhost", "port": 3306, - "user": "reports", + "user": "root", "password": "", - "database": "" + "database": "vn" }, "smtp": { "host": "localhost", diff --git a/services/mailer/application/mail.js b/services/mailer/application/mail.js index 3980e5128..04af6b007 100644 --- a/services/mailer/application/mail.js +++ b/services/mailer/application/mail.js @@ -12,15 +12,17 @@ module.exports = { * Load mail config. */ init: function() { + this.transporter = nodemailer.createTransport(config.smtp); this.transporter.verify(function(error, success) { if (error) { - throw new Error(error); + console.error(error); } else if (config.app.debug) { console.log('SMTP connection stablished'); } }); + }, /** diff --git a/services/print/application/config.js b/services/print/application/config.js index 1442e85ed..c46f236f8 100644 --- a/services/print/application/config.js +++ b/services/print/application/config.js @@ -1,15 +1,20 @@ var path = require('path'); -var fs = require('fs'); -var config = {}; +let defaultFile = 'datasources.json'; -let devConfigPath = path.join(__dirname, '/config/datasources.development.json'); -let configPath = path.join(__dirname, '/config/datasources.json'); +function getFile(fileName) { + return require(path.join(__dirname, `/config/${fileName}`)); +} try { - config = Object.assign(require(configPath), require(devConfigPath)); + let envFile = 'datasources.development.json'; + + if (process.env.NODE_ENV === 'test') + envFile = 'datasources.test.json'; + + config = getFile(envFile); } catch (e) { if (e.code == 'MODULE_NOT_FOUND') - config = require(configPath); + config = getFile(defaultFile); } config.proxy = require('../../nginx/config.json'); diff --git a/services/print/application/config/datasources.test.json b/services/print/application/config/datasources.test.json index 92965aa5a..d51ae1fa2 100644 --- a/services/print/application/config/datasources.test.json +++ b/services/print/application/config/datasources.test.json @@ -7,9 +7,9 @@ "mysql": { "host": "localhost", "port": 3306, - "user": "reports", + "user": "root", "password": "", - "database": "" + "database": "vn" }, "pdf": { "footer": {