git ssb

2+

mixmix / ticktack



Tree: de0ef825a9ce79b779be739bf4566c0077448919

Files: de0ef825a9ce79b779be739bf4566c0077448919 / router / sync / routes.js

1622 bytesRaw
1const nest = require('depnest')
2const { isMsg, isFeed } = 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.threadShow': 'first'
17})
18
19exports.create = (api) => {
20 return nest('router.sync.routes', (sofar = []) => {
21 const pages = api.app.page
22 // route format: [ routeValidator, routeFunction ]
23
24 const routes = [
25 [ location => location.page === 'home', pages.home ],
26 [ location => location.channel , pages.channel ],
27 [ location => location.page === 'settings', pages.settings ],
28
29 // Group pages
30 [ location => location.page === 'groupFind', pages.groupFind ],
31 [ location => location.page === 'groupIndex', pages.groupIndex ],
32 [ location => location.page === 'groupNew', pages.groupNew ],
33 [ location => location.type === 'groupShow' && isMsg(location.key), pages.groupShow ],
34
35 // User pages
36 [ location => location.page === 'userFind', pages.userFind ],
37 [ location => isFeed(location.feed), pages.userShow ],
38
39 // Thread pages
40 // QUESTION - should this be for private threads + group threads?
41 [ location => isMsg(location.key), pages.threadShow ],
42
43 // Error page
44 [ location => true, pages.error ]
45 ]
46
47 return [...routes, ...sofar]
48 })
49}
50
51
52
53
54
55
56
57
58
59
60
61

Built with git-ssb-web