Over a million developers have joined DZone.

Deploying Node Express Apps to OpenWhisk

DZone's Guide to

Deploying Node Express Apps to OpenWhisk

Want to know how to run an Express app in a serverless environment? Curious about OpenWhisk? Let's cover the advantages and challenges involved.

· Cloud Zone
Free Resource

See how the beta release of Kubernetes on DC/OS 1.10 delivers the most robust platform for building & operating data-intensive, containerized apps. Register now for tech preview.

I’m catching up with all the great new features that have been added to OpenWhisk over the last few months. My colleague Lionel Villard published two articles how to run Node Express web applications in a serverless environment. Very cool.

Rather than repeating everything from Lionel’s articles, let me give you a quick summary how this works.

In the OpenWhisk action, you use the openwhisk-expressjs module to send a redirect to the Express server.

const app = require('./server');
const redirect = require('openwhisk-expressjs')(app);

function main(args) {
  return redirect(args);

exports.main = main;

In order to make the OpenWhisk action accessible via URL, you use web actions. Since the action requires additional node modules, you need to zip everything up first.

zip -r app.zip
wsk action update api app.zip --kind nodejs:6 -a raw-http true -a web-export true

Since I’ve had some issues getting the sample running, I’ve submitted a pull request. For the time being, you can use the extensions I’ve done in my fork.

To run the web application, open the web action URL that you can get from the OpenWhisk dashboard in a browser (without the ‘.json’.


Please note that there are limitations, as Lionel describes. You shouldn’t host large amounts of static content. However, the mechanism above works well for Node applications that use Express to provide REST APIs.

New Mesosphere DC/OS 1.10: Production-proven reliability, security & scalability for fast-data, modern apps. Register now for a live demo.

openwhisk ,express ,node.js ,apps ,deploy ,serverless

Published at DZone with permission of Niklas Heidloff, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}