angular-resource
Advanced tools
Comparing version 0.1.1 to 1.2.27
{ | ||
"name": "angular-resource", | ||
"description": "AngularJS $resource bindings for express.", | ||
"version": "0.1.1", | ||
"licenses": [{ | ||
"type": "MIT", | ||
"url": "https://github.com/roylines/node-angular-resource/raw/master/LICENSE" | ||
}], | ||
"author": { "name": "Roy Lines", "url": "http://roylines.co.uk" }, | ||
"version": "1.2.27", | ||
"description": "AngularJS module for interacting with RESTful server-side data sources", | ||
"main": "angular-resource.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/roylines/node-angular-resource.git" | ||
"url": "https://github.com/angular/angular.js.git" | ||
}, | ||
"keywords": ["angularjs", "express", "$resource"], | ||
"dependencies": { | ||
"keywords": [ | ||
"angular", | ||
"framework", | ||
"browser", | ||
"rest", | ||
"client-side" | ||
], | ||
"author": "Angular Core Team <angular-core+npm@google.com>", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/angular/angular.js/issues" | ||
}, | ||
"devDependencies": { | ||
"mocha": "*", | ||
"sinon": "*" | ||
}, | ||
"main": "./lib/angular-resource", | ||
"engines": { "node": ">= 0.6.0" }, | ||
"scripts": { | ||
"test": "mocha test/*-test.js" | ||
} | ||
} | ||
"homepage": "http://angularjs.org" | ||
} |
115
README.md
@@ -1,94 +0,77 @@ | ||
# node-angular-resource [![Build Status](https://travis-ci.org/roylines/node-angular-resource.png?branch=master)](https://travis-ci.org/roylines/node-angular-resource) | ||
[AngularJS](http://angularjs.org/) [$resource](http://docs.angularjs.org/api/ngResource.$resource) bindings for express in node | ||
# packaged angular-resource | ||
## Description | ||
angular-resource is a node module that simplifies the use of [angularjs](http://angularjs.org/) | ||
[$resource](http://docs.angularjs.org/api/ngResource.$resource) factory by creating the default | ||
set of resource actions for get, save, query, remove and delete. | ||
This repo is for distribution on `npm` and `bower`. The source for this module is in the | ||
[main AngularJS repo](https://github.com/angular/angular.js/tree/master/src/ngResource). | ||
Please file issues and pull requests against that repo. | ||
It is best described by example. Suppose you have an angularjs service defined as follows: | ||
## Install | ||
```javascript | ||
var myServices = angular.module('myServices', ['ngResource']) | ||
You can install this package either with `npm` or with `bower`. | ||
myServices.factory('Task', function($resource) { | ||
return $resource('api/tasks/:id', { id: "@_id" }); | ||
}); | ||
### npm | ||
```shell | ||
npm install angular-resource | ||
``` | ||
The myServices Task will, by default, now support get, save, query, remove and delete. The | ||
required endpoints can simply be routed via express by using the angular-resource module: | ||
Add a `<script>` to your `index.html`: | ||
First create a task.js with the following details: | ||
```javascript | ||
var task = { }; | ||
```html | ||
<script src="/node_modules/angular-resource/angular-resource.js"></script> | ||
``` | ||
task.get = function(req, res) { | ||
res.json({}); | ||
}; | ||
Then add `ngResource` as a dependency for your app: | ||
task.save = function(req, res) { | ||
res.send(200); | ||
}; | ||
```javascript | ||
angular.module('myApp', ['ngResource']); | ||
``` | ||
task.query = function(req, res) { | ||
res.json([]); | ||
}; | ||
Note that this package is not in CommonJS format, so doing `require('angular-resource')` will | ||
return `undefined`. | ||
task.remove = function(req, res) { | ||
res.send(200); | ||
}; | ||
### bower | ||
module.exports = task; | ||
```shell | ||
bower install angular-resource | ||
``` | ||
and then use angular-resource to bind it into express. | ||
Add a `<script>` to your `index.html`: | ||
```javascript | ||
var angularResource = require('angular-resource'), | ||
express = require('express'); | ||
var app = express(); | ||
angularResource(app, '/api/1', 'task'); | ||
app.listen(3000); | ||
```html | ||
<script src="/bower_components/angular-resource/angular-resource.js"></script> | ||
``` | ||
This will bind the required endpoints through to task.js. Note that both 'delete' and 'remove' are | ||
routed to the 'remove' method. | ||
Then add `ngResource` as a dependency for your app: | ||
If you wish to use middleware, then define the binding as follows: | ||
```javascript | ||
var middleware = function(req, res, next) { | ||
return next(req, res); | ||
}; | ||
angularResource(app, '/api/1', 'task', middleware); | ||
angular.module('myApp', ['ngResource']); | ||
``` | ||
## Documentation | ||
If you don't want to support all of the default $resource actions, then just omit them | ||
from the object. In the example above, if you don't want to support remove then just define task.js as follows: | ||
Documentation is available on the | ||
[AngularJS docs site](http://docs.angularjs.org/api/ngResource). | ||
```javascript | ||
var task = { }; | ||
## License | ||
task.get = function(req, res) { | ||
res.json({}); | ||
}; | ||
The MIT License | ||
task.save = function(req, res) { | ||
res.send(200); | ||
}; | ||
Copyright (c) 2010-2012 Google, Inc. http://angularjs.org | ||
task.query = function(req, res) { | ||
res.json([]); | ||
}; | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
module.exports = task; | ||
``` | ||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
You can now create includes for all of the $resource objects your angularjs services require and | ||
bind them in the same way. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
40255
0
598
0
1
0
78
1