Skip to content
This repository has been archived by the owner on Sep 15, 2024. It is now read-only.

Commit

Permalink
feat: accept comma-separated status for loans
Browse files Browse the repository at this point in the history
  • Loading branch information
Dwigoric committed Nov 24, 2023
1 parent f45e688 commit 1ab221c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/routes/loans.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,15 @@ router.get('/user/:username', async (req, res, next) => {
}

const options = { username, deleted: false }
if (['approved', 'pending', 'rejected'].includes(req.query.status))

const { status } = req.query
if (
status
.split(',')
.some((s) =>
['pending', 'approved', 'released', 'rejected', 'complete'].includes(s)
)
)
options.status = req.query.status

const loans = await Loan.find(options).select('-__v -_id').lean()
Expand Down

0 comments on commit 1ab221c

Please sign in to comment.