Code Monkey home page Code Monkey logo

eight-track's Introduction

EightTrack

Cache HTTP requests in the Meteor framework. Based on the popular 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!

eight-track's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.