X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FUI.git;a=blobdiff_plain;f=skyquake%2Fplugins%2Fuser_management%2Fserver.js;fp=skyquake%2Fplugins%2Fuser_management%2Fserver.js;h=eb140b74eabf362fa9100aaa0ff017e26527d51f;hp=0000000000000000000000000000000000000000;hb=03156e335275de1dafbc2a816e98006afdf249bf;hpb=f2dc2462571800e62cba969964de621dca09299c diff --git a/skyquake/plugins/user_management/server.js b/skyquake/plugins/user_management/server.js new file mode 100644 index 000000000..eb140b74e --- /dev/null +++ b/skyquake/plugins/user_management/server.js @@ -0,0 +1,51 @@ +/* + * STANDARD_RIFT_IO_COPYRIGHT + */ + +var express = require('express'); +var path = require('path'); +var httpProxy = require('http-proxy'); +var bodyParser = require('body-parser'); +var cors = require('cors'); +var session = require('express-session'); +var proxy = httpProxy.createProxyServer(); +var app = express(); + +var isProduction = process.env.NODE_ENV === 'production'; +var port = isProduction ? 8080 : 8888; +var publicPath = path.resolve(__dirname, 'public'); + +if (!isProduction) { + + //Routes for local development + var lpRoutes = require('./routes.js'); + + app.use(express.static(publicPath)); + app.use(session({ + secret: 'ritio rocks', + })); + app.use(bodyParser.urlencoded({ + extended: true + })); + app.use(bodyParser.json()); + app.use(cors()); + app.use('/', lpRoutes); + var bundle = require('./server/bundle.js'); + bundle(); + + app.all('/build/*', function (req, res) { + proxy.web(req, res, { + target: 'http://localhost:8080' + }); + }); + +} +proxy.on('error', function(e) { + console.log('Could not connect to proxy, please try again...'); +}); + +app.listen(port, function () { + console.log('Server running on port ' + port); +}); + +app.get('/*')