## CTE Utils System
- Created comprehensive CTE (Common Table Expression) builder utilities
- Supports declarative query building with automatic relation handling
- Smart strategy selection between JOIN+GROUP BY and subquery patterns
- Handles nested relations with automatic optimization
- Type-safe query construction with Drizzle ORM
## Platform Users Enhancements
- Refactored to use new CTE utils for cleaner query building
- Added analytics middleware to Hono pipeline
- Improved query param handling with queryStringArray helper
- Changed timestamps from ISO strings to milliseconds for consistency
- Extracted cleanOrgSlug utility function
## Other Improvements
- Added analytics middleware for Hono routes
- Enhanced base middleware with better context handling
- Fixed template literal linting in initHono.ts
- Updated logger for better structured logging
- Added test files for CTE development
## File Changes
- New: server/src/db/cteUtils/ - Complete CTE builder system
- New: server/src/honoMiddlewares/analyticsMiddleware.ts
- Modified: handleListPlatformUsers.ts - Refactored with CTE utils
- Modified: platformModels.ts - Updated types and validation
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Implement paginated endpoint to list users and their organizations created by master org through the platform exchange flow.
## Changes
- Create shared/api/platform/platformModels.ts with Zod schemas for query params and response types
- Implement handleListPlatformUsers handler with pagination support (limit/offset)
- Add expand=organizations query param to fetch up to 100 orgs per user
- Clean org slugs by removing master org prefix in responses
- Create honoPlatformRouter and register it in Hono app at /v1/platform/users
- Export platform types from shared package index
- Apply biome linting fixes to platformRouter.ts (let -> const conversions)
## Features
✅ Paginated results (limit 1-100, default 10)
✅ Offset-based pagination matching handleBatchCustomers pattern
✅ Optional organizations expansion
✅ Filters by organizations.created_by = ctx.org_id
✅ Removes master org slug prefix from org responses
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>