Skip to content

Commit

Permalink
feat: fga-eps-mds/2020.2-Lend.it#138 Connect gateway with request fil…
Browse files Browse the repository at this point in the history
…ter available requests by category

Co-authored-by: Thais Reboucas <rotinasoftware@gmail.com>
Co-authored-by: Mateus Maia <mateusmaiamaia@hotmail.com>
Co-authored-by: Youssef Muhamad <emaildeyoussefmuhamad@gmail.com>
Co-authored-by: Vinicius Saturnino <viniciussaturnino78@gmail.com>
  • Loading branch information
5 people committed Apr 29, 2021
1 parent 0cc95b0 commit 618d3bd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
13 changes: 8 additions & 5 deletions src/microservices/Request.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,16 @@ async function getProductCategory(req, res) {
}

async function getFilteredByCategoryRequest(req, res) {
const response = await baseGet(
`${request}/requests/${req.params.categoryId}`
const { usermail } = req.query;
const response = await queryGet(
`${request}/requests/available/${req.params.categoryId}`,
{
usermail,
}
);
const requests = response.data.requests;
const { requests } = response.data;
const mergedUserWithRequest = await mergeUserDataFromRequest(requests);

res.json(mergedUserWithRequest);
res.status(200).json(mergedUserWithRequest);
}

async function createProductCategory(req, res) {
Expand Down
5 changes: 4 additions & 1 deletion src/routes/request.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ import Request from '../microservices/Request.js';
const requestRouter = Router();

requestRouter.get('/request', Request.getRequest);
requestRouter.get('/request/:categoryId', Request.getFilteredByCategoryRequest);
requestRouter.get(
'/request/available/:categoryId',
Request.getFilteredByCategoryRequest
);
requestRouter.post('/request', Request.createRequest);
requestRouter.put('/request/:id', Request.updateRequest);
requestRouter.delete('/request/:id', Request.deleteRequest);
Expand Down

0 comments on commit 618d3bd

Please # to comment.