mirror of
https://github.com/myfatemi04/wheelshare-old-backend.git
synced 2025-04-21 12:10:17 -04:00
fix sending promise through json
This commit is contained in:
parent
9622ede6e0
commit
fa4c931742
13
src/api.ts
13
src/api.ts
|
@ -15,7 +15,6 @@ router.get('/user', async (req, res) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
let userID = req.query.userID;
|
let userID = req.query.userID;
|
||||||
console.log(req.session, userID);
|
|
||||||
if (userID === '@me') {
|
if (userID === '@me') {
|
||||||
userID = req.session.accountID;
|
userID = req.session.accountID;
|
||||||
}
|
}
|
||||||
|
@ -127,10 +126,14 @@ router.post('/group', (req, res) => {
|
||||||
// }
|
// }
|
||||||
});
|
});
|
||||||
|
|
||||||
router.get('/my_pools', (req, res) => {
|
router.get('/my_pools', async (req, res) => {
|
||||||
let groupsWithUser = getPoolsWithUser(req.session.accountID);
|
if (req.session.accountID == null) {
|
||||||
if (groupsWithUser) {
|
res.status(401);
|
||||||
res.json({ status: 'success', data: groupsWithUser });
|
return res.json({ status: 'error', error: 'need_login' });
|
||||||
|
}
|
||||||
|
let pools = await getPoolsWithUser(req.session.accountID);
|
||||||
|
if (pools) {
|
||||||
|
res.json({ status: 'success', data: pools });
|
||||||
} else {
|
} else {
|
||||||
res.json({ status: 'error', error: 'not_found' });
|
res.json({ status: 'error', error: 'not_found' });
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,6 @@ export function createSession(accountID: string): string {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getSessionByToken(token: string): SessionData {
|
export function getSessionByToken(token: string): SessionData {
|
||||||
console.log(sessions);
|
|
||||||
if (token in sessions) {
|
if (token in sessions) {
|
||||||
return sessions[token];
|
return sessions[token];
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -15,8 +15,10 @@ export function getGroupsWithUser(userID: string) {
|
||||||
* @param userID The userID to find
|
* @param userID The userID to find
|
||||||
* @returns The post IDs with that userID as the author
|
* @returns The post IDs with that userID as the author
|
||||||
*/
|
*/
|
||||||
export function getPoolsWithUser(userID: string) {
|
export async function getPoolsWithUser(userID: string) {
|
||||||
return undefined;
|
return await PoolModel.find({
|
||||||
|
participant_ids: { $all: [userID] },
|
||||||
|
}).exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getUserByID(userID: string) {
|
export async function getUserByID(userID: string) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user