Can we add node.js as policy?

Hi,

I want to add node.js as first policy and then want to add other policies. How can i do it? i am not getting nodejs option in service callout.

please reply asap.

Solved Solved
1 7 1,297
2 ACCEPTED SOLUTIONS

In Apigee Edge, you cannot use nodejs as a policy. A Nodejs app can be a target. But not a policy.

It is possible to specify a JavaScript callout as a policy. But this is not nodejs.

Check the documentation for more details.

View solution in original post

Not applicable

Conceivably, you could do two things:

  • Leverage Node.js for the heavy lifting. You can use Node.js to fetch attachments and encode base64 and leverage variables two pass values to/from Node.js. In this case you'll have an API Proxy that supports both. I have applied this pattern in the past and it works fine.
  • Call Node.js from JavaScript Policy or Service Callout. In this case Node.js will be a separate API Proxy from the XML-based Proxy. There are some caveats with this approach as you'll be effectively doubling your requests to the same MP. So, you gotta account for capacity in this case as it will have an impact on it. In most cases this is okay.

Hope it helps!

View solution in original post

7 REPLIES 7

Have you gone through any of the Getting Started documentation?

In Apigee Edge, you cannot use nodejs as a policy. A Nodejs app can be a target. But not a policy.

It is possible to specify a JavaScript callout as a policy. But this is not nodejs.

Check the documentation for more details.

@dino Actually some operation I am doing is working in node.js but if I do the similar task in Java script ,it doesn't give me proper results. E.g. fetching attachment and encode base64.

Is there any other way to execute node.js code somehow in policies.

Not applicable

Conceivably, you could do two things:

  • Leverage Node.js for the heavy lifting. You can use Node.js to fetch attachments and encode base64 and leverage variables two pass values to/from Node.js. In this case you'll have an API Proxy that supports both. I have applied this pattern in the past and it works fine.
  • Call Node.js from JavaScript Policy or Service Callout. In this case Node.js will be a separate API Proxy from the XML-based Proxy. There are some caveats with this approach as you'll be effectively doubling your requests to the same MP. So, you gotta account for capacity in this case as it will have an impact on it. In most cases this is okay.

Hope it helps!

@diego can you please provide any link reference or examples which I can follow for these approach?

@Diego Zuluaga

can you please provide any link reference or examples which I can follow for these approach?

@Dino @Diego Zuluaga How can I access node.js in javascript policy ? can you please suggest any example?