A haXe Stack for Node.js
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Cloudshift - A haXe Stack for Node.js

See cloudshift.cl for full documentation.

Cloudshift is written and maintained by Ritchie Turner (blackdog@cloudshift.cl) and is currently under heavy development; the apis are subject to change.

Core Module

Cloudshift provides a consistent set of abstractions on client and server for dealing with common problems;

  • Asynchronous haXe remoting for inter tier and sub-process communication
  • Outcome<T> (approximately a Future<Either<String,T>>) as the means for dealing with async callback hell and error handling.
  • Parts are components which have an asynchronous new() in the start() method - start() returns an Outcome. Further they may be stopped asynchronously with stop(). Parts are also Observable.
  • Mixins, mostly the Stax prelude extensions.

Http Module

Simplest example …


and/or provide multiple handlers per url, e.g.


Flow Module

Publish/subscribe with session management, channel security. Currently a Push implementation (web socket conduit will be added).

Flow is comprised of Conduits, Sinks and Pipes.

  • Pipes are your typical channel and are created from Sinks (you drain and fill sinks via pipes)
  • Sinks also know about Sessions and Conduits
  • Conduits are message streams from remote sources.

Having 3 large concepts means Flow could be difficult to setup, however there is a Flow.quickFlow() method that creates a typical setup for you, e.g.,

  .deliver(function(http) {         
        .deliver(function(qf) {
           var sink = qf.sink;
           var conduit = qf.conduit;
           var session = qf.session;

           var mypipe<MyType> = sink.pipe("/my/pipe");

The quickFlow() method may be used on the client to provide the same basic interface. See the chat example for more.

Data Module

There is a database component with, so far, one driver, Sqlite3. The api is asynchronous and NoSQL. It stores haXe serialized objects in Sqlite, yet provides a general indexing facility which utilises the underlying sqlite indexes. This does mean that there is no generalized query facility, haXe programs require to be written to extract the data.

The Sqlite driver is a popular C++ module for Node.js supported by many of the leading names in the Node.js community. It’s asynchronous and embedded in the node.js instance, thus data access is very fast.

So, each Cloudshift instance has it’s own database, this can be easily augmented so that each instance running talks to a central Cloudshift instance just running data services. Cloudshift provides a remote api compatible driver for this purpose. The main point here is to think of the Node.js/Sqlite3 combination as a database server in it’s own right

Worker Module

Extend Worker and create seamless sub process workers using the haXe remoting protocol.

Sys Module

File I/O, Process services wrapped in Outcomes as appropriate for this kind of usage:

Sys.writeFile("woot","hi there")
   .onError(function(reason) {
       trace("Err is :"+reason);
   .flatMap(function(file) {
         return file.stat();
   .map(function(stat) {
       return stat.path;
   .flatMap(function(path) {
       return path.rename("niceone");
   .deliver(function(newFileName) {
       trace("cool "+newFileName);
       var p = Sys.events();
       p.observe(function(o) {
           switch(o) {
           case ProcessUncaughtException(ex):
             trace("uuncauthg exp:"+ex);

       trace("osuptime:"+Sys.osUptime()+", uptime:"+Sys.uptime());
       Sys.stdout().write("nice one laddie");
       Sys.spawn("ls").deliver(function(child) {
           child.stdout.observe(function(e) {
               switch(e) {
               case Data(s):

       Sys.execFile("ls").deliver(function(output) {

Installation and Dependencies

install node.js for your platform

  • npm install formidable
  • npm install sqlite3
  • haxelib install nodejs
  • haxelib install cloudshift

Note, the cloudshift haxelib does not include the nodejs dependency by default, as the cloudshift lib is used on both client and server having the -D nodejs defined automatically on the client is an unwanted side effect. So be sure to install nodejs bindings manually.