diff --git a/server/routers/dry-wash/order.js b/server/routers/dry-wash/order.js index f93edc3..872d3c1 100644 --- a/server/routers/dry-wash/order.js +++ b/server/routers/dry-wash/order.js @@ -74,7 +74,7 @@ const VALIDATION_MESSAGES = { }, } -router.post('/create', async (req, res) => { +const createOrder = async (req, res) => { const bodyErrors = [] const { customer } = req.body @@ -134,9 +134,9 @@ router.post('/create', async (req, res) => { }) res.status(200).send({ success: true, body: order }) -}) +} -router.get('/:id', async (req, res) => { +const getOrder = async (req, res) => { const { id } = req.params if (!mongoose.Types.ObjectId.isValid(id)) { throw new Error(VALIDATION_MESSAGES.orderId.invalid) @@ -148,9 +148,9 @@ router.get('/:id', async (req, res) => { } res.status(200).send({ success: true, body: order }) -}) +} -router.patch('/:id', async (req, res) => { +const updateOrder = async (req, res) => { const { id } = req.params if (!mongoose.Types.ObjectId.isValid(id)) { throw new Error(VALIDATION_MESSAGES.orderId.invalid) @@ -210,9 +210,9 @@ router.patch('/:id', async (req, res) => { } res.status(200).send({ success: true, body: order }) -}) +} -router.delete('/:id', async (req, res) => { +const deleteOrder = async (req, res) => { const { id } = req.params if (!mongoose.Types.ObjectId.isValid(id)) { throw new Error(VALIDATION_MESSAGES.orderId.invalid) @@ -225,6 +225,11 @@ router.delete('/:id', async (req, res) => { throw new Error(VALIDATION_MESSAGES.order.notFound) } res.status(200).send({ success: true, body: order }) -}) +} + +router.post('/create', createOrder) +router.get('/:id', getOrder) +router.patch('/:id', updateOrder) +router.delete('/:id', deleteOrder) module.exports = router \ No newline at end of file