Files: f3409d0dc8b00fb3846783f9e510314430c1ecd1 / router / sync / routes.js
1663 bytesRaw
1 | const nest = require('depnest') |
2 | const { isMsg, isFeed } = require('ssb-ref') |
3 | exports.gives = nest('router.sync.routes') |
4 | |
5 | exports.needs = nest({ |
6 | 'app.page.error': 'first', |
7 | 'app.page.home': 'first', |
8 | 'app.page.settings': 'first', |
9 | 'app.page.groupFind': 'first', |
10 | 'app.page.groupIndex': 'first', |
11 | 'app.page.groupNew': 'first', |
12 | 'app.page.groupShow': 'first', |
13 | 'app.page.userFind': 'first', |
14 | 'app.page.userShow': 'first', |
15 | 'app.page.threadNew': 'first', |
16 | 'app.page.threadShow': 'first', |
17 | }) |
18 | |
19 | exports.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.page === 'settings', pages.settings ], |
27 | |
28 | // Group pages |
29 | [ location => location.page === 'groupFind', pages.groupFind ], |
30 | [ location => location.page === 'groupIndex', pages.groupIndex ], |
31 | [ location => location.page === 'groupNew', pages.groupNew ], |
32 | [ location => location.type === 'groupShow' && isMsg(location.key), pages.groupShow ], |
33 | |
34 | // Thread pages |
35 | // QUESTION - should this be for private threads + group threads? |
36 | [ location => location.page === 'threadNew' && isFeed(location.feed), pages.threadNew ], |
37 | [ location => isMsg(location.key), pages.threadShow ], |
38 | |
39 | // User pages |
40 | [ location => location.page === 'userFind', pages.userFind ], |
41 | [ location => isFeed(location.feed), pages.userShow ], |
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 |
Built with git-ssb-web