-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
34 lines (32 loc) · 1.07 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
const GCLOUD = require('./lib/GoogleCloudStorageSystem');
const NFS = require('./lib/NFSStorageSystem');
const AWS3 = require('./lib/S3StorageSystem');
const CLOUDINARY = require('./lib/CloudinaryStorageSystem');
const DG = require('./lib/DigitalOceanStorageSystem');
class StorageFactory {
static getInstance(storageMode, Region) {
if (!storageMode) {
throw new Error('Please add a storage Instance');
}
if (storageMode === 'GCLOUD') {
return new GCLOUD();
}
else if (storageMode === 'AWS') {
return new AWS3(Region);
}
else if (storageMode === 'NFS') {
return new NFS();
}
else if (storageMode === 'CLOUDINARY') {
return new CLOUDINARY();
}
else if (storageMode === 'DG') {
return new DG(Region);
}
else {
throw new Error(`Cant recognize instance of ${storageMode}, Please Specify Instance of AWS, GCLOUD, NFS`);
}
}
}
const storageSystem = StorageFactory;
module.exports = storageSystem;