<commit_before># newspring:rest2ddp

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

## Installation

```bash
meteor add newspring:rest2ddp
```

## Server setup

After the package is installed, there are two methods for setting up
publications. You can use one or both:

### settings.json method

Add a settings file or add an object to your existing settings file that looks
like this:

```json
{
  "rest2ddp": {
    "verbose": true,
    "configs": [
      {
        "publicationName": "thePublication",
        "collectionName": "theCollection",
        "restUrl": "https://sub.domain.com/api/v1/widgets",
        "jsonPath": "$.query.results.channel.item.forecast.*",
        "secondsBetweenPolling": 5,
        "headers": {
          "Authorization-Token": "12345<PASSWORD>",
          "Other-Header-Key": "Other-Header-Value"
        }
      },
      {
        "collectionName": "otherCollection",
        "restUrl": "http://sub.otherdomain2.com/api/v2/people"
      }
    ]
  }
}
```

### Traditional publish method

Put code like this in a server block:

```js
REST2DDP.publish("thePublication", {
  collectionName: "theCollection",
  restUrl: "https://sub.domain.com/api/v1/widgets",
  secondsBetweenPolling: 5,
  headers: {
    "Authorization-Token": "123456789",
    "Other-Header-Key": "Other-Header-Value"
  }
});
```

## Client setup

Access the data on the client like this:

```js
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());
});<commit_msg>Add json path example to readme<commit_after># newspring:rest2ddp

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

## Installation

```bash
meteor add newspring:rest2ddp
```

## Server setup

After the package is installed, there are two methods for setting up
publications. You can use one or both:

### settings.json method

Add a settings file or add an object to your existing settings file that looks
like this:

```json
{
  "rest2ddp": {
    "verbose": true,
    "configs": [
      {
        "publicationName": "thePublication",
        "collectionName": "theCollection",
        "restUrl": "https://sub.domain.com/api/v1/widgets",
        "jsonPath": "$.query.results.channel.item.forecast.*",
        "secondsBetweenPolling": 5,
        "headers": {
          "Authorization-Token": "123456789",
          "Other-Header-Key": "Other-Header-Value"
        }
      },
      {
        "collectionName": "otherCollection",
        "restUrl": "http://sub.otherdomain2.com/api/v2/people"
      }
    ]
  }
}
```

### Traditional publish method

Put code like this in a server block:

```js
REST2DDP.publish("thePublication", {
  collectionName: "theCollection",
  restUrl: "https://sub.domain.com/api/v1/widgets",
  jsonPath: "$.query.results.channel.item.forecast.*",
  secondsBetweenPolling: 5,
  headers: {
    "Authorization-Token": "123456789",
    "Other-Header-Key": "Other-Header-Value"
  }
});
```

## Client setup

Access the data on the client like this:

```js
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());
});
{'fraction_non_alphanumeric': 0.14474708171206227, 'fraction_numerical': 0.014007782101167316, 'mean_word_length': 3.679611650485437, 'pattern_counts': {'":': 30, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1579074', 'n_tokens_mistral': 1241, 'n_tokens_neox': 1171, 'n_words': 297}