af6924a27c
This commit adds a '/metrics' endpoint in the API that can be exploited by Prometheus. This endpoint returns: - the number of connected sockets - the number of users per room - common NodeJS and system metrics WARNING: this endpoint is public right now and should be protected
29 lines
800 B
TypeScript
29 lines
800 B
TypeScript
import express from "express";
|
|
import {Application, Request, Response} from "express";
|
|
import {OK} from "http-status-codes";
|
|
import {URL_ROOM_STARTED} from "../Enum/EnvironmentVariable";
|
|
|
|
export class MapController {
|
|
App: Application;
|
|
|
|
constructor(App: Application) {
|
|
this.App = App;
|
|
this.getStartMap();
|
|
this.assetMaps();
|
|
}
|
|
|
|
assetMaps() {
|
|
this.App.use('/map/files', express.static('src/Assets/Maps'));
|
|
}
|
|
|
|
// Returns a map mapping map name to file name of the map
|
|
getStartMap() {
|
|
this.App.get("/start-map", (req: Request, res: Response) => {
|
|
res.status(OK).send({
|
|
mapUrlStart: req.headers.host + "/map/files" + URL_ROOM_STARTED,
|
|
startInstance: "global"
|
|
});
|
|
});
|
|
}
|
|
}
|