Edge Functions

Server code, next to your data.

Write Deno functions, call them from the SDK with typed errors and timeouts, and run them on demand, in the background or on a schedule.

Deno
runtime
3
ways to run: on demand, job, cron
functions.tsTS
import { createClient } from '@aurabase/aurabase-js'
const aura = createClient(
'https://my-project.aurabase.cloud',
'aura_anon_xxx',
)
const { data, error } = await aura.functions.invoke<{ ok: boolean }>(
'hello-world',
{ body: { name: 'Ada' } },
)
if (error) throw error

What’s included

Everything to run your code. Without managing servers.

Runtime

Deno functions

Write standard Request and Response handlers with Deno.serve and TypeScript.

Invocation

Invoke from the SDK

Call a function by name with a method, path, headers and body.

Routing

Sub-routes inside a function

One function can serve several paths and methods.

Control

Timeouts and cancellation

Set a timeout or pass an AbortSignal. Both report the same timeout error.

Errors

Typed errors

Tell an error your function returned from a relay failure, so you know whether it ran before you retry.

Responses

JSON, text, Blob or ArrayBuffer

Choose how the response body is decoded.

Background

Asynchronous jobs

List jobs by status and follow one by its ID.

Schedules

Cron jobs

Run a function on a cron schedule, with a payload.

Deploy

Deploy from the CLI or Studio

Ship a function with the aura CLI, from Studio, or through the HTTP API.

How it works

From a handler to a call.

  1. 1

    Write

    Create a Deno.serve handler that reads a Request and returns a Response.

  2. 2

    Deploy

    Ship it with aura functions deploy or from Studio.

  3. 3

    Invoke

    Call it by name with aura.functions.invoke.

  4. 4

    Schedule

    Optionally run it on a cron schedule.

REST API

Prefer plain HTTP? It’s all here.

The SDK is a thin layer over these routes. Send your project’s API key with each request.

MethodEndpointDescription
GET/v1/functionsList the project’s functions.
GET/v1/functions/{name}Read one function’s details.
POST/v1/functions/{name}/invokeRun a function with a method, path, headers and body.
GET/v1/functions/jobsList asynchronous jobs, filtered by status.
GET/v1/functions/jobs/{id}Read one job.
GET/v1/functions/cronList scheduled jobs.
POST/v1/functions/cronSchedule a function with a cron expression.
DELETE/v1/functions/cron/{name}Delete a scheduled job.

Questions

Good to know.

Which runtime do functions use?+
Deno. Your function is a Deno.serve handler written in TypeScript or JavaScript.
How do I deploy a function?+
Run aura functions deploy <name> with the CLI, or use Studio or the HTTP API. The SDK invokes functions but does not deploy them.
Can a function stream its response?+
No. The SDK waits for the whole response before it resolves, whichever response type you pick.
Is it safe to retry a failed call?+
After a 503 the function did not run, so retrying is safe. After a 504 it did start and may have had side effects, so only retry operations that are idempotent.
Can I schedule a function?+
Yes. Create a cron job with a name, a cron expression and the function to call. You can list and delete jobs from the SDK.
Can I pick the region a function runs in?+
Not at the moment. Region selection for functions isn’t available.

Ready to run code?

Ship your first function today.

Functions are included in every project. No credit card required.