-
Notifications
You must be signed in to change notification settings - Fork 17
/
app.js
46 lines (35 loc) · 1.16 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
module.exports = function () {
var express = require('express');
var app = express();
var bodyParser = require('body-parser');
var request = require('request');
var path = require('path');
var ejs = require('ejs');
//Globals
global.keys = require('./config/keys.js');
function setUpFEServices() {
try {
if (process.env["CLOUDBOOST_USER_SERVICE_SERVICE_HOST"]) {
global.keys.frontendServerUrl = "http://" + process.env["CLOUDBOOST_USER_SERVICE_SERVICE_HOST"] + ":" + process.env["CLOUDBOOST_USER_SERVICE_SERVICE_PORT"];
}
console.log("FE Services URL : " + global.keys.frontendServerUrl);
} catch (err) {
console.log('Setup user service error', err)
}
}
setUpFEServices()
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
//View engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');
app.use('*/public/',express.static(path.join(__dirname, 'public')));
//Usefull functions for ejs
app.locals.nospacelowcase = function (text) {
return (text.toLowerCase()).replace(/\s+/g, '');
};
//Routers
var routes = require('./routes/routes');
app.use('/', routes);
return app;
}