-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
49 lines (38 loc) · 1.01 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
49
const os = require('os');
const express = require('express');
const utils = require('./core/utils');
const commands = require('./core/commands');
// Initialize core logic
commands.initialize();
// Set up web server
const app = express();
const port = 4040;
app.use('/feed', (req, res, next) => {
commands.feed();
res.end();
});
app.use('/shake', (req, res, next) => {
commands.shake();
res.end();
});
app.use('/snapshot', (req, res, next) => {
commands.takeSnapshot();
res.end();
});
app.use('/toggleSchedule', (req, res, next) => {
commands.toggleSchedule();
res.end();
});
app.use('/uptime', (req, res, next) => {
res.send(utils.formatTimeDuration(os.uptime()));
});
app.use('/log', (req, res, next) => {
const logger = commands.getLogger();
res.send(logger.getLog());
})
app.use('/settings', (req, res, next) => {
const settings = commands.getSettings();
res.send(settings);
})
app.use(express.static('public'));
app.listen(port, () => console.log(`catfeeder listening on port ${port}!`));