fix(medusa): Apply middleware to GET customers/:id/addresses/:address_id (#11788)

This commit is contained in:
Kasper Fabricius Kristensen
2025-03-10 11:31:19 +00:00
committed by GitHub
parent 4c28efaadc
commit 90964a404e
3 changed files with 22 additions and 1 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"@medusajs/medusa": patch
---
fix(medusa): Apply middleware to GET customers/:id/addresses/:address_id
@@ -4,17 +4,18 @@ import {
AdminCreateCustomer, AdminCreateCustomer,
AdminCreateCustomerAddress, AdminCreateCustomerAddress,
AdminCustomerAddressesParams, AdminCustomerAddressesParams,
AdminCustomerAddressParams,
AdminCustomerParams, AdminCustomerParams,
AdminCustomersParams, AdminCustomersParams,
AdminUpdateCustomer, AdminUpdateCustomer,
AdminUpdateCustomerAddress, AdminUpdateCustomerAddress,
} from "./validators" } from "./validators"
import { MiddlewareRoute } from "@medusajs/framework/http"
import { import {
validateAndTransformBody, validateAndTransformBody,
validateAndTransformQuery, validateAndTransformQuery,
} from "@medusajs/framework" } from "@medusajs/framework"
import { MiddlewareRoute } from "@medusajs/framework/http"
import { createLinkBody } from "../../utils/validators" import { createLinkBody } from "../../utils/validators"
export const adminCustomerRoutesMiddlewares: MiddlewareRoute[] = [ export const adminCustomerRoutesMiddlewares: MiddlewareRoute[] = [
@@ -71,6 +72,16 @@ export const adminCustomerRoutesMiddlewares: MiddlewareRoute[] = [
), ),
], ],
}, },
{
method: ["GET"],
matcher: "/admin/customers/:id/addresses/:address_id",
middlewares: [
validateAndTransformQuery(
AdminCustomerAddressParams,
QueryConfig.retrieveTransformQueryConfig
),
],
},
{ {
method: ["POST"], method: ["POST"],
matcher: "/admin/customers/:id/addresses/:address_id", matcher: "/admin/customers/:id/addresses/:address_id",
@@ -90,6 +90,8 @@ export const AdminCreateCustomerAddress = WithAdditionalData(
export const AdminUpdateCustomerAddress = AdminCreateCustomerAddress export const AdminUpdateCustomerAddress = AdminCreateCustomerAddress
export const AdminCustomerAddressParams = createSelectParams()
export const AdminCustomerAddressesParams = createFindParams({ export const AdminCustomerAddressesParams = createFindParams({
offset: 0, offset: 0,
limit: 50, limit: 50,
@@ -108,6 +110,9 @@ export type AdminCustomerParamsType = z.infer<typeof AdminCustomerParams>
export type AdminCustomersParamsType = z.infer<typeof AdminCustomersParams> export type AdminCustomersParamsType = z.infer<typeof AdminCustomersParams>
export type AdminCreateCustomerType = z.infer<typeof CreateCustomer> export type AdminCreateCustomerType = z.infer<typeof CreateCustomer>
export type AdminUpdateCustomerType = z.infer<typeof UpdateCustomer> export type AdminUpdateCustomerType = z.infer<typeof UpdateCustomer>
export type AdminCustomerAddressParamsType = z.infer<
typeof AdminCustomerAddressParams
>
export type AdminCreateCustomerAddressType = z.infer< export type AdminCreateCustomerAddressType = z.infer<
typeof CreateCustomerAddress typeof CreateCustomerAddress
> >