Skip to content

Commit

Permalink
fix: handle id query parameter in Get Requests API (#2367)
Browse files Browse the repository at this point in the history
Co-authored-by: Vikas Singh <[email protected]>
Co-authored-by: Achintya Chatterjee <[email protected]>
  • Loading branch information
3 people authored Jan 26, 2025
1 parent d98bfa1 commit 2db248c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
7 changes: 7 additions & 0 deletions controllers/requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ export const getRequestsController = async (req: any, res: any) => {
return res.status(204).send();
}

if (query.id) {
return res.status(200).json({
message: REQUEST_FETCHED_SUCCESSFULLY,
data: requests,
});
}

const { allRequests, next, prev, page } = requests;
if (allRequests.length === 0) {
return res.status(204).send();
Expand Down
11 changes: 11 additions & 0 deletions test/integration/requests.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,17 @@ describe("/requests OOO", function () {
});
});

it("should return the request by Id query", function (done) {
chai
.request(app)
.get(`/requests?id=${oooRequestId}`)
.end(function (err, res) {
expect(res).to.have.status(200);
expect(res.body.data.id === oooRequestId);
done();
});
});

it("should return all requests by specific user", function (done) {
chai
.request(app)
Expand Down

0 comments on commit 2db248c

Please sign in to comment.