Skip to main content

Backend Functions

Backend Appnest functions platform-backed modules you import in server-side Appnest code (for example HTTP or event handlers). They are not separate deployable units—they are the $db, $fetch, $file, $next, $schedule, and getTraceId objects you load with require('@sparrowengg/appnest-app-sdk-utils') and call with await; Appnest supplies the implementation at runtime.

What they are for: persisting and reading app state, calling outbound APIs with supported options, uploading and downloading files via signed URLs, handing off work to another function (immediately or after a delay), managing scheduled jobs (one-time, cron, or recurring), and reading a trace ID so logs and support can follow a single request.

Together they cover storage ($db), outbound HTTP ($fetch), files via signed URLs ($file), chaining work to another function ($next), scheduled jobs ($schedule), and request correlation (getTraceId). Pick only the modules you need from AppnestFunctions.

Use this page for orientation; for exact signatures, parameters, return types, and constraints, use BackendAppnestFunctions.md as the single source of truth.

Import

const { AppnestFunctions } = require('@sparrowengg/appnest-app-sdk-utils');
const { $db, $fetch, $file, $next, $schedule, getTraceId } = AppnestFunctions;
  • Destructure from AppnestFunctions, not from the package root.
  • The SDK is provided at runtime by the Appnest platform — do not add @sparrowengg/appnest-app-sdk-utils to app-backend/package.json.

Modules at a glance

ModulePurpose
$dbKey/value by type: string, number (with increment/decrement), list, map, boolean.
$fetchOutbound HTTP via request({ url, method, headers, body, options? }).
$fileFile storage with signed URLs: upload, download, delete, list, exists (path, optional visibility).
$nextInvoke another function: run({ functionName, payload, delay? }) (delay in seconds).
$scheduleScheduled jobs: create, get, update, pause, resume, delete — types ONE_TIME, CRON, RECURRING.
getTraceIdString trace ID for logging and correlation.