# Build your own TCP log server with node.js part 3

Date: 2017-05-23

In the last part , we&#8217;ll push the logs and user comments to the database we created in [part 1](http://goldmanmalka.com/2017/05/23/build-your-own-tcp-log-server-with-node-js-part-1/)

<!--more-->

A reminder, post schema can be generated by the command :

npm run docs

&nbsp;

We&#8217;ll add simple handler on the user side in public/js/socketio.js:
```js
var url      = window.location.href;
var socket = io.connect(url);

postURL = window.location.host;
postURL = "http://" + postURL.split(":")[0] + ":9000/logs";

socket.on('connect', function(data) {
  socket.emit('join', 'Hello from client');
});
socket.on('messages', function(data) {
  $("#future").empty().append(data);
});
$(document).ready(function() {
  var t = $('#dataTable').DataTable();

$("#addComment").closest('form').on('submit', function(e) {
    e.preventDefault();
    var data = {};
    data.source = 'user';
    data.type = 'comment';
    data.message = $("#future").text();
    data.comment = $("#CommentInput").val();

    $.post(postURL,data,function(data){console.log(data)});
    // $('#hiddenInput').val(someVariable); //perform some operations
    // this.submit(); //now submit the form
});

$.get(postURL,function(data){

  $.each(data, function( index, value ) {
  // $("#dataTable").append( index + ": " + value + "&lt;br&gt;");
  console.log(index);
    t.row.add([index,value['createdAt'],value['source'],value['type'],value['message'],value['comment']]);
  });
  t.draw();
});
});
```

and add [datatables](https://datatables.net/examples/api/add_row.html) js and css to the public folder

It took around 20 minutes to build the base for a TCP log server&#8230;

next time we&#8217;ll handle the gui and add some more protocols and handlers to different type of messages
