From d94bfa0adc5d9290ae6ef2b91598a2790eba4dc1 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Thu, 6 Oct 2016 12:16:07 +0200 Subject: [PATCH] Servidor HTTP con express que sirve el archivo de rutas --- package.json | 1 + server.js | 24 ++++++++++++++++++++++++ webpack.config.js | 4 ++-- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 9478c538e..df20f4e4b 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "dependencies": { "angular": "^1.5.8", "angular-ui-router": "^1.0.0-beta.3", + "express": "^4.14.0", "material-design-lite": "^1.2.1", "oclazyload": "^0.6.3" }, diff --git a/server.js b/server.js index e69de29bb..cee4df2ea 100644 --- a/server.js +++ b/server.js @@ -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); + diff --git a/webpack.config.js b/webpack.config.js index 2738ae85e..6ff905c05 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,6 +1,6 @@ -var webpack = require('webpack'); -var path = require('path'); +var webpack = require ('webpack'); +var path = require ('path'); module.exports = {