Overview of Node.js on Apigee Edge

You're viewing Apigee Edge documentation.
Go to the Apigee X documentation.
info

You can host your Node.js APIs on Apigee Edge, where API proxies can call them as target services.

Node.js support on Apigee Edge allows you to build customized backend services for your proxies in Node.js. Essentially, Apigee Edge hosts your Node.js code in a runtime environment that is scoped to an Apigee organization and environment. API proxies that are deployed to the same organization and environment can call HTTP-based APIs exposed by the Node.js application.

Node.js deployment options

Apigee provides two options for hosting Node.js code: Hosted Targets and the traditional Node.js Edge deployment environment.

Deploy to Hosted Targets

Hosted Targets allows Node.js applications to run in a native environment that does not depend on any Apigee-specific run-time technology. It provides you a native node runtime, so you can use your favorite node packages.

You can debug and test your app locally before deploying it and be assured that the deployed version will work exactly as it does locally. At deployment time, you can choose any application runtime version for running your application in Hosted Targets. For example, you might specifically choose to run a Node.js app in a v8.10.0 environment or any other version.

The following figure illustrates the basic architecture:

The Hosted Targets runtime environment is scoped to an Apigee organization and environment and can serve as the target for any API proxies that are deployed to that same organization and environment.

Deploy to the traditional embedded Node.js environment

The traditional approach to deploying Node.js to Edge relies internally on an open-source bridge application called (Trireme) and a JavaScript interpreter called (Rhino). These components allow Node.js code to execute directly in the Edge Java runtime environment.

The traditional, embedded Node.js runtime environment is scoped to an Apigee organization and environment and can serve as the target for any API proxies that are deployed to that same organization and environment.

With this approach, you can use a supporting module called apigee-access that lets you access API proxy flow variables, caches, key value maps, and quotas from within your Node.js application code.

Choosing a Node.js approach

Apigee recommends that you consider using Hosted Targets. Node.js apps deployed to Hosted Targets do not depend on any Apigee-specific Node.js run-time technology. Your Node.js app will run in Hosted Targets exactly as it runs in your local development environment.

Furthermore, Apigee support for the traditional Node.js Edge deployment is has limitations:

  • Only an older version of Node.js (0.10.32) is supported.
  • There are subtle differences in behavior between the standard Node.js environment and the Trireme/Rhino environment.
  • Debugging Node.js apps after they are deployed to Edge is difficult.

Currently, Hosted Targets does not support the use of apigee-access to access resources in the proxy flow context, such as flow variables.

To learn more about traditional Node.js Edge deployment, see Traditional Node.js deployment on Edge.

Use cases

Common use cases for Node.js on Edge include:

  • Building highly customized standalone HTTP-based APIs and backend services.

  • Solving complex and mobile optimization problems with the advantage of a scriptable target endpoint.

  • Building composite services and mashups.

  • Rapidly developing prototypes of new APIs using frameworks like Express.

Next step

To decide which Node.js deployment approach is best for you, read the overviews: