git ssb

1+

mixmix / scuttle-book



Tree: 52b538d1c0b57ad5fe2d8c3e4af7b5d03fc6ebbb

Files: 52b538d1c0b57ad5fe2d8c3e4af7b5d03fc6ebbb / index.js

1218 bytesRaw
1const inject = require('./inject')
2
3const methods = {
4 async: {
5 comment: require('./async/comment'),
6 create: require('./async/create'),
7 get: require('./async/get'),
8 isBookComment: require('./async/isBookComment'),
9 isBookUpdate: require('./async/isBookUpdate'),
10 update: require('./async/update'),
11 },
12 // obs: {
13 // authors: require('./obs/authors'),
14 // book: require('./obs/book'),
15 // shelves: require('./obs/shelves'),
16 // },
17 // pull: {
18 // books: require('./pull/books'),
19 // comments: require('./pull/comments'),
20 // updates: require('./pull/updates'),
21 // },
22 sync: {
23 isBook: require('./sync/isBook'),
24 }
25}
26
27// Note : if you don't like this export pattern, there's no reason we can't add different mappings !!
28// e.g. book.validate.bookComment
29
30module.exports = function Book (client, opts) {
31 return inject(client, methods)
32}
33
34
35// auto-inject the ssb-client instance to all methods to reduce repition
36function inject (client, methods) {
37 for (var key in methods) {
38 if (typeof methods[key] === 'function') {
39 methods[key] = methods[key](client)
40
41 }
42 else {
43 methods[key] = inject(client, methods[key])
44 }
45 }
46
47 return methods
48}
49
50
51

Built with git-ssb-web