breaking: move shared HTTP utils to the framework (#9402)

Fixes: FRMW-2728, FRMW-2729

After this PR gets merged the following middleware will be exported from the `@medusajs/framework/http` import path.

- applyParamsAsFilters
- clearFiltersByKey
- applyDefaultFilters
- setContext
- getQueryConfig
- httpCompression
- maybeApplyLinkFilter
- refetchEntities
- unlessPath
- validateBody
- validateQuery

Co-authored-by: Adrien de Peretti <25098370+adrien2p@users.noreply.github.com>
This commit is contained in:
Harminder Virk
2024-10-03 09:42:00 +00:00
committed by GitHub
co-authored by Adrien de Peretti
parent 193f93464f
commit 48e00169d2
557 changed files with 2365 additions and 3499 deletions
@@ -10,13 +10,23 @@ import execa from "execa"
/**
* OAS output directory
*
*
* @privateRemarks
* This should be the only directory OAS is loaded from for Medusa V2.
* For now, we only use it if the --v2 flag it passed to the CLI tool.
*/
const oasOutputPath = path.resolve(
__dirname, "..", "..", "..", "..", "..", "..", "www", "utils", "generated", "oas-output"
__dirname,
"..",
"..",
"..",
"..",
"..",
"..",
"www",
"utils",
"generated",
"oas-output"
)
const basePath = path.resolve(__dirname, `../../`)
@@ -128,7 +138,13 @@ describe("command oas", () => {
beforeAll(async () => {
const outDir = path.resolve(tmpDir, uid())
await runCLI("oas", ["--type", "combined", "--out-dir", outDir, "--local"])
await runCLI("oas", [
"--type",
"combined",
"--out-dir",
outDir,
"--local",
])
const generatedFilePath = path.resolve(outDir, "combined.oas.json")
oas = (await readJson(generatedFilePath)) as OpenAPIObject
})
@@ -227,7 +243,7 @@ describe("command oas", () => {
outDir,
"--paths",
additionalPath,
"--local"
"--local",
])
const generatedFilePath = path.resolve(outDir, "store.oas.json")
oas = (await readJson(generatedFilePath)) as OpenAPIObject
@@ -363,7 +379,7 @@ components:
outDir,
"--base",
filePath,
"--local"
"--local",
])
const generatedFilePath = path.resolve(outDir, "store.oas.json")
oas = (await readJson(generatedFilePath)) as OpenAPIObject
@@ -473,7 +489,7 @@ components:
const routes = Object.keys(oas.paths)
expect(routes.includes("/admin/products")).toBeTruthy()
expect(routes.includes("/store/products")).toBeFalsy()
})
})
})
describe("public OAS with base", () => {
@@ -579,7 +595,7 @@ components:
])
const generatedFilePath = path.resolve(outDir, "store.oas.json")
oas = (await readJson(generatedFilePath)) as OpenAPIObject
})
})
it("should add new path to existing paths", async () => {
const routes = Object.keys(oas.paths)