Skip to content

Commit a89967c

Browse files
committed
Decouple proxy factory from service provider ♻️
1 parent 9133b75 commit a89967c

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

server/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const config = require('../config/server');
1717
const logger = require('./shared/logger')();
1818
const storage = require('./shared/storage')(config.storage);
1919
serviceProvider.set('storage', storage);
20-
const storageProxy = require('./shared/storage/proxy')(config.storage.proxy);
20+
const storageProxy = require('./shared/storage/proxy')(config.storage.proxy, storage);
2121
serviceProvider.set('storageProxy', storageProxy);
2222
const router = require('./router');
2323
/* eslint-enable */

server/shared/storage/proxy/index.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@
33
const autobind = require('auto-bind');
44
const flatMap = require('lodash/flatMap');
55
const path = require('path');
6-
const serviceProvider = require('../../serviceProvider');
76
const uniq = require('lodash/uniq');
87

98
class Proxy {
10-
constructor(config) {
11-
this.storage = serviceProvider.get('storage');
9+
constructor(config, storage) {
10+
this.storage = storage;
1211
this.provider = Proxy.createProvider(config);
1312
this.accessManagers = [this.provider.accessManager];
1413
autobind(this);
@@ -56,7 +55,7 @@ class Proxy {
5655
}
5756
}
5857

59-
module.exports = config => new Proxy(config);
58+
module.exports = (config, storage) => new Proxy(config, storage);
6059

6160
function loadProvider(name) {
6261
try {

0 commit comments

Comments
 (0)