Mongo Connection String Builder
Mongo Connection String Builder is an NPM module whose sole purpose is to a mongo connection string with details like user, password and any number of conneciton options. The username and password are set using the ENV variables MONGO_USER & MONGO_PASSWORD. If these ENV variables are not set you get a valid mongo connection string back without any authentication details.
Usage
Simple use case
var mcsb = ;var connectionString = mcsb; //example usage of the connection stringvar someMongoLib = ;someMongoLib;
With connection options
var mcsb = ; //Options with be appended into the connection string as &key=valuevar options = authmechanism : 'MONGOCR' authSource : 'admin'var connectionString = mcsb; //example usage of the connection stringvar someMongoLib = ;someMongoLib;
Setting the ENVs manually
Danger Will Robinson! - While this can be useful for testing its probably not appropriate for production.
processenvMONGO_USER = 'user';processenvMONGO_PASSWORD = 'password'; var mcsb = ;var connectionString = mcsb; //example usage of the connection stringvar someMongoLib = ;someMongoLib;