Skip to content

Commit 7ddd6e1

Browse files
author
Siva
committed
feat(samples): add Node.js ecommerce demo app
- Express.js server with flag-driven checkout, catalog, promotions - 9 flag YAML files matching the cross-language demo patterns - package.json with flagway SDK dependency
1 parent 6aca49b commit 7ddd6e1

15 files changed

Lines changed: 2243 additions & 0 deletions
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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

Comments
 (0)