Function

A function is a reusable block of code that you can deploy to the DigitalOcean Functions service and then access via a URL. For example, you can write a traditional Node.js function that returns a list of products from a database and then deploy that function to the Functions service.

Once deployed, users and applications can retrieve data from the database by making an HTTP request to the function’s URL.

Below is an example of a JavaScript function that prints a greeting.

function main(args) {
    let name = args.name || 'stranger'
    let greeting = 'Hello ' + name + '!'
    console.log(greeting)
    return {"body": greeting}
  }

exports.main = main

You refer to functions as actions in a project’s project.yml configuration.