git ssb

2+

mixmix / ticktack



Tree: b206911bfe9aa61b8eb303bde755d1d378e4361e

Files: b206911bfe9aa61b8eb303bde755d1d378e4361e / router / sync / routes.js

1858 bytesRaw
1const nest = require('depnest')
2const { isMsg, isFeed, isBlob } = require('ssb-ref')
3exports.gives = nest('router.sync.routes')
4
5exports.needs = nest({
6 'app.page.error': 'first',
7 'app.page.home': 'first',
8 'app.page.channel': 'first',
9 'app.page.settings': 'first',
10 'app.page.groupFind': 'first',
11 'app.page.groupIndex': 'first',
12 'app.page.groupNew': 'first',
13 'app.page.groupShow': 'first',
14 'app.page.userFind': 'first',
15 'app.page.userShow': 'first',
16 'app.page.threadNew': 'first',
17 'app.page.threadShow': 'first',
18 'app.page.image': 'first',
19})
20
21exports.create = (api) => {
22 return nest('router.sync.routes', (sofar = []) => {
23 const pages = api.app.page
24 // route format: [ routeValidator, routeFunction ]
25
26 const routes = [
27
28 // Thread pages
29 [ location => location.page === 'threadNew' && isFeed(location.feed), pages.threadNew ],
30 [ location => location.page === 'threadNew' && location.channel, pages.threadNew ],
31 [ location => isMsg(location.key), pages.threadShow ],
32
33 // User pages
34 [ location => location.page === 'userFind', pages.userFind ],
35 [ location => isFeed(location.feed), pages.userShow ],
36
37 // Group pages
38 [ location => location.page === 'groupFind', pages.groupFind ],
39 [ location => location.page === 'groupIndex', pages.groupIndex ],
40 [ location => location.page === 'groupNew', pages.groupNew ],
41 // [ location => location.type === 'groupShow' && isMsg(location.key), pages.groupShow ],
42 [ location => location.channel , pages.channel ],
43
44 [ location => location.page === 'home', pages.home ],
45 [ location => location.page === 'settings', pages.settings ],
46 [ location => isBlob(location.blob), pages.image ],
47
48 // Error page
49 [ location => true, pages.error ]
50 ]
51
52 return [...routes, ...sofar]
53 })
54}
55
56

Built with git-ssb-web