forked from st8998/commitwall
-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.js
36 lines (27 loc) · 1000 Bytes
/
demo.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
var redis = require('redis'),
client = redis.createClient();
var $ = require('underscore');
function attach(app) {
app.get('/-/demo/:streamName/:groupName', function(req, res) {
var streamName = req.param('streamName');
var groupName = req.param('groupName');
var message = JSON.stringify({
text: 'useless text that should wrap and be really long really long really long really long really long really long really long really long really long really long',
source: 'demo',
group: groupName,
author: {
email: '[email protected]',
name: 'Ilia Ablamonov'
},
weight: Math.random(),
timestamp: new Date(),
url: 'http://www.google.com/?query=joppa'
});
client.lpush('messages:' + streamName, message, function(err, rep) {
client.publish('messages:' + streamName, message);
});
client.ltrim('messages:' + streamName, 0, 999);
res.send('demo message sent');
});
}
exports.attach = attach;