-
Notifications
You must be signed in to change notification settings - Fork 0
/
web.js
28 lines (22 loc) · 864 Bytes
/
web.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
/* global require, module, process, __dirname */
'use strict';
var express = require('express');
var app = express();
var bindControllers = require('express-bind-controllers');
var PORT = 5000;
if (!process.env.BUILD_DIR || !process.env.BUILD_JS_DIR) {
console.log('Please specify the BUILD_DIR and BUILD_JS_DIR environment variables');
process.exit(1);
}
// Set the port
app.set('port', process.env.PORT || PORT);
app.listen(app.get('port'), function () {
console.log('Node app is running at localhost:' + app.get('port'));
});
// Setup /public access
app.use(express['static'](__dirname + '/' + process.env.BUILD_DIR + '/'));
app.use(express['static'](__dirname + '/' + process.env.BUILD_JS_DIR + '/'));
// Bind controllers
bindControllers(app, __dirname + '/fixture-api/controllers', true);
// Export app to be used externally
module.exports = app;