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

method-override

Package Overview
Dependencies
Maintainers
6
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

method-override - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

History.md

17

package.json
{
"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 [![Build Status](https://travis-ci.org/expressjs/method-override.svg)](https://travis-ci.org/expressjs/method-override) [![NPM version](https://badge.fury.io/js/method-override.svg)](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

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