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.
backbone-hypermedia
Advanced tools
Backbone plugin providing support for following hypermedia controls from Backbone models and collections.
Backbone plugin providing support for following hypermedia controls from Backbone models and collections.
Assuming a resource with a links
property, something like this:
{
"name": {
"first" : "Joe",
"last": "Bloggs"
},
"links" : [
{ "rel": "country", "href": "/countries/GB" }
]
}
Define a corresponding Backbone model by extending Backbone.HypermediaModel
(instead of Backbone.Model
):
var User = Backbone.HypermediaModel.extend({
...
});
Then define a links
property for the model like this:
links: {
'country': Country,
'timezone': TimeZone
}
Each key corresponds to the rel
value of a link which may be present when the model is fetched from the server. The value defines the type of Backbone model you would like to be constructed based on that relation, so in this example Country
and TimeZone
are Backbone models (which must themselves extend Backbone.HypermediaModel
).
Backbone.HypermediaModel
overrides fetch
so that for each link found in the response, if there is a corresponding value in the links property on your model, then the related model will also be fetched and a property added to your model under the same key. The return value of fetch
is a promise which represents the collective fetch operations for the model and all related resources.
By using the promise returned from fetch
you can wait until all related resources are fetched before rendering your view:
user.fetch().then(function () {
// show user view
});
You can also add a links
property to each related resource and have those relations followed as well, if you need to.
toJSON
will include any related models which have been added to your model as properties.
The package is available via npm:
npm install backbone-hypermedia
The package is available via NuGet:
Install-Package backbone.hypermedia
FAQs
Backbone plugin providing support for following hypermedia controls from Backbone models and collections.
The npm package backbone-hypermedia receives a total of 1 weekly downloads. As such, backbone-hypermedia popularity was classified as not popular.
We found that backbone-hypermedia demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 6 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.