Init rate-limiter with mongoose connection coming from external file
Hi!

I'm trying to use this package to limit requests number but I'm having some troubles with Mongoose connections. 

The point is that I init the DB connection through a file called `db.js` wich is then imported in my `app.js`. 

The fact is that the DB connection is available only after the app has been initialized but the limiter-middleware needs the connection during the app initialization. 

As you can see in the following files I've stored the DB connection in a variable called `_db` wich is readable with the `getDb()` method. 

But If I call the `getDb()` method inside the `rate-limiter.js` file I get an error because DB connection is not initialized yet.

I don't want to init a second connection inside `ip-limiter.js` file.

Have you some suggestions on how I can acheive my goal? :)

Any help would be very appreciated

--

"mongoose": "^5.5.11",
"rate-limiter-flexible": "^1.0.2"

--

app.js
```javascript
// Import core packeges
const path = require('path');

// Import third-party packages
const express = require('express');

// Import custom packages
const CONFIG = require('./config/config');
const initDb = require('./db').initDb;
const getDb = require('./db').getDb;

// Import middlewares and routes
... import some middlewares and routes
const routeIPLimiterMiddleware = require('./middlewares/limiters/ip-limiter');


// Init & config express
const app = express();

// BEGIN - Middlewares and routes
... some middlewares and routes
app.use(routeIPLimiterMiddleware); // Limit request number per seconds per IP
.. some other middlewares and routes
// END - Middlewares and routes

// Connect to db
initDb(err => {
  if (err) {
    console.warn('initDb error', err);
  }
  app.listen(CONFIG.PORT, err => {
    if (err) {
      throw err;
    }
    console.log(`API Up and running on port ${CONFIG.PORT}`);
  });
});
```

db.js
```javascript
const assert = require('assert');
const mongoose = require('mongoose');
const CONFIG = require('./config/config');

let _db;

// Get current db connection
module.exports.getDb = () => {
  assert.ok(_db, 'Db has not been initialized. Please called init first.');
  return _db;
}

// Init database connection
module.exports.initDb = (callback) => {
  if (_db) {
    return callback(null, _db);
  }

  mongoose.connect(CONFIG.DATABASE.URI, CONFIG.DATABASE.OPTIONS)
    .then(db => {
      _db = db;
      return callback(null, _db);
    })
    .catch(err => {
      return callback(err);
    });
}
```


ip-limiter.js
```javascript
const getDb = require('../../db').getDb;
const { RateLimiterMongo  } = require('rate-limiter-flexible');
const CONFIG = require('../../config/config');

const mongoConn = getDb();

const ipRateLimiterOptions = {
  storeClient: mongoConn,
  points: 1, // Maximum number of points can be consumed over duration
  duration: 2, // Number of seconds before consumed points are reset
  dbName: CONFIG.DATABASE.NAME,
  keyPrefix: 'rl-100'
}

const rateLimiter = new RateLimiterMongo(ipRateLimiterOptions);

/**
 * Limit requests number per second per IP
 */
module.exports = (req, res, next) => {
  rateLimiter.consume(req.ip)
    .then(() => {
      next();
    })
    .catch(() => {
      res.status(429).json({
        status: false,
        message: 'Too many requests'
      });
    });
}
```