1.0.1 • Published 7 years ago

ddp-micro v1.0.1

Weekly downloads
3
License
ISC
Repository
github
Last release
7 years ago

Meteor DDP server, supporting Meteor-style reactive subscriptions and methods. Implemented in a small efficient way.

Create DDP Server

var DDP = new DDPServer({port:3000});

Create Subscriptions

Subscriptions are not backed by Mongo documents. You can create fully custom subscriptions. Internally the data structure is a hash object where the keys are the _id's and the values are the values:

var Files = server.publish('Files');
Files.id1 = {name:'swiggity-swooty.mp4'};
Files.id2 = {name:'coming-for-that-booty.mp4'};

When you set or remove a property of Files, it will send the appropriate message over DDP.

Methods

Methods are invoked with the arguments supplied by the connected client and a node-style callback. To return a value, invoke the callback.

DDP.methods({
    test(value, callback) {
        callback(null, value)
    }
});

Add DDP to an existing HTTP server

var app = express();
app.server = http.createServer(app);
var server = new DDPServer({httpServer: app.server});