-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
32 lines (25 loc) · 1.07 KB
/
server.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
const nconf = require('nconf');
nconf.env().argv();
nconf.required(['HOUR_API_HOST', 'SERVER_TYPE', 'LUIS_APP_ID', 'LUIS_APP_KEY']);
const serverType = nconf.get('SERVER_TYPE');
console.log('SERVER_TYPE=' + serverType);
const SERVER_TYPE = {
BOT: 'bot',
DIRECTLINE: 'directline',
STANDALONE: 'standalone'
};
if (serverType === SERVER_TYPE.BOT || serverType === SERVER_TYPE.STANDALONE) {
const restify = require('restify');
const Bot = require('./bot/bot');
const server = restify.createServer();
server.post('/api/messages', Bot.connector.listen());
server.listen(nconf.get('port') || 3978, function () {
console.log('%s listening to %s', server.name, server.url);
});
}
if (serverType === SERVER_TYPE.DIRECTLINE || serverType === SERVER_TYPE.STANDALONE) {
const directline = require('./directline_server');
const botHost = nconf.get('BOT_HOST') || 'http://localhost:3978';
const directlineHost = nconf.get('DIRECTLINE_HOST') || 'http://localhost:3000';
directline.server.start(directlineHost, botHost + '/api/messages');
}