forked from medusajs/medusa
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Chore/finish migration zod (medusajs#7098)
* chore: Finish migrating all http endpoints to zod * chore: Final changes to fully migrate to zod in the HTTP layer
- Loading branch information
Showing
48 changed files
with
839 additions
and
985 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
28 changes: 14 additions & 14 deletions
28
packages/medusa/src/api-v2/admin/draft-orders/[id]/route.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,21 @@ | ||
import { | ||
ContainerRegistrationKeys, | ||
remoteQueryObjectFromString, | ||
} from "@medusajs/utils" | ||
import { MedusaError } from "@medusajs/utils" | ||
import { MedusaRequest, MedusaResponse } from "../../../../types/routing" | ||
import { refetchOrder } from "../helpers" | ||
import { defaultAdminOrderFields } from "../query-config" | ||
|
||
export const GET = async (req: MedusaRequest, res: MedusaResponse) => { | ||
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY) | ||
const draftOrder = await refetchOrder( | ||
req.params.id, | ||
req.scope, | ||
defaultAdminOrderFields | ||
) | ||
|
||
const variables = { id: req.params.id } | ||
if (!draftOrder) { | ||
throw new MedusaError( | ||
MedusaError.Types.NOT_FOUND, | ||
`Draft order with id: ${req.params.id} was not found` | ||
) | ||
} | ||
|
||
const queryObject = remoteQueryObjectFromString({ | ||
entryPoint: "order", | ||
variables, | ||
fields: defaultAdminOrderFields, | ||
}) | ||
|
||
const [draft_order] = await remoteQuery(queryObject) | ||
res.status(200).json({ draft_order }) | ||
res.status(200).json({ draft_order: draftOrder }) | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { MedusaContainer } from "@medusajs/types" | ||
import { | ||
ContainerRegistrationKeys, | ||
remoteQueryObjectFromString, | ||
} from "@medusajs/utils" | ||
|
||
export const refetchOrder = async ( | ||
orderId: string, | ||
scope: MedusaContainer, | ||
fields: string[] | ||
) => { | ||
const remoteQuery = scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY) | ||
const queryObject = remoteQueryObjectFromString({ | ||
entryPoint: "order", | ||
variables: { | ||
filters: { id: orderId }, | ||
}, | ||
fields: fields, | ||
}) | ||
|
||
const orders = await remoteQuery(queryObject) | ||
return orders[0] | ||
} |
This file contains 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
This file contains 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
Oops, something went wrong.