-
Notifications
You must be signed in to change notification settings - Fork 32
/
frontend.js
59 lines (50 loc) · 2.06 KB
/
frontend.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
49
50
51
52
53
54
55
56
57
58
59
/**
* JBoss, Home of Professional Open Source
* Copyright 2016, Red Hat, Inc. and/or its affiliates, and individual
* contributors by the @authors tag. See the copyright.txt in the
* distribution for a full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License")
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var express = require('express')
var mustacheExpress = require('mustache-express')
var app = express()
// Register '.html' extension with The Mustache Express
app.engine('html', mustacheExpress())
app.engine('json', mustacheExpress())
app.set('view engine', 'mustache')
app.set('views', __dirname)
// Return a custom index.html file
var customIndex = function (req, res) {
var view = {
hystrix: process.env.ENABLE_HYSTRIX ? JSON.parse(process.env.ENABLE_HYSTRIX): null,
jaeger: process.env.ENABLE_JAEGER ? JSON.parse(process.env.ENABLE_JAEGER) : null,
sso: process.env.ENABLE_SSO ? JSON.parse(process.env.ENABLE_SSO) : null,
threescale: process.env.ENABLE_THREESCALE ? JSON.parse(process.env.ENABLE_THREESCALE) : null
}
res.render('index.html', view)
}
app.get('/', customIndex)
app.get('/index.html', customIndex)
// Return a custom keycloak.json file
app.get('/keycloak.json', function (req, res) {
var view = {
keycloak_server: process.env.KEYCLOAK_AUTH_SERVER_URL
}
res.render('keycloak.json', view)
})
// Serve all static files
app.use('/', express.static('.'))
var server = app.listen(8080, '0.0.0.0', function () {
var host = server.address().address
var port = server.address().port
console.log('Frontend service running at http://%s:%s', host, port)
})