Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/drewmoore/eight-track
HTTP caching for the Meteor framework.
https://github.com/drewmoore/eight-track
javascript meteor meteor-framework meteorjs vcr
Last synced: 8 days ago
JSON representation
HTTP caching for the Meteor framework.
- Host: GitHub
- URL: https://github.com/drewmoore/eight-track
- Owner: drewmoore
- Created: 2016-10-16T03:16:23.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-11-21T02:52:20.000Z (about 8 years ago)
- Last Synced: 2024-11-16T01:42:11.762Z (2 months ago)
- Topics: javascript, meteor, meteor-framework, meteorjs, vcr
- Language: JavaScript
- Size: 15.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
EightTrack
==========
Cache HTTP requests in the Meteor framework. Based on the popular [VCR](https://github.com/vcr/vcr) package
for other frameworks, such as Rails. This typically is used in testing code that involves outgoing http requests for APIs and such. By caching, the chance of maxing out requests is drastically reduced. Plus, it is more considerate to your API providers, as well :).## Installation
`meteor add drewmoore:eight-track`
- It is recommended that you add `eight-track-cassettes/` to your project's `.gitignore`.## Usage
In any server-only code (for the time being), wrap an http response in the following manner:
```
EightTrack.useCassette('myCachedResponse', function () {
result = HTTP.get('https://jsonplaceholder.typicode.com/posts/1');
});
```- This will first find or create a directory in the project root called `eight-track-cassettes/`.
- This will then find or create a file named `myCachedResponse.json` in the directory.
- If the file does not exist or it is determined to be expired (see below), `myCachedResponse.json` will store a replica of the http response.
- If the file exists and is not expired, the json file will be parsed and the original http response simulated, complete with headers and all.## Cache Expiration
Currently, all cassettes are set to expire 24 hours after creation, according to EightTrack's `reRecordInterval`. In the near future, I plan on allowing this to be customized through a config file.## Client-Side Caching
This is currently a wish list feature.## Bug Reporting / Suggestions
Please feel free to create new issues on the repo. Pull requests always welcome!