Up to now, database is set and it’s main table ‘CallTable’ is populated through a c++ application, ‘SVRCapturer’, a VoIP call recorder. Now, let’s prepare a user interface to database content using a popular server side asynchronous utility nodejs, http://nodejs.org/
Start with getting node to a brand new vm. Nodejs can be obtained through backports repository for wheezy. However, here I will use curl option as given below,
Connection to PostgreSQL database will be obtained using popular ‘pg’ module https://www.npmjs.com/package/pg. Let’s start with preparing ‘package.json’ to include this dependent module.
Then running ‘npm install’ will get missing packages that are listed in ‘package.json’ and performs a local install.
Make some use of ‘pg’ as follows. We will try to establish connection to PostgreSQL server and retrieve contents of ‘CallTable’ that has previously populated with c++ application. Give necessary privileges to user ‘svrserve’ by creting a role and modifying ‘/etc/postgresql/9.1/main/ph_hba.conf’ as demonstrated part I of this series.
If user ‘svrserve’ has been created successfully, the contents of ‘CallTable’ should be displayed properly,
Now display contents through web. But first we have to create certificates with openssl,
Then serving a web page is as easy as adding a few lines. This is where the elegance of nodejs comes. The following single page code is able to connect to a PostgreSQL server and display the contents of a table as web page. Of course there is pretty much space for hardening but what a fast prototyping!
Contents of ‘CallTable’ as a web page;
Next step will be displaying content in a more elegant manner