Skip to content

Commit

Permalink
Add Patch Endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
ingalls committed Jun 21, 2024
1 parent 1db1ce0 commit 2652de0
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
24 changes: 23 additions & 1 deletion api/routes/task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion api/web/src/components/Admin/AdminTasks.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
Expand Down
2 changes: 1 addition & 1 deletion api/web/src/components/Layer/utils/TaskModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 2652de0

Please sign in to comment.