Merge branch 'dev' of ssh://git.verdnatura.es:/var/lib/git/salix into dev

This commit is contained in:
Dani Herrero 2017-06-01 09:32:01 +02:00
commit 0cc64bf285
15 changed files with 14 additions and 111 deletions

View File

@ -1,9 +0,0 @@
{
"name": "MailServer",
"version": "1.0.0",
"port": 3003,
"debug": true,
"defaultLanguage": "es",
"senderMail": "noreply@localhost",
"senderName": ""
}

View File

@ -1,7 +0,0 @@
{
"host": "test-db.verdnatura.es",
"port": 3307,
"user": "",
"password": "",
"database": "vn2008"
}

View File

@ -1,9 +0,0 @@
{
"host": "smtp.verdnatura.es",
"port": 465,
"secure": true,
"auth": {
"user": "",
"pass": ""
}
}

View File

@ -1,7 +0,0 @@
{
"host": "localhost",
"port": 3306,
"user": "reports",
"password": "",
"database": ""
}

View File

@ -1,9 +0,0 @@
{
"host": "localhost",
"port": 465,
"secure": true,
"auth": {
"user": "noreply",
"pass": ""
}
}

View File

@ -1,8 +1,4 @@
module.exports = {
<<<<<<< HEAD
=======
>>>>>>> 0c82c83ca33798a69686c98e44de2753bc50c021
/**
* Obtiene las variables de entorno
* @param {String} env - Nombre de la variable de entorno

View File

@ -1,19 +0,0 @@
<<<<<<< HEAD
var Settings = require('../Settings.js');
module.exports = {
/**
* Imprimir cabecera
*/
printHeader: function() {
console.log('##########################################################');
console.log('## ' + Settings.name + ' ##');
console.log('##########################################################');
}
=======
module.exports = {
>>>>>>> 0c82c83ca33798a69686c98e44de2753bc50c021
};

View File

@ -1,6 +1,5 @@
var mysql = require('mysql');
var settings = require('./settings.js');
var logger = require('./logger.js');
module.exports = {
/**
@ -16,9 +15,9 @@ module.exports = {
this.pool.getConnection(function(error, connection) {
if (error) {
logger.print(__LOG_ERROR, 'No se ha podido establecer la conexión con la base de datos. ' + error.code);
console.log('No se ha podido establecer la conexión con la base de datos. ' + error.code);
} else {
logger.print(__LOG_INFO, 'Conexión con la base de datos establecida');
console.log('Conexión con la base de datos establecida');
}
});
}

View File

@ -10,8 +10,8 @@ module.exports = {
* @return {Object} Devuelve el objeto con las claves de idioma
*/
load: function(templateName, langCode) {
var localeFile = path.join(__dirname, 'Language', `${langCode}.${templateName}.json`);
var defaultLocaleFile = path.join(__dirname, 'Language', `${settings.defaultLanguage}.${templateName}.json`);
var localeFile = path.join(__dirname, 'language', `${langCode}.${templateName}.json`);
var defaultLocaleFile = path.join(__dirname, 'language', `${settings.defaultLanguage}.${templateName}.json`);
if (fs.existsSync(localeFile)) {
return require(localeFile);

View File

@ -1,28 +0,0 @@
/**
* Tipos de advertencias
*/
global.__LOG_INFO = 1;
global.__LOG_WARNING = 2;
global.__LOG_ERROR = 3;
module.exports = {
/**
* Imprimir advertencia directamente en consola
* @param {Integer} type Constante tipo de advertencia
* @param {String} message Mensaje a mostrar
*/
print: function(type, message) {
switch (type) {
case __LOG_INFO:
console.log(`[INFO] -> ${message}`);
break;
case __LOG_WARNING:
console.log(`[WARN] -> ${message}`);
break;
case __LOG_ERROR:
console.log(`[ERROR] -> ${message}`);
break;
}
}
};

View File

@ -1,6 +1,5 @@
var nodemailer = require('nodemailer');
var settings = require('./settings.js');
var logger = require('./logger.js');
var path = require('path');
/**
@ -18,9 +17,9 @@ module.exports = {
this.transporter.verify(function(error, success) {
if (error) {
logger.print(__LOG_ERROR, error);
console.log(error);
} else {
logger.print(__LOG_INFO, 'Conexión SMTP establecida');
console.log('Conexión SMTP establecida');
}
});
},
@ -51,9 +50,9 @@ module.exports = {
this.transporter.sendMail(mailOptions, (error, info) => {
if (error) {
logger.print(__LOG_ERROR, error);
console.log(error);
} else if (settings.app().debug) {
logger.print(__LOG_INFO, 'Se ha enviado el email ' + info.messageId + ' [' + info.response + ']');
console.log('Se ha enviado el email ' + info.messageId + ' [' + info.response + ']');
return true;
}

View File

@ -8,9 +8,9 @@ router.get('/', function(request, response) {
});
// Rutas de los escritos.
router.use('/manuscript', require('./Route/manuscript.js'));
router.use('/manuscript', require('./route/manuscript.js'));
// Rutas de las notificaciones.
router.use('/notification', require('./Route/notification.js'));
router.use('/notification', require('./route/notification.js'));
module.exports = router;

View File

@ -1,4 +1,3 @@
var path = require('path');
/**
@ -17,7 +16,7 @@ module.exports = {
if (!env)
env = 'development';
return require(path.join(__dirname, 'Config', `${name}.${env}.json`));
return require(path.join(__dirname, 'config', `${name}.${env}.json`));
},
/**

View File

@ -20,7 +20,7 @@ var Template = {
var langParams = language.load(templateName, langCode);
params = Object.assign({}, langParams, params);
var templatePath = path.join(__dirname, 'Template', `${rs[0].name}.html`);
var templatePath = path.join(__dirname, 'template', `${rs[0].name}.html`);
if (!fs.existsSync(templatePath))
throw new Error('No se ha podido cargar la plantilla ' + templateName + '.html');

View File

@ -4,10 +4,8 @@
var express = require('express');
var app = module.exports = express();
var bodyParser = require('body-parser');
var settings = require('./Application/settings.js');
var mail = require('./Application/mail.js');
var logger = require('./Application/logger.js');
var database = require('./Application/database.js');
// Middleware
@ -22,9 +20,9 @@ app.start = function() {
return app.listen(settings.app().port, function() {
mail.init();
database.init();
logger.print(__LOG_INFO, 'Servidor de correo iniciado en el puerto ' + settings.app().port);
console.log('Servidor de correo iniciado en el puerto ' + settings.app().port);
if (settings.app().debug) {
logger.print(__LOG_WARNING, 'El modo debug está activado');
console.log('El modo debug está activado');
}
});
};