-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
49 lines (40 loc) · 1.12 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
46
47
48
49
var express = require('express');
var Path = require('path');
var fs = require('fs');
var cors = require('cors');
require('colors');
var platform = 'web';
var port = ('production' == process.env.NODE_ENV) ? process.env.PORT : 3015;
var hostname = 'localhost';
var debug = true;
var dir = ('production' == process.env.NODE_ENV) ? process.env.HOME : '.';
runServer({
dir: dir,
debug: debug,
port: port,
hostname: hostname
});
function runServer(opts) {
var server = express();
server.set('port', opts.port);
server.set('hostname', opts.hostname || 'localhost');
server.use(cors());
var staticPaths = opts.staticPaths || [
'/assets/shared',
'/assets',
'/web_modules',
'/node_modules/reapp-ui/assets'
];
staticPaths.forEach(function(path) {
server.use('/assets', express.static(opts.dir + path));
});
server.use(express.static('./build/' + platform));
console.log(
'Your app is running on http://%s:%s'.green.bold,
server.get('hostname'),
server.get('port')
);
server.listen(
server.get('port')
);
}