javascript - Multitenant configuration data for the SDK Library -
this question builds on answer previous question, looking solution share configuration data between actors (nodejs modules) of system (sdk) without using factory pattern.
this time need make sdk multi-tenant providing different configuration data distinct sdk instances.
app.js
var sdkaccta = require("./sdk"); sdkaccta.config = {key: "key", secret: "secret"}; var sdkacctb = require("./sdk"); sdkacctb.config = {key: "key2", secret: "secret2"}; // use both of them concurrently without each 1 overriding config data of other var ma = new sdkaccta.m1(); ma.dosomething(); var mb = new sdkacctb.m1(); mb.dosomething();
sdk.js
var sdk = function(){}; sdk.config = {key: null, secret: null}; module.exports = sdk; require("./m1"); //executing other modules make work
m1.js
var sdk = require("./sdk"); var m1 = function(){}; m1.prototype.dosomething = function(){ var config = sdk.config //getting access main module's config data }; sdk.m1 = m1;
question:
right configuration data getting overriden other instance , that's issue is. please advise.
Comments
Post a Comment