Administering orders
Now that the product features are in place, it is time to turn to the order data. Add a file named admin_order_routes.ts
to the src/routes/admin
folder with the content shown in Listing 20.36.
Listing 20.36: The contents of the admin_order_routes.ts file in the src/routes/admin folder
import { Router } from "express";
import { AddressModel, OrderModel, ProductSelectionModel }
from "../../data/orm/models/order_models";
import { CustomerModel } from "../../data/orm/models/customer_models";
import { ProductModel } from "../../data/orm/models";
export const createAdminOrderRoutes = (router: Router) => {
router.get("/table", async (req, resp) => {
const orders = (await OrderModel.findAll({
include: [
{ model: CustomerModel, as: "customer"},
{ model: AddressModel, as: "address"},
{ model: ProductSelectionModel...