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.
- Create the shell of an app extension. For more information, see Creating the Shell of an App Extension.
Define the new API in the
app.server
callback method of theapp.js
file, in the Publisher or Store, based on your customization requirements. Theapp.js
files of the Publisher and Store app extension are as follows:ES Component File 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 namedtiers
, which is defined in thetiers.jag
file, is defined.app.server = function(ctx) { return { endpoints: { apis: [{ url: 'tiers', path: 'tiers.jag' }] } } };
Add the controller, which is defined in a
.jag
file, into theapis
directory. This controller will serve the newly added API. Theapis
directory of the Publisher and Store app extension are as follows:ES Component Directory 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
Restart ES, 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
ComponentURL Store http://localhost:9763/store/apis/tiers
https://localhost:9443/store/apis/tiersPublisher http://localhost:9763/publisher/apis/tiers
https://localhost:9443/publisher/apis/tiers- If the API exists in the Publisher: