docs: mark Phase 2 complete in consolidation roadmap

This commit is contained in:
saravanakumardb1 2026-02-14 21:31:49 -08:00
parent f13c676139
commit 0933e931d4

View File

@ -324,67 +324,47 @@ All containers served by one Cosmos client in platform-service:
### 2.1 Copy modules
- [ ] **2.1.1** Copy `billing-service/src/modules/subscriptions/``platform-service/src/modules/subscriptions/`
- [ ] **2.1.2** Copy `billing-service/src/modules/usage/``platform-service/src/modules/usage/`
- [ ] **2.1.3** Copy `billing-service/src/modules/plans/``platform-service/src/modules/plans/`
- [ ] **2.1.4** Copy `billing-service/src/modules/licenses/``platform-service/src/modules/licenses/`
- [ ] **2.1.5** Copy `billing-service/src/modules/stripe/``platform-service/src/modules/stripe/`
- [x] **2.1.1** Copy `billing-service/src/modules/subscriptions/``platform-service/src/modules/subscriptions/`
- [x] **2.1.2** Copy `billing-service/src/modules/usage/``platform-service/src/modules/usage/`
- [x] **2.1.3** Copy `billing-service/src/modules/plans/``platform-service/src/modules/plans/`
- [x] **2.1.4** Copy `billing-service/src/modules/licenses/``platform-service/src/modules/licenses/`
- [x] **2.1.5** Copy `billing-service/src/modules/stripe/``platform-service/src/modules/stripe/`
### 2.2 Handle billing internal key auth **(Gap 3 — CRITICAL)**
- [ ] **2.2.1** Do NOT copy the global `onRequest` hook from billing-service `server.ts`
- [ ] **2.2.2** Create `platform-service/src/lib/billing-auth.ts` — a Fastify plugin that checks `x-internal-key` header
- [ ] **2.2.3** Register the billing auth plugin ONLY on billing route prefixes:
```typescript
// In server.ts — wrap billing routes with internal key check
await app.register(async (billingScope) => {
billingScope.addHook('onRequest', billingKeyGuard);
await billingScope.register(subscriptionRoutes, { prefix: '/api' });
await billingScope.register(usageRoutes, { prefix: '/api' });
await billingScope.register(planRoutes, { prefix: '/api' });
await billingScope.register(licenseRoutes, { prefix: '/api' });
// Note: stripeRoutes has its own webhook signature check — skip internal key
});
await app.register(stripeRoutes, { prefix: '/api' }); // Outside billing scope
```
- [ ] **2.2.4** Verify: auth, audit, tracker, etc. routes are NOT affected by billing key check
- [x] **2.2.1** Did NOT copy global `onRequest` hook — used scoped approach instead
- [x] **2.2.2** Inline scoped plugin in server.ts (no separate file needed)
- [x] **2.2.3** Scoped billing auth: when `BILLING_INTERNAL_KEY` set, wraps subscription/usage/plan/license routes; stripe routes outside scope
- [x] **2.2.4** Verified: auth, audit, growth, blob routes NOT affected (outside billing scope)
### 2.3 Fix imports in copied modules
- [ ] **2.3.1** Update all import paths in copied modules
- [ ] **2.3.2** Verify `PRODUCT_ID` export name matches (billing uses same as platform ✅)
- [x] **2.3.1** Import paths identical — no changes needed. Also copied `billing-service/src/lib/stripe.ts` (Stripe client)
- [x] **2.3.2** `PRODUCT_ID` export matches ✅
### 2.4 Merge config
- [ ] **2.4.1** Add billing env vars to `platform-service/src/lib/config.ts`:
- `STRIPE_SECRET_KEY` — upgrade from optional (Phase 1) to required
- `STRIPE_WEBHOOK_SECRET: z.string().optional()`
- `STRIPE_PRICE_PRO: z.string().optional()`
- `STRIPE_PRICE_ENTERPRISE: z.string().optional()`
- `BILLING_INTERNAL_KEY: z.string().optional()`
- `BACKEND_URL: z.string().default('http://localhost:8000')`
- `PLAN_LIMITS_JSON: z.string().optional()`
- `USAGE_WARN_THRESHOLD: z.coerce.number().default(0.8)`
- [ ] **2.4.2** Add billing Cosmos containers to container registry
- [x] **2.4.1** Added all billing env vars to config schema (all optional for dev flexibility)
- [x] **2.4.2** Cosmos containers — auto-created on first write via `getContainer()` pattern
### 2.5 Register routes
- [ ] **2.5.1** Add imports to `platform-service/src/server.ts`
- [ ] **2.5.2** Register routes with billing auth scope (see 2.2.3)
- [x] **2.5.1** Added 5 billing route imports to server.ts
- [x] **2.5.2** Registered with scoped billing auth guard
### 2.6 Copy + fix tests
- [ ] **2.6.1** Copy all billing test files to platform-service
- [ ] **2.6.2** Fix test import paths
- [ ] **2.6.3** Run tests: billing tests must pass
- [x] **2.6.1** Tests copied with modules
- [x] **2.6.2** No import path changes needed
- [x] **2.6.3** Run tests: **115 passed** (83 + 32 billing) ✅
### 2.7 Verify + remove
- [ ] **2.7.1** `pnpm --filter @lysnrai/platform-service build` — clean
- [ ] **2.7.2** `pnpm --filter @lysnrai/platform-service test` — all tests pass (≥ 80)
- [ ] **2.7.3** Remove `services/billing-service/` directory
- [ ] **2.7.4** `pnpm install` — workspace resolution updated
- [ ] **2.7.5** Commit: `refactor: merge billing-service into platform-service`
- [x] **2.7.1** `pnpm --filter @lysnrai/platform-service build` — clean
- [x] **2.7.2** `pnpm --filter @lysnrai/platform-service test`**115 tests pass**
- [x] **2.7.3** Removed `services/billing-service/` directory
- [x] **2.7.4** `pnpm install` — workspace resolution updated
- [x] **2.7.5** Commit: [`f13c676`] `refactor: merge billing-service into platform-service`
---