npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-red-contrib-meteor-ddp

v0.1.0

Published

A node-red suite of nodes to connect node-red flows to meteor application via DDP

Downloads

5

Readme

NODE-RED DDP CLIENT

A suite of Node-Red nodes for communicate with MeteorJS DDP servers.

MeteorJS is a great Javascript framework, it's reactivity model is very interesting for IoT applications, but it can't run on edge devices like Raspberry PI with no tricky compilations.

Furthermore NODE-RED runs on Raspberry PI very well, and can be used not only on these devices but in the cloud too or on desktop PC. So if you want to connect a NODE-RED flow to a MeteorJS application re-using your API with Publish and Methods you are in the right place.

Another reason we at Techmakers developed this nodes is we want to connect to our MeteorJS developed applications with some technologies were the DDP protocol implememtation is difficult and time conuming, so we use NODE-RED as a "broker" from these tecnologies to the MeteorJS applications we distribute.

This work is a NODE-RED full implmementation of the DDP Client NodeJS package.

You can connect to one ore more MeteorJS applications, subscribe to the Meteor.publish and call the Meteor.methods from your NODE-RED flow.

Using the SESSION parameter in every node you can attach any subscribe, observe and call node to the right MeteorJS connection.

MeteorJS connections are stored in the NODE-RED global context so you can attach to the same MeteorJS connection from different NODE-RED flows.

Installing the NODE-RED nodes

This is a standard NODE-RED contribution, the name is: node-red-contrib-meteor-ddp so the usual

npm install node-red-contrib-meteor-ddp

will do the job. Don't forget to cd in the .node-red directory before lounching the npm install command.

Example flow

This picture shows how the example flow should appear on your NODE-RED interface.

NODE-RED DDP NODES EXAMPLE FLOW

Example Meteor application

  1. download if needed MeteorJS
  2. enter a desired directory
  3. create a Meteor Application with the command meteor create myexample and enter the directory with cd myexample
  4. edit the file in myexample/server/main.js to obtain something like that
import { Meteor } from 'meteor/meteor';

var list = new Mongo.Collection("list") ;

Meteor.publish("list",function(params){
	console.log("Params",params) ;
	return list.find(params) ;
})

Meteor.methods({"add":function(params){
	return list.insert(params) ;
}});

Meteor.methods({"update":function(params){
	return list.update(params.criteria,params.modifier,{multi:true}) ;
}});

Meteor.methods({"remove":function(params){
	return list.remove(params) ;
}});

Meteor.startup(() => {
	// code to run on server at startup
	list.insert({
		name:'Ciao',
		addedOn: new Date() 
	})
});
  1. now you can run the Meteor application with command meteor and test the example flow clicking on the left-side injections nodes.

How to use example flow

We suggest some readings before start to play with this about the Meteor Publish and Subscribe concepts

  1. Be sure you have the Meteor Example Application up and running on the same machine you are running node-red, otherwise, update the meteor-ddp-connect node to attach to a different server
  2. Import the example flow in your NODE-RED application
  3. Deploy the imported flow
  4. The flow automatically connects to the Meteor Example Application
  5. Subscribe and observe all documents in the list collection with name equals to "Adam" by clicking on the {"name":"Adam"} node.
  6. Add a document to the collection clicking on the add:{"name":"Adam"} node.
  7. If everything is ok you should see on the right debug pane messages coming from the subscribe list and meteor-ddp-observe nodes.
  8. You can play switching from Adam to Eve and see what appens if you add a document in the list collection with the subscribe and observe.
  9. You can also try to modifiy documents in the meteor database using MongoDB commands to insert, update, remove documents and receive events on the NODE-RED flow thanks the Meteor reactivity model.

Some words about security

MeteorJS security is usually implemented server side by limiting the access to datasets in the Meteor.publish and specifying the rules about writing in the database collection via the allow and deny collection methods: https://docs.meteor.com/api/collections.html#Mongo-Collection-allow.

These rules are based on checking the Meteor.userId() before publishing documents to the subscribing clients.

You can use the meteor-ddp-call node to call the "login" DDP method to have a valid Meteor.userId() on server side to check against methods and subscribes calls from the clients. Passing the credentials in the msg.payload object is possible.