DanB
DanB
CDCloudflare Developers
Created by DanB on 11/19/2024 in #workers-help
Redundant wrapper in schema created by cli?
In a Cloudflare worker project created from cli, I get a hono server created, and the response to TaskFetch endpoint is described with this openApi schema:
responses: {
"200": {
description: "Returns a single task if found",
content: {
"application/json": {
schema: z.object({
series: z.object({
success: Bool(),
result: z.object({
task: Task,
}),
}),
}),
},
},
},
"404": {
description: "Task not found",
content: {
"application/json": {
schema: z.object({
series: z.object({
success: Bool(),
error: Str(),
}),
}),
},
},
},
}
responses: {
"200": {
description: "Returns a single task if found",
content: {
"application/json": {
schema: z.object({
series: z.object({
success: Bool(),
result: z.object({
task: Task,
}),
}),
}),
},
},
},
"404": {
description: "Task not found",
content: {
"application/json": {
schema: z.object({
series: z.object({
success: Bool(),
error: Str(),
}),
}),
},
},
},
}
The endpoint returns this:
return {
success: true,
task: {
name: "my task",
slug: taskSlug,
description: "this needs to be done",
completed: false,
due_date: new Date().toISOString().slice(0, 10),
},
};
return {
success: true,
task: {
name: "my task",
slug: taskSlug,
description: "this needs to be done",
completed: false,
due_date: new Date().toISOString().slice(0, 10),
},
};
I'm trying to understand what does series in the schema means, because I don't see it in the response. In the TaskList endpoint there's also an additional wrapper:
schema: z.object({
series: z.object({
success: Bool(),
result: z.object({
tasks: Task.array(),
}),
}),
})
schema: z.object({
series: z.object({
success: Bool(),
result: z.object({
tasks: Task.array(),
}),
}),
})
both series and result do not appear to be part of the response.:
return {
success: true,
tasks: [
{
name: "Clean my room",
slug: "clean-room",
description: null,
completed: false,
due_date: "2025-01-05",
},
{
name: "Build something awesome with Cloudflare Workers",
slug: "cloudflare-workers",
description: "Lorem Ipsum",
completed: true,
due_date: "2022-12-24",
},
],
};
return {
success: true,
tasks: [
{
name: "Clean my room",
slug: "clean-room",
description: null,
completed: false,
due_date: "2025-01-05",
},
{
name: "Build something awesome with Cloudflare Workers",
slug: "cloudflare-workers",
description: "Lorem Ipsum",
completed: true,
due_date: "2022-12-24",
},
],
};
1 replies
CDCloudflare Developers
Created by DanB on 5/4/2024 in #general-help
How to control a worker's location
Hi, I'm building a monitoring service based on Workers and durable objects (DO). DO are used to get per-monitored-resource scheduling. A common feature of monitoring services is to be able to run probes from different locations and get up time and time measurement per location. Is there any way to control where a worker or a DO will be executed from? Thanks
10 replies