import http from 'http';
import express from 'express';
import io from 'socket.io';
import bodyparser from 'body-parser';
import chatbot from './chatterbot/chatbotController.js';
import analyzerController from './controllers/analyzerController.js';

const routes = require('./config/routes.js');

const app = express();
const theServer = http.Server(app);
const ioServer = io(theServer);

const port = process.env.PORT || 1337;
app.use(express.static(__dirname + '/../client'));
app.use(bodyparser);
routes(app);

ioServer.on('connection', (socket) => {
  console.log('a user connected: ', socket);

  let msgCount = 0;
  socket.on('message', (msg) => {
    analyzerController.setAnalysis(msg);
    chatbot.response(socket.conn.id + msgCount.toString(), msg, (response) => {
      socket.emit(response);
    });
    msgCount++;
  });
});

theServer.listen(port, () => {
  console.log('listening on localhost:', port);
});

@@ -444,16 +444,19 @@
 .static(
+%60$%7B
 __dirnam
@@ -460,12 +460,9 @@
 name
- + '
+%7D
 /../
@@ -467,17 +467,17 @@
 ./client
-'
+%60
 ));%0Aapp.
@@ -507,16 +507,17 @@
 (app);%0A%0A
+%0A
 ioServer
@@ -594,31 +594,19 @@
 cket
-);%0A%0A  let msgCount = 0;
+.conn.id);%0A
 %0A  s
@@ -716,38 +716,21 @@
 n.id
- +
+,
  msg
-Count.toString(), msg
+, (err
 , 
-(
 resp
@@ -736,24 +736,61 @@
 ponse) =%3E %7B%0A
+      if (err) %7B console.log(err); %7D%0A
       socket
@@ -795,16 +795,27 @@
 et.emit(
+'message', 
 response
@@ -831,23 +831,80 @@
 ;%0A  
-  msgCount++;%0A 
+%7D);%0A%0A  socket.on('disconnect', () =%3E %7B console.log('user disconnected');
  %7D);

Store Alchemy emotion on MongoDB