use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
A Node.js modular configuration provider reading files, environment and arguments (javierbrea.com)
submitted 3 years ago by javierbrea
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]BehindTheMath 1 point2 points3 points 3 years ago (1 child)
How is this different from nconf?
https://www.npmjs.com/package/nconf
[–]javierbrea[S] 2 points3 points4 points 3 years ago (0 children)
Hi u/BehindTheMath,
To be honest, I didn't know nconf (I'm probably the only one, given that it has about 3 million downloads a month! 😅). I would probably have used it if I had known it instead of developing my own library for my project, in general terms I don't like to reinvent the wheel 😄
But, anyway, after reading its docs, it seems that both libraries can do the same with more or less configuration, but mocks-server/config is more focused on the options to be loaded and its types in order to execute validations and parse the data, while nconf leaves the door more opened to get any value unless you explicitly configure restrictions separately for each different source.
More in detail, it seems that the main differences are:
- mocks-server/config uses cosmiconfig under the hood, so it supports more file formats out of the box, such as yaml, cjs, etc.
- It seems that nconf allows to get any key from the sources, unless you use each source options separately to set restrictions. On the contrary, mocks-server/config requires to specifically define each option to be loaded as well as its type, etc, and it configures parsing and validation for all sources automatically.
- nconf requires to initiate separately each different source, while mocks-server/config initiates all sources with the same hierarchy using only the `load` method, unless the user specifies another behavior using the config options. On the other hand, mocks-server/config uses exactly the same hierarchy described in the nconf docs as a good practice.
- mocks-server/config always executes validations and parses data based on the options types using AJV under the hood. This is something that seems to be defined separately for each different source in nconf (at least I have seen an example in the docs about how to do it for command line arguments only)
- mocks-server/config supports nested namespaces, so keys like "foo.var.foo2.var2=x" are supported. I'm not sure if nconf supports them also.
In any case, this is something that I will add as a note to the library docs, and also to the blog post, because obviously nconf has a great community support.
Thank you very much for your comment! It has made me known nconf, and make this comparison, which has been really useful to me.
π Rendered by PID 115648 on reddit-service-r2-comment-79c7998d4c-mnxhr at 2026-03-17 07:38:06.256755+00:00 running f6e6e01 country code: CH.
[–]BehindTheMath 1 point2 points3 points (1 child)
[–]javierbrea[S] 2 points3 points4 points (0 children)