forked from RunOnFlux/flux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
37 lines (30 loc) · 982 Bytes
/
app.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
process.env.NODE_CONFIG_DIR = `${__dirname}/ZelBack/config/`;
const log = require('./ZelBack/src/lib/log');
const path = require('path');
const compression = require('compression');
const express = require('express');
const apiServer = require('./apiServer');
async function initiate() {
const apiPort = await apiServer.initiate();
if (process.argv[2] === '--dev') {
log.info('Running FluxOS development server.');
return;
}
const homePort = +apiPort - 1;
// Flux Home configuration
const home = path.join(__dirname, './HomeUI/dist');
const homeApp = express();
homeApp.use(compression());
homeApp.use(express.static(home));
homeApp.get('/robots.txt', (req, res) => {
res.type('text/plain');
res.send('User-agent: *\nDisallow: /');
});
homeApp.get('*', (req, res) => {
res.sendFile(path.join(home, 'index.html'));
});
homeApp.listen(homePort, () => {
log.info(`Flux Home running on port ${homePort}!`);
});
}
initiate();