Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
backbone-requester
Advanced tools
Make server-based requests in Backbone via request
This is based off of backbone-request but forked due to lack of support for updates.
Install the module with: npm install backbone-requester
// Load in our dependencies
var Backbone = require('Backbone');
var BackboneRequester = require('backbone-requester');
var request = require('request');
// Initialize and bind `BackboneRequester` to `Backbone`
var requester = new BackboneRequester(request);
requester.attach(Backbone);
// Create a new model and save it via `request`
var person = new Backbone.Model({name: 'Bark Ruffalo'});
person.save({
error: function (model, err, options) {
// Handle error from request (e.g. `ECONNREFUSED`)
},
success: function (model, response, options) {
// Handle response data from request
}
});
// For error-first callback handling, this can be combined with `backbone-callbacks`
backbone-requester
exposes BackboneRequester
via its module.exports
.
new BackboneRequester(request)
Constructor for a new backbone-requester
instance
Function
- Request library (or drop-in replacement) to use for making requestsbackboneRequester.attach(Backbone)
Bind backboneRequester
instance to Backbone
library. This will override Backbone.sync
and replace it with our custom one.
Object
- Backbone library to bind toReturns:
Object
- Mutated Backbone
library with new .sync
backboneRequester.getSync(Backbone)
Generates custom Backbone.sync
method but returns instead of attaching.
Object
- Backbone library to grab configuration fromReturns:
Function
- Generated custom Backbone.sync
to bind as you see fitExample: Bind only to Backbone.Model
// Load in our dependencies
var Backbone = require('Backbone');
var BackboneRequester = require('backbone-requester');
var request = require('request');
// Initialize `BackboneRequester`
var requester = new BackboneRequester(request);
// Create a new model and save it via `request`
Backbone.Model.prototype.sync = requester.getSync();
Backbone.sync
Once bound via .attach
, the new Backbone.sync
will use the passed in request
library to make all requests. We try to be consistent with Backbone's API but have some one-off differences due to using request
.
request
object over jQuery deferred
.success
/.error
methods will not be accessible after the .save
/.fetch
requestbeforeSend
)error
can receive node
errors like ECONNREFUSED
dataType's
Everything else remains the same:
url
, method
, headers
, and data
as valid input as documented with jQueryemulateHTTP
and emulateJSON
are supportederror
function signature is same (model, err, options)
Object
- Current model being interacted withError
- Error from requestObject
- Options initially passed intosuccess
function signature is same (model, response, options)
Object
- Current model being interacted withObject
- Response data from requestObject
- Options initially passed intoIn lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint via npm run lint
and test via npm test
.
Copyright (c) 2015 Underdog.io
Licensed under the MIT license.
FAQs
Make server-based requests in Backbone via request
We found that backbone-requester demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.