|
|
@@ -208,53 +208,53 @@ export namespace Server {
|
|
|
return c.json(info)
|
|
|
},
|
|
|
)
|
|
|
- .put(
|
|
|
+ .get(
|
|
|
"/pty/:id",
|
|
|
describeRoute({
|
|
|
- description: "Update PTY session",
|
|
|
- operationId: "pty.update",
|
|
|
+ description: "Get PTY session info",
|
|
|
+ operationId: "pty.get",
|
|
|
responses: {
|
|
|
200: {
|
|
|
- description: "Updated session",
|
|
|
+ description: "Session info",
|
|
|
content: {
|
|
|
"application/json": {
|
|
|
schema: resolver(Pty.Info),
|
|
|
},
|
|
|
},
|
|
|
},
|
|
|
- ...errors(400),
|
|
|
+ ...errors(404),
|
|
|
},
|
|
|
}),
|
|
|
validator("param", z.object({ id: z.string() })),
|
|
|
- validator("json", Pty.UpdateInput),
|
|
|
async (c) => {
|
|
|
- const info = await Pty.update(c.req.valid("param").id, c.req.valid("json"))
|
|
|
+ const info = Pty.get(c.req.valid("param").id)
|
|
|
+ if (!info) {
|
|
|
+ throw new Storage.NotFoundError({ message: "Session not found" })
|
|
|
+ }
|
|
|
return c.json(info)
|
|
|
},
|
|
|
)
|
|
|
- .get(
|
|
|
+ .put(
|
|
|
"/pty/:id",
|
|
|
describeRoute({
|
|
|
- description: "Get PTY session info",
|
|
|
- operationId: "pty.get",
|
|
|
+ description: "Update PTY session",
|
|
|
+ operationId: "pty.update",
|
|
|
responses: {
|
|
|
200: {
|
|
|
- description: "Session info",
|
|
|
+ description: "Updated session",
|
|
|
content: {
|
|
|
"application/json": {
|
|
|
schema: resolver(Pty.Info),
|
|
|
},
|
|
|
},
|
|
|
},
|
|
|
- ...errors(404),
|
|
|
+ ...errors(400),
|
|
|
},
|
|
|
}),
|
|
|
validator("param", z.object({ id: z.string() })),
|
|
|
+ validator("json", Pty.UpdateInput),
|
|
|
async (c) => {
|
|
|
- const info = Pty.get(c.req.valid("param").id)
|
|
|
- if (!info) {
|
|
|
- throw new Storage.NotFoundError({ message: "Session not found" })
|
|
|
- }
|
|
|
+ const info = await Pty.update(c.req.valid("param").id, c.req.valid("json"))
|
|
|
return c.json(info)
|
|
|
},
|
|
|
)
|
|
|
@@ -295,20 +295,14 @@ export namespace Server {
|
|
|
},
|
|
|
},
|
|
|
},
|
|
|
- 404: {
|
|
|
- description: "Session not found",
|
|
|
- content: {
|
|
|
- "application/json": {
|
|
|
- schema: resolver(z.boolean()),
|
|
|
- },
|
|
|
- },
|
|
|
- },
|
|
|
+ ...errors(404),
|
|
|
},
|
|
|
}),
|
|
|
validator("param", z.object({ id: z.string() })),
|
|
|
upgradeWebSocket((c) => {
|
|
|
const id = c.req.param("id")
|
|
|
let handler: ReturnType<typeof Pty.connect>
|
|
|
+ if (!Pty.get(id)) throw new Error("Session not found")
|
|
|
return {
|
|
|
onOpen(_event, ws) {
|
|
|
handler = Pty.connect(id, ws)
|