Is it possible to import npm modules (ex. request-promise) for JS in a reverse proxy?

I have to send parallel call out using JS (JavaScript), I am trying to use "revereproxy" to do this, but cannot figure out below.

- How to load npm modules that I use in JS.

- What is the resource name I need to use for package.json, actual .js.

- What should be Http Target, should I need to need to get rid of it and set node:// ?

Any help to elaborate this would be useful.

Many thanks!!

0 6 323
6 REPLIES 6

Yes, it is possible.

For a specific example, see here:

https://community.apigee.com/comments/78552/view.html

Sorry @Dino-at-Google didn't get you. I assume I have to:

- Use javascript, where the .js automatically generates in jsc resource?

- But, where do I need to place the package.json, *lock.json. Will these be part of node resource?

- Is there any other configuration change required in "reverse proxy" compare to something implemented in "HT"?

Thanks,

Ravi

Did you click the link? There is a working API proxy there. It shows where package.log goes.

I don't know what you mean by "I assume I have to Use javascript, where the .js automatically generates in jsc resource?" I don't understand that question. I think maybe for this question too, even though I didn't understand it, you could clarify the answer for yourself by looking at the actual, working API Proxy bundle I referenced.

For your third question, same. Look at the working example. It shows you what you need to do. You said you imported it and it is working. So I know you have seen the attachment. Just look at the proxy. Also, There is documentation on this.

Thanks for coming back Dino, and sorry for the confusion. Yes, I understand the link you are referring to, is a "Hosted Target" sample and it works there.

But I want to create a "Reverse Proxy", and make the above working there. I have attached the reverse proxy.reverse-proxy-rev1-2020-01-24.zip . I know something is definitely not right here (like I think I have to remove listening port which is required in HT but not here etc.,), but might need your help.

You have pointed out that my example shows how to use a Hosted Target, and you tell me you want to do something different; you want to use a "Reverse Proxy". But the distinction you are trying to make is not valid.

The central metaphor in Apigee is the "reverse proxy". All Apigee Proxies can be considered as "reverse proxies".

Within the proxy you can configure one or more different targets. The types of targets available to you include:

  1. HTTP Target
  2. Hosted Target
  3. Local Target
  4. null target (no target at all)

Hosted Target implies connecting to a nodejs server that you write (today, anyway). Conversely, if you are not using a Hosted Target in your Apigee proxy, then there is no way to use nodejs.

If by saying, "I want to create a Reverse Proxy", you mean to imply "I don't want to use a Hosted Target", then the inevitable implication is, you will not use nodejs. If you do not use a Hosted Target, you cannot use nodejs.

The link is no longer available.