ui

package
v1.41.0 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2026 License: MIT Imports: 5 Imported by: 0

README

commerce/ui

Embedded admin SPA — built externally in the Hanzo GUI workspace.

Build

cd ../gui/apps/admin-commerce && bun run build

Sync

./scripts/sync-admin-ui.sh

The synced dist/ is baked into the commerced binary via //go:embed. Served at /_/commerce/ by pkg/commerce/server.go.

Documentation

Overview

Package ui exposes the built admin-commerce (Hanzo GUI v7) bundle as an embedded filesystem.

The bundle is produced externally in the @hanzo/gui workspace at ~/work/hanzo/gui/apps/admin-commerce (Vite + Hanzo GUI v7) and synced into ui/dist by scripts/sync-admin-ui.sh. The synced dist/ is baked into the commerced binary at compile time — no external static-assets directory, no sidecar, no separate deploy.

Mount the returned handler at /_/commerce/ in the commerced HTTP router so it serves the SPA shell for every non-API request:

import commerceui "github.com/hanzoai/commerce/ui"
mux.Handle("/_/commerce/", http.StripPrefix("/_/commerce", commerceui.Handler()))

API routes under /v1/commerce/* take precedence via earlier route registration; anything else falls through to the SPA, which uses client-side routing so deep links survive reload.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FS

func FS() fs.FS

FS returns the embedded built-UI filesystem rooted at dist/. Empty when scripts/sync-admin-ui.sh has not been run.

func Handler

func Handler() http.Handler

Handler returns an http.Handler that serves the embedded SPA.

Behaviour:

  • Hashed assets under /assets/ are cached forever (Vite emits content-addressed names).
  • index.html and other static files are served with no-cache.
  • Anything that doesn't exist falls through to index.html so react-router's BrowserRouter handles the deep link.
  • If the build hasn't run and index.html is missing, every request returns 503 so operators notice in staging before shipping a blank image to production.

Types

This section is empty.

Jump to

Keyboard shortcuts

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