ServiceEdge Controller
Service

Edge Controller

Edge controller ontology reference for defining custom routes, edge functions, and their REST, Kafka, and cron settings in a Mindbricks service.

MPO Version: 1.3.0

An edge controller defines a fully customized route handled by a developer-defined function. Unlike standard Busines APIs, it gives full control over the request processing by directly calling a function from the service library. This allows advanced operations like database queries, external API calls, or dynamic responses without following the CRUD cycle. Edge controllers are ideal for building special-purpose APIs or custom flows outside Mindbricks' automatic route generation.

Automatic M2M Edge Functions:

Mindbricks automatically generates M2M-enabled edge functions and their corresponding REST and Kafka controllers for all dbLayer utility functions that perform create, update, or delete operations. These automatic edge functions are generated for each data object and include:

  • m2mCreate{ObjectName} - Create single record
  • m2mBulkCreate{ObjectName} - Create multiple records in bulk
  • m2mUpdate{ObjectName}ById - Update record by ID
  • m2mUpdate{ObjectName}ByQuery - Update records by query
  • m2mUpdate{ObjectName}ByIdList - Update multiple records by ID list
  • m2mDelete{ObjectName}ById - Delete record by ID
  • m2mDelete{ObjectName}ByQuery - Delete records by query

These automatic edge functions are configured with M2MAllowed: true and loginRequired: false, allowing secure inter-service communication via machine-to-machine tokens. They enable other services to call your service's database operations directly without requiring user session tokens.

interface EdgeController = {
  edgeControllerOptions : EdgeControllerOptions;
  edgeRestSettings : EdgeRestSettings;
  edgeKafkaSettings : EdgeKafkaSettings;
  edgeCronSettings : EdgeCronSettings;
}
FieldDescription
edgeControllerOptionsConfiguration object for the edge controller. It defines which edge function will be executed and whether login is required to access it.
edgeRestSettingsHTTP settings for exposing the edge controller as a REST API. It allows specifying the URL path and HTTP method that will trigger the edge function.
edgeKafkaSettingsKafka settings for exposing the edge controller as a Kafka consumer/producer. It allows specifying the Kafka topics that will trigger the edge function and optionally where to send responses.
edgeCronSettingsCron settings for scheduling the edge controller to run at specified intervals. It allows defining a cron expression that will trigger the edge function automatically.

EdgeControllerOptions

MPO Version: 1.3.0

Options that define the execution behavior of the edge controller, including the function to call and login requirement.

interface EdgeControllerOptions = {
  functionName : String;
  M2MAllowed : Boolean;
  loginRequired : Boolean;
}
FieldDescription
functionNameThe name of the function defined in the service library that will handle this controller's logic. The function must be an async module under 'edgeFunctions' and should return an object or throw an error as response.
M2MAllowedIf true, this edge controller can be accessed using machine-to-machine (M2M) tokens without requiring a user session. When enabled, services can call this controller using M2M tokens in addition to (or instead of) user session tokens. This allows for secure inter-service communication. Can be combined with loginRequired to allow both M2M tokens and user sessions, or set loginRequired to false for M2M-only access.
loginRequiredWhether the caller must be logged in to access this edge route. If true, Mindbricks will enforce authentication using session or token checks before invoking the function.

EdgeRestSettings

MPO Version: 1.3.0

Defines the public REST endpoint for the edge controller. Specifies how the route is exposed via HTTP, including path and method.

interface EdgeRestSettings = {
  restEnabled : Boolean;
  path : String;
  method : HTTPRequestMethods;
}
FieldDescription
restEnabledSet to true if you want your edge function to be called through its own REST API. Default is true.
pathThe relative URL path for this controller. It determines where the edge function will be accessible in the REST API (e.g., '/generate-invoice').
methodThe HTTP method that will trigger the edge controller. Typical values include GET, POST, PUT, DELETE, etc.

EdgeKafkaSettings

MPO Version: 1.3.0

Defines Kafka consumer/producer settings for the edge controller. Specifies how the edge function will be triggered by Kafka messages and optionally where to send responses.

interface EdgeKafkaSettings = {
  kafkaEnabled : Boolean;
  requestTopic : String;
  responseTopic : String;
}
FieldDescription
kafkaEnabledSet to true if you want your edge function to be triggered by Kafka messages from the specified request topic. Default is false.
requestTopicThe Kafka topic name from which messages will be consumed to trigger the edge function. When a message arrives on this topic, the edge function will be invoked with the message payload.
responseTopicOptional Kafka topic name where the edge function's response will be published. If not specified, the response will not be sent to Kafka (useful for fire-and-forget scenarios or when using REST for responses).

EdgeCronSettings

MPO Version: 1.3.0

Defines cron scheduling settings for the edge controller. Specifies how the edge function will be triggered automatically at scheduled intervals using a cron expression.

interface EdgeCronSettings = {
  cronEnabled : Boolean;
  cronExpression : String;
}
FieldDescription
cronEnabledSet to true if you want your edge function to be triggered automatically on a schedule. Default is false.
cronExpressionA cron expression that defines when the edge function should be executed. Uses standard cron syntax (e.g., '0 0 * * ' for daily at midnight, '/5 * * * *' for every 5 minutes).
Was this page helpful?
Built with Documentation.AI

Last updated today