feat(httpapi): bridge project update endpoint (#24398)

This commit is contained in:
Kit Langton
2026-04-25 18:55:49 -04:00
committed by GitHub
parent 27b0877714
commit 58c65874ba
5 changed files with 75 additions and 5 deletions

View File

@@ -2,6 +2,7 @@ import * as InstanceState from "@/effect/instance-state"
import { AppRuntime } from "@/effect/app-runtime"
import { Project } from "@/project"
import { InstanceBootstrap } from "@/project/bootstrap"
import { ProjectID } from "@/project/schema"
import { Effect, Layer, Schema } from "effect"
import { HttpApi, HttpApiBuilder, HttpApiEndpoint, HttpApiGroup, OpenApi } from "effect/unstable/httpapi"
import { Authorization } from "./auth"
@@ -40,6 +41,17 @@ export const ProjectApi = HttpApi.make("project")
description: "Create a git repository for the current project and return the refreshed project info.",
}),
),
HttpApiEndpoint.patch("update", `${root}/:projectID`, {
params: { projectID: ProjectID },
payload: Project.UpdatePayload,
success: Project.Info,
}).annotateMerge(
OpenApi.annotations({
identifier: "project.update",
summary: "Update project",
description: "Update project properties such as name, icon, and commands.",
}),
),
)
.annotateMerge(
OpenApi.annotations({
@@ -83,8 +95,15 @@ export const projectHandlers = Layer.unwrap(
return next
})
const update = Effect.fn("ProjectHttpApi.update")(function* (ctx: {
params: { projectID: ProjectID }
payload: Project.UpdatePayload
}) {
return yield* svc.update({ ...Project.UpdatePayload.zod.parse(ctx.payload), projectID: ctx.params.projectID })
})
return HttpApiBuilder.group(ProjectApi, "project", (handlers) =>
handlers.handle("list", list).handle("current", current).handle("initGit", initGit),
handlers.handle("list", list).handle("current", current).handle("initGit", initGit).handle("update", update),
)
}),
).pipe(Layer.provide(Project.defaultLayer))

View File

@@ -62,6 +62,7 @@ export const InstanceRoutes = (upgrade: UpgradeWebSocket): Hono => {
app.get("/project", (c) => handler(c.req.raw, context))
app.get("/project/current", (c) => handler(c.req.raw, context))
app.post("/project/git/init", (c) => handler(c.req.raw, context))
app.patch("/project/:projectID", (c) => handler(c.req.raw, context))
app.get(FilePaths.findText, (c) => handler(c.req.raw, context))
app.get(FilePaths.findFile, (c) => handler(c.req.raw, context))
app.get(FilePaths.findSymbol, (c) => handler(c.req.raw, context))