-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.js
More file actions
executable file
·66 lines (53 loc) · 1.83 KB
/
app.js
File metadata and controls
executable file
·66 lines (53 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*eslint-env node*/
//------------------------------------------------------------------------------
// node.js starter application for Bluemix
//------------------------------------------------------------------------------
// This application uses express as its web server
// for more info, see: http://expressjs.com
var express = require('express');
//var https = require('https');
// Set up self signed ssl certificate credentials
//var fs = require('fs');
//var private_key = fs.readFileSync('sslCert/private-key.pem', 'utf-8');
//var certificate = fs.readFileSync('sslCert/certificate.pem', 'utf-8');
//var credentials = {
//key: private_key,
//cert: certificate
//};
// import alexa skill
var bpmHandler = require('./src/index.js');
// cfenv provides access to your Cloud Foundry environment
// for more info, see: https://www.npmjs.com/package/cfenv
var cfenv = require('cfenv');
// create a new express server
var app = express();
var bodyParser = require('body-parser');
app.use(bodyParser.json());
// serve the files out of ./public as our main files
app.use(express.static(__dirname + '/public'));
app.post('/alexa', function(req, res, next) {
var body = req.body;
console.log('/alexa body', body);
res.set('Content-Length', '');
var context = {
succeed: function(data) {
res.json(data);
},
fail: function(data) {
res.json(data);
},
done: function(data) {
res.json(data);
}
}
bpmHandler.handler(body, context);
});
// get the app environment from Cloud Foundry
var appEnv = cfenv.getAppEnv();
// create https server
//var httpsServer = https.createServer(credentials, app);
// start server on the specified port and binding host
app.listen(appEnv.port, '0.0.0.0', function() {
// print a message when the server starts listening
console.log("server starting on " + appEnv.url);
});