A Cloudflare Worker which works in conjunction with https://github.com/indexxing/bsky-alt-text
1import { Bool, OpenAPIRoute, Str } from "chanfana";
2import { z } from "zod";
3import { type AppContext, Task } from "../types";
4
5export class TaskDelete extends OpenAPIRoute {
6 schema = {
7 tags: ["Tasks"],
8 summary: "Delete a Task",
9 request: {
10 params: z.object({
11 taskSlug: Str({ description: "Task slug" }),
12 }),
13 },
14 responses: {
15 "200": {
16 description: "Returns if the task was deleted successfully",
17 content: {
18 "application/json": {
19 schema: z.object({
20 series: z.object({
21 success: Bool(),
22 result: z.object({
23 task: Task,
24 }),
25 }),
26 }),
27 },
28 },
29 },
30 },
31 };
32
33 async handle(c: AppContext) {
34 // Get validated data
35 const data = await this.getValidatedData<typeof this.schema>();
36
37 // Retrieve the validated slug
38 const { taskSlug } = data.params;
39
40 // Implement your own object deletion here
41
42 // Return the deleted task for confirmation
43 return {
44 result: {
45 task: {
46 name: "Build something awesome with Cloudflare Workers",
47 slug: taskSlug,
48 description: "Lorem Ipsum",
49 completed: true,
50 due_date: "2022-12-24",
51 },
52 },
53 success: true,
54 };
55 }
56}