I have a Node + Express app. In many of my files I am doing this at the top
const config = require('./config');
const Twit = require('twit');
const TwitConnector = new Twit(config);
Is there a way to DRY this, so I don't have to repeat this everywhere?
Is there a, best practice, pattern to make something like TwitConnector
globally available so that I can use it anytime I need it?
Or maybe that's not a good idea and explicitly requiring it is the right thing to do?
via vinhboy
No comments:
Post a Comment