Skip to content

Commit 09b523e

Browse files
committed
require mongo and firebase only if used
1 parent 1a90e7f commit 09b523e

3 files changed

Lines changed: 26 additions & 29 deletions

File tree

package-lock.json

Lines changed: 24 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/server/db/firebase.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
*/
88

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

1211
const ENGINE_FIRESTORE = 'Firestore';
1312
const ENGINE_RTDB = 'RTDB';
@@ -35,7 +34,7 @@ export class Firebase {
3534
config = {};
3635
}
3736

38-
this.client = firebase;
37+
this.client = require('firebase');
3938
this.engine = engine === ENGINE_RTDB ? engine : ENGINE_FIRESTORE;
4039
this.config = config;
4140
this.dbname = dbname;

src/server/db/mongo.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
* https://opensource.org/licenses/MIT.
77
*/
88

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

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

23-
this.client = mockClient || MongoClient;
22+
this.client = mockClient || require('mongodb').MongoClient;
2423
this.url = url;
2524
this.dbname = dbname;
2625
this.cache = new LRU({ max: cacheSize });

0 commit comments

Comments
 (0)