diff --git a/.changeset/gorgeous-rats-watch.md b/.changeset/gorgeous-rats-watch.md new file mode 100644 index 0000000000..3565235eda --- /dev/null +++ b/.changeset/gorgeous-rats-watch.md @@ -0,0 +1,5 @@ +--- +"@medusajs/medusa": patch +--- + +fix(medusa): Apply middleware to GET customers/:id/addresses/:address_id diff --git a/packages/medusa/src/api/admin/customers/middlewares.ts b/packages/medusa/src/api/admin/customers/middlewares.ts index 525f971ae8..0e8999a9ff 100644 --- a/packages/medusa/src/api/admin/customers/middlewares.ts +++ b/packages/medusa/src/api/admin/customers/middlewares.ts @@ -4,17 +4,18 @@ import { AdminCreateCustomer, AdminCreateCustomerAddress, AdminCustomerAddressesParams, + AdminCustomerAddressParams, AdminCustomerParams, AdminCustomersParams, AdminUpdateCustomer, AdminUpdateCustomerAddress, } from "./validators" -import { MiddlewareRoute } from "@medusajs/framework/http" import { validateAndTransformBody, validateAndTransformQuery, } from "@medusajs/framework" +import { MiddlewareRoute } from "@medusajs/framework/http" import { createLinkBody } from "../../utils/validators" 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"], matcher: "/admin/customers/:id/addresses/:address_id", diff --git a/packages/medusa/src/api/admin/customers/validators.ts b/packages/medusa/src/api/admin/customers/validators.ts index bbfef44a06..a7121a9ba2 100644 --- a/packages/medusa/src/api/admin/customers/validators.ts +++ b/packages/medusa/src/api/admin/customers/validators.ts @@ -90,6 +90,8 @@ export const AdminCreateCustomerAddress = WithAdditionalData( export const AdminUpdateCustomerAddress = AdminCreateCustomerAddress +export const AdminCustomerAddressParams = createSelectParams() + export const AdminCustomerAddressesParams = createFindParams({ offset: 0, limit: 50, @@ -108,6 +110,9 @@ export type AdminCustomerParamsType = z.infer export type AdminCustomersParamsType = z.infer export type AdminCreateCustomerType = z.infer export type AdminUpdateCustomerType = z.infer +export type AdminCustomerAddressParamsType = z.infer< + typeof AdminCustomerAddressParams +> export type AdminCreateCustomerAddressType = z.infer< typeof CreateCustomerAddress >