Hello. I’m trying to use Tyk as a gateway that can take in a single request and perform multiple calls to another API and return a specially crafted result.
e.g.
User sends request to ‘http://tykmachine:8080/test/createMeal’
tyk calls to my back-end API methods, ‘createStarter’, ‘createMain’, ‘createDesert’, takes the created IDs and calls ‘createFullMeal’ and returns a response with the ID of final created meal item and the other pieces created.
From reading the site it seems like Virtual EndPoints are my best option, listening on a path and specifying a JavaScript file that can then make calls to the API. I have some questions about this.
-
I can’t hardcode the address of my back-end API into the JavaScript files. The API is a Docker container that will run in many different environments so no fixed IP or hostname is available and it isn’t feasible to have people update the urls in multiple JavaScript files. What is the best way to provide the address of the back-end API for use in the JavaScript file? The issue of config has come up previously in the thread but I’m hoping there may be some way to pass even the ‘target_url’ from the app config file since creating a service to provide configuration information is leading us away from the reason for using Tyk (to simplify our APIs).
-
Are there any suggestions for debugging the JavaScript endpoints? The docs suggest using ‘log’ however a call like ‘log(config)’ just outputs “[object Object]” which is of limited use. Currently I’m planning to isolate my JS and test it separately, mocking up the parameters provided by Tyk and importing the API functions available but was wondering if there’s any better advice?
The Tyk Gateway is running as a Docker container, as is the back-end API.
Thanks for any assistance you can provide.