With this very simple module you can create a singelton application instance (global application instance) that can be required/imported by other modules in the same application, so that they all share the same instance of the application module.
All you need to do is to require the singelton-app from your main module (for example app.js) and then extend it with your application functions:
app.js
var app = require('singelton-app');
app.extend({
initialize: function () {
console.log( 'initialize function' );
},
sayHello: function () {
console.log( 'Hello!' );
}
});
app.initialize();
Then you can access the extended functions of the singelton application from any project module with:
someModule.js
var app = require('singelton-app');
exports.someFunction = function() {
app.sayHello();
});