Skip to content

Instantly share code, notes, and snippets.

@christopherbauer
Created July 2, 2023 17:45
Show Gist options
  • Save christopherbauer/b53c6fe20319e0e0109ad23c035ed545 to your computer and use it in GitHub Desktop.
Save christopherbauer/b53c6fe20319e0e0109ad23c035ed545 to your computer and use it in GitHub Desktop.
import express, { Request } from "express";
import orderRepository from "../data";
const itemRouter = express.Router();
itemRouter
.route("/:id/item")
.post(async (req: Request<{ id: string }, {}, { product_id: number; quantity: number }, {}>, res) => {
const { body, params } = req;
const { product_id, quantity } = body;
const { id } = params;
const order = orderRepository.addOrderItem(Number(id), product_id, quantity);
res.status(200).send(order);
});
export default itemRouter;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment