Using CSON with nconf (nodejs)

nconf for nodejs offers hierarchical configuration with files, environment variables, command-line arguments, and atomic object merging. Out of the box, nconf supports JSON and ini file formats. Getting nconf to support custom formats, e.g. CSON is straightforward: provide a format handler as an option to nconf.

nconf.file file : "somefile.cson", format : { stringify : cson.stringifySync, parse : cson.parseSync }

See gist for a longer example.

REST Command Line Tool

restit is a command line tool (CLI) for talking to RESTful APIs. It’s intended to reduce some of the repetition and verbosity that comes with using general purpose CLI tools such as curl with RESTful APIs.

NodeJS Custom Start Script on OpenShift

The nodejs cartridge provides Node.JS on OpenShift. The default entry point for the nodejs cartridge is /server.js, which can be changed with the following package.json entry:

"scripts": { "start": "supervisor <relative-path-from-repo-to>/app.js" },

However, we couldn’t get node to cooperate without this additional package.json entry:

  "scripts" : { "start" : "supervisor" },
  "main" : "",

Of course, use of coffeescript requires a corresponding entry in the dependencies section.