Comparing version 0.2.1 to 0.3.0
11
index.js
@@ -32,5 +32,6 @@ var approot = process.env.PWD; | ||
app[method].apply(app, [joinParam(url, router.params)] | ||
app[method.toLowerCase()].apply(app, [joinParam(url, router.params)] | ||
.concat(filters) | ||
.concat([router])); | ||
.concat([router]) | ||
); | ||
} | ||
@@ -50,4 +51,8 @@ | ||
methods.forEach(function (method) { | ||
var eachRouter = router[method]; | ||
var eachRouter = router[method.toLowerCase()] || router[method.toUpperCase()]; | ||
if (eachRouter) { | ||
if (method != method.toUpperCase()) { | ||
console.log('npm rainbow: Lower case HTTP methods are deprecated. Please change ' + method + ' to upper case.'); | ||
} | ||
route(app, method, url, eachRouter); | ||
@@ -54,0 +59,0 @@ } |
{ | ||
"name": "rainbow", | ||
"description": "Express router middleware for RESTful API base on certain folder path", | ||
"version": "0.2.1", | ||
"version": "0.3.0", | ||
"author": "mytharcher <mytharcher@gmail.com>", | ||
@@ -9,3 +9,3 @@ "main" : "index.js", | ||
"glob": "3.x", | ||
"methods": "0.0.1" | ||
"methods": "1.x" | ||
}, | ||
@@ -12,0 +12,0 @@ "keywords": [ |
@@ -41,3 +41,3 @@ Rainbow | ||
```javascript | ||
exports.get = function (req, res, next) { | ||
exports.GET = function (req, res, next) { | ||
res.send(200, 'Simple getting.'); | ||
@@ -50,7 +50,7 @@ }; | ||
```javascript | ||
exports.get = function (req, res, next) { | ||
exports.GET = function (req, res, next) { | ||
res.send(200, 'Simple getting.'); | ||
}; | ||
// add filters | ||
exports.get.filters = ['authorization']; | ||
exports.GET.filters = ['authorization']; | ||
``` | ||
@@ -61,3 +61,3 @@ | ||
```javascript | ||
exports.get = function (req, res, next) { | ||
exports.GET = function (req, res, next) { | ||
User.find({where: req.query.name}).success(function (user) { | ||
@@ -68,3 +68,3 @@ res.send(200, user); | ||
exports.put = function (req, res, next) { | ||
exports.PUT = function (req, res, next) { | ||
User.create(req.body).success(function (user) { | ||
@@ -90,3 +90,3 @@ res.send(201, user.id); | ||
```coffeescript | ||
exports.get = (req, res, next) -> | ||
exports.GET = (req, res, next) -> | ||
User.find(where: req.query.name) | ||
@@ -96,3 +96,3 @@ .success (user) -> | ||
exports.put = (req, res, next) -> | ||
exports.PUT = (req, res, next) -> | ||
User.create(req.body) | ||
@@ -108,3 +108,3 @@ .success (user) -> | ||
```javascript | ||
exports.get = function (req, res, next) { | ||
exports.GET = function (req, res, next) { | ||
var id = req.params.id; | ||
@@ -114,3 +114,3 @@ // your business | ||
exports.get.params = ':id?'; | ||
exports.GET.params = ':id?'; | ||
``` | ||
@@ -121,7 +121,7 @@ | ||
```javascript | ||
exports.get = function (req, res, next) { | ||
exports.GET = function (req, res, next) { | ||
console.log(req.params); | ||
} | ||
exports.get.params = /(\d+)(?:\.\.(\d+))?/; | ||
exports.GET.params = /(\d+)(?:\.\.(\d+))?/; | ||
``` | ||
@@ -128,0 +128,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6673
51
+ Addedmethods@1.1.2(transitive)
- Removedmethods@0.0.1(transitive)
Updatedmethods@1.x