git ssb

2+

mixmix / ticktack



Tree: 17b2f7bb97825fb0650e466902418fcf8442c5fd

Files: 17b2f7bb97825fb0650e466902418fcf8442c5fd / router / sync / routes.js

1838 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 [ location => isBlob(location.blob), pages.image ],
28 [ location => location.page === 'home', pages.home ],
29 [ location => location.channel , pages.channel ],
30 [ location => location.page === 'settings', pages.settings ],
31
32 // Group pages
33 [ location => location.page === 'groupFind', pages.groupFind ],
34 [ location => location.page === 'groupIndex', pages.groupIndex ],
35 [ location => location.page === 'groupNew', pages.groupNew ],
36 [ location => location.type === 'groupShow' && isMsg(location.key), pages.groupShow ],
37
38 // Thread pages
39 // QUESTION - should this be for private threads + group threads?
40 [ location => location.page === 'threadNew' && isFeed(location.feed), pages.threadNew ],
41 [ location => isMsg(location.key), pages.threadShow ],
42
43 // User pages
44 [ location => location.page === 'userFind', pages.userFind ],
45 [ location => isFeed(location.feed), pages.userShow ],
46
47 // Error page
48 [ location => true, pages.error ]
49 ]
50
51 return [...routes, ...sofar]
52 })
53}
54
55
56
57

Built with git-ssb-web