Skip to content

feat: $HTTP_NU const + examples hub#42

Merged
cablehead merged 5 commits intomainfrom
feat/http-nu-const
Feb 26, 2026
Merged

feat: $HTTP_NU const + examples hub#42
cablehead merged 5 commits intomainfrom
feat/http-nu-const

Conversation

@cablehead
Copy link
Owner

@cablehead cablehead commented Feb 26, 2026

$env.HTTP_NU was a mutable env var with just {dev: bool}. Scripts had no way to inspect how the server was started.

$HTTP_NU is now an immutable const record exposing all CLI options: dev, datastar, watch, store, topic, expose, tls, services. Optional string fields are null when not set.

> http-nu --datastar --store ./store :3001 serve.nu
> $HTTP_NU
╭───────────┬─────────╮
 dev        false   
 datastar   true    
 watch      false   
 store      ./store 
 topic              
 expose             
 tls                
 services   false   
╰───────────┴─────────╯

Examples hub

examples/serve.nu mounts individual examples under one server:

http-nu --datastar :3001 examples/serve.nu
http-nu --datastar --store ./store :3001 examples/serve.nu

The hub uses $HTTP_NU.store to conditionally mount store-dependent examples (quotes) and grey them out in the index when unavailable. Templates auto-seeds its store topics on startup.

Other changes

  • All example sub-handlers use relative ./ paths so they work both standalone and mounted
  • quotes: .head -> .last, threshold-gate filter for clean SSE startup
  • templates: seeds store topics at source time when $HTTP_NU.store != null
  • basic: drains $in before generate for /time streaming

Exposes all CLI options (dev, datastar, watch, store, topic, expose,
tls, services) as an immutable const record so scripts can inspect
how the server was started.
Root examples/serve.nu mounts individual examples under path prefixes.
All sub-handlers use relative ./ paths so they work both standalone and
mounted. Store-dependent examples (quotes) are conditionally mounted
based on $HTTP_NU.store and greyed out in the index when unavailable.

- basic: use relative paths, drain $in before generate for /time
- datastar-sdk: @post('./increment') etc.
- mermaid-editor: ./mermaid-diagram.js, @post('./')
- quotes: .head -> .last, add threshold-gate filter, @get('./')
- templates: seed store topics on startup, relative nav links
Move mount from inline defs into http-nu/router so it's reusable.
Fixes path stripping (substring instead of str replace), adds
$req.mount_prefix for sub-handlers that need absolute paths.

www/serve.nu mounts examples hub at /examples/ with nav link.
@cablehead cablehead merged commit 1818768 into main Feb 26, 2026
7 checks passed
@cablehead cablehead deleted the feat/http-nu-const branch February 26, 2026 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant