Skip to content

Commit

Permalink
Add notes endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
Jneville0815 committed Jan 17, 2024
1 parent 3c6deb3 commit aa96329
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
5 changes: 5 additions & 0 deletions models/User.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ const UserSchema = mongoose.Schema({
required: false,
default: 0,
},
note: {
type: String,
required: false,
default: "",
}
},
food: [
{
Expand Down
18 changes: 18 additions & 0 deletions routes/userInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,24 @@ router.post('/:id/fitness/currentDay', verify, async (req, res) => {
}
})

router.get('/:id/fitness/note', verify, async (req, res) => {
const user = await User.findOne({ _id: req.params.id })

res.send({note: user.fitness.note})
})

router.post('/:id/fitness/note', verify, async (req, res) => {
const user = await User.findOne({ _id: req.params.id })

try {
user.fitness.note = req.body.note
user.save()
res.send({ sent: true })
} catch (err) {
res.status(400).send(err)
}
})

router.post('/:id/addFood', verify, async (req, res) => {
const food = {
name: req.body.name,
Expand Down

0 comments on commit aa96329

Please sign in to comment.