Excellent, that second option looks great.

Thanks for the help!

Best,

Tony


On Tue, Jun 3, 2014 at 11:46 PM, Aria Stewart <[email protected]> wrote:

>
> On Jun 3, 2014, at 1:41 PM, Tony Barbieri <[email protected]> wrote:
>
> > Hello!
> >
> > I'm writing a library that will be used as a submodule and I would like
> to allow developers to setup configuration for it.  A few of these config
> options would be setting defaults for server url, login and password.
> >
> > Is there already a pattern for dealing with this situation?  I imagine
> it could be done a couple of ways:
> >
> >       • The submodule will always look for a config at some "hard-coded"
> location in the app hierarchy i.e. {app}/config/{submodule.config}?  Using
> this method, what is the best way for the submodule to find that location
> relative to the running application at run time?
> >       • Provide a function as part of my exports that allows the
> developer to load a config from any location at run time.  Given this
> technique, maybe a config file is unnecessary and the config settings
> should just be set using javascript rather than loading a file.
> > Should both methods be used?  Are there other options or patterns that
> are common?
>
> I prefer the latter by far — more like a constructor. You can always do
> something like this:
>
> var library = require(‘mylib’).create(require(‘./config.json’)).
>
>
>

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/CAJhmvsS%3D8wqsSnHcxvgV88eLhBiULsmBdyOP1Br0dbXnuS0QhA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to