This Meteor package uses the amazing work done by "OK GROW!" to allow apps to publish REST resources directly to the client (hence: rest to ddp).
https://github.com/okgrow/rest2ddp
meteor add newspring:rest2ddp
After the package is installed, there are two methods for setting up publications. You can use one or both:
Add a settings file or add an object to your existing settings file that looks like this:
{
"rest2ddp": {
"verbose": true,
"configs": [
{
"publicationName": "thePublication",
"collectionName": "theCollection",
"restUrl": "https://sub.domain.com/api/v1/widgets",
"jsonPath": "$.query.results.channel.item.forecast.*",
"pollInterval": 5000,
"headers": {
"Authorization-Token": "123456789",
"Other-Header-Key": "Other-Header-Value"
}
},
{
"collectionName": "otherCollection",
"restUrl": "http://sub.otherdomain2.com/api/v2/people"
}
]
}
}
Put code like this in a server block:
REST2DDP.publish("thePublication", {
collectionName: "theCollection",
restUrl: "https://sub.domain.com/api/v1/widgets",
jsonPath: "$.query.results.channel.item.forecast.*",
pollInterval: 5000,
headers: {
"Authorization-Token": "123456789",
"Other-Header-Key": "Other-Header-Value"
}
});
Access the data on the client like this:
theCollection = new Mongo.Collection("theCollection");
Meteor.subscribe("thePublication");
Tracker.autorun(function () {
console.table(theCollection.find().fetch());
});
otherCollection = new Mongo.Collection("otherCollection");
Meteor.subscribe("otherCollection");
Tracker.autorun(function () {
console.table(otherCollection.find().fetch());
});