Hi all,

I've been meaning to post this up, as it's a pattern I've been using with
any modules that act as a wrapper to something.
I just wanted to get some feedback, as I haven't seen this explicitly
anywhere, and I am curious if I may be causing problems down the line.

I have quite a few apps, which all share a common set of libraries, in a
package; ie: logging, configuration, database, etc.
I'll take logging as an example, I use bunyan.

exports.init = function(opts) {

// Do something with options
// There's a bunch of stuff for different streams to different services

var logger = bunyan.createLogger(...);
module.exports = logger;

Then in the app initialization:

require('package/lib/logger').init({ ... });

And now in some other module:

var logger = require('package/lib/logger');


Basically replacing the exports with the instance, and then it can be
called from anywhere, and accessed.
So my question would be - aside from losing the ability to re-initialize
(these should theoretically only be initialized once) - is there any
downside to this pattern; in terms of memory or efficiency?


Job Board: http://jobs.nodejs.org/
Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
For more options, visit this group at

You received this message because you are subscribed to the Google Groups "nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

Discussion Posts

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 18 | next ›
Discussion Overview
groupnodejs @
postedMar 22, '13 at 5:50a
activeMar 25, '13 at 10:27a



site design / logo © 2022 Grokbase