Files: 28f088d0fbc23ee56ac8ad25e58199bd9c3262fd / router / sync / routes.js
718 bytesRaw
1 | const nest = require('depnest') |
2 | const ref = require('ssb-ref') |
3 | exports.gives = nest('router.sync.routes') |
4 | |
5 | exports.needs = nest({ |
6 | 'app.page.home': 'first', |
7 | 'app.page.group': 'first', |
8 | 'app.page.private': 'first' |
9 | }) |
10 | |
11 | exports.create = (api) => { |
12 | return nest('router.sync.routes', (sofar = []) => { |
13 | const pages = api.app.page |
14 | // route format: [ routeValidator, routeFunction ] |
15 | |
16 | const routes = [ |
17 | [ location => location.page === 'home', pages.home ], |
18 | [ location => location.type === 'group', pages.group ], |
19 | [ location => location.page === 'channel', pages.channel ], |
20 | [ location => ref.isMsg(location.key), pages.private ] |
21 | ] |
22 | |
23 | return [...routes, ...sofar] |
24 | }) |
25 | } |
26 | |
27 | |
28 | |
29 | |
30 | |
31 | |
32 | |
33 | |
34 | |
35 | |
36 |
Built with git-ssb-web