Servidor HTTP con express que sirve el archivo de rutas

This commit is contained in:
Juan Ferrer Toribio 2016-10-06 12:16:07 +02:00
parent 5a5820328c
commit d94bfa0adc
3 changed files with 27 additions and 2 deletions

View File

@ -11,6 +11,7 @@
"dependencies": { "dependencies": {
"angular": "^1.5.8", "angular": "^1.5.8",
"angular-ui-router": "^1.0.0-beta.3", "angular-ui-router": "^1.0.0-beta.3",
"express": "^4.14.0",
"material-design-lite": "^1.2.1", "material-design-lite": "^1.2.1",
"oclazyload": "^0.6.3" "oclazyload": "^0.6.3"
}, },

View File

@ -0,0 +1,24 @@
var express = require ('express');
function getRoutes (req, res)
{
var routes = require ('./build/salix.routes.json');
res.send (JSON.stringify (routes));
}
function getDefault (res, res)
{
res.sendStatus (404);
}
function onListen ()
{
console.log ('HTTP server started.');
}
var app = express ();
app.get ('/routes.json', getRoutes);
app.all (/.*/, getDefault);
app.listen (8080, onListen);