deno

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EdgeSubprocessEnv

func EdgeSubprocessEnv(srv *serverconf.ServerConfig, apiExternalURLFallback string) []string

EdgeSubprocessEnv returns KEY=value pairs appended after os.Environ() for the Deno child. Go merges env with last-wins for duplicate keys, so these override inherited values.

Injected when non-empty:

  • SUPATYPE_URL — from srv.SupatypeURL, else apiExternalURLFallback
  • SUPATYPE_ANON_KEY — from srv.AnonKey
  • SUPATYPE_SERVICE_ROLE_KEY — from srv.ServiceRoleKey

Additionally, any process env key starting with SUPATYPE_EDGE_ is passed with that prefix stripped (e.g. SUPATYPE_EDGE_FOO=1 → FOO=1) for user-defined function env.

Types

type LogLine

type LogLine struct {
	Timestamp time.Time
	Level     string // "info" or "error"
	Message   string
}

LogLine is a captured line from the Deno process stdout/stderr.

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager supervises a Deno process that serves edge functions. It spawns `deno run [--watch] --allow-net --allow-env --allow-read {serveEntry}` where serveEntry is the generated router (uses `Deno.serve` internally — equivalent role to a dedicated `deno serve` file server, but `deno run` is required for our multi-route TS entry). Restarts on crash with exponential backoff (1s → 2s → 4s → … → 30s cap). PORT must be communicated via environment; the child's PORT is overridden so it cannot inherit the main server's listen port by mistake.

func New

func New(denoPath, serveEntry string, port int, env []string, watch bool) *Manager

New creates a Manager. serveEntry is the script path passed to `deno run` (router generated under .supatype/functions-router.ts during `supatype dev`). port is the port Deno will listen on. env is appended after inheriting OS env minus PORT= plus the explicit PORT=value for Deno children. When watch is true, `deno run --watch` reloads the worker when source files change.

func (*Manager) RecentLogs

func (m *Manager) RecentLogs(since time.Time, n int) []LogLine

RecentLogs returns up to n log lines captured since the given time. If since is zero, all buffered lines are returned.

func (*Manager) Start

func (m *Manager) Start(ctx context.Context)

Start spawns the Deno process and begins the crash-restart loop. It returns immediately; the process runs in background goroutines. ctx cancellation (or Stop) shuts Deno down cleanly.

func (*Manager) Stop

func (m *Manager) Stop()

Stop signals the Deno process to terminate and stops the restart loop.

Jump to

Keyboard shortcuts

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