-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
45 lines (37 loc) · 1.41 KB
/
app.js
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
(function () {
"use strict";
require('dotenv').config();
const conversationCredentials = {
username: process.env.CONVERSATION_USERNAME,
password: process.env.CONVERSATION_PASSWORD,
version:process.env.CONVERSATION_VERSION,
workspace_id: process.env.CONVERSATION_WORKSPACE
};
const express = require("express"),
app = express(),
path = require("path"),
bodyParser = require("body-parser"),
cfenv = require("cfenv"),
http = require("http"),
cors = require("cors"),
watsonConversation = require("./server/helpers/WatsonConversation")(conversationCredentials),
port = process.env.PORT || process.env.VCAP_APP_PORT || 6010;
app.use(express.static(path.join(__dirname + '/client')));
app.use(bodyParser.urlencoded({extended: true}));
app.use(bodyParser.json({limit: "50mb"}));
app.use(cors());
require('./server/routes/index.js')(app, watsonConversation);
// if intent needs API, the watson response is changed
// else it will be returned
// watsonConversation.sendMessage({
// text:"hallo",
// context: {}
// }).then(function (data) {
// console.log(data.response.entities);
// }).catch(function (err) {
// console.log("ERROR: ",err);
// });
app.listen(port, function () {
console.log('Server running on port: %d', port);
});
}());