Functions

Deploy TypeScript functions that run on Deno. Invoke them via HTTP from your Flutter app, or bind them to database events so they run automatically when data changes.

What are functions?

Koolbase Functions are serverless TypeScript functions that run on Deno in an isolated subprocess. They are ideal for logic that cannot run on the client — sending emails, processing payments, calling third-party APIs, or reacting to database changes.

Each function receives a ctx object that gives access to the incoming request, your project database, and any secrets you have configured.

The context object

Every function receives a single ctx argument:

ctx.requestobjectThe incoming request — body, headers, event type, collection, payload
ctx.db.insert()functionInsert a record into a collection
ctx.db.find()functionQuery records from a collection
ctx.db.update()functionUpdate a record by ID
ctx.db.delete()functionDelete a record by ID
Deno.env.get()functionAccess encrypted secrets injected at runtime

Two invocation modes

HTTP Invoke

Call the function directly from your Flutter app using the SDK. Useful for on-demand logic like sending a message, processing a form, or triggering a workflow.

DB Triggers

Bind the function to a database collection event — created, updated, or deleted. The function fires automatically whenever a matching record is mutated. No polling, no glue code.

In this section

Runtime: Deno 2.7.7

Functions run on Deno 2.7.7 in an isolated subprocess with --deny-read --deny-write flags. Network access is available for calling external APIs. File system access is restricted.