Created
August 16, 2017 19:58
-
-
Save MadaraUchiha/eb13b3c29b26e7f53a1d849beaf0ddd0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export async function reserve(req, res) { | |
try { | |
const locker = await Locker.find({ | |
where: { | |
_id: req.params.id | |
} | |
}); | |
await handleEntityNotFound(res, true)(locker); | |
const reservation = req.body.reservation || {}; | |
if (!reservation.tmpToken) { | |
reservation.tmpToken = req.cookies.tmpToken; | |
} | |
const canDoReservation = await checkCanDoReservation({ locker, reservation }); | |
const { tmpToken } = await doReserving(canDoReservation); | |
res.cookie('tmpToken', tmpToken, { maxAge: 600000, httpOnly: true }); | |
return await respondWithResult(res)({ tmpToken }); | |
} catch (e) { | |
return await handleError(res, 204); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment