functions

package
v0.8.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 8, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package functions builds server-side functions: `backd functions build` bundles each function of a database's Deno project into one file with `deno bundle`, and records the bundles in a manifest that startup checks.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Build

func Build(ctx context.Context, reg *registry.Registry, opts Options) error

Build bundles every function of every database in reg that has any.

func DenoVersion

func DenoVersion(ctx context.Context, deno string) (string, error)

DenoVersion returns the version of the deno binary.

func JSDocTypes

func JSDocTypes(reg *registry.Registry) string

JSDocTypes generates JSDoc typedefs from every function's input and output JSON Schemas (`backd functions types`), for editor autocomplete on ctx.input and the return value. A function without a schema, or whose schema can't be read or parsed, is skipped (with a comment explaining why for the latter): this never fails outright, so the command always produces something to paste into an editor.

func Watch

func Watch(ctx context.Context, reg *registry.Registry, opts Options, interval time.Duration)

Watch rebuilds each functions project's bundles whenever its sources change, until ctx is done. For `BACKD_DEV=true`: function code is picked up automatically; schemas, rules and realm.yaml still need a restart. A build failure (e.g. a syntax error) is logged and retried every tick until the source changes again or the problem is fixed.

Types

type Options

type Options struct {
	Deno  string // the deno binary; default "deno" on the PATH
	Check bool   // type-check TypeScript while bundling
	// Log receives one line per bundled function.
	Log func(format string, args ...any)
}

Options configure a build.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL