refactor(server): serve raw filesystem content (#31911)
This commit is contained in:
parent
31b233e9db
commit
31c5454ee6
12 changed files with 67 additions and 93 deletions
|
|
@ -709,10 +709,18 @@ const scenarios: Scenario[] = [
|
|||
"status",
|
||||
),
|
||||
http.protected
|
||||
.get("/api/fs/read", "v2.fs.read")
|
||||
.get("/api/fs/read/*", "v2.fs.read")
|
||||
.seeded((ctx) => ctx.file("hello.txt", "hello\n"))
|
||||
.at((ctx) => ({ path: "/api/fs/read?path=hello.txt", headers: ctx.headers() }))
|
||||
.json(200, locationData(object)),
|
||||
.at((ctx) => ({ path: "/api/fs/read/hello.txt", headers: ctx.headers() }))
|
||||
.status(
|
||||
200,
|
||||
(_ctx, result) =>
|
||||
Effect.sync(() => {
|
||||
check(result.text === "hello\n", "v2 fs read should return the file body")
|
||||
check(result.contentType.includes("text/plain"), "v2 fs read should return the file content type")
|
||||
}),
|
||||
"status",
|
||||
),
|
||||
http.protected.get("/api/fs/list", "v2.fs.list").json(200, locationData(array)),
|
||||
http.protected
|
||||
.get("/api/fs/find", "v2.fs.find")
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ describe("PublicApi OpenAPI v2 errors", () => {
|
|||
test("documents references separately from filesystem routes", () => {
|
||||
const spec = OpenApi.fromApi(PublicApi) as OpenApiSpec
|
||||
|
||||
for (const path of ["/api/fs/read", "/api/fs/list"]) {
|
||||
for (const path of ["/api/fs/read/*", "/api/fs/list"]) {
|
||||
expect(spec.paths[path]?.get?.parameters, path).not.toContainEqual(expect.objectContaining({ name: "reference" }))
|
||||
}
|
||||
expect(spec.paths["/api/reference"]?.get).toBeDefined()
|
||||
|
|
|
|||
|
|
@ -389,12 +389,9 @@ describe("HttpApi SDK", () => {
|
|||
workspaceID,
|
||||
onRequest: (value) => (request = value),
|
||||
})
|
||||
const file = yield* call(() => sdk.v2.fs.read({ path: "hello.txt" }))
|
||||
const found = yield* call(() => sdk.v2.fs.find({ query: "hello", type: "file" }))
|
||||
const url = new URL(request!.url)
|
||||
|
||||
expect(file.response.status).toBe(200)
|
||||
expect(file.data).toMatchObject({ data: { content: "hello" } })
|
||||
expect(found.response.status).toBe(200)
|
||||
expect(found.data).toMatchObject({ data: [{ path: "hello.txt", type: "file" }] })
|
||||
expect(url.searchParams.get("directory")).toBe(directory)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue