From 2652de0a7aed31655c8ebc02334338bff793ce65 Mon Sep 17 00:00:00 2001 From: ingalls Date: Fri, 21 Jun 2024 16:32:53 -0600 Subject: [PATCH] Add Patch Endpoint --- api/routes/task.ts | 24 ++++++++++++++++++- api/web/src/components/Admin/AdminTasks.vue | 2 +- .../src/components/Layer/utils/TaskModal.vue | 2 +- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/api/routes/task.ts b/api/routes/task.ts index bdd9c13b2..2ca2e80ed 100644 --- a/api/routes/task.ts +++ b/api/routes/task.ts @@ -188,7 +188,29 @@ export default async function router(schema: Schema, config: Config) { } }); - await schema.get('/task/prefix/:task/readme', { + await schema.patch('/task/:task', { + name: 'Update Task', + group: 'Task', + description: 'Update Registered Task', + body: Type.Object({ + name: Type.Optional(Type.String()), + repo: Type.Optional(Type.String()), + readme: Type.Optional(Type.String()), + }), + res: TaskResponse + }, async (req, res) => { + try { + await Auth.as_user(config, req); + + const task = await config.models.Task.commit(req.params.task, req.body); + + return res.json(task); + } catch (err) { + return Err.respond(err, res); + } + }); + + await schema.get('/task/:task/readme', { name: 'Task README', group: 'Task', description: 'Return README Contents', diff --git a/api/web/src/components/Admin/AdminTasks.vue b/api/web/src/components/Admin/AdminTasks.vue index e4708c2e4..11f2e4d3a 100644 --- a/api/web/src/components/Admin/AdminTasks.vue +++ b/api/web/src/components/Admin/AdminTasks.vue @@ -184,7 +184,7 @@ export default { this.loading = true; if (this.edit.id) { - await std(`/api/task/${this.edit.prefix}`, { + await std(`/api/task/${this.edit.id}`, { method: 'PATCH', body: this.edit }); diff --git a/api/web/src/components/Layer/utils/TaskModal.vue b/api/web/src/components/Layer/utils/TaskModal.vue index ec6184762..54ac2e431 100644 --- a/api/web/src/components/Layer/utils/TaskModal.vue +++ b/api/web/src/components/Layer/utils/TaskModal.vue @@ -155,7 +155,7 @@ export default { } if (this.current.readme) { - const readme = await std(`/api/task/prefix/${this.current.prefix}/readme`); + const readme = await std(`/api/task/${this.current.id}/readme`); this.current.readme = readme.body; }