chore(medusa): default endpoints size limit (#9616)
This commit is contained in:
@@ -1,9 +1,11 @@
|
|||||||
import * as QueryConfig from "./query-config"
|
|
||||||
import { MiddlewareRoute, unlessPath } from "@medusajs/framework/http"
|
|
||||||
import {
|
import {
|
||||||
validateAndTransformBody,
|
validateAndTransformBody,
|
||||||
validateAndTransformQuery,
|
validateAndTransformQuery,
|
||||||
} from "@medusajs/framework"
|
} from "@medusajs/framework"
|
||||||
|
import { MiddlewareRoute, unlessPath } from "@medusajs/framework/http"
|
||||||
|
import { DEFAULT_BATCH_ENDPOINTS_SIZE_LIMIT } from "../../../utils/middlewares"
|
||||||
|
import { createBatchBody } from "../../utils/validators"
|
||||||
|
import * as QueryConfig from "./query-config"
|
||||||
import {
|
import {
|
||||||
AdminCreateInventoryItem,
|
AdminCreateInventoryItem,
|
||||||
AdminCreateInventoryLocationLevel,
|
AdminCreateInventoryLocationLevel,
|
||||||
@@ -14,7 +16,6 @@ import {
|
|||||||
AdminUpdateInventoryItem,
|
AdminUpdateInventoryItem,
|
||||||
AdminUpdateInventoryLocationLevel,
|
AdminUpdateInventoryLocationLevel,
|
||||||
} from "./validators"
|
} from "./validators"
|
||||||
import { createBatchBody } from "../../utils/validators"
|
|
||||||
|
|
||||||
export const adminInventoryRoutesMiddlewares: MiddlewareRoute[] = [
|
export const adminInventoryRoutesMiddlewares: MiddlewareRoute[] = [
|
||||||
{
|
{
|
||||||
@@ -83,6 +84,9 @@ export const adminInventoryRoutesMiddlewares: MiddlewareRoute[] = [
|
|||||||
{
|
{
|
||||||
method: ["POST"],
|
method: ["POST"],
|
||||||
matcher: "/admin/inventory-items/:id/location-levels/batch",
|
matcher: "/admin/inventory-items/:id/location-levels/batch",
|
||||||
|
bodyParser: {
|
||||||
|
sizeLimit: DEFAULT_BATCH_ENDPOINTS_SIZE_LIMIT,
|
||||||
|
},
|
||||||
middlewares: [
|
middlewares: [
|
||||||
validateAndTransformBody(
|
validateAndTransformBody(
|
||||||
createBatchBody(
|
createBatchBody(
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
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 { DEFAULT_BATCH_ENDPOINTS_SIZE_LIMIT } from "../../../utils/middlewares"
|
||||||
import { createBatchBody } from "../../utils/validators"
|
import { createBatchBody } from "../../utils/validators"
|
||||||
import * as QueryConfig from "./query-config"
|
import * as QueryConfig from "./query-config"
|
||||||
import {
|
import {
|
||||||
@@ -73,6 +74,9 @@ export const adminPriceListsRoutesMiddlewares: MiddlewareRoute[] = [
|
|||||||
{
|
{
|
||||||
method: ["POST"],
|
method: ["POST"],
|
||||||
matcher: "/admin/price-lists/:id/prices/batch",
|
matcher: "/admin/price-lists/:id/prices/batch",
|
||||||
|
bodyParser: {
|
||||||
|
sizeLimit: DEFAULT_BATCH_ENDPOINTS_SIZE_LIMIT,
|
||||||
|
},
|
||||||
middlewares: [
|
middlewares: [
|
||||||
validateAndTransformBody(
|
validateAndTransformBody(
|
||||||
createBatchBody(AdminCreatePriceListPrice, AdminUpdatePriceListPrice)
|
createBatchBody(AdminCreatePriceListPrice, AdminUpdatePriceListPrice)
|
||||||
|
|||||||
@@ -1,12 +1,14 @@
|
|||||||
|
import {
|
||||||
|
validateAndTransformBody,
|
||||||
|
validateAndTransformQuery,
|
||||||
|
} from "@medusajs/framework"
|
||||||
import {
|
import {
|
||||||
maybeApplyLinkFilter,
|
maybeApplyLinkFilter,
|
||||||
MiddlewareRoute,
|
MiddlewareRoute,
|
||||||
unlessPath,
|
unlessPath,
|
||||||
} from "@medusajs/framework/http"
|
} from "@medusajs/framework/http"
|
||||||
import {
|
import multer from "multer"
|
||||||
validateAndTransformBody,
|
import { DEFAULT_BATCH_ENDPOINTS_SIZE_LIMIT } from "../../../utils/middlewares"
|
||||||
validateAndTransformQuery,
|
|
||||||
} from "@medusajs/framework"
|
|
||||||
import { createBatchBody } from "../../utils/validators"
|
import { createBatchBody } from "../../utils/validators"
|
||||||
import * as QueryConfig from "./query-config"
|
import * as QueryConfig from "./query-config"
|
||||||
import { maybeApplyPriceListsFilter } from "./utils"
|
import { maybeApplyPriceListsFilter } from "./utils"
|
||||||
@@ -33,7 +35,6 @@ import {
|
|||||||
CreateProduct,
|
CreateProduct,
|
||||||
CreateProductVariant,
|
CreateProductVariant,
|
||||||
} from "./validators"
|
} from "./validators"
|
||||||
import multer from "multer"
|
|
||||||
|
|
||||||
// TODO: For now we keep the files in memory, as that's how they get passed to the workflows
|
// TODO: For now we keep the files in memory, as that's how they get passed to the workflows
|
||||||
// This will need revisiting once we are closer to prod-ready v2, since with workflows and potentially
|
// This will need revisiting once we are closer to prod-ready v2, since with workflows and potentially
|
||||||
@@ -71,6 +72,9 @@ export const adminProductRoutesMiddlewares: MiddlewareRoute[] = [
|
|||||||
{
|
{
|
||||||
method: ["POST"],
|
method: ["POST"],
|
||||||
matcher: "/admin/products/batch",
|
matcher: "/admin/products/batch",
|
||||||
|
bodyParser: {
|
||||||
|
sizeLimit: DEFAULT_BATCH_ENDPOINTS_SIZE_LIMIT,
|
||||||
|
},
|
||||||
middlewares: [
|
middlewares: [
|
||||||
validateAndTransformBody(
|
validateAndTransformBody(
|
||||||
createBatchBody(CreateProduct, AdminBatchUpdateProduct)
|
createBatchBody(CreateProduct, AdminBatchUpdateProduct)
|
||||||
@@ -168,6 +172,9 @@ export const adminProductRoutesMiddlewares: MiddlewareRoute[] = [
|
|||||||
{
|
{
|
||||||
method: ["POST"],
|
method: ["POST"],
|
||||||
matcher: "/admin/products/:id/variants/batch",
|
matcher: "/admin/products/:id/variants/batch",
|
||||||
|
bodyParser: {
|
||||||
|
sizeLimit: DEFAULT_BATCH_ENDPOINTS_SIZE_LIMIT,
|
||||||
|
},
|
||||||
middlewares: [
|
middlewares: [
|
||||||
validateAndTransformBody(
|
validateAndTransformBody(
|
||||||
createBatchBody(CreateProductVariant, AdminBatchUpdateProductVariant)
|
createBatchBody(CreateProductVariant, AdminBatchUpdateProductVariant)
|
||||||
@@ -282,6 +289,9 @@ export const adminProductRoutesMiddlewares: MiddlewareRoute[] = [
|
|||||||
{
|
{
|
||||||
method: ["POST"],
|
method: ["POST"],
|
||||||
matcher: "/admin/products/:id/variants/inventory-items/batch",
|
matcher: "/admin/products/:id/variants/inventory-items/batch",
|
||||||
|
bodyParser: {
|
||||||
|
sizeLimit: DEFAULT_BATCH_ENDPOINTS_SIZE_LIMIT,
|
||||||
|
},
|
||||||
middlewares: [
|
middlewares: [
|
||||||
validateAndTransformBody(
|
validateAndTransformBody(
|
||||||
createBatchBody(
|
createBatchBody(
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
import { MiddlewareRoute, unlessPath } from "@medusajs/framework/http"
|
|
||||||
import {
|
import {
|
||||||
validateAndTransformBody,
|
validateAndTransformBody,
|
||||||
validateAndTransformQuery,
|
validateAndTransformQuery,
|
||||||
} from "@medusajs/framework"
|
} from "@medusajs/framework"
|
||||||
|
import { MiddlewareRoute, unlessPath } from "@medusajs/framework/http"
|
||||||
|
import { DEFAULT_BATCH_ENDPOINTS_SIZE_LIMIT } from "../../../utils/middlewares"
|
||||||
import { createBatchBody } from "../../utils/validators"
|
import { createBatchBody } from "../../utils/validators"
|
||||||
import * as QueryConfig from "./query-config"
|
import * as QueryConfig from "./query-config"
|
||||||
import {
|
import {
|
||||||
@@ -76,6 +77,9 @@ export const adminPromotionRoutesMiddlewares: MiddlewareRoute[] = [
|
|||||||
{
|
{
|
||||||
method: ["POST"],
|
method: ["POST"],
|
||||||
matcher: "/admin/promotions/:id/rules/batch",
|
matcher: "/admin/promotions/:id/rules/batch",
|
||||||
|
bodyParser: {
|
||||||
|
sizeLimit: DEFAULT_BATCH_ENDPOINTS_SIZE_LIMIT,
|
||||||
|
},
|
||||||
middlewares: [
|
middlewares: [
|
||||||
validateAndTransformBody(
|
validateAndTransformBody(
|
||||||
createBatchBody(AdminCreatePromotionRule, AdminUpdatePromotionRule)
|
createBatchBody(AdminCreatePromotionRule, AdminUpdatePromotionRule)
|
||||||
@@ -89,6 +93,9 @@ export const adminPromotionRoutesMiddlewares: MiddlewareRoute[] = [
|
|||||||
{
|
{
|
||||||
method: ["POST"],
|
method: ["POST"],
|
||||||
matcher: "/admin/promotions/:id/target-rules/batch",
|
matcher: "/admin/promotions/:id/target-rules/batch",
|
||||||
|
bodyParser: {
|
||||||
|
sizeLimit: DEFAULT_BATCH_ENDPOINTS_SIZE_LIMIT,
|
||||||
|
},
|
||||||
middlewares: [
|
middlewares: [
|
||||||
validateAndTransformBody(
|
validateAndTransformBody(
|
||||||
createBatchBody(AdminCreatePromotionRule, AdminUpdatePromotionRule)
|
createBatchBody(AdminCreatePromotionRule, AdminUpdatePromotionRule)
|
||||||
@@ -102,6 +109,9 @@ export const adminPromotionRoutesMiddlewares: MiddlewareRoute[] = [
|
|||||||
{
|
{
|
||||||
method: ["POST"],
|
method: ["POST"],
|
||||||
matcher: "/admin/promotions/:id/buy-rules/batch",
|
matcher: "/admin/promotions/:id/buy-rules/batch",
|
||||||
|
bodyParser: {
|
||||||
|
sizeLimit: DEFAULT_BATCH_ENDPOINTS_SIZE_LIMIT,
|
||||||
|
},
|
||||||
middlewares: [
|
middlewares: [
|
||||||
validateAndTransformBody(
|
validateAndTransformBody(
|
||||||
createBatchBody(AdminCreatePromotionRule, AdminUpdatePromotionRule)
|
createBatchBody(AdminCreatePromotionRule, AdminUpdatePromotionRule)
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
import { maybeApplyLinkFilter, MiddlewareRoute } from "@medusajs/framework/http"
|
|
||||||
import {
|
import {
|
||||||
validateAndTransformBody,
|
validateAndTransformBody,
|
||||||
validateAndTransformQuery,
|
validateAndTransformQuery,
|
||||||
} from "@medusajs/framework"
|
} from "@medusajs/framework"
|
||||||
|
import { maybeApplyLinkFilter, MiddlewareRoute } from "@medusajs/framework/http"
|
||||||
|
import { DEFAULT_BATCH_ENDPOINTS_SIZE_LIMIT } from "../../../utils/middlewares"
|
||||||
import { createBatchBody } from "../../utils/validators"
|
import { createBatchBody } from "../../utils/validators"
|
||||||
import {
|
import {
|
||||||
listTransformQueryConfig,
|
listTransformQueryConfig,
|
||||||
@@ -75,6 +76,9 @@ export const adminShippingOptionRoutesMiddlewares: MiddlewareRoute[] = [
|
|||||||
{
|
{
|
||||||
method: ["POST"],
|
method: ["POST"],
|
||||||
matcher: "/admin/shipping-options/:id/rules/batch",
|
matcher: "/admin/shipping-options/:id/rules/batch",
|
||||||
|
bodyParser: {
|
||||||
|
sizeLimit: DEFAULT_BATCH_ENDPOINTS_SIZE_LIMIT,
|
||||||
|
},
|
||||||
middlewares: [
|
middlewares: [
|
||||||
validateAndTransformBody(
|
validateAndTransformBody(
|
||||||
createBatchBody(
|
createBatchBody(
|
||||||
|
|||||||
@@ -1,2 +1,4 @@
|
|||||||
export { authenticate } from "./authenticate-middleware"
|
export { authenticate } from "./authenticate-middleware"
|
||||||
export { errorHandler } from "./error-handler"
|
export { errorHandler } from "./error-handler"
|
||||||
|
|
||||||
|
export const DEFAULT_BATCH_ENDPOINTS_SIZE_LIMIT = "2mb"
|
||||||
|
|||||||
Reference in New Issue
Block a user