-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver.js
More file actions
35 lines (28 loc) · 1.25 KB
/
server.js
File metadata and controls
35 lines (28 loc) · 1.25 KB
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
'use strict';
const express = require('express');
const status = require('./modules/status');
const app = express();
const clc = require('cli-color');
status.check(); // initial check before we listen
console.log(clc.reset); // reset the screen
setInterval(() => status.check(), 6000);
setInterval(() => status.update(), 3000);
app.get('/', (req, res) => res.json({server_time: new Date().toISOString()}));
app.get('/main.mp3', (req, res) => res.redirect(302, status.choose(req.headers['x-forwarded-proto'])));
app.get('/status.json', (req, res) => res.json(status.relays()));
app.listen(process.env.PORT || 3030, process.env.HOST || 'localhost');
// const management = express();
// const config = require('./config');
//
// middleware for input
// config.use(parser.json());
// config.use(parser.urlencoded({ extended: true }));
//
// CRUD operations
// config.get('/status.json', (req, res) => res.json(status.relays()));
// config.put('/relay/:relay', (req, res) => res.json(config.update(req.params.relay, req.body)));
// config.post('/relay', (req, res) => res.json(config.create(req.body)));
// config.delete('/relay/:relay', (req, res) => res.json(config.delete(req.params.relay)));
//
// listen on a custom port
// config.listen(process.env.CONFIG_PORT || 4040);