This question already has answers here:
What is the purpose of Node.js module.exports and how do you use it?
(13 answers)
Closed 1 year ago.
Regarding this question: What is the purpose of Node.js module.exports and how do you use it? I'm a Javascript beginner. In the referenced question...
Consider modules to be the same as JavaScript libraries.
A set of functions you want to include in your application.
https://www.w3schools.com/nodejs/nodejs_modules.asp
Related
This question already has answers here:
Determine direct shared object dependencies of a Linux binary?
(4 answers)
Closed 5 years ago.
This probably already has an answer but I couldn't find it.
I want to know which shared object is used by the binary (based on LD_LIBRARY_PATH, /etc/ld.so.conf, etc...). Something similar to the which command but for .so.
Thanks
You should use the ldd utility. In the same environment you would load your executable (Same LD_LIBRARY_PATH, e.t.c.)
This question already has answers here:
When is the thread pool used?
(4 answers)
Closed 5 years ago.
I remember it seems that nodejs by default is using 4 back-end threads, therefore the fifth reading action will wait until 1 thread is available.
But I can't find any testify-example in google. Could someone explain and find the example please? Thanks.
It's in this post, as referred in the post from jfriend00. Thanks.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
Is there any rationale why HapiJS endorses using 4-space indentations?
Source: http://hapijs.com/styleguide
Short answer: No better reason than anyone else - styleguides are typically only rules for project maintainers. They had to adopt some convention and that was the choice. As a user, you don't really need to care.
Long answer: Hapi is a great framework, built by the folks at Walmart. and specifically a person named Eran Hammer who was unhappy about some architectural choices made by Express, another server framework for Node. It is somewhat opinionated in general, it was effectively created in an environment of opinion, not to mention a large company (which means it desperately needed a convention). That said, you can safely use the Hapi API with any indentation you want, including tabs, though. Likewise, the Hapi internals could have been written the same way. Their specific choice likely comes down to established tools or conventions already in use at the company. Many different projects make different choices for a variety of reasons. In my experience, many large JavaScript applications go with 2 spaces and the Node.js core itself is written with 2. But there's nothing wrong with those that do otherwise.
This question already has answers here:
Read environment variables in Node.js
(8 answers)
Closed 9 years ago.
I see some NodeJS programs executed like this PARAM=1;node program.js
Im assuming its putting PARAM=1 into the environment. How do I access this in the node program? thanks,
Yes, PARAM=1 is setting an environment variable.
Depending on which shell you're using, you may need to use export PARAM=1 so the setting makes it to the child process. Otherwise the value would only exist for the shell.
As dystroy pointed out, the rest of your question is answered here.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I try to find a good directory structure for my nodejs/express/mongoDB application.
Currently I use the native-mongodb driver which feels nice and fast but is limited when a proper structure should be defined... when MVC is the express/node way to go defining proper db models is not that easy.
Although mongoose and its concept of schemas would make the actual design of models easy but I am not that big of a fan of another layer on top of my stack... it feels kinda bloated to me.
I looked for an alternative and found mongoskin which is a thin wrapper on top of the native-driver but adds some features to support MVC-ish patterns.
In general I found this to be a common problem for other people too. I appreciate the idea presented in the link: https://stackoverflow.com/a/8428281/1055685
Nevertheless the query inside the model directory is not really MVC-like (as mentioned in the comments...) - I do not like it...
The MVC demos in express are not that helpful... did you find some inspiration there?
Which pattern do you recommend to follow (if MVC is recommended models are the real problem)?
Do you recommend mongoskin in general?
I would suggest looking at either LocomotiveJS or RailwayJS
LocomotiveJS is more "lightweight" and there is a great boilerplate available to get you started.
RailwayJS contains more "generators" to make it more rails-like however.