-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
45 lines (36 loc) · 1.43 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
var express = require('express');
var logfmt = require('logfmt');
var serverProfiles = require('./server-profile-loader');
/*
WebUml UI
---------
Usage (run in project root folder):
$> node "node server.js"
*/
var argv = require('minimist')(process.argv.slice(2));
var activeProfileName = argv.profiles && argv.profiles.active;
var appConfig = serverProfiles.loadProfile(activeProfileName);
// default configuration
var buildFolder = "/build/target";
var port = Number(process.env.PORT || 8080);
function openClassDiagramView(req, res) {
res.sendfile(__dirname + buildFolder + "/classes.html");
}
function sendActiveProfile(req, res) {
res.set('Content-Type', 'application/x-javascript');
var clientConfigScript = "var WebUmlProfile = WebUmlProfile || " + JSON.stringify(appConfig);
res.send(clientConfigScript);
}
// ##########################################################################
// App starts here.
// ##########################################################################
var app = express();
app.use(logfmt.requestLogger());
app.get("/projects/:projectid", openClassDiagramView);
app.get("/lightTables/:lightTableViewId", openClassDiagramView);
app.get("/profile.js", sendActiveProfile);
app.use(express.static(__dirname + buildFolder));
app.listen(port);
console.log('Active Profile : ' + (activeProfileName || ''));
console.log('Serving static from : ' + buildFolder);
console.log('Listening on port : ' + port);