Add a method to view the game's current state without affecting it.
This commit is contained in:
parent
444010e206
commit
a5dd1aac4e
1 changed files with 21 additions and 0 deletions
21
src/endpoints/view_game_state.ts
Normal file
21
src/endpoints/view_game_state.ts
Normal file
|
|
@ -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;
|
||||||
Loading…
Add table
Add a link
Reference in a new issue