Add server endpoint to compare a list of user guilds to the registered bracket guilds
This commit is contained in:
parent
e8a1dbcb51
commit
fcda612970
1 changed files with 24 additions and 0 deletions
24
server/src/endpoints/site/guild_intersection.ts
Normal file
24
server/src/endpoints/site/guild_intersection.ts
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
import { Request, ResponseToolkit } from "@hapi/hapi";
|
||||||
|
import { config } from "@/main";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
method: `POST`, path: `/guilds/compare`,
|
||||||
|
options: {
|
||||||
|
auth: false,
|
||||||
|
cors: {
|
||||||
|
origin: [ `*` ],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
async handler(request: Request, h: ResponseToolkit) {
|
||||||
|
let userGuilds = request.payload as Array<string>;
|
||||||
|
let registeredGuilds = [];
|
||||||
|
|
||||||
|
for (var gid in config.guilds) {
|
||||||
|
if (userGuilds.includes(gid)) {
|
||||||
|
registeredGuilds.push(gid);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
return registeredGuilds;
|
||||||
|
},
|
||||||
|
};
|
||||||
Loading…
Add table
Add a link
Reference in a new issue