gangway
Advanced tools
Comparing version 1.0.1 to 1.1.0
# Changelog | ||
## 1.1.0 | ||
- Add resource API as shorthand for RESTful resources | ||
## 1.0.1 | ||
@@ -4,0 +8,0 @@ |
@@ -10,9 +10,10 @@ var Gangway = require('../src') | ||
API.resource("users") | ||
API.route({ | ||
users: { | ||
comments: { | ||
read: { | ||
method : 'GET', | ||
path : '/users/{user_id?}' | ||
}, | ||
mock: { foo: 'bar' } | ||
method: "GET", | ||
path: "/comments" | ||
} | ||
} | ||
@@ -19,0 +20,0 @@ }) |
{ | ||
"name": "gangway", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "A client-side API abstraction layer", | ||
@@ -5,0 +5,0 @@ "main": "src/api.js", |
@@ -35,2 +35,6 @@ # Gangway | ||
// this is equivalent to creating a create, read, update, and destroy | ||
// route. Options are folded into every route. | ||
API.resource("comments", { query: {} }) | ||
// this will send a request to GET http://example.com/users | ||
@@ -37,0 +41,0 @@ API.users.read() |
var ajax = require('./ajax') | ||
var route = require('./route') | ||
var resource = require('./resource') | ||
@@ -24,2 +25,6 @@ module.exports = function (config, routes) { | ||
return route(API, routes) | ||
}, | ||
resource: function (routes, options) { | ||
return resource(API, routes, options) | ||
} | ||
@@ -26,0 +31,0 @@ |
var remap = require('./remap') | ||
var prepare = require('./prepare') | ||
module.exports = function route(API, routes) { | ||
module.exports = function route (API, routes) { | ||
return remap(routes || {}, function(resource) { | ||
// For each endpoint (create, read, update, delete...) | ||
@@ -9,0 +8,0 @@ return remap(resource, function(options) { |
Sorry, the diff of this file is not supported yet
30686
31
591
73