npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

angular-model-factory

v1.0.3

Published

modelFactory makes working with RESTful APIs in AngularJS easy

Downloads

13

Readme

modelFactory

Build Status npm version semantic-release Bower version Codacy Badge Join the chat at https://gitter.im/Swimlane/angular-model-factory

A light-weight model layer that bridges the gap between AngularJS and your RESTful APIs.

Why would you use this over other available solutions?

  • Lightweight/Simple, the code simply does some basic copy/extending and prototypical instances; no magic required.
  • Patterns/Practices, the model definition closely resembles Angular's ngResource meaning its easy to swap out, replace later, eases scaling/transition, and its designed for Angular; not a backbone port!
  • Utilizes Angular at the core, it doesn't duplicate things Angular already does. Any action can be passed a $http configuration option, all your interceptors still work, it uses Angular's cache, etc!
  • Compliant, URI Template matches the specs.
  • Small - 1.45KB gzipped/minified ( excludes depedencies )
  • Minimal Dependencies, only use URI template and deep-diff ( this isn't even required ) utility. NO underscore, lodash, jquery, etc!
  • Its full of awesome features

See wiki for documentation.

Features

  • URI Templates (RFC6570)
  • Model instances
  • Collections
  • Single Datastore
  • Caching / Cache invalidation
  • Default value population
  • Pending / Completed Status
  • Relationships
  • Object Deep Diff / Reversion
  • Track active promises to prevent duplicate sends

Other Solutions

After doing quite a bit of research before writing this, I took a look at other solutions. Here is what I found and why I wrote my own.

  • Restmod Very nice solution but very opinionated and hyper-active. 22kb min

  • Modelizer Good but requires Lodash. 23kb min

  • ModelCore Good but not very well tested and not active.

  • angular-watch-resource - Really only handles collections

  • angular-restful - Very basic but nice

  • ngResource Out of the box model layer, very limited.

  • angularjs-rails-resource Too rails-ish.

  • angular-nested-resource - Okay API, not loving the nested architecture.

  • Aar.js Very light, not sure what value this adds.

  • Angular Activerecord A copy of BackboneModel but doesn't really work with Angular patterns.

  • Angular-Data Not really a model layer but a data store. Very very heavy ( 67kb min )

  • ngActiveResource Very ruby-ish api. Requires lodash. Has validation but thats not needed in angular if you do it right.

  • restangular I don't consider this a model layer; it feels moore like a fancy http layer that returns promises because everyone complains about ngResource not doing it. It requires underscore.

  • BreezeJS This is a very full featured model/cache/validation etc. Its framework agnostic, which means it follows its own patterns and not angulars. Its very heavy, requires server data massaging, and the API looks like Microsoft Entity Framework.

  • ng-backbone Another backbone model clone. This one actually requires backbone and lodash.

Install

Install via bower:

$ bower install angular-model-factory --save

Install via npm:

$ npm install angular-model-factory --save

Alternatively you can download/clone the repo and link the files in dist/.

Dependencies

Contribute

Libraries like this live and get better with an active community. Have something to contribute? We'd love to see it. Just head over to our contribution guidelines.

Credits

angular-model-factory is a Swimlane open-source project; we believe in giving back to the open-source community by sharing some of the projects we build for our application. Swimlane is an automated cyber security operations and incident response platform that enables cyber security teams to leverage threat intelligence, speed up incident response and automate security operations.