Add an endpoint for accessing a guild's bracket history
This commit is contained in:
parent
f22e74b599
commit
7cbf104c32
1 changed files with 23 additions and 0 deletions
23
server/src/endpoints/site/history.ts
Normal file
23
server/src/endpoints/site/history.ts
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
import { Request, ResponseToolkit } from "@hapi/hapi";
|
||||||
|
import { loadHistory } from "@/utils/data";
|
||||||
|
import { config } from "@/main";
|
||||||
|
import boom from "@hapi/boom";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
method: `GET`, path: `/{guild_id}/history`,
|
||||||
|
options: {
|
||||||
|
auth: false,
|
||||||
|
cors: {
|
||||||
|
origin: [ `*` ],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
async handler(request: Request, h: ResponseToolkit) {
|
||||||
|
let { guild_id: gID } = request.params;
|
||||||
|
|
||||||
|
if (!config.guilds[gID].history_site) {
|
||||||
|
throw boom.notFound();
|
||||||
|
};
|
||||||
|
|
||||||
|
return await loadHistory(gID);
|
||||||
|
},
|
||||||
|
};
|
||||||
Loading…
Add table
Add a link
Reference in a new issue