Functions
Execute edge functions.
Function nodes are JavaScript lambdas that allow for quick and easy parsing, re-mapping or otherwise modifying the data. Inputs of the node are provided as function's arguments. The second argument provides some extra helpers for the function:
- moment - used for date parsing and manipulation
- env - variables either passed via API or through GORULES_EXPOSED_ environment variable for on-premise hosting
Maximum execution time of the function is limited to 50ms.
Getting started
To start off create a simple decision with input, function node and an output through graph edit mode. Switch back to content edit mode and click on the function node (Open).
By default, function will return anything that is provided as an input.
Writing a sample function
Let's create a function that will calculate the sum of all numbers provided in the request. Our expected JSON for the request will be:
{
"numbers": [1, 2, 3, 4]
}
And our function will look something like this:
Debugging
To debug a function you may use console.log
statements. It supports all primitive data types which can be
represented in JSON format.
As an example: