
Security News
Crates.io Users Targeted by Phishing Emails
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
rested-resources
Advanced tools
RESTed Resources is a client-side REST-based API layer for your resources. Conceptually similar to `ngResource`, it handles http requests and URL building to give you simple, consistent logic.
RESTed Resources is a client-side REST-based API layer for your resources. Conceptually similar to ngResource
, it
handles http requests and URL building to give you simple, consistent logic.
Resources automatically generate URLs based on their hierarchy. Requests are managed by superagent and results/errors are handled via Promises.
npm install rested-resources --save
yarn add rested-resources
While RESTed Resources works as a client-side library, it's built as an NPM module with the assumption you're using webpack or a related library to compile your application.
Examples below are written with some ES6, which will require babel to transpile.
Import the resource classes:
import { IdentifiedResource, ResultsResource } from 'resource';
While you can export resource classes directly, you'll likely want to use a factory to help setup relationships.
-- student.js
export default class Student extends IdentifiedResource {}
-- students.js
export default class Students extends ResultsResource {}
-- course.js:
import Student from './student';
import Students from './students';
class Course extends IdentifiedResource {}
export function(data) {
let resource = new Course(data);
resource.nest(Student);
resource.nest(Students);
return resource;
}
You now have everything needed to interact with these resources.
Querying for all students in a course:
var course = new Course({ courseId: 'history-101' });
// performs: GET /courses/history-101/students
course.students.query().then((results) => {
// results will be the resulting JSON
});
Query for a specific student's course data:
var course = new Course({ courseId: 'history-101' });
var student = new course.Student({ studentId: 1234 });
// performs: GET /courses/history-101/students/1234
student.get().then((result) => {
// result will be the resulting JSON
});
Create a new student record:
var student = new Student({ name: 'Kermit' });
// performs: POST /students
student.save().then((result) => {});
FAQs
RESTed Resources is a client-side REST-based API layer for your resources. Conceptually similar to `ngResource`, it handles http requests and URL building to give you simple, consistent logic.
We found that rested-resources 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
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Product
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.