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

@types/method-override

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/method-override

TypeScript definitions for method-override

  • 0.0.32
  • ts3.6
  • ts3.7
  • ts3.8
  • ts3.9
  • ts4.0
  • ts4.1
  • ts4.2
  • ts4.3
  • ts4.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
358K
decreased by-5.48%
Maintainers
1
Weekly downloads
 
Created

What is @types/method-override?

@types/method-override provides TypeScript definitions for the method-override middleware, which allows you to use HTTP verbs such as PUT or DELETE in places where the client doesn't support it.

What are @types/method-override's main functionalities?

Override HTTP Methods

This feature allows you to override HTTP methods using a custom header. In this example, the middleware checks for the 'X-HTTP-Method-Override' header and uses its value to override the HTTP method.

const methodOverride = require('method-override');
const express = require('express');
const app = express();

// Override with the X-HTTP-Method-Override header in the request
app.use(methodOverride('X-HTTP-Method-Override'));

app.post('/resource', (req, res) => {
  res.send('POST request to the resource');
});

app.put('/resource', (req, res) => {
  res.send('PUT request to the resource');
});

app.listen(3000, () => {
  console.log('Server is running on port 3000');
});

Override using a query value

This feature allows you to override HTTP methods using a query parameter. In this example, the middleware checks for the '_method' query parameter and uses its value to override the HTTP method.

const methodOverride = require('method-override');
const express = require('express');
const app = express();

// Override with the _method query parameter in the request
app.use(methodOverride('_method'));

app.post('/resource', (req, res) => {
  res.send('POST request to the resource');
});

app.put('/resource', (req, res) => {
  res.send('PUT request to the resource');
});

app.listen(3000, () => {
  console.log('Server is running on port 3000');
});

Other packages similar to @types/method-override

FAQs

Package last updated on 06 Jul 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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