Getting started with Node.js on Apigee Edge

You're viewingApigee Edge documentation.
Go to theApigee X documentation.
info

Private Cloud Deprecation Notice:

Support forNode.js proxies andsecure vaults

Since 2013, Apigee has supported theuse of Node.js proxies within Apigee Edge through the use ofTrireme, which enables you to run your Node.js code within Apigee Edge for Private Cloud and expose it as an API.

Apigee recommends Private Cloud customers take the following steps:

  • Migrate data in secure vaults toEncrypted Key Value Maps (KVM) to access sensitive data from an API proxy.
  • Migrate Trireme (Node.js) based API proxies to a native Node.js environment outside of Apigee.

See alsoApigee deprecations and retirements.

Public Cloud Retired feature: The traditional, Trireme-based Node.js support on Apigee Edge Cloud is retired and, by extension,apigee-access is also retired because it is only used in Trireme-based Node.js applications deployed on Apigee Edge. Trireme-based Node.js was retired on October 10, 2019. SeeTrireme-based Node.js End of Life.

This topic explains the simplest way to wrap a Node.js application in an API proxy using the management UI.

Introduction

Chances are, the first Node.js app you ever created was an HTTP server that responds to requests with "Hello World!" The simplest way to try out Node.js on Apigee Edge is to do something very similar. With just a few mouse clicks, you'll have a functioning, proxied Node.js HTTP server running on Edge. After that, you can use the code editor in the UI to modify the Node.js app, add additional Node.js files, add policies, and so on.

Creating the sample Hello World! API proxy

This section explains how to create an Edge API proxy that interacts with a Node.js HTTP server. The Node.js HTTP server code is already written for you and is automatically deployed to Edge when you follow these simple steps.
Note: If you have not done so, you need to set up an account onApigee Edge before you can try out this example. You can find a working sample of the proxy described in this tutorial in theApigee samples repo on GitHub.
  1. In the Build a Proxy wizard, selectNode.js App.
  2. ClickNext.
  3. Follow the Build a Proxy wizard and make the following selections.
    FieldSelection
    Details
    Proxy NameEnterNodejs-Hello. The name displayed for your API.
    Proxy Base PathEnter nodejs-hello
    SourceSelect"Hello World" Sample. (We'll discuss the other options later in this topic.)
    DescriptionEnter a description of the API.
    Security
    Pass through (none)SelectPass through (none). Creates a simple pass through proxy.
    Virtual Hosts
    default, secureDo not change the defaults. To learn about virtual hosts, seeAbout virtual hosts (Beta).
    Build
    Deploy EnvironmentsSelecttest.
  4. ClickBuild and Deploy
    In response, you should see an acknowledgment that your new API proxy was successfully created and deployed in the 'test' environment.
  5. Click View the <proxy name> proxy in the editor to display the details page for the API proxy.

Invoking the hello proxy

When you call thehello proxy, the Node.js application executes automatically, responding with "Hello, World!". Note that unless you specified otherwise, the Node.js application is deployed to the environment calledtest. Here's the basic call using Curl (substitute your organization name formyorg).
$ curl http://myorg-test.apigee.net/nodejs-helloHello, World!

Viewing and editing the Node.js code

Let's look at the Node.js code that was added to the API proxy. Go to the summary page for the Hello World proxy and clickDevelop.



This opens the Develop view which includes a code editor. You can edit the code there directly.

For example, change the response fromHello, World! to something else, likeHello, Node!, then clickSave. The proxy is saved and redeployed.

Finally, re-invoke the proxy to verify the change:

$ curl http://myorg-test.apigee.net/nodejs-helloHello, Node!

More about running Node.js applications on Apigee Edge

Like all Node.js applications, Node.js applications running on Apigee Edge run in a single thread of control. There is no need (and in fact no ability) to start another thread, or synchronize variables between threads. Since Node.js enforces non-blocking programming, a single script can support thousands of concurrent requests because the script gives up the CPU whenever it has to wait for something, and it is notified later when it happens.

To use Node.js on Apigee Edge, you need to specify a main Node.js script file. This script must be configured to handle incoming requests, which you typically do by using thehttp orhttps modules, creating a client, and so on. (If the main script is not configured this way, it will simply execute and exit after it is deployed.) Within Apigee Edge, each Node.js application script is started from the beginning when the proxy is deployed, and stopped when the proxy is undeployed. In between it will wait for new requests and process them. For more information, see "Invoking an imported Node.js file" inDeploying a standalone Node.js app.

Next Steps

You can also create and deploy standalone Node.js applications directly from your file system. The next topic,Deploying a standalone Node.js app, explains how to use theapigeetool command to deploy a Node.js app from the command line.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2026-02-02 UTC.