Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Fetchr augments Flux applications by allowing Flux stores to be used on server and client to fetch data
Fetchr augments Flux applications by allowing Flux stores to be used on server and client to fetch data.
On the server, stores can call the database directly to fetch some data.
On the client, however, stores can NOT call the database in the same way. Instead, xhr requests need to be made to the server( then to the database) and then the response can be parsed client side.
Fetchr provides an appropriate abstraction so that you can fetch (CRUD) your data in your stores using the same exact syntax on server and client side.
Fetchr needs delicate set up to work properly.
On the server side, add the fetchr middleware into your express app.
var express = require('express'),
fetcher = require('fetchr'),
app = express();
app.use(fetcher.middleware(
pathPrefix: '/myCustomAPIEndpoint'
));
pathPrefix
config option for the middleware is optional. Defaults to /api
.
It is necessary to expose this prefix to the client side fetcher (fetchr.client.js
) via a global variable, window.fetcherPathPrefix
.
After setting up the middleware, you can get the pathPrefix by calling fetcher.getPathPrefix()
and assign it to the global window.fetcherPathPrefix
.
//app.js
//...
var fetcher = require('fetchr'),
myDataFetcher = require('./dataFetcher');
fetcher.addFetcher(myDataFetcher);
//...
//dataFetcher.js
module.exports = {
//Name is required
name: 'data_api_fetcher',
//At least one of the CRUD methods is Required
read: function(resource, params, context, callback) {
//...
},
//other methods
//create: function(resource, params, body, context, callback) {},
//update: function(resource, params, body, context, callback) {},
//del: function(resource, params, context, callback) {}
}
Fetchr relies on a build process that swaps out lib/fetchr.js
with lib/fetchr.client.js
in the bundle that is generated for client side use. Usually the bundle is generated using tools like webpack or browserify.
//webpack config
plugins: [
//...
//Replace fetcher lib with client side fetcher lib
new webpack.NormalModuleReplacementPlugin(/^fetchr$/, require.resolve('fetchr/libs/fetcher.client.js'))
//...
]
This software is free to use under the Yahoo! Inc. BSD license. See the LICENSE file for license text and copyright information.
FAQs
Fetchr augments Flux applications by allowing Flux stores to be used on server and client to fetch data
The npm package fetchr receives a total of 302 weekly downloads. As such, fetchr popularity was classified as not popular.
We found that fetchr demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.