What Are Controllers?
Controllers handle incoming requests from different sources, process them, and then delegate the business logic to services. They:- Accept input from various sources (HTTP, GraphQL, scheduled jobs, etc.)
- Validate and transform the input as needed
- Call the appropriate services to execute business logic
- Return responses in the appropriate format
Types of Controllers
Orionjs supports several types of controllers, each serving a specific purpose:HTTP Controllers (Routes)
Handle HTTP requests through REST endpoints. They define routes, methods, authentication, and validation for web API endpoints.GraphQL Controllers
Manage GraphQL operations through resolvers. There are three subtypes:- Query Resolvers: Handle data fetching operations
- Mutation Resolvers: Handle data modification operations
- Model Resolvers: Define how GraphQL types resolve their fields
Job Controllers
Execute scheduled or on-demand background tasks. These can be:- Scheduled Jobs: Run at specific times or intervals
- Event-Triggered Jobs: Run in response to specific events