docs: make the component sections executable in one pass
Expands 3.1 and 3.2 so the work can be done without re-deriving anything. 3.1 now records what 0.8.6 already fixed, separated into the ten components that were miswired and the five that gained outputs they had been firing undeclared, with the caveat that Map's three were converted but never confirmed in a browser. For the 22 that remain it adds the finding that changes the decision: all nine are pure scaffolds with no state, functions or handlers, and five of them duplicate a component that already works -- FileUpload against FileInput and FileUploadProgress, Toast and ToastNotifications against Toaster, AdvancedDatePicker against DatePicker, AdvancedRangeSlider against RangeSlider. Superseding those is a migration entry rather than new code, and leaves Chart, TreeView, Confetti and CopyMarkup as the only ones needing to be built. 3.2 corrects the scaffold count from 23 to 28; the earlier figure used a looser rule. Nine of the 28 are the 3.1 components, so the two items must be planned together, and several of the rest are primitives that need only their styles moved out of ui.css rather than any behaviour. Also corrects the dead-output component count from 11 to 9 in both documents. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,19 +1,44 @@
|
||||
# Inter-app + external API showcase
|
||||
# inter-app-api-showcase
|
||||
|
||||
`GET /api/product-summary?sku=starter` demonstrates one request handler making:
|
||||
A WrNexus **workspace** — multiple apps, one gateway, interconnected.
|
||||
|
||||
1. an RPC request to the `catalog` app (`getProduct`);
|
||||
2. an external HTTPS request to GitHub's public REST API; and
|
||||
3. an RPC request to the `audit` app (`recordLookup`).
|
||||
|
||||
The handler deliberately forwards `as: ctx` only to WRNexus peer apps. The RPC package turns that into a short-lived subject/tenant token; it is never forwarded to GitHub. Each peer app must implement the same contract from `app/lib/contracts.ts` (normally a shared workspace package) under `app/services/`, and must authorize its own procedures.
|
||||
|
||||
Before running this app, configure all three apps with the same private internal-origin map and a distinct, 32+ character RPC secret:
|
||||
|
||||
```sh
|
||||
WRNEXUS_RPC_SECRET=replace-with-a-private-32-character-minimum-secret
|
||||
WRNEXUS_APP_NAME=product-summary
|
||||
WRNEXUS_INTERNAL_ORIGINS={"catalog":"http://127.0.0.1:4101","audit":"http://127.0.0.1:4102"}
|
||||
```
|
||||
inter-app-api-showcase/
|
||||
wrnexus.workspace.ts # apps ↔ domains map (used by `wrnexus gateway`)
|
||||
apps/
|
||||
web/ # a WrNexus app → localhost, web.localhost
|
||||
admin/ # a WrNexus app → admin.localhost
|
||||
packages/
|
||||
shared/ # @app/shared — shared code + cross-app pubsub bus
|
||||
```
|
||||
|
||||
The peer app processes must remain private; the public gateway blocks the RPC route by design. Run with `bun run --cwd examples/inter-app-api-showcase dev`.
|
||||
## Run everything (one port, routed by domain)
|
||||
|
||||
```bash
|
||||
bun install
|
||||
bun run dev # = wrnexus gateway → http://127.0.0.1:3000
|
||||
```
|
||||
|
||||
Add the hosts to your machine (e.g. /etc/hosts):
|
||||
|
||||
```
|
||||
127.0.0.1 web.localhost admin.localhost
|
||||
```
|
||||
|
||||
Open `http://localhost:3000` for the web app or
|
||||
`http://admin.localhost:3000` for the admin app. The ports printed for individual
|
||||
apps are internal gateway targets, not public workspace URLs.
|
||||
|
||||
## Interconnect
|
||||
|
||||
- **Shared code:** import `@app/shared` in any app.
|
||||
- **Runtime messaging:** `import { bus } from "@app/shared"` then
|
||||
`bus.publish("tenant:created", {...})` in one app and
|
||||
`bus.subscribe("tenant:*", fn)` in another (needs Redis).
|
||||
- **Databases:** point apps at the same `db`/`databases` in their config.
|
||||
|
||||
## Add another app
|
||||
|
||||
```bash
|
||||
wrnexus workspace add reports --domain=reports.localhost
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user