eslint
This commit is contained in:
parent
a65b8a9067
commit
8564088a3b
2 changed files with 26 additions and 25 deletions
|
|
@ -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(),
|
||||
|
|
@ -33,17 +33,17 @@ const route: FastifyPluginAsync = async (fastify): Promise<void> => {
|
|||
type: 'object',
|
||||
required: ['nextGame'],
|
||||
properties: {
|
||||
nextGame: { type: 'string' }
|
||||
}
|
||||
}
|
||||
}
|
||||
}, async (req, reply) => {
|
||||
const gameLink: Promise<string> = Promise.resolve(req.body as string );
|
||||
if (gameLink)
|
||||
nextGame: { type: 'string' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}, async (req, reply) => {
|
||||
const gameLink: Promise<string> = Promise.resolve(req.body as string);
|
||||
if (gameLink) {
|
||||
broadcastNextGame(fastify, gameLink);
|
||||
|
||||
}
|
||||
return reply.send({ status: 'ok' });
|
||||
});
|
||||
});
|
||||
};
|
||||
export default route;
|
||||
|
||||
|
|
|
|||
|
|
@ -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}`);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue