Files: 9836e9e9dcd5acec7ee3725da3b5e9784a5490bd / router / sync / routes.js
730 bytesRaw
1 | const nest = require('depnest') |
2 | const isEmpty = require('lodash/isEmpty') |
3 | |
4 | exports.gives = nest('router.sync.routes') |
5 | |
6 | exports.needs = nest({ |
7 | 'app.page.home': 'first', |
8 | 'app.page.group': 'first', |
9 | 'app.page.private': 'first' |
10 | }) |
11 | |
12 | exports.create = (api) => { |
13 | return nest('router.sync.routes', (sofar = []) => { |
14 | const pages = api.app.page |
15 | // route format: [ routeValidator, routeFunction ] |
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 => !isEmpty(location.key), pages.privatePage ] |
21 | ] |
22 | |
23 | return [...routes, ...sofar] |
24 | }) |
25 | } |
26 | |
27 | |
28 | |
29 | |
30 | |
31 | |
32 | |
33 | |
34 | |
35 |
Built with git-ssb-web