diff --git a/packages/partywhen/README.md b/packages/partywhen/README.md index 1a7e9a5b..d6b058f0 100644 --- a/packages/partywhen/README.md +++ b/packages/partywhen/README.md @@ -36,6 +36,7 @@ export default { A task has a few parts: +- **id**: a unique identifier for the task - **description**: which is a string that you can use to identify the task - **payload**: which is a JSON object that is passed to the task - **type**: which is one of "delayed", "cron", or "scheduled" @@ -54,6 +55,7 @@ Here are some examples: ```ts scheduler.scheduleTask({ + id: "my-task", description: "my-task", type: "delayed", delayInSeconds: 60, @@ -71,6 +73,7 @@ Here are some examples: ```ts scheduler.scheduleTask({ + id: "my-task", description: "my-task", type: "cron", cron: "0 18 * * 5", @@ -90,6 +93,7 @@ Here are some examples: ```ts scheduler.scheduleTask({ + id: "my-task", description: "my-task", type: "scheduled", time: new Date("2024-01-01T12:00:00Z"), diff --git a/packages/partywhen/src/index.ts b/packages/partywhen/src/index.ts index cf47a8b0..b7800264 100644 --- a/packages/partywhen/src/index.ts +++ b/packages/partywhen/src/index.ts @@ -63,6 +63,7 @@ type Callback = | { type: "webhook"; url: string; + headers?: Record; } | { type: "durable-object"; @@ -359,6 +360,7 @@ export class Scheduler extends Server { method: "POST", body: JSON.stringify(task), headers: { + ...(task.callback.headers || {}), "Content-Type": "application/json" } });