crabfit/crabfit-backend/routes/getEvent.js
2021-02-27 00:52:20 +11:00

20 lines
336 B
JavaScript

module.exports = async (req, res) => {
const { eventId } = req.params;
try {
const event = (await req.datastore.get(req.datastore.key(['Event', eventId])))[0];
if (event) {
res.send({
id: eventId,
...event,
});
} else {
res.sendStatus(404);
}
} catch (e) {
console.error(e);
res.sendStatus(404);
}
};