diff --git a/src/endpoints/view_game_state.ts b/src/endpoints/view_game_state.ts new file mode 100644 index 0000000..16bb104 --- /dev/null +++ b/src/endpoints/view_game_state.ts @@ -0,0 +1,21 @@ +import { ServerRoute } from "@hapi/hapi"; +import { database } from "$/main"; +import Joi from "joi"; + +const route: ServerRoute = { + method: `GET`, path: `/{channel}/game`, + options: { + validate: { + params: Joi.object({ + channel: Joi.string().alphanum(), + }), + }, + }, + async handler(request) { + const { channel } = request.params; + + let { current, incorrect } = await database.getChannel(channel); + return { current, incorrect }; + }, +}; +export default route; \ No newline at end of file