Skip to content

Commit 99f5963

Browse files
docs: Add examples for scheduled handlers in Cron Triggers documentation
1 parent 5d4194d commit 99f5963

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

src/content/docs/workers/configuration/cron-triggers.mdx

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,36 @@ Cron Triggers execute on UTC time.
2727

2828
To respond to a Cron Trigger, you must add a [`"scheduled"` handler](/workers/runtime-apis/handlers/scheduled/) to your Worker.
2929

30-
Refer to the following examples to write your code:
30+
import { TabItem, Tabs } from "~/components";
31+
32+
<Tabs syncKey="workersExamples"> <TabItem label="JavaScript" icon="seti:javascript">
33+
34+
```js
35+
export default {
36+
async scheduled(event, env, ctx) {
37+
console.log("cron processed");
38+
},
39+
};
40+
```
41+
42+
</TabItem> <TabItem label="TypeScript" icon="seti:typescript">
43+
44+
```ts
45+
interface Env {}
46+
export default {
47+
async scheduled(
48+
controller: ScheduledController,
49+
env: Env,
50+
ctx: ExecutionContext,
51+
) {
52+
console.log("cron processed");
53+
},
54+
};
55+
```
56+
57+
</TabItem> </Tabs>
58+
59+
Refer to the following additional examples to write your code:
3160

3261
- [Setting Cron Triggers](/workers/examples/cron-trigger/)
3362
- [Multiple Cron Triggers](/workers/examples/multiple-cron-triggers/)

0 commit comments

Comments
 (0)