Book Image

Meteor Design Patterns

By : Marcelo Reyna
Book Image

Meteor Design Patterns

By: Marcelo Reyna

Overview of this book

Table of Contents (13 chapters)

External APIs

Now that we know how to secure our application, we need to understand how to keep external data sources up to date. There are two patterns that we can use to ensure that the information on our server is recent: synchronization and webhooks.


Synchronization will, basically, get data from our source continuously and refresh the database. This type of technique is useful when we need to save information from our data source and use that information to produce analytical data via the aggregation framework.

To keep our servers synchronized, we need to make sure that the process that fetches information does not block the server. We can ensure that this happens using nonblocking functions like Meteor.setInterval.

Let's synchronize with Stripe. First, we will need to create a collection to capture payments, then we will have to set permissions and our Stripe secret, and finally, we will build the HTTP GET function:

# /_globals/lib/collections/stripe/payments_collection...