Name: expressjs-openwhisk
Owner: International Business Machines
Description: Apache OpenWhisk Web action redirecting request to Express.js applications
Created: 2017-05-11 20:49:54.0
Updated: 2018-02-22 12:06:17.0
Pushed: 2017-08-30 12:41:10.0
Size: 12
Language: JavaScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
This project shows how to deploy new and existing Express.js applications to OpenWhisk. This tutorial takes less then 5 minutes to complete.
Open a terminal, and type
m install express-generator -g
press --view=pug myexpressapp
myexpressapp
m install
This creates a minimal Express.js application.
To check it is working, start the application by typing the command
npm start
and load http://localhost:3000 in a browser.
The generated Express.s application expects resources to be installed in the domain root folder but by default Apache OpenWhisk web actions are served from a sub-directory.
Change views/layout.pug
:
ype html
ad
title= title
if baseurl
base(href=baseurl)
link(rel='stylesheet', href='stylesheets/style.css')
dy
block content
Add expressjs-openwhisk
module dependency in your project.
m install expressjs-openwhisk --save
Then create the Apache OpenWhisk action handling Web requests by forwarding
them to expressjs-openwhisk
. Create a file named action.js
with this content:
t app = require('./app');
t forward = require('expressjs-openwhisk')(app);
tion main(request) {
turn forward(request);
rts.main = main;
In package.json
, add the following entry:
main": "action.js",
..
To deploy the application and dependencies on Bluemix, do:
p -r app.zip .
k action update express app.zip --kind nodejs:6 --web raw \
-p baseurl https://openwhisk.ng.bluemix.net/api/v1/web/<org>_<space>/default/express/
Replace <org>
and <space>
by your Bluemix organization and space, respectively.
And finally test the application by opening
https://openwhisk.ng.bluemix.net/api/v1/web/<org>_<space>/default/express
in a browser