with Hapi.js

I recently got to work with hapi.js for building an api and I like the Hapi way. To add web-sockets I needed to integrate

Because I couldn’t find an up to date explanation on how to do this:

var Hapi = require('hapi');

var server = new Hapi.Server();


    host: 'localhost', 

    port: 8000 


var io = require("")(server.listener);

io.on("connection", function (socket) {


    // Do all the socket stuff here.



In your html do the usual:

<!DOCTYPE html>




        <script src=""></script>

        <script src="/"></script>


			$(function () {

  				var socket = io.connect('http://localhost:8000');

				socket.on('topic', function (data) {

					// do something with data