chore(medusa,types): [4] Add request types to API routes (#8561)
This commit is contained in:
1 parent
578e5182dd
commit
078c2df773
27 files changed
+143
-19
No files matched your search
@@ -7,10 +7,11 @@ import {
|
||||
wrapProductsWithTaxPrices,
|
||||
} from "../helpers"
|
||||
import { StoreGetProductParamsType } from "../validators"
|
||||
import { HttpTypes } from "@medusajs/types"
|
||||
|
||||
export const GET = async (
|
||||
req: RequestWithContext<StoreGetProductParamsType>,
|
||||
res: MedusaResponse
|
||||
res: MedusaResponse<HttpTypes.StoreProductResponse>
|
||||
) => {
|
||||
const withInventoryQuantity = req.remoteQueryConfig.fields.some((field) =>
|
||||
field.includes("variants.inventory_quantity")
|
||||
|
||||
@@ -7,10 +7,11 @@ import { MedusaResponse } from "../../../types/routing"
|
||||
import { wrapVariantsWithInventoryQuantity } from "../../utils/middlewares"
|
||||
import { StoreGetProductsParamsType } from "./validators"
|
||||
import { RequestWithContext, wrapProductsWithTaxPrices } from "./helpers"
|
||||
import { HttpTypes } from "@medusajs/types"
|
||||
|
||||
export const GET = async (
|
||||
req: RequestWithContext<StoreGetProductsParamsType>,
|
||||
res: MedusaResponse
|
||||
res: MedusaResponse<HttpTypes.StoreProductListResponse>
|
||||
) => {
|
||||
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
|
||||
const context: object = {}
|
||||
|
||||
@@ -4,8 +4,12 @@ import {
|
||||
remoteQueryObjectFromString,
|
||||
} from "@medusajs/utils"
|
||||
import { MedusaRequest, MedusaResponse } from "../../../../types/routing"
|
||||
import { HttpTypes } from "@medusajs/types"
|
||||
|
||||
export const GET = async (req: MedusaRequest, res: MedusaResponse) => {
|
||||
export const GET = async (
|
||||
req: MedusaRequest,
|
||||
res: MedusaResponse<HttpTypes.StoreRegionResponse>
|
||||
) => {
|
||||
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
|
||||
const queryObject = remoteQueryObjectFromString({
|
||||
entryPoint: "region",
|
||||
|
||||
@@ -3,8 +3,12 @@ import {
|
||||
remoteQueryObjectFromString,
|
||||
} from "@medusajs/utils"
|
||||
import { MedusaRequest, MedusaResponse } from "../../../types/routing"
|
||||
import { HttpTypes } from "@medusajs/types"
|
||||
|
||||
export const GET = async (req: MedusaRequest, res: MedusaResponse) => {
|
||||
export const GET = async (
|
||||
req: MedusaRequest,
|
||||
res: MedusaResponse<HttpTypes.StoreRegionListResponse>
|
||||
) => {
|
||||
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
|
||||
|
||||
const queryObject = remoteQueryObjectFromString({
|
||||
|
||||
@@ -4,10 +4,11 @@ import {
|
||||
} from "@medusajs/utils"
|
||||
import { MedusaRequest, MedusaResponse } from "../../../../types/routing"
|
||||
import { StoreReturnReasonParamsType } from "../validators"
|
||||
import { HttpTypes } from "@medusajs/types"
|
||||
|
||||
export const GET = async (
|
||||
req: MedusaRequest<StoreReturnReasonParamsType>,
|
||||
res: MedusaResponse
|
||||
res: MedusaResponse<HttpTypes.StoreReturnReasonResponse>
|
||||
) => {
|
||||
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
|
||||
|
||||
|
||||
@@ -3,8 +3,12 @@ import {
|
||||
remoteQueryObjectFromString,
|
||||
} from "@medusajs/utils"
|
||||
import { MedusaRequest, MedusaResponse } from "../../../types/routing"
|
||||
import { HttpTypes } from "@medusajs/types"
|
||||
|
||||
export const GET = async (req: MedusaRequest, res: MedusaResponse) => {
|
||||
export const GET = async (
|
||||
req: MedusaRequest,
|
||||
res: MedusaResponse<HttpTypes.StoreReturnReasonListResponse>
|
||||
) => {
|
||||
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
|
||||
|
||||
const queryObject = remoteQueryObjectFromString({
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import { createAndCompleteReturnOrderWorkflow } from "@medusajs/core-flows"
|
||||
import { MedusaRequest, MedusaResponse } from "../../../types/routing"
|
||||
import { StorePostReturnsReqSchemaType } from "./validators"
|
||||
import { HttpTypes } from "@medusajs/types"
|
||||
|
||||
export const POST = async (
|
||||
req: MedusaRequest<StorePostReturnsReqSchemaType>,
|
||||
res: MedusaResponse
|
||||
res: MedusaResponse<HttpTypes.StoreReturnResponse>
|
||||
) => {
|
||||
const input = req.validatedBody as StorePostReturnsReqSchemaType
|
||||
|
||||
@@ -13,5 +14,5 @@ export const POST = async (
|
||||
input,
|
||||
})
|
||||
|
||||
res.status(200).json({ return: result })
|
||||
res.status(200).json({ return: result as HttpTypes.StoreReturn })
|
||||
}
|
||||
@@ -1,9 +1,12 @@
|
||||
import { listShippingOptionsForCartWorkflow } from "@medusajs/core-flows"
|
||||
import { ICartModuleService } from "@medusajs/types"
|
||||
import { HttpTypes, ICartModuleService } from "@medusajs/types"
|
||||
import { MedusaError, ModuleRegistrationName } from "@medusajs/utils"
|
||||
import { MedusaRequest, MedusaResponse } from "../../../types/routing"
|
||||
|
||||
export const GET = async (req: MedusaRequest, res: MedusaResponse) => {
|
||||
export const GET = async (
|
||||
req: MedusaRequest,
|
||||
res: MedusaResponse<HttpTypes.StoreShippingOptionListResponse>
|
||||
) => {
|
||||
const { cart_id } = req.filterableFields as { cart_id: string }
|
||||
if (!cart_id) {
|
||||
throw new MedusaError(
|
||||
|
||||
Reference in new issue
Block a user