Files: c70c742f67f3d60df3aedead6dbea7fbac4f4ae8 / 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