Documentation
¶
Overview ¶
Package appserve is anfra serve's Data App component, its backend: the pages a browser opens (/apps/<path>, the appserve frontend), the Data Apps under the repo's apps/ (their tree, and the files themselves), who reads them, and live reload. It reaches no data: a Data App's queries go to the core API, from the browser.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Context ¶
type Context struct {
Repo RepoInfo `json:"repo"`
Reader Reader `json:"reader"`
Watch bool `json:"watch"`
}
Context is what the frontend starts from: the repo, who reads it, and whether it live-reloads.
type Entry ¶
type Entry struct {
Kind string `json:"kind"`
Path string `json:"path"`
Label string `json:"label,omitempty"`
Name string `json:"name,omitempty"`
Children []Entry `json:"children,omitempty"`
}
Entry is one node of the Data App tree: a Data App definition, or a folder of them.
type Event ¶
type Event struct {
Type string `json:"type" enum:"apps,aml"`
Paths []string `json:"paths,omitempty"`
}
Event is what a live-reloading frontend hears: Data App definitions (or files next to them) changed, by their paths under apps/; or the AML changed, so datasets and problems may have.
type Options ¶
type Options struct {
// RepoDir is the repo whose Data Apps are served, under its apps/.
RepoDir string
// Watch turns live reload on: while a Data App is open, a change in the repo is an event.
Watch bool
Logger *slog.Logger
// DevFrontendURL, when set, is a Vite dev server serving the frontend from source (make dev):
// the pages redirect there, and it proxies the rest back. The built-in frontend, rebuilt only
// by `pnpm build:web`, would be stale.
DevFrontendURL string
}
Options configure a Server.
type Permissions ¶
type Reader ¶
type Reader struct {
ID int `json:"id"`
Name string `json:"name"`
Email string `json:"email"`
Role string `json:"role"`
Timezone string `json:"timezone"`
Permissions Permissions `json:"permissions"`
}
Reader is who reads the Data Apps, as the Anfra SDK provisions a user: on anfra serve, the local user, who may see everything.
func LocalReader ¶
func LocalReader() Reader
LocalReader is the local user, with the machine's time zone.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server serves a repo's Data Apps. Mount it for /, /apps/ and /appserve/.
func (*Server) Close ¶
func (s *Server) Close()
Close ends every event stream, so a server can shut down without waiting on them.
func (*Server) FrontendBuilt ¶
FrontendBuilt reports whether the pages have a frontend, built into this binary or a dev server: without one, the pages say how to build it, and the backend's routes still work.