diff --git a/functions-templates/typescript/scheduled-function/{{name}}.mts b/functions-templates/typescript/scheduled-function/{{name}}.mts new file mode 100644 index 00000000000..8613ce21de7 --- /dev/null +++ b/functions-templates/typescript/scheduled-function/{{name}}.mts @@ -0,0 +1,11 @@ +import type { Config } from "@netlify/functions" + +export default async (req: Request) => { + const { next_run } = await req.json() + + console.log("Received event! Next invocation at:", next_run) +} + +export const config: Config = { + schedule: "@hourly" +} diff --git a/functions-templates/typescript/scheduled-function/{{name}}.ts b/functions-templates/typescript/scheduled-function/{{name}}.ts deleted file mode 100644 index 266482ee25c..00000000000 --- a/functions-templates/typescript/scheduled-function/{{name}}.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { schedule } from '@netlify/functions' - -// To learn about scheduled functions and supported cron extensions, -// see: https://ntl.fyi/sched-func -export const handler = schedule('@hourly', async (event) => { - const eventBody = JSON.parse(event.body) - console.log(`Next function run at ${eventBody.next_run}.`) - - return { - statusCode: 200, - } -})