Service Definition

An application can access external services only when these services are specified in a prescribed way. Specifying an external API service includes authentication and endpoints. The platform hides internal details of these services and exposes new URIs for consumption by the front-end.

Trillo applications integrate with several external services such as a credit agency, business verification service, Google Place, document generation service, payment service, email service, etc.

The platform has an API Gateway Service as a part of its cluster. This API Gateway supports integration with external services. A service can be imported into the application by merely adding its Swagger file and its definition in a JSON file (security settings mainly). If the service uses OAuth2, the API Gateway transparently manages the life cycle of tokens (“access-token”, “refresh-token”). The server, in turn, publishes API like any other Gateway. Besides, the external APIs become available as callable methods and can be invoked from the serverless functions.

A sample service definition is shown below. The specification also includes the endpoints learned from the associated Swagger API specifications (more details will follow in later sections).

{
  "authBodyTemplate" : "grant_type=password&username={username}&password={password}",
  "docUrl" : "/_model/api-service/quote/d3",
  "name" : "d3",
  "props" : {
    "grant_type" : "password",
    "oauthUrl" : "https://***********",
    "client_id" : "d3-api",
    "client_secret" : "*******",
    "username" : "*******",
    "password" : "*******",
    "deployParameters" : { }
  },
  "routeSpecs" : [
    {
      "location" : "https://***",
      "path" : "/svc/quote/***",
      "secure" : true
    },
    {
      "location" : "https://***",
      "path" : "/svc/quote/***",
      "secure" : true
    }
  ],
  "trilloService" : false,
  "type" : "externalService",
  "useHttps" : true,
  "useOAuth" : true
}