dev

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package dev implements `gombit dev`: one command that runs the Go API (with reload when air or watchexec is available), the Vite frontend with HMR, and live OpenAPI → TypeScript client regeneration.

Index

Constants

View Source
const (
	// DefaultHTTPAddr is the Go API listen address when config and flags omit it.
	DefaultHTTPAddr = ":8080"
	// DefaultFrontendHost is the Vite bind host.
	DefaultFrontendHost = "127.0.0.1"
	// DefaultFrontendPort is Vite's conventional port.
	DefaultFrontendPort = 5173
	// DefaultPollInterval is how often the OpenAPI watcher fetches /openapi.json.
	DefaultPollInterval = time.Second
	// DefaultClientOut is the generated TypeScript client directory (design §23.3).
	DefaultClientOut = client.DefaultOutDir
)

Variables

This section is empty.

Functions

func APIPrefixFromConfig added in v0.1.3

func APIPrefixFromConfig(cfg config.Config) string

APIPrefixFromConfig returns config.API.Prefix, or D8 `/api/v1`.

func AdminURLFromConfig added in v0.1.3

func AdminURLFromConfig(cfg config.Config, httpAddr string) string

AdminURLFromConfig returns the admin SPA URL for cookie-mode apps with auth enabled. JWT apps and auth-disabled configs return "".

func FormatServiceTable

func FormatServiceTable(services Services) string

FormatServiceTable renders the Backend / Frontend / OpenAPI / API docs table. Cookie-mode apps also get an Admin row when Admin is set.

func HTTPAddrFromConfig

func HTTPAddrFromConfig(cfg config.Config) string

HTTPAddrFromConfig returns the listen address from cfg, or DefaultHTTPAddr.

func Run

func Run(ctx context.Context, opts Options) error

Run starts the backend, Vite frontend, and OpenAPI client watcher until ctx is cancelled.

func ValidateFlags

func ValidateFlags(httpAddr string, frontendHost string, frontendPort int, poll time.Duration, clientOut string) error

ValidateFlags reports user-facing errors for `gombit dev` flag values before defaults are applied.

Types

type CommandFunc

type CommandFunc func(name string, args ...string) *exec.Cmd

CommandFunc starts a subprocess. Tests replace this with short-lived fakes.

type GenerateFunc

type GenerateFunc func(ctx context.Context, spec []byte) error

GenerateFunc regenerates the TypeScript client from an OpenAPI document.

type HTTPGetFunc

type HTTPGetFunc func(ctx context.Context, rawURL string) ([]byte, error)

HTTPGetFunc fetches a URL. Tests replace this to stub /openapi.json.

type LookPathFunc

type LookPathFunc func(file string) (string, error)

LookPathFunc locates an executable. Tests replace this to simulate air/pnpm.

type Options

type Options struct {
	WorkDir      string
	HTTPAddr     string
	APIPrefix    string
	FrontendHost string
	FrontendPort int
	ClientOut    string
	PollInterval time.Duration
	Stdout       io.Writer
	Stderr       io.Writer
	LookPath     LookPathFunc
	Command      CommandFunc
	HTTPGet      HTTPGetFunc
	Generate     GenerateFunc
	ShutdownWait time.Duration
	// AdminURL is printed in the service table when non-empty (cookie-mode
	// apps that mount the framework admin SPA). JWT apps leave this empty.
	AdminURL string
}

Options configures `gombit dev`.

type ProcSpec

type ProcSpec struct {
	Name string
	Dir  string
	Env  []string
	Path string
	Args []string
}

ProcSpec is one supervised child process.

type Services

type Services struct {
	Backend  string
	Frontend string
	// Admin is the cookie-mode admin SPA URL. Empty omits the row (JWT apps
	// do not mount /admin/).
	Admin string
}

Services holds the URLs printed in the startup service table.

Jump to

Keyboard shortcuts

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