Commit b4e7ba90af1e22153fb4b857f562935d5b33d350
extract raw methods api
mix irving committed on 3/5/2018, 5:08:33 AMParent: 07a5f24f2034628892c7c9ed0782b63b30fc7911
Files changed
index.js | changed |
methods.js | added |
stance.js | deleted |
index.js | ||
---|---|---|
@@ -1,23 +1,12 @@ | ||
1 | -const verboseMethods = { | |
2 | - poll: { | |
3 | - async: { | |
4 | - // publishPoll: require('./async/publishPoll') | |
5 | - }, | |
6 | - sync: { | |
7 | - isPoll: require('./sync/isPoll') | |
8 | - // Poll: // this is not exported - doesn't follow the inject pattern atm | |
9 | - } | |
10 | - }, | |
11 | - position: { | |
1 | +const raw = require('./methods') | |
12 | 2 | |
13 | - } | |
3 | +const niceMappings = { | |
4 | + isPoll: raw.poll.sync.isPoll | |
14 | 5 | } |
6 | +// by following this pattern you can write your own API | |
15 | 7 | |
16 | -const easyMethods = { | |
17 | - isPoll: require('./sync/isPoll') | |
18 | -} | |
8 | +module.exports = function (server, opts) { | |
9 | + const methods = Object.assign({}, raw, niceMappings) | |
19 | 10 | |
20 | -module.exports = function (server, opts) { | |
21 | - const methods = Object.assign({}, verboseMethods, easyMethods) | |
22 | 11 | return require('./lib/inject')(server, methods) |
23 | 12 | } |
methods.js | ||
---|---|---|
@@ -1,0 +1,18 @@ | ||
1 | +// verbose export of public methods | |
2 | + | |
3 | +module.exports = { | |
4 | + poll: { | |
5 | + async: { | |
6 | + // publishPoll: require('./async/publishPoll') | |
7 | + }, | |
8 | + sync: { | |
9 | + isPoll: require('./poll/sync/isPoll') | |
10 | + // Poll: // this is not exported - doesn't follow the inject pattern atm | |
11 | + } | |
12 | + }, | |
13 | + position: { | |
14 | + sync: { | |
15 | + isPosition: require('./position/sync/isPosition') | |
16 | + } | |
17 | + } | |
18 | +} |
stance.js | ||
---|---|---|
@@ -1,17 +1,0 @@ | ||
1 | -var Validate = require('is-my-json-valid') | |
2 | -const { msgIdRegex, feedIdRegex, blobIdRegex } = require('ssb-ref') | |
3 | - | |
4 | -function create () { | |
5 | - | |
6 | -} | |
7 | - | |
8 | -const schema = { | |
9 | -} | |
10 | - | |
11 | -const validate = Validate(schema, { verbose: true }) | |
12 | - | |
13 | -module.exports = { | |
14 | - create, | |
15 | - schema, | |
16 | - validate | |
17 | -} |
Built with git-ssb-web