method-override
Advanced tools
Comparing version
{ | ||
"name": "method-override", | ||
"description": "method override", | ||
"version": "1.0.0", | ||
"description": "Override HTTP verbs", | ||
"version": "1.0.1", | ||
"author": { | ||
@@ -21,13 +21,14 @@ "name": "Jonathan Ong", | ||
"dependencies": { | ||
"methods": "*" | ||
"methods": "1.0.0" | ||
}, | ||
"devDependencies": { | ||
"mocha": "^1.17.0", | ||
"should": "^3.0.0", | ||
"supertest": "*", | ||
"connect": "*" | ||
"mocha": "~1.18.2", | ||
"supertest": "~0.12.1" | ||
}, | ||
"engines": { | ||
"node": ">= 0.8.0" | ||
}, | ||
"scripts": { | ||
"test": "make test" | ||
"test": "mocha --reporter spec" | ||
} | ||
} |
@@ -1,11 +0,45 @@ | ||
# Method Override | ||
# method-override [](https://travis-ci.org/expressjs/method-override) [](http://badge.fury.io/js/method-override) | ||
Lets you use HTTP verbs such as PUT or DELETE in places you normally can't. | ||
Previously `connect.methodOverride()`. | ||
Usage: | ||
## Install | ||
```sh | ||
$ npm install method-override | ||
``` | ||
## API | ||
**NOTE** It is very important that this module is used **before** any module that | ||
needs to know the method of the request (for example, it _must_ be used prior to | ||
the `csurf` module). | ||
### methodOverride(key) | ||
Create a new middleware function to override the `req.method` property with a new | ||
value. This value will be pulled from the `X-HTTP-Method-Override` header of the | ||
request. If this header is not present, then this module will look in the `req.body` | ||
object for a property name given by the `key` argument (and if found, will delete | ||
the property from `req.body`). | ||
If the found method is supported by node.js core, then `req.method` will be set to | ||
this value, as if it has originally been that value. The previous `req.method` | ||
value will be stored in `req.originalMethod`. | ||
#### key | ||
This is the property to look for the overwritten method in the `req.body` object. | ||
This defaults to `"_method"`. | ||
## Examples | ||
```js | ||
var app = require('connect'); | ||
app.use(require('body-parser')()); | ||
app.use(require('method-override')()) | ||
var bodyParser = require('body-parser') | ||
var connect = require('connect') | ||
var methodOverride = require('method-override') | ||
app.use(bodyParser()) | ||
app.use(methodOverride()) | ||
``` | ||
@@ -12,0 +46,0 @@ |
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Wildcard dependency
QualityPackage has a dependency with a floating version range. This can cause issues if the dependency publishes a new major version.
Found 1 instance in 1 package
4744
40.65%2
-50%0
-100%70
94.44%5
-16.67%1
Infinity%+ Added
- Removed
Updated