Created
July 2, 2023 17:45
-
-
Save christopherbauer/b53c6fe20319e0e0109ad23c035ed545 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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