nodeadmin

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: MIT Imports: 24 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

nodeadmin

Mountable admin HTTP/UI surface for nodestore-based workflows — the Node-RED-style flow editor, workflow management, and JSON API. Follows the dracory admin-module pattern (like taskadmin/shopadmin).

Currently developed inside the goflow module as pkg/nodeadmin; this repository is the extraction target once the package is fully working.

Usage

handler, err := nodeadmin.New(nodeadmin.Options{
    Store:        store,              // nodestore.StoreInterface (required)
    AuthUserID:   authUserIDFunc,     // optional; "" redirects to AdminHomeURL
    AdminHomeURL: "/",
    NodeAdminURL: "/nodes",           // mount point used for link building
    FuncLayout:   myLayout,           // optional outer chrome
})
mux.Handle("/nodes/", http.StripPrefix("/nodes", handler))

New returns an Interface (a plain http.Handler) mountable on any router — ServeMux, chi, gin, echo.

Structure

  • nodeadmin.go — entry point: Options, Interface, controller dispatch on ?controller=
  • api/ — JSON API under /api/*: workflow/message CRUD, start/stop/status, node palette + schemas, inject, run journal, queues, groups, global env, Node-RED import. Responses keep the gouniverse/api envelope (status/message/data).
  • editor/ — the Drawflow-based flow editor (Vue 3 + dracory/floweditor fork via CDN, no build step)
  • home/ — admin dashboard landing section
  • workflows/ — workflow list/groups section
  • messages/ — message inspection section
  • shared/ — section nav, layout fallback, controller constants

Rules

  • Depends on nodestore.StoreInterface only — never on concrete store types.
  • Execution is opt-in: nodeadmin defines a narrow engine interface (deploy/stop/inject/status/journal/queue ops) that a noderun WorkflowEngine satisfies structurally — nodestore stays a pure storage layer and knows nothing about execution or admin.
  • One wildcard route + manual dispatch — http.ServeMux panics on overlapping wildcards.

Documentation

Overview

Package nodeadmin provides a mountable admin interface for the nodestore-backed node domain, following the same dracory admin module pattern as flowadmin.

The package exposes a single entry point, New(Options), which returns an http.Handler that the host application can mount under any path on any router (net/http ServeMux, chi, gin, echo, etc.).

The admin UI surface is one Handle(w, r) mounted at "/" dispatching on the ?controller= query parameter through a routes map built once at construction (default: the home dashboard). Sections are functions (section.UI(uiConfig).SectionName(w, r)); outer chrome is host-owned through Options.FuncLayout, falling back to shared.Layout. The API is served under /api/* by the api subpackage backed by nodestore.

Index

Constants

This section is empty.

Variables

View Source
var ErrStoreRequired = errors.New("nodeadmin: store is required")

ErrStoreRequired is returned by New when Options.Store is nil

Functions

func BasicAuthenticator

func BasicAuthenticator(path string) (func(r *http.Request) (string, bool), error)

BasicAuthenticator loads a Node-RED-style auth file and returns a request authenticator reporting the authenticated username — the signature noderunner.WorkflowEngine.HTTPAuthenticator expects, so runtime listeners (submitIn auth "admin") share the admin credentials.

func HashPassword

func HashPassword(password string) (string, error)

HashPassword returns a bcrypt hash suitable for the auth file's "password" field

Types

type Interface

type Interface interface {
	http.Handler
	// Handle is the single admin-surface entry point: the
	// ?controller= query parameter is dispatched through the routes
	// map built once at construction.
	Handle(w http.ResponseWriter, r *http.Request)
	// HTTPRouter returns the shared-listener adapter mounted on this
	// handler — the nodebase.HTTPRouter the engine is wired with at New.
	// Routes registered through it serve on this handler, behind the
	// same auth middleware.
	HTTPRouter() nodebase.HTTPRouter
}

Interface defines the node admin. It is a standard http.Handler and can be mounted on any router.

func New

func New(opts Options) (Interface, error)

New creates a new node admin instance. Returns ErrStoreRequired if Options.Store is nil.

type Options

type Options struct {
	// Store is the nodestore.StoreInterface used for persistence
	// (required).
	Store nodestore.StoreInterface

	// AuthUserID returns the authenticated user ID for the request.
	// If set and it returns "", the request is redirected to
	// AdminHomeURL. If nil, authentication falls back to the basic-auth
	// credentials (AuthFile, then the config store).
	AuthUserID func(r *http.Request) string

	// AuthFile is the path to a Node-RED adminAuth-style JSON
	// credentials file ({"users":[{"username","password(bcrypt)"}]}).
	// When set and AuthUserID is nil, HTTP Basic auth is enforced —
	// the same file-based protection Node-RED's adminAuth provides.
	// When empty, credentials are read from the config store key
	// "admin.auth" (interim source; the creds entity lands in P4).
	AuthFile string

	// AdminHomeURL is the URL unauthenticated requests are redirected
	// to (default: "/").
	AdminHomeURL string

	// NodeAdminURL is the base URL the node admin is mounted on —
	// injected into the request context for section link building
	// (default: "/nodes").
	NodeAdminURL string

	// Engine is the engine deployed workflows run in, expressed as the
	// narrow api.EngineInterface contract — nodeadmin does not depend
	// on a concrete runner (GOD ruling 2026-11-24; the stock
	// noderunner.WorkflowEngine satisfies it structurally). If nil a
	// fresh noderunner engine is created. On mount, engines that
	// support it resume every workflow whose persisted deployed flag
	// is set (restart-resume).
	Engine api.EngineInterface

	// FuncLayout is an optional function to render the admin interface
	// inside your own layout (branding, menus, etc.). If nil, the
	// default shared.Layout is used.
	FuncLayout shared.FuncLayout
}

Options contains all dependencies and configuration for the node admin.

Directories

Path Synopsis
Package api provides the JSON API for the node admin surface — POST endpoints returning gouniverse/api envelopes, same convention as flowadmin/api but backed by nodestore.
Package api provides the JSON API for the node admin surface — POST endpoints returning gouniverse/api envelopes, same convention as flowadmin/api but backed by nodestore.
Package dashboard serves the end-user dashboard client page — the single-file HTML shell + widget renderers ported from the retiring pkg/flowdashboard.
Package dashboard serves the end-user dashboard client page — the single-file HTML shell + widget renderers ported from the retiring pkg/flowdashboard.
Package editor serves the workflow editor — the same Vue app as flowadmin's /editor — as a nodeadmin section selected through ?controller=editor.
Package editor serves the workflow editor — the same Vue app as flowadmin's /editor — as a nodeadmin section selected through ?controller=editor.
Package settings is the settings section of the node admin, modeled on flowadmin's settingsmanager (itself the taskadmin/shopadmin folder-per-controller pattern): the nodeadmin dispatch map invokes section.UI(uiConfig).SettingsManager(w, r) for ?controller=settings — no action renders the page through the UiConfig layout, ?action=load-settings and ?action=save-setting answer JSON AJAX requests in the gouniverse/api envelope under the same controller URL.
Package settings is the settings section of the node admin, modeled on flowadmin's settingsmanager (itself the taskadmin/shopadmin folder-per-controller pattern): the nodeadmin dispatch map invokes section.UI(uiConfig).SettingsManager(w, r) for ?controller=settings — no action renders the page through the UiConfig layout, ?action=load-settings and ?action=save-setting answer JSON AJAX requests in the gouniverse/api envelope under the same controller URL.

Jump to

Keyboard shortcuts

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