API Routes
API Routes
Section titled âAPI RoutesâStelo CMS provides a comprehensive API layer built with tRPC for type-safe client-server communication, with REST fallbacks for external integrations.
tRPC Router Structure
Section titled âtRPC Router Structureâexport const appRouter = router({ // Entity routers pages: pagesRouter, collections: collectionsRouter, globals: globalsRouter, users: usersRouter, media: mediaRouter,
// Utility routers search: searchRouter, analytics: analyticsRouter, auth: authRouter});Common Patterns
Section titled âCommon PatternsâQuery Operations
Section titled âQuery OperationsâgetAll- List all entitiesgetById- Get single entity by IDgetBySlug- Get entity by sluggetPublished- Get published content
Mutation Operations
Section titled âMutation Operationsâcreate- Create new entityupdate- Update existing entitydelete- Delete entitypublish/unpublish- Status changes
Authentication
Section titled âAuthenticationâAll API routes are protected with session-based authentication and role-based permissions.
Response Format
Section titled âResponse FormatâStandard response format ensures consistency:
{ data: T | T[], meta?: { total: number, page: number, limit: number }, error?: string}This section will be expanded with detailed implementation examples.