forked from reapp/reapp-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
48 lines (38 loc) · 1.05 KB
/
index.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
// opts:
// staticPaths: array of strings, relative paths of where to serve static assets
// dir: dir of where to serve app
// debug: log out stuff
var express = require('express');
var Path = require('path');
var fs = require('fs');
var cors = require('cors');
require('colors');
function runServer(opts) {
var server = express();
server.set('port', opts.port);
server.set('hostname', opts.hostname || 'localhost');
server.use(cors());
var staticPaths = opts.staticPaths || [
'/build/public',
'/assets',
'/web_modules',
'/node_modules/reapp-ui/assets'
];
staticPaths.forEach(function(path) {
server.use('/assets', express.static(opts.dir + path));
});
server.use('/', express.static(opts.dir + "/assets/shared"));
server.get('*', function(req, res) {
res.send(opts.template);
});
console.log(
'Your app is running on http://%s:%s'.green.bold,
server.get('hostname'),
server.get('port')
);
server.listen(
server.get('port'),
server.get('hostname')
);
}
module.exports = runServer;