chore done endpoint

This commit is contained in:
2025-10-15 00:03:20 -05:00
parent 0e8a09682b
commit b809e647e8

View File

@@ -96,6 +96,33 @@ class Web {
});
});
app.post('/api/chores/:id', async (req, res) => {
const doer = req.body?.done_by;
const chore = req.params?.id;
if (typeof doer != 'number' || doer < 0) {
res.status(400).send({
error: 'done_by value is invalid.'
});
return;
}
if (typeof chore != 'number' || chore < 0) {
res.status(400).send({
error: 'chore id value is invalid.'
});
return;
}
try {
const resp = await this.grocy.doChore(chore, doer);
res.send(resp);
}
catch (err) {
console.error(err);
res.status(400).send({
error: 'grocy didn\'t like that.'
});
}
});
app.get('/api/users/:id', async (req, res) => {
const user = await this.grocy.user(parseInt(req.params.id))
res.send({