Skip to content

Commit

Permalink
Merge pull request #3 from open-source-at-illinois/Attempt2forProblem
Browse files Browse the repository at this point in the history
Updated events.ts file to showcase only active or inactive events.
  • Loading branch information
xuxey authored Oct 16, 2022
2 parents ebab9aa + 9b7531b commit 7abd11c
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/routes/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,18 @@ router.use((_req, _res, next) => {

// define the home page route
router.get('/', async (_req, res) => {
const events = await Event.find({});
let isActive: any|undefined = _req.query.active;

let events;

if(isActive !== undefined) {
events = await Event.find({
active: (isActive.toLowerCase() === 'true'),
})
} else {
events = await Event.find({});
}

res.send(events.map(toMaskedEvent));
});

Expand Down

0 comments on commit 7abd11c

Please sign in to comment.