-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
48 lines (37 loc) · 1.48 KB
/
server.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
47
48
// OpenShift sample Node application
var express = require('express'),
http = require('http'),
request = require('request'),
fs = require('fs'),
app = express(),
path = require("path"),
keycloakConfig = require('./app/keycloak.config.js'),
coolstoreConfig = require('./app/coolstore.config.js'),
Keycloak = require('keycloak-connect'),
cors = require('cors');
var port = process.env.PORT || process.env.OPENSHIFT_NODEJS_PORT || 8080,
ip = process.env.IP || process.env.OPENSHIFT_NODEJS_IP || '0.0.0.0',
secport = process.env.PORT || process.env.OPENSHIFT_NODEJS_PORT || 8443;
// Enable CORS support
app.use(cors());
// error handling
app.use(function (err, req, res, next) {
console.error(err.stack);
res.status(500).send('Something bad happened!');
});
// keycloak config server
app.get('/keycloak.json', function (req, res, next) {
res.json(keycloakConfig);
});
// coolstore config server
app.get('/coolstore.json', function (req, res, next) {
res.json(coolstoreConfig);
});
app.use(express.static(path.join(__dirname, '/views')));
app.use('/app', express.static(path.join(__dirname, '/app')));
app.use('/bower_components', express.static(path.join(__dirname, '/bower_components')));
console.log("coolstore config: " + JSON.stringify(coolstoreConfig));
console.log("keycloak config: " + JSON.stringify(keycloakConfig));
http.createServer(app).listen(port);
console.log('HTTP Server running on http://%s:%s', ip, port);
module.exports = app;