Get started

Liteflow is a toolkit for developers to build applications efficiently. Liteflow is centered around the concept of workflows that connect different services. Workflows can connect events from a service to a series of tasks from other services. Check out the Liteflow website to learn more and see what it can do for you.

We’ll start by showing you how to create an application with a single feature that calls a Javascript function when there are an HTTP request.

1. Installation

Run the following command in a console to install the Liteflow CLI:

npm install -g @liteflow/cli

2. Create your function

Let's create our function that will accept the request's inputs and return an object with greetings based on the input of the request.

Start by creating a new file at the root of your project directory called myfunction.js with the following content:

myfunction.js
module.exports = (inputs) => {
  const name = inputs.body.name;
  return {
    greetings: `hello ${name || "world"}`,
  };
};

3. Connect your function to an HTTP endpoint

Now that our function is defined, let's connect it to an HTTP endpoint through a workflow.

Create a new file at the root of your project directory called workflow.yml with an endpoint trigger and a task that uses the defined function.

workflow.yml
name: my-cloud-function
steps:
  - type: trigger
    endpointKey: my-endpoint
  - type: task
    handler: ./myfunction.js

4. Deploy your application

To deploy on Liteflow, make sure to be logged into the CLI with liteflow login and use the following command:

liteflow deploy

The command will automatically deploy your workflow and create a dedicated HTTP endpoint for you to use.

To trigger your workflow, execute the command (don't forget to replace the following URL with the one generated for you):

curl -XPOST https://gateway.liteflow.com/xxxxxxxx --data name=my-name
fetch("https://gateway.liteflow.com/xxxxxxxx", {
  method: "POST",
  body: JSON.stringify({
    name: "my-name",
  }),
})
  .then((x) => x.json())
  .then((x) => console.log(x));

From now on, your workflow will run autonomously without having to manage any server or infrastructure.

You can anytime run your application locally before publishing by using the command liteflow dev.