Instruction file imported from AugusDogus/multiplex (
.cursor/rules/api-patterns.mdc). Copyright stays with the author.
API Development Patterns
Plex API Integration
- Follow existing patterns in packages/plex-query/src/plex/clients/
- Use
PlexServerClientandPlexTvClientconsistently - Handle authentication and connection management as existing methods do
Request/Response Handling
- DO NOT handle API requests differently than current implementations
- Parse Plex responses with Zod schemas at the
plex-queryboundary - Follow the pattern: raw fetch → schema validation → typed return
- Use existing error handling patterns from packages/plex-query/src/plex/types/client-types.ts
Schema Development
- Study existing schemas in packages/plex-query/src/plex/schemas/
- Use real API responses to build schemas, not assumptions
- Test schema validation with actual Plex server responses
- If you don't have example responses, ask for them or research the Plex API docs
tRPC Integration
- Server data is owned by tRPC, TanStack Query, SuperJSON, and RSC hydration; follow apps/web/src/server/api/ and apps/web/src/trpc/
- Use
protectedProcedurefor authenticated endpoints - Validate inputs with Zod schemas
- Return properly typed responses