Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This extends the initial Inngest implementation by adding a weekly digest function for the Notes app. This first function is meant to show how to run something asynchronously using Inngest. A cron is the most basic example.
Improvements
I was tempted to extend this with additional best practices, but held off prior to getting Kent's thoughts. If this were production-grade the cron function would use
step.invoke()
orstep.sendEvent()
to fan-out the actual email sending to another function. This would two functions each with a single responsibility:The benefits of that approach is that the second function can then use flow control, such as
throttle
to match Resend (or whatever provider's) API rate limit. Resend, by default limits to 2 requests per second, so sending a digest to many users so quickly may easily result in an 429 response from Resend's API. In the demo this isn't bad since emails aren't actually being sent, and just being printed to stdout, but in production, you would 100% want to add throttling.Test Plan
Start up the server as typical with
npm run dev
then in another terminal, run the Inngest dev server pointing to the route:Note -
--no-discovery
disables Inngest app port and path scanning that is helpful when originally getting started with Inngest.Notes
/api/inngest
,npx inngest-cli dev
command as annpm run
script and potentially run this concurrently. This could also be achieved by wrapping the CLI and executing it via child process indev-server.js
Checklist
Screenshots
Function available in the Inngest dashboard:

Test run of the function using local data:
