
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
An all-in-one angularjs factory that wraps multiple backends.
AngularJS is great and there are tons of amazing backends like pouch, firebase, etc... Unfortunately, some of your backend's structure ultimately leaks into your angular controllers. This means that your controllers are then tightly coupled with your backend, which makes it difficult to switch your backend without modifying your controllers.
With factoryng, you can feel free to develop your controllers with little regard to your backend. If you choose to switch backends, include a new backend or use multiple backends you don't have to worry about rewriting your controllers. Sure, your current backend works great for you now, but will it still be your top choice in 6 months?
And, the Contacts Demo Source Code
Download via bower
bower install factoryng
Download via npm
npm install factoryng
Include the scripts
You must include factoryng.js, any adapters that you are using and any underlying adapter technologies, e.g.
<script src="bower_components/factoryng/dist/factoryng.min.js"></script>
<script src="//cdn.jsdelivr.net/pouchdb/3.0.5/pouchdb.min.js"></script>
<script src="bower_components/factoryng/dist/adapters/pouchyng.min.js"></script>
<script src="//cdn.firebase.com/js/client/1.0.21/firebase.js"></script>
<script src="bower_components/factoryng/dist/adapters/firyng.min.js"></script>
Let Adapter be the adapter, e.g. Pouchyng, DeltaPouchyng, Firying, etc...
Instantiate
var adapter = new Adapter(name[, url, sortBy]);
e.g.
var adapter = new Adapter('todos', 'http://127.0.0.1:5984', yngutils.ASC);
or:
var adapter = new Adapter('todos', 'http://127.0.0.1:5984', function (a, b) {
return a.someAttr - b.someAttr;
});
Bind
adapter.bind(scope);
e.g.
// Bind to $scope and load all docs
adapter.bind($scope).then(function () {
console.log('done binding');
console.log($scope.todos);
// $scope.todos[0] = adapter.at(0)
// $scope.todos[0].$id = the unique id of the doc
// $scope.todos[0].$priority = the priority/order of the doc
});
Create Doc
adapter.create(doc);
e.g.
adapter.create(doc).then(function(createdDoc) {
console.log('done creating doc');
// createdDoc.$id = the unique id of the new doc
});
Update Doc
adapter.update(doc);
e.g.
adapter.update(doc).then(function (updatedDoc) {
console.log('done updating doc');
// updatedDoc.$id = the unique id of the updated doc
});
Prioritize/Order Doc
adapter.setPriority(docOrId, priority);
e.g.
adapter.setPriority('123', 4).then(function (updatedDoc) {
console.log('done setting priority');
// updatedDoc.$id = the unique id of the updated doc
// adapter.get('123').$priority = 4
});
Remove Doc
adapter.remove(docOrId);
e.g.
adapter.remove(docOrId).then(function (deletedDoc) {
console.log('done removing');
// deletedDoc.$id = the unique id of the updated doc
});
For Each
adapter.forEach(callback[, thisArg]);
e.g.
adapter.forEach(function (element, index, array) {
console.log('a[' + index + '] = ' + element);
});
At
adapter.at(index);
e.g.
adapter.at(0); // first doc
adapter.at(1); // second doc
Get
adapter.get(id);
e.g.
adapter.get('123'); // get doc with $id = '123'
A few adapters have already been written. Is yours missing? Can you help us write it?
FAQs
An all-in-one angularjs factory that wraps multiple backends
We found that factoryng 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
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.