1. Install NodeJS

You’ll need Node.js v0.12.7 or above.
Check what version you have if you already have it

node --version

 

2. Clone project

Clone the repo using this command.

git clone https://github.com/jakearchibald/wittr.git

 

3. Install Dependencies

Run npm install to install all dependencies the application requires.

cd wittr
npm install 

 

4. Running

Use npm run serve to kickoff the build scripts and launch a server that hosts the demo application at http://localhost:8888

npm run serve

You should now have the app server at localhost:8888 and the config server at localhost:8889.

 

5. Configure Ports (Optional)

You can also configure the ports:

npm run serve -- --server-port=8000 --config-server-port=8001

Quick App Overview

The starting point is public/js/main/index.js
However, the main work happens in public/js/main/indexController.js

PostsView()
is used to update the posts on the page.

ToastsView()
is used to display error messages.

_openSocket()
opens a WebSocket connection.

ws.addEventListener(‘message’, … )
The message event is fired when data is received for a new post to display.

_onSocketMessage(event.data)
When your posts are received, this method is called, and it passes the data as json and passes the result to this._postsView.addPosts(message)