Releases: yahoo/fetchr
Module export format changed to Fetchr Class
Breaking changes:
-
Fetchr now exports the class itself, rather than the class creating factory function.
var Fetcher = require('fetchr')(), //Fetcher class fetcher = new Fetcher(); //Fetcher instance
now becomes
var Fetcher = require('fetchr'), //Fetcher class fetcher = new Fetcher(); //Fetcher instance
-
addFetcher
method renamed toregisterFetcher
. This is to keep the api somewhat consistent between fetchr and dispatchr. -
Fetcher.middleware()
should no longer be mounted directly on the app. It should always be mounted on a path.app.use(Fetcher.middleware());
now becomes
app.use('/api', Fetcher.middleware());
-
pathPrefix
config option renamed toxhrPath
.- This config option used to be passed into the class creator function, but is now passed into the class upon instantiation.
- This option's value should point to the exact path the
Fetcher.middleware()
was mounted on.
No need to manually swap server/client fetchr file.
We use libs/fetcher.js
on the server and libs/fetcher.client.js
on the client. Which meant that when require('fetchr')
was called we had to grab different files based on the environment(server or client).
This is no longer necessary due to the browser
key in package.json
where we can explicitly substitute the client file for the server file, and allow users to not worry about this minor detail anymore.
Bugfix for passing in req to data fetchers
New Module Export Format
Fetchr now exports a function that returns the Fetchr class. This allows the Fetcher class to be instantiated per each request so that the request object can be passed into the CRUD methods on registered data fetchers (aka API callers).
Fetcher was implemented as a singleton before this breaking change.
var fetchr = require('fetchr')
now becomes
var Fetchr = require('fetchr')();
var fetchr = new Fetchr();