35 lines
870 B
JavaScript
35 lines
870 B
JavaScript
/**
|
|
* Módulos necesarios
|
|
*/
|
|
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 database = require('./application/database.js');
|
|
|
|
// Middleware
|
|
app.use(bodyParser.json());
|
|
app.use(bodyParser.urlencoded({extended: true}));
|
|
|
|
// Cargar rutas
|
|
app.use('/', require('./application/router.js'));
|
|
|
|
// Iniciar escucha del servidor
|
|
app.start = function() {
|
|
return app.listen(settings.app().port, function() {
|
|
mail.init();
|
|
database.init();
|
|
console.log('Servidor de correo iniciado en el puerto ' + settings.app().port);
|
|
if (settings.app().debug) {
|
|
console.log('El modo debug está activado');
|
|
}
|
|
});
|
|
};
|
|
|
|
if (require.main === module) {
|
|
app.start();
|
|
}
|
|
|
|
|