Feat(orders,utils, cart): orders get endpoints and cart totals (#7010)

This commit is contained in:
Carlos R. L. Rodrigues authored and GitHub committed 2024-04-22 09:01:18 +00:00
1 parent 89143e1032
commit cc557c8752
23 files changed
+2411 -30

No files matched your search

@@ -0,0 +1,27 @@
import {
ContainerRegistrationKeys,
remoteQueryObjectFromString,
} from "@medusajs/utils"
import { MedusaRequest, MedusaResponse } from "../../../types/routing"
export const GET = async (req: MedusaRequest, res: MedusaResponse) => {
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
const queryObject = remoteQueryObjectFromString({
entryPoint: "order",
variables: {
filters: req.filterableFields,
...req.remoteQueryConfig.pagination,
},
fields: req.remoteQueryConfig.fields,
})
const { rows: orders, metadata } = await remoteQuery(queryObject)
res.json({
orders,
count: metadata.count,
offset: metadata.skip,
limit: metadata.take,
})
}