All files / src/routes/orders_routes orders_getOrderById_get.js

85.71% Statements 6/7
83.33% Branches 5/6
100% Functions 1/1
83.33% Lines 5/6

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13          2x 2x 2x 2x 1x      
import OrdersControllers from "../../controllers/orders-controllers/OrdersControllers.js";
import asyncRouteHandler from "../../utilities/asyncRouteHandler.js";
 
export default asyncRouteHandler(
    async function orders_getOrderById_get(req, res) {
        const { userId, params: { orderId } } = req;
        if (userId && orderId) {
            const orders = await OrdersControllers.getOrders({ orderId, userId }, req.query)
            if (orders?.length) res.status(200).json(orders[0])
            else res.status(404).json(null)
        } else Eres.status(400).json()
    }
)