-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathloader.js
More file actions
44 lines (35 loc) · 1.16 KB
/
loader.js
File metadata and controls
44 lines (35 loc) · 1.16 KB
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
35
36
37
38
39
40
41
42
43
44
var nano = require('nano')('http://localhost:5984'),
noflo = require('noflo');
var loader = function (loader, done) {
console.log('loading components');
var db = nano.use('signage');
console.log('registerComponent: %s', typeof(loader.registerComponent) === 'function');
db.view('signage', 'components', function (err, res) {
if (!err) {
res.rows.forEach(function (doc) {
console.log(doc);
});
} else {
done(err);
}
});
if (typeof(loader.registerGraph) === 'function') {
db.view('signage', 'graphs', function (err, res) {
if (!err) {
res.rows.forEach(function (doc) {
console.log('registering component %s', doc.id);
loader.registerGraph('helloworld', doc.id, {
getComponent: function () {
return new noflo.Graph(doc.json);
}
});
console.log(doc);
});
} else {
done(err);
}
});
}
done();
};
module.exports = loader;