0
0
Fork 0
Chatman/src/endpoints/view_game_state.ts
2023-02-20 19:57:37 -07:00

22 lines
No EOL
563 B
TypeScript

import { channelSchema } from "$/schemas/general";
import { config, database } from "$/main";
import { ServerRoute } from "@hapi/hapi";
import Joi from "joi";
const route: ServerRoute = {
method: `GET`, path: `/{channel}/game`,
options: {
validate: {
params: Joi.object({
channel: channelSchema,
}),
},
},
async handler(request) {
const { channel } = request.params;
let { current, incorrect } = await database.getChannel(channel);
return `${current} (incorrect: ${incorrect}/${config.game.max_incorrect})`;;
},
};
export default route;