feat(medusa): Order preview endpoint (#8144)

* feat: Add order preview endpoint

* remove log

* add test

* add note
This commit is contained in:
Oli Juhl
2024-07-16 12:42:02 +01:00
committed by GitHub
parent 7123f9ff63
commit 4024935e91
4 changed files with 96 additions and 4 deletions
@@ -0,0 +1,19 @@
import { ModuleRegistrationName } from "@medusajs/utils"
import {
AuthenticatedMedusaRequest,
MedusaResponse,
} from "../../../../../types/routing"
export const GET = async (
req: AuthenticatedMedusaRequest,
res: MedusaResponse
) => {
const { id } = req.params
// NOTE: Consider replacing with remoteQuery when possible
const orderModuleService = req.scope.resolve(ModuleRegistrationName.ORDER)
const order = await orderModuleService.previewOrderChange(id)
res.status(200).json({ order })
}
@@ -33,6 +33,16 @@ export const adminOrderRoutesMiddlewares: MiddlewareRoute[] = [
),
],
},
{
method: ["GET"],
matcher: "/admin/orders/:id/preview",
middlewares: [
validateAndTransformQuery(
AdminGetOrdersOrderParams,
QueryConfig.retrieveTransformQueryConfig
),
],
},
{
method: ["POST"],
matcher: "/admin/orders/:id/archive",