I'm start with hapi-ninja boilerplate.
I need to make accessible some variable.
For example I create a service and I start ("construct", "load") it in the server.js (main file).
I would that this variable so var user_service = require(__dirname + '/service/user.js'); is accessible from other service.
For example:
server.js
var user_service = require(__dirname + '/service/user.js');
var test_service = require(__dirname + '/service/test.js');
module.exports.useUserFunction = function() {
return user_service.someFunction();
// I got error because user_service is undefined
};
I solution that I'd found is load inside the test_service again user_service but it's bad because I'd load too much times user_service.
What is the best solution for shared variables??
Hi,
I'm start with hapi-ninja boilerplate. I need to make accessible some variable. For example I create a service and I start ("construct", "load") it in the server.js (main file). I would that this variable so
var user_service = require(__dirname + '/service/user.js');
is accessible from other service. For example:server.js
user.js
test.js
I solution that I'd found is load inside the test_service again user_service but it's bad because I'd load too much times
user_service
. What is the best solution for shared variables??