mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 19:16:44 +00:00
src/server/Worker.ts
This commit is contained in:
@@ -35,7 +35,7 @@ export function startWorker() {
|
||||
|
||||
const gm = new GameManager(config, log);
|
||||
|
||||
if (config.env() == GameEnv.Prod && config.otelEnabled()) {
|
||||
if (config.env() === GameEnv.Prod && config.otelEnabled()) {
|
||||
initWorkerMetrics(gm);
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ export function startWorker() {
|
||||
const clientIP = req.ip || req.socket.remoteAddress || "unknown";
|
||||
const gc = req.body?.gameConfig as GameConfig;
|
||||
if (
|
||||
gc?.gameType == GameType.Public &&
|
||||
gc?.gameType === GameType.Public &&
|
||||
req.headers[config.adminHeader()] !== config.adminToken()
|
||||
) {
|
||||
log.warn(
|
||||
@@ -140,7 +140,7 @@ export function startWorker() {
|
||||
gatekeeper.httpHandler(LimiterType.Put, async (req, res) => {
|
||||
// TODO: only update public game if from local host
|
||||
const lobbyID = req.params.id;
|
||||
if (req.body.gameType == GameType.Public) {
|
||||
if (req.body.gameType === GameType.Public) {
|
||||
log.info(`cannot update game ${lobbyID} to public`);
|
||||
return res.status(400).json({ error: "Cannot update public game" });
|
||||
}
|
||||
@@ -182,7 +182,7 @@ export function startWorker() {
|
||||
gatekeeper.httpHandler(LimiterType.Get, async (req, res) => {
|
||||
const lobbyId = req.params.id;
|
||||
res.json({
|
||||
exists: gm.game(lobbyId) != null,
|
||||
exists: gm.game(lobbyId) !== null,
|
||||
});
|
||||
}),
|
||||
);
|
||||
@@ -191,7 +191,7 @@ export function startWorker() {
|
||||
"/api/game/:id",
|
||||
gatekeeper.httpHandler(LimiterType.Get, async (req, res) => {
|
||||
const game = gm.game(req.params.id);
|
||||
if (game == null) {
|
||||
if (game === null) {
|
||||
log.info(`lobby ${req.params.id} not found`);
|
||||
return res.status(404).json({ error: "Game not found" });
|
||||
}
|
||||
@@ -213,8 +213,8 @@ export function startWorker() {
|
||||
}
|
||||
|
||||
if (
|
||||
config.env() != GameEnv.Dev &&
|
||||
gameRecord.gitCommit != config.gitCommit()
|
||||
config.env() !== GameEnv.Dev &&
|
||||
gameRecord.gitCommit !== config.gitCommit()
|
||||
) {
|
||||
log.warn(
|
||||
`git commit mismatch for game ${req.params.id}, expected ${config.gitCommit()}, got ${gameRecord.gitCommit}`,
|
||||
@@ -295,7 +295,7 @@ export function startWorker() {
|
||||
JSON.parse(message.toString()),
|
||||
);
|
||||
|
||||
if (clientMsg.type == "join") {
|
||||
if (clientMsg.type === "join") {
|
||||
// Verify this worker should handle this game
|
||||
const expectedWorkerId = config.workerIndex(clientMsg.gameID);
|
||||
if (expectedWorkerId !== workerId) {
|
||||
|
||||
Reference in New Issue
Block a user