Skip to content
Documentation menu

Custom Functions

Custom functions are plain TypeScript functions that run in the BACLET runtime.

Defining a function

backend/functions/createInvoice.ts
import { defineFunction } from "baclet";

export default defineFunction({
  name: "createInvoice",
  auth: "required",
  async handler(ctx, input: { amount: number }) {
    return ctx.db.invoices.create({ amount: input.amount });
  },
});

Illustrative example. Context methods are not final.