Skip to content

Commit

Permalink
Add currentDay endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
Jneville0815 committed Jan 10, 2024
1 parent 2317e36 commit 3c6deb3
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
5 changes: 5 additions & 0 deletions models/User.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ const UserSchema = mongoose.Schema({
},
},
fitness: {
currentDay: {
type: Number,
required: false,
default: 0,
},
benchMax: {
type: Number,
required: false,
Expand Down
25 changes: 24 additions & 1 deletion routes/userInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ router.get('/:id/emailAndName', verify, async (req, res) => {
router.get('/:id/fitness', verify, async (req, res) => {
const user = await User.findOne({ _id: req.params.id })

res.send(user.fitness)
res.send({
benchMax: user.fitness.benchMax,
deadliftMax: user.fitness.deadliftMax,
squatMax: user.fitness.squatMax,
pressMax: user.fitness.pressMax
})
})

router.post('/:id/fitness', verify, async (req, res) => {
Expand All @@ -45,6 +50,24 @@ router.post('/:id/fitness', verify, async (req, res) => {
}
})

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

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

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

try {
user.fitness.currentDay = req.body.currentDay
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 3c6deb3

Please sign in to comment.