Skip to content

Commit

Permalink
require mongo and firebase only if used
Browse files Browse the repository at this point in the history
  • Loading branch information
darthfiddler committed Aug 6, 2018
1 parent 1a90e7f commit 09b523e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 29 deletions.
49 changes: 24 additions & 25 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions src/server/db/firebase.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
*/

const LRU = require('lru-cache');
const firebase = require('firebase');

const ENGINE_FIRESTORE = 'Firestore';
const ENGINE_RTDB = 'RTDB';
Expand Down Expand Up @@ -35,7 +34,7 @@ export class Firebase {
config = {};
}

this.client = firebase;
this.client = require('firebase');
this.engine = engine === ENGINE_RTDB ? engine : ENGINE_FIRESTORE;
this.config = config;
this.dbname = dbname;
Expand Down
3 changes: 1 addition & 2 deletions src/server/db/mongo.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
* https://opensource.org/licenses/MIT.
*/

const MongoClient = require('mongodb').MongoClient;
const LRU = require('lru-cache');

/**
Expand All @@ -20,7 +19,7 @@ export class Mongo {
if (cacheSize === undefined) cacheSize = 1000;
if (dbname === undefined) dbname = 'bgio';

this.client = mockClient || MongoClient;
this.client = mockClient || require('mongodb').MongoClient;
this.url = url;
this.dbname = dbname;
this.cache = new LRU({ max: cacheSize });
Expand Down

0 comments on commit 09b523e

Please sign in to comment.