Description
Describe the problem
As SvelteKit projects are often deployed in serverless environments, tools like node-cron
are not really usable, and makes scheduled tasks quite hard to implement.
Fortunately, many serverless deployment environments now have built-in support for this, for example Netlify. However, integrating those functionality into SvelteKit projects is currently not trivial, as the different adapters are not built to output in the required formats.
Describe the proposed solution
To make those scheduled functions as easy to implement as possible and to keep them in style with current SvelteKit features, I suggest to define them using a directory-based structure.
My current idea is to have a special folder named +cron
that contains the different time rules as folders with their names in a crontab
syntax, with spaces replaced with underscores. The actual function to be triggered would simply be placed in a regular +server.{js|ts}
file, which would export a single (perhaps POST
) endpoint.
src
`-- routes
`-- +cron
`-- 2_20_*_*_*
`-- +server.ts
This would allow for an intuitive platform-agnostic way to define scheduled functions.
Importance
would make my life easier
Additional Information
#10471 is a prototype implementation of this feature request for Netlify via the @sveltejs/adapter-netlify
.