From ad7f746d883dfe0ddbfce64bc62cd53abc560ef2 Mon Sep 17 00:00:00 2001 From: Michael Fatemi Date: Sat, 10 Apr 2021 20:34:15 -0400 Subject: [PATCH] Add querying pools by group ID --- src/api.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/api.ts b/src/api.ts index 706c522..e744483 100644 --- a/src/api.ts +++ b/src/api.ts @@ -102,7 +102,7 @@ router.delete('/pool', (req, res) => {}); router.get('/group', (req, res) => { if (typeof req.query.groupID != 'string') { - return; + return res.json({ status: 'error' }); } let groupID = req.query.groupID; @@ -115,6 +115,17 @@ router.get('/group', (req, res) => { } }); +router.get('/group_pools', async (req, res) => { + if (typeof req.query.groupID != 'string') { + return; + } + + let groupID = req.query.groupID; + let pools = await PoolModel.find({ group_id: groupID }).exec(); + + res.json({ status: 'success', data: pools }); +}); + router.post('/join_pool', async (req, res) => { if (!req.session.accountID) { return res.json({ status: 'error', error: 'need_login' });