Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

angular-resource

Package Overview
Dependencies
Maintainers
2
Versions
103
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

angular-resource - npm Package Compare versions

Comparing version 0.1.1 to 1.2.27

angular-resource.js

40

package.json
{
"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"
}

@@ -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.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc