||
Skip to end of metadata
Go to start of metadata

Follow the instructions below to add a new global API, which will affect all the asset types:

For more information on app extensions, see Introduction to App Extensions.

  1. Create the shell of an app extension. For more information, see Creating the Shell of an App Extension.
  2. Define the new API in the app.server callback method of the app.js file, in the Publisher or Store, based on your customization requirements. The app.js files of the Publisher and Store app extension are as follows:

    ES ComponentFile Path
    Publisher<ES_HOME>/repository/deployment/server/jaggeryapps/publisher/extensions/app/<APP_EXTENSION_NAME>/app.js
    Store<ES_HOME>/repository/deployment/server/jaggeryapps/store/extensions/app/<APP_EXTENSION_NAME>/app.js

    Example:
    The following screenshot shows how an API named tiers, which is defined in the tiers.jag file, is defined.

    app.server = function(ctx) {
        return {
            endpoints: {
                apis: [{
                    url: 'tiers',
                    path: 'tiers.jag'
                }]
            }
        }
    };
  3. Add the controller, which is defined in a .jag  file, into the apis  directory. This controller will serve the newly added API. The apis  directory of the Publisher and Store app extension are as follows:

    ES ComponentDirectory
    Publisher<ES_HOME>/repository/deployment/server/jaggeryapps/publisher/extensions/app/<APP_EXTENSION_NAME>/apis
    Store<ES_HOME>/repository/deployment/server/jaggeryapps/store/extensions/app/<APP_EXTENSION_NAME>/apis
  4. Restart the ES server, so that ES evaluates the changes in the app.js file.
    Thereafter, access the respective ES console and access the newly created endpoint.

    • If the API exists in the Publisher:
      http://<ES_HOST>:<ES_HTTP_PORT>/publisher/apis/<API_NAME>
      https://<ES_HOST>:<ES_HTTPS_PORT>/publisher/apis/<API_NAME> 
    • If the API exists in the Store:
      http://<ES_HOST>:<ES_HTTP_PORT>/store/apis/<API_NAME>

      https://<ES_HOST>:<ES_HTTPS_PORT>/store/apis/<API_NAME>

    Example:

    You can access the API using one of the following URLs based on where you created the new API (i.e., Store or Publisher):

    ES
    Component
    URL
    Storehttp://localhost:9763/store/apis/tiers
    https://localhost:9443/store/apis/tiers
    Publisherhttp://localhost:9763/publisher/apis/tiers
    https://localhost:9443/publisher/apis/tiers
  • No labels