node package manager
It’s your turn. Help us improve JavaScript. Take the 2017 JavaScript Ecosystem Survey »



Social network users who are concerned about privacy and censorship want to run their own decentralized instances, yielding full control over own data. channel-server is a building block for a bright future: it exposes your data to the network, featuring access control and real-time update notification.

The primary network protocol is Buddycloud Channels.

channel-server is distributed under the Apache License 2.0. See the LICENSE file.


At this early stage you should be prepared to upgrade this software in the future.


You will need Node and its package manager npm. Then install development packages for installing the required libraries:

apt-get install -t testing libicu-dev libexpat-dev  # on Ubuntu/Debian

Next, depending on your preference, you may choose to just npm install channel-server or install further dependencies manually and run channel-server from the repository:

npm install node-xmpp step node-uuid node-stringprep
npm install cradle  # for CouchDB
npm install pg      # for PostgreSQL


Edit config.js. It's not just JSON but full JavaScript, meaning you can use unquoted object keys and even code.

The xmpp section sets up a component connection. For ejabberd the listener configuration should look like this:

{5233, ejabberd_service, [{hosts, [""], [{password, "secret"}]}]}

CouchDB configuration

PostgreSQL configuration

The pg library uses TCP connections, no Unix domain sockets with user account credentials. Hence, use createuser -P and grant the new user privileges on your database.

Next, install the database schema:

psql channel-server
\i postgres.sql


Simply do:

node main.js


The most important concept with Node is asynchronous event handlers. We try to flatten the code flow by using the Step library. Pay attention to always call a callback in success as well as error cases. Lost control flows may result in hanging requests and unfinished database transactions.


Network applications are proxies. In general, they provide a well-defined interface to databases with additional access control, data sanitization, and in this case, notification hooks.

Additionally, the MVC pattern influenced this application much:

  • View: network frontend such as xmpp_pubsub.js
  • Controller: core logic in controller.js
  • Model: database-specific backends with transaction support



Implementing new features is easy with CouchDB as developers may change their database schema as they please. Unless you're able to optimize the hell out of it, don't use in production.


Sporting real transactions and a normalized database schema, this SQL backend is expected to yield high performance.


  • grep TODO *.js
  • Result Set Management
  • Outcast affiliation
  • Access Models
  • More configurability (channel presets)
  • Topic channels
  • More backends (MySQL? SQLite?)
  • Discoverability
  • Further frontends: Web, oStatus