Ddp-server-reactive


#1

To convince my Q42 colleagues to add DDP APIs alongside their REST APIs, I created DDP-Server-Reactive, which allows you to add DDP server functionality to your NodeJS app with almost no effort:

// Create a server listening on the default port 3000
var server = new DDPServer();
 
// Create a reactive collection
// All the changes below will automatically be sent to subscribers
var todoList = server.publish("todolist");
 
// Add items
todoList[0] = { title: "Cook dinner", done: false };
todoList[1] = { title: "Water the plants", done: true };
 
// Change items
todoList[0].done = true;
 
// Remove items
delete todoList[1];

// Add methods
server.methods({
  test: function() {
    return true;
  }
});

How to integrate with backend in different language?
#2

This is fantastic! Nice work!


#3

DDP servers (not clients) are notoriously hard to build because there’s no spec anywhere. So props for putting this together and for making sure it’s really easy to use! Very Meteoric of you.


#4

Isn’t this a spec?


#5

Yes, that’s what I used. But I still had quite some trouble getting it all to work, because some very important details are hidden in the prose.

Before I started working on this I was surprised that there wasn’t a (working) DDP server library for Node. Now I know why.


#6

@sjoerdvisscher Sjoerd, did you actually convince your colleagues and what happened to your effort? Still care to build something from it? I am interested because our project would be a perfect fit. Heavy real time data, almost no persistence requirements… we just want to avoid using mongodb as a bottleneck. So we’re probably going for the classic way now, but in the future we might put ourselves on the implementation task as well.


#7

@jhohlfeld I think most colleagues see the value of DDP now. But I don’t think anyone is using my library, it turns out that just using Meteor is the better solution most of the time.


#8

@rgoomar @rahul @sjoerdvisscher @benjick @jhohlfeld
Hi guys, I build a web service REST API from meteor and the client is native
android java. I wanna upload file from my android using rest or ddp. but
until now, i havent found the solution about uploading file via ddp or
using rest. Anybody wants to help me?


#9

Uploading a file “using REST” shouldn’t be any different than uploading a file on any other platform. I imagine you’d just POST the file to the endpoint. Where are you getting stuck?


#10

Cool! It’s interesting to see the usage of the Proxy object.


#11

I was just looking for alternatives to Meteor on server side and found this… It’s pretty lightweight, not tested, and not much added over the fork it came from, but it can probably get me off the ground well enough to get some benchmarks. It’s a real shame MDG didn’t a) elevate the DDP spec to something more than an afterthought (how about a decent documentation site for example?) b) provide node reference implementations for client and server. Asteroid for the client is doing pretty well, but I’m still evaluating server options…