-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* updating gitignore * adding new POC app * updating host * Proxy OpenWhisk Integration * Updated with feedback * Holding back locales package from being updated during image creation. Was causing issues with initdb.
- Loading branch information
Showing
7 changed files
with
118 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
'use strict'; | ||
var express = require('express'); | ||
var bodyParser = require('body-parser'); | ||
var csync = require('csync'); | ||
var request = require('request'); | ||
|
||
// create a new express server | ||
var app = express(); | ||
app.use(bodyParser.json()); // for parsing application/json | ||
|
||
// CSync | ||
var csyncApp = csync({ host: "localhost", port: 6005, useSSL: false }); | ||
var keys = {}; | ||
csyncApp.authenticate("demo", "demoToken"); | ||
|
||
|
||
// render index page | ||
app.put('/webhooks', function (req, res) { | ||
console.log("Put Request: ", req.body); | ||
var url = req.body.url; | ||
var csyncKey = csyncApp.key(req.body.key); | ||
keys[req.body.key] = csyncKey; | ||
csyncKey.listen(function (error, value) { | ||
if (error) { | ||
// handle error | ||
console.log("Error: ", error); | ||
res.sendStatus(404); | ||
} else { | ||
value["state"] = req.body.state; | ||
request({ | ||
method: "POST", | ||
uri: url, | ||
body: value, | ||
headers: { | ||
"Authorization": "Basic YzU1YWZjMDUtOTc3My00ODk0LTgyMWQtMGI4NjBjYTU1MjRmOjB5QXRaZm51dGJMY2U3TzRoTnNYNmFBWVJVM25zRXNNam1SbFBTcE9xeUNsUHZtN3JLVzQ4b0owZ3Z4ZWZGbDI=", | ||
"Content-Type": "application/json" | ||
}, | ||
json: true | ||
}, | ||
function (error, response, body) { | ||
console.log("Response Body: ", body); | ||
}); | ||
} | ||
}); | ||
res.sendStatus(200); | ||
}); | ||
|
||
app.delete('/webhooks', function (req, res) { | ||
console.log("Delete Request: ", req.body); | ||
var url = req.body.url; | ||
var csyncKey = keys[req.body.key]; | ||
if (!csyncKey) { | ||
res.sendStatus(404); | ||
} | ||
csyncKey.unlisten(); | ||
delete keys[req.body.key]; | ||
res.sendStatus(200); | ||
}); | ||
|
||
// start server on the specified port and binding host | ||
app.listen(6004, '0.0.0.0', function () { | ||
console.log("server started"); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"name": "openwhisk", | ||
"version": "0.0.1", | ||
"private": true, | ||
"dependencies": { | ||
"body-parser": "^1.17.1", | ||
"csync": "^1.4.0", | ||
"express": "^4.15.2", | ||
"request": "^2.81.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters