Skip to content

Commit 5d043ba

Browse files
committed
Migrated hyperflow server to express 4.x
1 parent f851e70 commit 5d043ba

File tree

3 files changed

+15
-32
lines changed

3 files changed

+15
-32
lines changed

bin/restapi_test.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#!/bin/sh
22

3-
if [ "$#" -ne 1 ]; then
3+
if [ "$#" -ne 2 ]; then
44
echo "restapi_test.sh: creates an instance of the Ping Pong workflow"
55
echo " and sends a signal to it using the HyperFlow REST API."
66
echo
77
echo "Usage:"
88
echo "- first run the HyperFlow server: node app.js"
9-
echo "- then run this script: scripts/restapi_test.sh <port>"
9+
echo "- then run this script: scripts/restapi_test.sh <port> <path to workflow.json>"
1010
echo "where <port> is the port number on which the server is running"
1111
exit
1212
fi
@@ -18,7 +18,7 @@ uri="http://localhost:$1/apps"
1818
# Body: valid workflow description in JSON
1919
# on success returns: 201, Location: {appuri}
2020
# "location" - wf instance URI extracted from the HTTP header
21-
location=`curl -v -X POST -d @workflows/Montage_143.json $uri --header "Content-Type:application/json" 2>&1 | grep Location | cut -f 3 -d' '`
21+
location=`curl -v -X POST -d @$2 $uri --header "Content-Type:application/json" 2>&1 | grep Location | cut -f 3 -d' '`
2222

2323
appuri="http://localhost:$1"$location
2424
echo $appuri

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"name": "hyperflow",
3-
"version": "1.1.1",
3+
"version": "1.2.0",
44
"engines": {
5-
"node": "~4.8.7"
5+
"node": "~10.15.1"
66
},
77
"bin": {
88
"hflow": "./bin/hflow",
@@ -15,13 +15,14 @@
1515
"adm-zip": "0.4.11",
1616
"amqplib": "0.5.2",
1717
"async": "0.2.x",
18+
"body-parser": "^1.18.3",
1819
"consolidate": "0.10.x",
1920
"crc": "0.2.1",
2021
"cross-spawn": "^6.0.5",
2122
"docopt": "0.6.2",
2223
"ejs": "2.6.1",
2324
"eventemitter2": "5.x",
24-
"express": "3.x",
25+
"express": "4.16.x",
2526
"eyes": "0.1.8",
2627
"file": "0.2.x",
2728
"form-data": "2.3.x",

server/hyperflow-server.js

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
11
/*
22
** HyperFlow engine
3-
** Author: Bartosz Balis (2012-2014)
3+
** Author: Bartosz Balis (2012-2019)
44
**
55
** HyperFlow server implementing the REST API for HyperFlow workflows.
66
*/
77

88
'use strict';
99

10-
/**
11-
* Module dependencies.
12-
*/
13-
1410

1511
var redisURL = process.env.REDIS_URL ? {url: process.env.REDIS_URL} : undefined;
1612
// for express
1713
var express = require('express'),
14+
bodyParser = require('body-parser'),
1815
cons = require('consolidate'),
1916
spawn = require('child_process').spawn,
2017
http = require('http'),
@@ -47,29 +44,14 @@ var contentType = 'text/html';
4744
//var baseUrl = 'http://localhost:'+process.env.PORT;
4845
var baseUrl = ''; // with empty baseUrl all links are relative; I couldn't get hostname to be rendered properly in htmls
4946

50-
// Configuration
51-
app.configure(function() {
52-
//app.use(express.compress());
53-
app.engine('ejs', cons.ejs);
54-
app.set('views', __dirname + '/views');
55-
app.set('view engine', 'ejs');
56-
app.use(express.bodyParser({strict: false}));
57-
app.use(express.methodOverride());
58-
app.use(app.router);
59-
app.use(express.static(__dirname + '/public'));
60-
app.disable('strict routing');
61-
});
47+
// parse application/x-www-form-urlencoded
48+
app.use(bodyParser.urlencoded({ extended: false }))
6249

63-
app.configure('development', function() {
64-
app.use(express.errorHandler({
65-
dumpExceptions: true,
66-
showStack: true
67-
}));
68-
});
50+
// parse application/json
51+
app.use(bodyParser.json())
52+
53+
app.disable('strict routing');
6954

70-
app.configure('production', function() {
71-
app.use(express.errorHandler());
72-
});
7355

7456
/////////////////////////////////////////////////////////////////
7557
//// REST API for HyperFlow workflows ////

0 commit comments

Comments
 (0)