git ssb

2+

mixmix / ticktack



Tree: 03dfe69caaa894d0106facac00e1c06356e78e05

Files: 03dfe69caaa894d0106facac00e1c06356e78e05 / router / sync / routes.js

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

Built with git-ssb-web