DailyJS

Node Roundup: 0.3.8, node-database-cleaner, node-config

2011-02-09 00:00:00 +0000 by Alex R. Young

Welcome to the Node Roundup. Send in your apps and libraries using our
contact form or @dailyjs.

Node 0.3.8

Node 0.3.8
is out. Here's the change log with some annotations:

Download:
nodejs.org/dist/node-v0.3.8.tar.gz\ Website: nodejs.org/docs/v0.3.8\
Documentation:
nodejs.org/docs/v0.3.8/api

node-database-cleaner

node-database-cleaner (MIT Licensed) by Emerson Macedo knows how to wipe databases. This is useful for writing tests that test against a test database -- you might
have seen me do something similar in our Node tutorials. It currently
works with Mongo.

node-config

node-config (Apache License 2.0) by Loren West is a configuration management library for Node. It
can be used to provide consistent access to configuration variables, but
also makes it easy to override defaults with values from command-line
options or configuration files.

Defining configurations looks like this:

// Customers.js - Customer management utilities

// Configuration parameters and default values
var config = require('config')('Customers', {
  dbHost: 'localhost',
  dbPort: 5984,
  dbName: 'customers',
  syncFrequency: 60
});

Which makes this possible:

$ node billing.js -config smokeTest.js -Customers.dbPort 5985

One useful trick Loren points out in the README is programmatic
configuration through argv:

process.argv.push('-Customers.dbPort', 5994);
require('Customers');