sbarbase
Contents

Edge Functions

Edge Functions run your own Deno code next to an environment, called with supabase.functions.invoke() at <address>/functions/v1/<name>, as on Supabase. Each environment has its own runtime, the original upstream edge-runtime, and it starts with the first deploy.

Deploy from a Supabase project

If you already have functions in a Supabase project, deploy the whole supabase/functions folder in one command from a checkout of Sbarbase:

SBARBASE_EMAIL=you@example.com bun lab/functions-deploy.ts https://console.example.com <environment id> ../my-app/supabase/functions

The environment id is on the environment's page in the console. A redeploy takes effect at once, with no restart; a request already running finishes on the version it started with.

Deploy with the Supabase CLI or an agent

With a personal access token (sbp_...), the Supabase CLI deploys to this server through a profile file, supabase --profile ./sbarbase-profile.yaml functions deploy <name> --project-ref <ref> --use-api, and sets secrets with secrets set. An AI agent connected to the server's /mcp endpoint deploys with its deploy_edge_function tool. AI agents has the profile, the token and the steps.

Write one in the console

On the environment's page, under Edge Functions, Write a function takes a name and an index.ts and deploys it. It suits small functions; a project folder suits the rest.

Call a function

const { data, error } = await supabase.functions.invoke('hello-world', { body: { name: 'Sbarbase' } })

Every function gets these variables, like on Supabase:

Variable What it is
SUPABASE_URL This environment's API, for createClient() inside the function
SUPABASE_ANON_KEY Acts as a visitor; row level security applies
SUPABASE_SERVICE_ROLE_KEY Acts as the service; bypasses row level security. Keep it inside functions

Add your own under Secrets (for example STRIPE_SECRET_KEY) and read them with Deno.env.get('STRIPE_SECRET_KEY'). A value is never shown again after you save it.

Who may call a function

How it runs

CI deploys a functions folder with the command above on a clean machine with every change, and calls the functions through the gateway with supabase-js, including one that uses supabase-js from npm with the service role (evidence).

Limits

Edit on GitHub