git ssb

3+

ev / sdash



Tree: 3cd5d5225307fd500aaea83a68cbed379ce6ac72

Files: 3cd5d5225307fd500aaea83a68cbed379ce6ac72 / index.js

1332 bytesRaw
1var client = require('ssb-client');
2var pull = require('pull-stream');
3var moment = require('moment');
4var app = require('koa')();
5var router = require('koa-router')();
6var views = require('co-views');
7
8var port = 1337;
9var me = '@8Qee0I/DwI5DHSCi3p5fsl6FyLGArrnDz3ox9qZr5Qc=.ed25519'
10var message = 'I said nothing';
11
12client(function (err, sbot) {
13 if (err) {
14 throw err;
15 }
16 pull(sbot.createUserStream({
17 id: me,
18 limit: 1,
19 reverse: true
20 }),
21 pull.drain(function printMessage(msg) {
22 date = moment(msg.value.timestamp).fromNow()
23 if (msg.value.content.type === 'post') {
24 message = (msg.value.content.text)
25 }
26 else if (msg.value.content.type === 'vote') {
27 message = ('I dug ' + msg.value.content.vote.link)
28 }
29 else if (msg.value.content.type === 'about') {
30 message = ('I identified ' + msg.value.content.about + ' as ' + msg.value.content.name)
31 }
32 else if (msg.value.content.type === 'git-update') {
33 message = ('I pushed a commit ')
34 }
35 else {
36 message = ('I sent a private message ')
37 }
38 }));
39 app.use(router.routes())
40 app.use(router.allowedMethods())
41
42 var render = views(__dirname, { ext: 'jade'});
43
44 router.get('/', function *(next) {
45 this.body = yield render('index', {title: 'sdash', message, date});
46 });
47 app.listen(port);
48});
49
50

Built with git-ssb-web