git ssb

2+

mixmix / ticktack



Tree: c70c742f67f3d60df3aedead6dbea7fbac4f4ae8

Files: c70c742f67f3d60df3aedead6dbea7fbac4f4ae8 / router / sync / routes.js

819 bytesRaw
1const nest = require('depnest')
2const isEmpty = require('lodash/isEmpty')
3const ref = require('ssb-ref')
4exports.gives = nest('router.sync.routes')
5
6exports.needs = nest({
7 'app.page.home': 'first',
8 'app.page.group': 'first',
9 'app.page.private': 'first'
10})
11
12exports.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