Documentation

Writing Serverless Functions

ServerlessFlow allows you to deploy code without provisioning servers. Your functions are event-driven, meaning they execute instantly when triggered by an HTTP request or test run.

How it works

  1. Write or edit your function code in our unified web workspace.
  2. Save and deploy — automatically creating an OpenWhisk action.
  3. Invoke via HTTP endpoint or execute directly via the Test Run button.
  4. Monitor response payload, duration, and runtime logs in the output drawer.

Function Anatomy

Regardless of the language, every function follows a simple input/output contract.

Input (args)

Your function receives a parameter containing:

  • HTTP Query Parameters
  • HTTP Body (JSON)
  • Path Parameters

Output (Return)

Return a JSON object or dictionary containing:

  • body: The actual response data.
  • statusCode: (Optional) HTTP code.
  • headers: (Optional) Custom headers.

Runtime Examples

Select a runtime below to view boilerplate code ready for deployment:

nodejs runtime
function main(params) {
  // 1. Parse Input
  const name = params.name || 'stranger';

  // 2. Logic & Logging
  console.log('Processing request for:', name);

  // 3. Return JSON
  return { body: 'Hello ' + name + '!' };
}

Runtime Note

We run Node.js 18.x LTS. Function handler defaults to main(params).

Best Practices

Stateless Execution

Functions should be stateless. Do not rely on in-memory variables persisting between requests.

Fast Execution

Keep handlers lean to minimize latency. Offload heavy background work to async queues.

Logging & Monitoring

ServerlessFlow automatically captures stdout and stderr output. Everything printed via console.log() or print() appears directly in your execution output drawer.