forked from OpenLake/Activity-Tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
44 lines (38 loc) · 1006 Bytes
/
main.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
require('./packages/desktop/.babel');
require('./packages/server/.babel/app');
const isBundled = ['/snapshot', 'C:\\snapshot'].some(prefix =>
__dirname.startsWith(prefix),
);
if (isBundled) {
const AutoLaunch = require('auto-launch');
const autolauncher = new AutoLaunch({
name: 'Activity-Tracker',
path: process.execPath,
isHidden: true,
});
autolauncher
.isEnabled()
.then(isEnabled => {
if (isEnabled) {
return;
}
autolauncher.enable();
console.log('Enabled autolaunch');
})
.catch(err => {
console.error("Couldn't enable autolaunch");
console.error(err);
});
}
const path = require('path');
const express = require('express');
const app = express();
const PORT = 3001;
const STATIC_DIR = path.join(__dirname, './packages/server/.babel/static/');
app.use(express.static(STATIC_DIR));
app.use((req, res) => {
res.sendFile(path.join(STATIC_DIR, 'index.html'));
});
app.listen(PORT, () => {
console.log(`React build is being served on port ${PORT}`);
});