DZone
Cloud Zone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > Cloud Zone > Deploying Node Express Apps to OpenWhisk

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.

Niklas Heidloff user avatar by
Niklas Heidloff
CORE ·
May. 29, 17 · Cloud Zone · Tutorial
Like (3)
Save
Tweet
3.07K Views

Join the DZone community and get the full member experience.

Join For Free

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’.

openwhisk-express

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.

Express

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

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Making Your Own Express Middleware
  • API Security Weekly: Issue 165
  • Reactive Kafka With Streaming in Spring Boot
  • How Low Code Demands More Creativity From Developers

Comments

Cloud Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo