summaryrefslogtreecommitdiffstats
path: root/afm-client/app/Backend/server.js
diff options
context:
space:
mode:
authorFulup Ar Foll <fulup@iot.bzh>2016-05-29 15:50:40 +0200
committerFulup Ar Foll <fulup@iot.bzh>2016-05-29 15:50:40 +0200
commit96190f9cd583d9182c692c88d3342109bad81157 (patch)
tree5d5b098e64c14b7be1da47961ed6600ce355020b /afm-client/app/Backend/server.js
parent922b183f441a6e68b55592596fa62cc6e1814f74 (diff)
Clean up to prepare new version of API
Diffstat (limited to 'afm-client/app/Backend/server.js')
-rw-r--r--afm-client/app/Backend/server.js58
1 files changed, 0 insertions, 58 deletions
diff --git a/afm-client/app/Backend/server.js b/afm-client/app/Backend/server.js
deleted file mode 100644
index 11c5486..0000000
--- a/afm-client/app/Backend/server.js
+++ /dev/null
@@ -1,58 +0,0 @@
-var config = require('../etc/_Config');
-var trace = require('../etc/_Trace');
-var RestAPI = require('./RestApis/_all');
-var fs = require('fs');
-
-var express = require('express');
-var session = require('express-session');
-var bodyParser = require('body-parser');
-var methodOverride = require('method-override');
-
-// instanciate express HTTP server
-var app = express();
-
-// chose dev or prod rootdir
-var staticdir = 'dist.dev';
-if (process.env.MODE) staticdir = process.env.MODE === 'prod' ? 'dist.prod' : 'dist.dev';
-else staticdir = config.MODE === 'prod' ? 'dist.prod' : 'dist.dev';
-
-var rootdir = __dirname + '/../../' + staticdir;
-if (!fs.existsSync(rootdir)) {
- console.log("### HOOPS Rootdir not found rootdir=%s\n", rootdir);
- process.exit();
-}
-
-// get all data/stuff of the body (POST) parameters
-app.use(bodyParser.json()); // parse application/json
-app.use(methodOverride('X-HTTP-Method-Override')); // override with the X-HTTP-Method-Override header in the request. simulate DELETE/PUT
-
-// This handle should contain enough for application logic
-var serverHandle = {
- app : app, // Express server
- config: config,
- trace: config.DBG_LVL > 0 ? trace : function(){/*empty function */}
-};
-
-// set the static files location /public/img will be /img for users
-app.use(express.static(rootdir));
-
-// Load Mock APIs
-var apirest = new RestAPI(serverHandle);
-
-app.get(config.URLBASE, function (req, res) {
- console.log ("Angular OPA %s", req.originalUrl);
- res.sendfile(config.URLBASE +"index.html", {root: rootdir});
-});
-
-// rewrite requested URL to include Angular hashPrompt and set session flag for RestAPI
-app.get(config.URLBASE + '*', function(req, res) {
- // Warning redirect should be under exact "/opa/#!page" or a redirect to home will be done
- var redirect=config.URLBASE + '#!' + req.originalUrl.substring(config.URLBASE.length);
- res.redirect(redirect);
- console.log ("Redirect to: ", redirect);
-});
-
-
-// start app ===============================================
-app.listen(config.EXPRESS_PORT, config.EXPRESS_HOST);
-console.log('Server Listening http://%s:%d (rootdir=%s)', config.EXPRESS_HOST, config.EXPRESS_PORT, rootdir); \ No newline at end of file