Skip to content

Instantly share code, notes, and snippets.

@badri
Last active April 20, 2017 15:27
Show Gist options
  • Save badri/e98ac0481e1792205e05bd061498f5f1 to your computer and use it in GitHub Desktop.
Save badri/e98ac0481e1792205e05bd061498f5f1 to your computer and use it in GitHub Desktop.
deepstream express integration
<!DOCTYPE html>
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/deepstream.io-client-js/2.1.4/deepstream.js"></script>
</head>
<body>
<input type="text" />
<script type="text/javascript">
var client = deepstream('localhost:6020').login()
var record = client.record.getRecord('ds/sb')
var input = document.querySelector('input')
record.subscribe('item', function(value) {
input.value = value
})
</script>
</body>
</html>
var deepstream = require('deepstream.io-client-js');
var http = require( 'http' );
var express = require( 'express' );
var app = express();
var server = http.createServer(app);
var dsClient = deepstream('localhost:6020').login();
var port = process.env.PORT || 8080;
app.get('/hello/:val', function ( req, res ) {
var record = dsClient.record.getRecord('ds/sb');
record.set('item', req.params.val);
res.send( 'Hello to you too!' );
});
server.listen(port);
console.log('Magic happens on port ' + port);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment