server

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2026 License: MIT Imports: 32 Imported by: 0

Documentation

Overview

Package server exposes the store over an HTTP+JSON API and serves the embedded web UI. It binds localhost only and defends the no-auth API with Host/Origin checks. Live updates (SSE), search, attachments, and git status are layered on in later milestones.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileItem added in v0.5.0

type FileItem struct {
	Path string `json:"path"`
	Kind string `json:"kind"` // "file" | "dir"
}

FileItem is one autocomplete suggestion from /api/files.

type Server

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

Server wires the store into HTTP handlers.

func New

func New(st *store.Store, version string) *Server

New constructs a server over the given store (single-repo).

func NewWithRegistry added in v0.7.0

func NewWithRegistry(reg *StoreRegistry, version string) *Server

NewWithRegistry constructs a server over a multi-repo registry. The active store backs legacy /api routes; /api/r/{alias}/… addresses a specific repo.

func (*Server) Handler

func (srv *Server) Handler() http.Handler

Handler builds the chi router with all routes and middleware.

func (*Server) Registry added in v0.7.0

func (srv *Server) Registry() *StoreRegistry

Registry returns the store registry (never nil after New/NewWithRegistry).

func (*Server) SetActiveRepo added in v0.7.0

func (srv *Server) SetActiveRepo(alias string) error

SetActiveRepo switches the active store used by legacy /api routes.

func (*Server) StartLiveSync

func (srv *Server) StartLiveSync() func()

StartLiveSync begins watching the .pine directory and broadcasting external changes over SSE. It returns a stop function. When the watcher cannot start, the server still runs (without live updates). In workspace mode every repo is watched; events are tagged with the repo alias.

type StoreRegistry added in v0.7.0

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

StoreRegistry holds one or more open .pine stores for multi-repo serve. Repos register themselves on `pine init` into ~/.pine/repos.json, and `pine serve` auto-discovers them — no workspace name or flag is required.

func NewRegistry added in v0.7.0

func NewRegistry(ordered []string, stores map[string]*store.Store, paths map[string]string) (*StoreRegistry, error)

NewRegistry builds a registry from alias -> store. The first alias in order becomes active.

func SingleRegistry added in v0.7.0

func SingleRegistry(st *store.Store) *StoreRegistry

SingleRegistry wraps one store under alias "default".

func (*StoreRegistry) Active added in v0.7.0

func (r *StoreRegistry) Active() *store.Store

func (*StoreRegistry) ActiveAlias added in v0.7.0

func (r *StoreRegistry) ActiveAlias() string

func (*StoreRegistry) AliasOf added in v0.7.0

func (r *StoreRegistry) AliasOf(st *store.Store) string

func (*StoreRegistry) All added in v0.7.0

func (r *StoreRegistry) All() []string

All returns aliases in registration order.

func (*StoreRegistry) Entries added in v0.7.0

func (r *StoreRegistry) Entries() []map[string]string

Entries returns alias, project name, and repo path for each store.

func (*StoreRegistry) Get added in v0.7.0

func (r *StoreRegistry) Get(alias string) (*store.Store, bool)

func (*StoreRegistry) IsWorkspace added in v0.7.0

func (r *StoreRegistry) IsWorkspace() bool

IsWorkspace reports whether more than one repo is registered. The UI uses this to decide whether to render the repo switcher.

func (*StoreRegistry) SetActive added in v0.7.0

func (r *StoreRegistry) SetActive(alias string) error

Jump to

Keyboard shortcuts

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