Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/partywhen/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -54,6 +55,7 @@ Here are some examples:

```ts
scheduler.scheduleTask({
id: "my-task",
description: "my-task",
type: "delayed",
delayInSeconds: 60,
Expand All @@ -71,6 +73,7 @@ Here are some examples:

```ts
scheduler.scheduleTask({
id: "my-task",
description: "my-task",
type: "cron",
cron: "0 18 * * 5",
Expand All @@ -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"),
Expand Down
2 changes: 2 additions & 0 deletions packages/partywhen/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ type Callback =
| {
type: "webhook";
url: string;
headers?: Record<string, string>;
}
| {
type: "durable-object";
Expand Down Expand Up @@ -359,6 +360,7 @@ export class Scheduler<Env> extends Server<Env> {
method: "POST",
body: JSON.stringify(task),
headers: {
...(task.callback.headers || {}),
"Content-Type": "application/json"
}
});
Expand Down