Using Nodejs with Apigee? You should check out Hosted Targets

In the simplest case, an API Proxy is just a stand-in, a thing a client calls instead of calling a backend service directly. The proxy can do things like: enforce security with OAuth token verification, rate limit with Quota policies, transform payloads by injecting client-specific default values, route to different backends, and so on.

Normally a "target" in Apigee Edge-speak is an external backend system accessible via HTTPS. This system could be hosted in the cloud: GCP, or AWS, or Rackspace, or a SaaS vendor cloud like Salesforce.com, or a nodejs app running in Heroku, or whatever. Anything, as long as it's accessible via HTTPS.

As a variation on that idea, for years, Apigee Edge has allowed API Proxy developers the possibility to embed a nodejs "backend" into the proxy definition itself. We called these "nodejs targets", and the node code for such targets runs inside Trireme, which is hosted in a Java VM, part of Apigee Edge. No external hoster. An potentially no external service, although, the utility of an API Proxy that doesn't connect to anything else, is limited.

What does the nodejs inside an API Proxy do? Well it can do anything! It can rely on builtin node modules like http to create a server and handle requests, or it can rely on third-party rpm modules like express, requestjs and handlebars. Often people use the nodejs code to wrap some other service with some intelligence.

This capability - hosting nodejs code inside Trireme and Java - is really cool. It greatly simplifies the deployment of a Proxy + target, when you need some relatively thin JS code to wrap a remote system. It's not intended to be a container for arbitrary application logic. You don't want to try using the cluster module, and you don't want to do raft elections, and so on. It's better for simple, lightweight servers. And many many customers have adopted it, and many are using it.

There are some drawbacks. The main one is the Trireme runtime is based on node 0.10.32. WAT?!?! YES. It's pretty old. And so it does not support ES6 including Promises, let/const, arrow function syntax, destructuring assignments, and so on. And that also means you cannot use the latest versions of various modules, including request.

Many of our customers that use nodejs targets want to take advantage of ES6, or to take advantage of the latest rpm modules that use ES6. They can't do that with Trireme. But they can do it with a new capability we're introducing. We're calling it "Hosted Targets". The beta is described here:

https://apigee.com/about/blog/api-technology/apigee-edge-hosted-target-beta-release-here

Check it out !!!

Comments
ankita10j
New Member

Hi @Dino

I am using hosted target to connect my application for SMTP connection. I want to use flow variables in my node code.

As per document, hosted target does not support apigee-access and flow variables. Any workaround for it?

Ankita

sidd-harth
Bronze 1
Bronze 1

Hi @Ankita Jain, did you check this options, headers/env variables,

https://docs.apigee.com/api-platform/hosted-targets/hosted-targets-faq#how-should-we-work-around-the...

BTW create a new question/post for further dicussion.

Version history
Last update:
‎05-01-2018 12:01 PM
Updated by: