CLI
The Velocity CLI is currently the only way you can create and invoke Velocity functions. I will be adding custom function invocation URLs pretty soon.
Installing the CLI
Download the precompiled binary for your operating system on the release page
Creating a function
Let's use the CLI to create a function that just returns hello world. Create a file called function.js
and input the following code
module.exports = (args) => {
return {
hello: "world",
}
}
Next, you have to create a zip file containing this code. If you are on windows with poershell, use the following command
Compress-Archive -LiteralPath .\function.js -DestinationPath code.zip
If you are on Linux/Mac, use the following command
zip code.zip function.js
Next, create a function by running the following command
.\cli.exe create --name demo-func --file-path code.zip --handler function

Listing functions
To list all the functions you have deployed, run the following command
.\cli.exe list

Invoking a function
To invoke a function, run the following command
.\cli.exe invoke --name demo-func

Deleting a function
To delete a function, run the following command
.\cli.exe delete --name demo-func

Last updated