Muri is your friendly neighborhood MongoDB URI parser for Node.js
JavaScript Makefile
Latest commit 374500c Jul 6, 2017 @vkarpov15 vkarpov15 chore: release 1.2.2
Permalink
Failed to load latest commit information.
lib Simpler way to fetch version Jul 5, 2017
test test: add coverage for #11 Feb 2, 2017
.gitignore initial commit Nov 1, 2012
.travis.yml travis Feb 19, 2013
History.md chore: release 1.2.1 Feb 2, 2017
LICENSE initial commit Nov 1, 2012
Makefile tests; allow mocha options Nov 2, 2012
README.md
index.js initial commit Nov 1, 2012
package.json chore: release 1.2.2 Jul 5, 2017

README.md

Meet Muri!

Muri is your friendly neighborhood MongoDB URI parser for Node.js.

Install

$ npm install muri

Use

 var muri = require('muri');
 var o = muri('mongodb://user:pass@local,remote:27018,japan:27019/neatdb?replicaSet=myreplset&journal=true&w=2&wtimeoutMS=50');

 console.log(o);

 { hosts: [ { host: 'local',  port: 27017 },
            { host: 'remote', port: 27018 },
            { host: 'japan',  port: 27019 } ],
   db: 'neatdb',
   options: {
     replicaSet: 'myreplset',
     journal: true,
     w: 2,
     wtimeoutMS: 50
   },
   auth: {
     user: 'user',
     pass: 'pass'
   }
 }

Details

The returned object contains the following properties:

  • db: the name of the database. defaults to "admin" if not specified
  • auth: if auth is specified, this object will exist { user: 'username', pass: 'password' }
  • hosts: array of host/port objects, one for each specified [{ host: 'local', port: 27107 }, { host: '..', port: port }]
    • if a port is not specified for a given host, the default port (27017) is used
    • if a unix domain socket is passed, host/port will be undefined and ipc will be set to the value specified [{ ipc: '/tmp/mongodb-27017' }]
  • options: this is a hash of all options specified in the querystring

License

MIT