nodeadmin

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: MIT Imports: 22 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).

Usage

handler, err := nodeadmin.New(nodeadmin.Options{
    Store:            store,            // nodestore.StoreInterface (required)
    IsAccessAllowed:  isAllowed,       // optional; nil = open. Host-owned auth.
    OnUnauthorized:   onDenied,        // optional denied-response writer
    GetAuthUserID:    authUserIDFunc,  // optional identity for display/audit
    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.

Auth

Auth is host-owned: the library stores no users and verifies no credentials. IsAccessAllowed(r) is the only gate — wire it to your session middleware, SSO, or a Basic-auth adapter. OnUnauthorized(w, r) writes the denied response (redirect to your login, JSON 401, …); default is a plain 401. GetAuthUserID(r) supplies an identity string for display/audit only. The same seam protects node-served HTTP listeners (listener "main") via the engine's HTTPAuthenticator.

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 dracory/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

This section is empty.

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 access check.
	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

	// IsAccessAllowed reports whether the request may use the admin.
	// Authentication is host-owned (GOD ruling 2026-11-25): sessions,
	// login, users and roles all live outside this package — it only
	// asks this one question per request. Nil means open (standalone
	// or dev mode).
	IsAccessAllowed func(r *http.Request) bool

	// OnUnauthorized writes the response for a request IsAccessAllowed
	// denied — the host decides: a redirect to its login page, a JSON
	// 401 for API clients, etc. Nil replies "authentication required"
	// with status 401.
	OnUnauthorized func(w http.ResponseWriter, r *http.Request)

	// GetAuthUserID returns the authenticated user's ID for display
	// and audit purposes only — it is never consulted for the access
	// decision. Optional.
	GetAuthUserID func(r *http.Request) string

	// AdminHomeURL is the admin home link exposed to sections through
	// the request context (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

	// DisableChrome hands chrome ownership to the host: the editor —
	// a standalone page that bypasses FuncLayout — emits no nodeadmin
	// navbar or section pills so an embedding host can wrap it in its
	// own chrome. Sections are unaffected (they already render through
	// FuncLayout when set). The zero value keeps the default chrome.
	DisableChrome bool
}

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 dracory/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 dracory/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 nodes renders the all-node-instances list section — a flat inventory of every stored node entity across workflows, with its type, parent workflow, node group and wire counts, and an open-in-editor deep link.
Package nodes renders the all-node-instances list section — a flat inventory of every stored node entity across workflows, with its type, parent workflow, node group and wire counts, and an open-in-editor deep link.
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 dracory/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 dracory/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