Skip to content

Commit f4c0a2f

Browse files
committed
Reviewed comments
1 parent 3a0e0ff commit f4c0a2f

2 files changed

Lines changed: 11 additions & 11 deletions

File tree

src/controllers/member.controller.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ import { SupabaseClient } from "@supabase/supabase-js";
77
// List all approved members
88
export const listAllApprovedMembers = async (req: Request, res: Response) => {
99

10-
const body = req.body;
10+
const {email} = req.query;
1111

12-
if(body.email) {
12+
if(email) {
1313

14-
const user = memberService.getUserByEmail(body.email);
14+
const user = await memberService.getUserByEmail(email);
1515

1616
if(!user) throw new ApiError('Incorrect email', 400);
1717

@@ -24,7 +24,7 @@ export const listAllApprovedMembers = async (req: Request, res: Response) => {
2424
const user = await memberService.approvedMembers();
2525
res
2626
.status(200)
27-
.json({ user, success: true, message: "Fetched approved users" });
27+
.json({ user, success: true });
2828
}
2929

3030
};

src/routes/members.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,18 @@ export default function membersRouter(
2323
router.get("/:memberId", memberCtrl.getUserDetails);
2424

2525
/**
26-
* @api {get} /members List all approved members
26+
* @api {get} /members List all approved members or get member by email
2727
* @apiName ListAllApprovedMembers
2828
* @apiGroup Member
2929
*
30-
* * @apiDescription
31-
* - Returns a list of all approved members if no email is provided.
32-
* - If `email` is provided in the request body, returns the member associated with that email.
30+
* @apiDescription
31+
* - Returns a list of all approved members if no email query parameter is provided.
32+
* - If `email` query parameter is provided, returns the member associated with that email.
3333
*
34-
* @apiBody {String} [email] Optional email to fetch a specific member.
34+
* @apiQuery {String} [email] Optional email to fetch a specific member.
3535
*
36-
* @apiSuccess {Boolean} success Whether the operation was successful.
37-
* @apiSuccess {Object|Object[]} user The user object (if email provided) or list of approved members.
36+
* @apiSuccess {Object} user Single user object when email provided.
37+
+ * @apiSuccess {Object[]} user Array of approved members when no email provided.
3838
* @apiSuccess {String} [message] Message in case of full list fetch.
3939
*
4040
* @apiError (400) IncorrectEmail The provided email does not match any user.

0 commit comments

Comments
 (0)