forked from fnproject/ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
30 lines (22 loc) · 819 Bytes
/
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
var logger = require('config-logger');
var express = require('express');
var path = require('path');
var url = require('url');
var bodyParser = require('body-parser');
var app = express();
var apiUrl = url.parse(process.env.FN_API_URL);
if (!apiUrl || !apiUrl.hostname) {
logger.error("API URL not set. Please specify Functions API URL via environment variable, e.g. FN_API_URL=http://localhost:8080 npm start");
process.exit(1);
}
app.set('api-url', apiUrl);
var port = process.env.PORT || 4000;
var publicPath = path.resolve(__dirname, 'public');
app.use(express.static(publicPath));
app.use(bodyParser.json());
app.use(require('./server/router.js'));
app.disable('etag');
app.listen(port, function () {
logger.info('Using API url: ' + apiUrl.host);
logger.info('Server running on port ' + port);
});