aboutsummaryrefslogtreecommitdiff
path: root/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'index.js')
-rw-r--r--index.js17
1 files changed, 13 insertions, 4 deletions
diff --git a/index.js b/index.js
index 3108183..797791a 100644
--- a/index.js
+++ b/index.js
@@ -6,15 +6,23 @@ const app = express();
app.use(express.static('public'));
app.set("view engine", "ejs");
-app.get('/', function (req, res) {
+app.get('/', (req, res) => {
res.render("index");
-})
+});
+
+// API
+var serverCache = {};
+
+app.get("/api/servers", (req, res) => {
+ res.json(serverCache);
+});
const refresh = require('./refresh');
setInterval(() => {
console.log("Running refresh...");
- refresh().then(() => {
+ refresh().then(data => {
console.log("Refresh done!");
+ serverCache = data;
});
}, 300000);
@@ -24,7 +32,8 @@ const server = app.listen(8099, function () {
console.log("Vapor Trail server listening at http://%s:%s", host, port)
console.log("Running refresh...");
- refresh().then(() => {
+ refresh().then(data => {
console.log("Refresh done!");
+ serverCache = data;
});
}) \ No newline at end of file