From 8564088a3bb7c744c40e416999325d4a2760330c Mon Sep 17 00:00:00 2001 From: bgoulard Date: Fri, 9 Jan 2026 11:14:16 +0100 Subject: [PATCH] eslint --- src/chat/src/routes/broadcast.ts | 32 ++++++++++++++++---------------- src/pong/src/state.ts | 19 ++++++++++--------- 2 files changed, 26 insertions(+), 25 deletions(-) diff --git a/src/chat/src/routes/broadcast.ts b/src/chat/src/routes/broadcast.ts index d795dfd..b709d73 100644 --- a/src/chat/src/routes/broadcast.ts +++ b/src/chat/src/routes/broadcast.ts @@ -1,6 +1,6 @@ import { FastifyPluginAsync } from 'fastify'; import { Static, Type } from 'typebox'; -import { broadcastNextGame} from '../broadcastNextGame'; +import { broadcastNextGame } from '../broadcastNextGame'; export const ChatReq = Type.Object({ message: Type.String(), @@ -28,22 +28,22 @@ export type ChatReq = Static; const route: FastifyPluginAsync = async (fastify): Promise => { fastify.post('/api/chat/broadcast', { - schema: { - body: { - type: 'object', - required: ['nextGame'], - properties: { - nextGame: { type: 'string' } - } - } - } -}, async (req, reply) => { - const gameLink: Promise = Promise.resolve(req.body as string ); - if (gameLink) + schema: { + body: { + type: 'object', + required: ['nextGame'], + properties: { + nextGame: { type: 'string' }, + }, + }, + }, + }, async (req, reply) => { + const gameLink: Promise = Promise.resolve(req.body as string); + if (gameLink) { broadcastNextGame(fastify, gameLink); - - return reply.send({ status: 'ok' }); -}); + } + return reply.send({ status: 'ok' }); + }); }; export default route; diff --git a/src/pong/src/state.ts b/src/pong/src/state.ts index 5197522..2c7d940 100644 --- a/src/pong/src/state.ts +++ b/src/pong/src/state.ts @@ -205,19 +205,20 @@ class StateI { this.fastify.db.setPongGameOutcome(gameId, { id: game.userLeft, score: game.score[0] }, { id: game.userRight, score: game.score[1] }, outcome, game.local); this.fastify.log.info('SetGameOutcome !'); if (!game.local) { - let payload = {'nextGame':chat_text}; + const payload = { 'nextGame':chat_text }; try { - const resp = await fetch("http://app-chat/api/chat/broadcast", { + const resp = await fetch('http://app-chat/api/chat/broadcast', { method:'POST', - headers:{'Content-type':'application/json'}, + headers:{ 'Content-type':'application/json' }, body: JSON.stringify(payload), - }); + }); - if (!resp.ok) - throw(resp); - else - this.fastify.log.info("game-end info to chat success"); - } catch (e : any) { + if (!resp.ok) { throw (resp); } + else { this.fastify.log.info('game-end info to chat success'); } + } + // disable eslint for err catching + // eslint-disable-next-line @typescript-eslint/no-explicit-any + catch (e : any) { this.fastify.log.error(`game-end info to chat failed: ${e}`); } }