Push Files

- Uploaded Backend
- Uploaded Mod Code
- Started Documentation
This commit is contained in:
2025-04-08 20:12:57 -05:00
parent 6c33c0b76a
commit b06a49e54d
18 changed files with 3344 additions and 0 deletions

14
Backend/package.json Normal file
View File

@@ -0,0 +1,14 @@
{
"name": "gp-server",
"version": "1.0.0",
"description": "",
"main": "server.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node server.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"type": "module"
}

39
Backend/server.js Normal file
View File

@@ -0,0 +1,39 @@
import express from "express";
import client from "prom-client";
const registry = new client.Registry();
const app = express();
var active_users = 0;
const users = new client.Gauge({
name: "active_users",
help: "active_users",
async collect() {
this.set(active_users);
},
});
registry.registerMetric(users);
app.get("/", (req, res) => {
res.send("player-metrics");
});
app.post("/api/players", (req, res) => {
res.send("ok");
active_users++;
});
app.get("/metrics", async (req, res) => {
res.setHeader("Content-Type", client.contentType);
res.send(await registry.metrics());
res.end();
active_users = 0; // reset the active_users when prometheus gets metrics (aka reset every minute -- prometheus default poll time)
});
app.listen(5008, () => {
console.log("listening on :" + 5008);
});

1
Backend/start.sh Normal file
View File

@@ -0,0 +1 @@
node server.js