Last active
April 20, 2017 15:27
-
-
Save badri/e98ac0481e1792205e05bd061498f5f1 to your computer and use it in GitHub Desktop.
deepstream express integration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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