Files: 5d53dd6aa9aad22cb634152c1035a243557b12f5 / router / sync / routes.js
819 bytesRaw
1 | const nest = require('depnest') |
2 | const isEmpty = require('lodash/isEmpty') |
3 | const ref = require('ssb-ref') |
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 | console.log('LOCATION', location, isEmpty(location.key)) |
17 | const routes = [ |
18 | [ location => location.page === 'home', pages.home ], |
19 | [ location => location.type === 'group', pages.group ], |
20 | [ location => location.page === 'channel', pages.channel ], |
21 | [ location => ref.isMsg(location.key), pages.private ] |
22 | ] |
23 | |
24 | return [...routes, ...sofar] |
25 | }) |
26 | } |
27 | |
28 | |
29 | |
30 | |
31 | |
32 | |
33 | |
34 | |
35 | |
36 | |
37 |
Built with git-ssb-web