Skip to content

Commit

Permalink
User stories
Browse files Browse the repository at this point in the history
  • Loading branch information
Brad Traversy authored and Brad Traversy committed Jun 19, 2020
1 parent 96be737 commit a8e2e89
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions routes/stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,24 @@ router.delete('/:id', ensureAuth, async (req, res) => {
}
})

// @desc User stories
// @route GET /stories/user/:userId
router.get('/user/:userId', ensureAuth, async (req, res) => {
try {
const stories = await Story.find({
user: req.params.userId,
status: 'public',
})
.populate('user')
.lean()

res.render('stories/index', {
stories,
})
} catch (err) {
console.error(err)
res.render('error/500')
}
})

module.exports = router

0 comments on commit a8e2e89

Please sign in to comment.