MCPcopy Create free account
hub / github.com/dhatGuy/PERN-Store / createOrder

Function createOrder

server/controllers/orders.controller.js:4–22  ·  view source on GitHub ↗
(req, res)

Source from the content-addressed store, hash-verified

2const cartService = require("../services/cart.service");
3
4const createOrder = async (req, res) => {
5 const { amount, itemTotal, paymentMethod, ref } = req.body;
6 const userId = req.user.id;
7 const cartId = req.user.cart_id;
8
9 const newOrder = await orderService.createOrder({
10 cartId,
11 amount,
12 itemTotal,
13 userId,
14 paymentMethod,
15 ref,
16 });
17
18 // delete all items from cart_items table for the user after order has been processed
19 await cartService.emptyCart(cartId);
20
21 res.status(201).json(newOrder);
22};
23
24const getAllOrders = async (req, res) => {
25 const { page = 1 } = req.query;

Callers

nothing calls this directly

Calls 1

createOrderMethod · 0.80

Tested by

no test coverage detected