Deepstream can currently be passed a http server to initialize its websocket server. However this behavior is being deprecated in the very near future as we want to further optimize deepstream.io by moving it more into the c++ space, meaning the http server will be able to handle much many more concurrent connections at the expense of not being configurable.
In most cases you can build your entire application using a deepstream client. The combination of data-sync, events and rpcs means that as long as you aren't looking at doing actions such as binary uploads/transfers you can benefit from picking the best tool to accomplish a task.
For example, you can use RPCs when requiring classic request/response atomic operations:
ds.rpc.provide( 'add-numbers', function( data, response ) {
var result = data.reduce(function(previousValue, currentValue) {
return previousValue + currentValue;
})
response.send( result )
} )
ds.rpc.make( 'add-numbers', [ 1, 3 ], function( err, data ) {
console.log( 'result: ', data )
} )
which is similar to express:
app.post( '/add-two', function( req, res ) {
var result = req.body.data.reduce(function(previousValue, currentValue) {
return previousValue + currentValue;
})
res.send( result )
} )
Except deepstream would also manage concepts such as service discovery and load balancing for you and even allow clients the opportunity to become endpoints if wanted.
or use events:
ds.event.emit( 'score-changed', score++ )
ds.event.subscribe( 'score-changed', function( newScore ) {
console.log( `The score changed on: ${newScore}` )
} )
or model your application data and synchronize it across all clients using records:
var record = ds.record.getRecord( 'playerA' )
record.subscribe( 'score', function( newScore ) {
console.log( `Player A score has changed to: ${newScore}` );
} );
record.set( 'score', record.get('score')++ );
I hope that helps!