forked from vol7/feathers-sync
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsync.js
More file actions
31 lines (25 loc) · 746 Bytes
/
sync.js
File metadata and controls
31 lines (25 loc) · 746 Bytes
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
var debug = require('debug')('feathers-sync');
var mongo = require('./mongodb');
var redis = require('./redis');
var amqp = require('./amqp');
module.exports = function (config) {
var proto = '';
config = config || { db: 'mongodb://localhost:27017/sync' };
if (config.db) {
proto = config.db.split('://')[0];
} else if (config.uri) {
proto = config.uri.split('://')[0];
}
if (['mongodb', 'redis', 'amqp'].indexOf(proto) === -1) {
return debug('Adapter not found %s', proto);
}
debug('will sync via adapter: %s ', proto);
if (proto === 'mongodb') {
return mongo(config);
} else if (proto === 'redis') {
return redis(config);
} else if (proto === 'amqp') {
return amqp(config);
} else {
}
};