serve()
function to define an endpoint that runs a workflow.
It accepts two arguments:
- Route Function: an async function that receives the workflow context and defines the workflow steps.
- Options: configuration options for the workflow.
Route Function
The route function defines the execution logic of the workflow. It is an async function that receives a context object, which is automatically created and passed by Upstash Workflow. The context object provides:- Workflow APIs – functions for defining workflow steps.
- Workflow Run Properties – request payload, request headers, and other metadata.