|
| 1 | +# FlagWay JS/TS SDK Demo — ecommerce-app-node |
| 2 | + |
| 3 | +A demo Express application showing the **@flagway/sdk** in action with a **Flag-to-Code Traceability Dashboard**. |
| 4 | + |
| 5 | +## Quick Start |
| 6 | + |
| 7 | +```bash |
| 8 | +# From the flagway-js monorepo root |
| 9 | +pnpm install |
| 10 | +pnpm --filter @flagway/sdk build |
| 11 | +pnpm --filter @flagway/loader build |
| 12 | + |
| 13 | +# Run the demo |
| 14 | +cd samples/ecommerce-app-node |
| 15 | +node server.js |
| 16 | +``` |
| 17 | + |
| 18 | +Open [http://localhost:3001/dashboard](http://localhost:3001/dashboard) |
| 19 | + |
| 20 | +## What It Demonstrates |
| 21 | + |
| 22 | +| Feature | Endpoint | SDK Methods | |
| 23 | +|---------|----------|-------------| |
| 24 | +| Catalog features | `GET /catalog` | `isEnabled`, `getValueAs` | |
| 25 | +| Checkout (env-aware) | `GET /checkout/:env` | `isEnabledInEnv`, `getValueInEnv` | |
| 26 | +| Promotions (env-aware) | `GET /promotions/:env` | `getValueInEnv`, `getValueInEnvAs` | |
| 27 | +| Full traceability | `GET /flagway/state` | `exportState()` | |
| 28 | +| Flag inventory | `GET /flagway/flags` | `getAllFlags` | |
| 29 | +| Aggregate metrics | `GET /flagway/metrics` | `getAllFlags` | |
| 30 | +| Traceability Dashboard | `GET /dashboard` | All of the above | |
| 31 | + |
| 32 | +## Architecture |
| 33 | + |
| 34 | +``` |
| 35 | +SDK provides data → App owns the HTTP layer |
| 36 | +``` |
| 37 | + |
| 38 | +The entire `/flagway/state` integration is **4 lines**: |
| 39 | + |
| 40 | +```typescript |
| 41 | +app.get('/flagway/state', (req, res) => { |
| 42 | + res.json(client.exportState()); |
| 43 | +}); |
| 44 | +``` |
| 45 | + |
| 46 | +The dashboard consumes this endpoint to render a rich traceability UI. |
| 47 | + |
| 48 | +## Flag Files |
| 49 | + |
| 50 | +The `flags/` directory contains 10 example Flag CRDs covering: |
| 51 | +- Active flags with environment overrides |
| 52 | +- Archived flags (tombstones) |
| 53 | +- Expired flags past cleanup deadline |
| 54 | +- Snoozed migrations |
0 commit comments