From c9968cf5503fc81373d9643946719c8e750ea12b Mon Sep 17 00:00:00 2001 From: Joan Date: Thu, 1 Jun 2017 08:51:29 +0200 Subject: [PATCH] Eliminado logger y renombradas carpetas --- services/mailer/Application/Config/app.json | 9 ------ .../Application/Config/mailerMysql.json | 7 ----- .../mailer/Application/Config/mailerSmtp.json | 9 ------ services/mailer/Application/Config/mysql.json | 7 ----- services/mailer/Application/Config/smtp.json | 9 ------ services/mailer/Application/Util/system.js | 4 --- services/mailer/Application/Util/terminal.js | 19 ------------- services/mailer/Application/database.js | 5 ++-- services/mailer/Application/language.js | 4 +-- services/mailer/Application/logger.js | 28 ------------------- services/mailer/Application/mail.js | 9 +++--- services/mailer/Application/router.js | 4 +-- services/mailer/Application/settings.js | 3 +- services/mailer/Application/template.js | 2 +- services/mailer/server.js | 6 ++-- 15 files changed, 14 insertions(+), 111 deletions(-) delete mode 100644 services/mailer/Application/Config/app.json delete mode 100644 services/mailer/Application/Config/mailerMysql.json delete mode 100644 services/mailer/Application/Config/mailerSmtp.json delete mode 100644 services/mailer/Application/Config/mysql.json delete mode 100644 services/mailer/Application/Config/smtp.json delete mode 100644 services/mailer/Application/Util/terminal.js delete mode 100644 services/mailer/Application/logger.js diff --git a/services/mailer/Application/Config/app.json b/services/mailer/Application/Config/app.json deleted file mode 100644 index f7a13d3ef..000000000 --- a/services/mailer/Application/Config/app.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "name": "MailServer", - "version": "1.0.0", - "port": 3003, - "debug": true, - "defaultLanguage": "es", - "senderMail": "noreply@localhost", - "senderName": "" -} \ No newline at end of file diff --git a/services/mailer/Application/Config/mailerMysql.json b/services/mailer/Application/Config/mailerMysql.json deleted file mode 100644 index 1fb440bfb..000000000 --- a/services/mailer/Application/Config/mailerMysql.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "host": "test-db.verdnatura.es", - "port": 3307, - "user": "", - "password": "", - "database": "vn2008" -} \ No newline at end of file diff --git a/services/mailer/Application/Config/mailerSmtp.json b/services/mailer/Application/Config/mailerSmtp.json deleted file mode 100644 index d7e9c0c47..000000000 --- a/services/mailer/Application/Config/mailerSmtp.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "host": "smtp.verdnatura.es", - "port": 465, - "secure": true, - "auth": { - "user": "", - "pass": "" - } -} \ No newline at end of file diff --git a/services/mailer/Application/Config/mysql.json b/services/mailer/Application/Config/mysql.json deleted file mode 100644 index ddfd88bed..000000000 --- a/services/mailer/Application/Config/mysql.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "host": "localhost", - "port": 3306, - "user": "reports", - "password": "", - "database": "" -} \ No newline at end of file diff --git a/services/mailer/Application/Config/smtp.json b/services/mailer/Application/Config/smtp.json deleted file mode 100644 index a6579d067..000000000 --- a/services/mailer/Application/Config/smtp.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "host": "localhost", - "port": 465, - "secure": true, - "auth": { - "user": "noreply", - "pass": "" - } -} \ No newline at end of file diff --git a/services/mailer/Application/Util/system.js b/services/mailer/Application/Util/system.js index 89503ea70..358346184 100644 --- a/services/mailer/Application/Util/system.js +++ b/services/mailer/Application/Util/system.js @@ -1,8 +1,4 @@ module.exports = { -<<<<<<< HEAD - -======= ->>>>>>> 0c82c83ca33798a69686c98e44de2753bc50c021 /** * Obtiene las variables de entorno * @param {String} env - Nombre de la variable de entorno diff --git a/services/mailer/Application/Util/terminal.js b/services/mailer/Application/Util/terminal.js deleted file mode 100644 index fe7b3bd9d..000000000 --- a/services/mailer/Application/Util/terminal.js +++ /dev/null @@ -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 -}; diff --git a/services/mailer/Application/database.js b/services/mailer/Application/database.js index 0b4144775..528cb1be6 100644 --- a/services/mailer/Application/database.js +++ b/services/mailer/Application/database.js @@ -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'); } }); } diff --git a/services/mailer/Application/language.js b/services/mailer/Application/language.js index b73042429..960f3fde9 100644 --- a/services/mailer/Application/language.js +++ b/services/mailer/Application/language.js @@ -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); diff --git a/services/mailer/Application/logger.js b/services/mailer/Application/logger.js deleted file mode 100644 index e378049b9..000000000 --- a/services/mailer/Application/logger.js +++ /dev/null @@ -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; - } - } -}; diff --git a/services/mailer/Application/mail.js b/services/mailer/Application/mail.js index 3eb7e57ac..7e5a20456 100644 --- a/services/mailer/Application/mail.js +++ b/services/mailer/Application/mail.js @@ -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; } diff --git a/services/mailer/Application/router.js b/services/mailer/Application/router.js index dbdd8c5f4..64f91c2d2 100644 --- a/services/mailer/Application/router.js +++ b/services/mailer/Application/router.js @@ -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; diff --git a/services/mailer/Application/settings.js b/services/mailer/Application/settings.js index eccef95fe..8c651ab29 100644 --- a/services/mailer/Application/settings.js +++ b/services/mailer/Application/settings.js @@ -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`)); }, /** diff --git a/services/mailer/Application/template.js b/services/mailer/Application/template.js index 89267f398..7589e632a 100644 --- a/services/mailer/Application/template.js +++ b/services/mailer/Application/template.js @@ -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'); diff --git a/services/mailer/server.js b/services/mailer/server.js index 2c43ce8d3..5ee3412e8 100644 --- a/services/mailer/server.js +++ b/services/mailer/server.js @@ -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'); } }); };