-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathserver.js
31 lines (23 loc) · 888 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
31
var express = require('express');
var path = require('path');
var url = require('url');
var bodyParser = require('body-parser');
var helpers = require('./server/helpers/app-helpers.js');
var app = express();
var isProduction = process.env.NODE_ENV === 'production';
var apiUrl = url.parse(process.env.API_URL);
if (!apiUrl || !apiUrl.hostname) {
console.log("API URL not set. Please specify Functions API URL via environment variable, e.g. 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 () {
console.log('Using API url: ' + apiUrl.host);
console.log('Server running on port ' + port);
});