Javascript function

This service runs your Javascript functions in a controlled, secured, and scalable environment so you can focus on your business logic.

Environment

  • Node version: 12.16 (LTS)
  • RAM: 256 MB

Definition of a function

Each function can me defined in a dedicated file that exports the function.

eg:

myfunction.js
module.exports = async (inputs) => {
  return 'hello world'
}

Task

Execute

Definition

By setting the parameter handler, the workflow will execute the function exported in the file when reaching the step.

KeyTypeDescription
type"task"
service"js-function"Select the js-function service
taskKey"execute"Name of the task
handlerstringThe relative path of the file that exports the function
inputsmap<string,Input>(optional) Function's inputs. If not defined, inputs are the previous output's step

Example

liteflow.yml
workflows:
  my-workflow:
    steps:
      - ...
      - type: task
        service: js-function
        taskKey: execute
        handler: ./myfunction.js

Outputs

The result of your function contains the following data:

KeyTypeDescription
resultAnyThe data returned by your function