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

express-resource

Package Overview
Dependencies
Maintainers
0
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-resource - npm Package Compare versions

Comparing version 0.0.2 to 0.1.0

5

History.md
0.1.0 / 2011-03-27
==================
* Added support for top-level resources [Daniel Gasienica]
0.0.2 / 2011-03-03

@@ -3,0 +8,0 @@ ==================

27

index.js
/*!
* Express - Resource
* Copyright(c) 2010 TJ Holowaychuk <tj@vision-media.ca>
* Copyright(c) 2010-2011 TJ Holowaychuk <tj@vision-media.ca>
* Copyright(c) 2011 Daniel Gasienica <daniel@gasienica.ch>
* MIT Licensed

@@ -12,6 +13,3 @@ */

var express = require('express')
, Server = express.HTTPServer
? express.HTTPServer
: express.Server;
var express = require('express');

@@ -48,3 +46,4 @@ /**

, id = this.id
, name = '/' + this.name;
, name = '/' + (this.name || '')
, path = this.name ? name + '/' : '/';

@@ -56,3 +55,3 @@ switch (key) {

case 'new':
app.get(name + '/new', fn);
app.get(path + 'new', fn);
break;

@@ -63,12 +62,12 @@ case 'create':

case 'show':
app.get(name + '/:' + id, fn);
app.get(path + ':' + id, fn);
break;
case 'edit':
app.get(name + '/:' + id + '/edit', fn);
app.get(path + ':' + id + '/edit', fn);
break;
case 'update':
app.put(name + '/:' + id, fn);
app.put(path + ':' + id, fn);
break;
case 'destroy':
app.del(name + '/:' + id, fn);
app.del(path + ':' + id, fn);
break;

@@ -81,3 +80,3 @@ }

*
* @param {String} name
* @param {String|Object} name or actions
* @param {Object} actions

@@ -88,3 +87,5 @@ * @return {Resource}

Server.prototype.resource = function(name, actions){
express.HTTPServer.prototype.resource =
express.HTTPSServer.prototype.resource = function(name, actions){
if ('object' == typeof name) actions = name, name = null;
this.resources = this.resources || {};

@@ -91,0 +92,0 @@ var res = this.resources[name] = new Resource(name, actions, this);

{ "name": "express-resource"
, "description": "Resourceful routing for express"
, "version": "0.0.2"
, "version": "0.1.0"
, "author": "TJ Holowaychuk <tj@vision-media.ca>"
, "contributors": [
{ "name": "Daniel Gasienica", "email": "daniel@gasienica.ch" }
]
, "keywords": ["express", "rest", "resource"]

@@ -6,0 +9,0 @@ , "main": "index"

# Express Resource
express-resource provides resourceful routing to express.

@@ -47,3 +47,3 @@

exports.id = 'uid';
exports.destroy = function(req, res) {

@@ -58,3 +58,3 @@ res.send('destroy user ' + req.params.uid);

, app = express.createServer();
app.resource('forums', require('./forum'));

@@ -72,2 +72,22 @@

Specify a top-level resource using the empty string:
var express = require('express')
, Resource = require('express-resource')
, app = express.createServer();
app.resource(require('./forum'));
Top-level actions are then mapped as follows (by default):
GET / -> index
GET /new -> new
POST / -> create
GET /:id -> show
GET /:id/edit -> edit
PUT /:id -> update
DELETE /:id -> destroy
__NOTE:__ this functionality will surely grow with time, and as data store clients evolve we can provide close integration.

@@ -85,25 +105,26 @@

## License
## License
(The MIT License)
The MIT License
Copyright (c) 2010 TJ Holowaychuk &lt;tj@vision-media.ca&gt;
Copyright (c) 2010-2011 TJ Holowaychuk <tj@vision-media.ca>
Copyright (c) 2011 Daniel Gasienica <daniel@gasienica.ch>
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:
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:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
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.
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