kit
kit copied to clipboard
feat: support for scheduled functions
closes https://github.com/sveltejs/kit/issues/10477
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
- [x] It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
- [ ] This message body should clearly illustrate what problems it solves.
- [ ] Ideally, include a test that fails without this PR but passes with it.
Tests
- [x] Run the tests with
pnpm testand lint the project withpnpm lintandpnpm check
Changesets
- [x] If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running
pnpm changesetand following the prompts. Changesets that add features should beminorand those that fix bugs should bepatch. Please prefix changeset messages withfeat:,fix:, orchore:.
🦋 Changeset detected
Latest commit: fdd066346f92e28b51fb0b2fdfa03c3499d2d71d
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 1 package
| Name | Type |
|---|---|
| @sveltejs/adapter-netlify | Minor |
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR
Please open an issue first for new features so we can discuss the problem we are trying to solve and how we want to solve it.
A few notes on this particular PR, separate from that:
- We use
camelCasefor externally visible APIs, notsnake_case. - Conversely, we use
snake_casefor internal APIs and variable names, notcamelCase. @netlify/functionsshould not be a required peer dependency of this adapter.- You checked the box indicating that you included a changeset, but there is no changeset.
@Conduitry Sorry for the mistakes, this is my first time contributing to a major open source project.
-
I am working on opening an issue about the problem, but the rough idea is to add support for Netlify scheduled functions in
@sveltejs/adapter-netlify. -
I believe I have fixed the
snake_caseandcamelCaseissues, but I may have missed some. -
@netlify/functions should not be a required peer dependency of this adapter.
I do not think this is possible. Netlify seems to only detect a function as scheduled if it is wrapped in the
schedulefunction imported directly from@netlify/functions. Based on my experiments, re-exporting it or bundling it seems to prevent correct identification from Netlify. -
I accidentaly didn't initially push the commit containing the changeset. This should now be fixed.
This would need to update the README.md for adapter-netlify. It's hard for me to understand this PR without docs or a corresponding issue describing how it would be used
Also, you will need to run pnpm format to fix the lint failure
@benmccann Sorry for the delayed response, I was away from my messages for personal reasons. I still think that it would be very interesting for Svelte Kit to have built-in support for scheduled functions on compatible platforms, but I don't have a lot of experience with open-source software and I am unsure what the next steps should be. This would require a new convention and modifications to most adapters, this PR was just an experiment of a Netlify prototype.
My suggestion would be to have something like a special src/+cron folder that would contain folders whose name are cron rules. Each folder would contain a +server.js with a POST endpoint to be executed at the schedule time.
Ah, I see the issue you created now: https://github.com/sveltejs/kit/issues/10477. Thanks for the details