# express-allow-methods

> Express middleware for sending HTTP 405 Method Not Allowed response

Latest version **0.3.1** (published 2021-06-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install express-allow-methods
pnpm add express-allow-methods
yarn add express-allow-methods
bun add express-allow-methods
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.1 |
| Published | 2021-06-14 |
| First published | 2021-04-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=0.11.8 |
| Dependencies | 1 |
| Unpacked size | 11.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Dima Parzhitsky |
| Maintainers | parzhitsky |
| Keywords | express, middleware, http, response, 405, method, not, allowed, helper, util |

## Links

- npm: https://www.npmjs.com/package/express-allow-methods
- Repository: https://github.com/parzh/express-allow-methods
- Homepage: https://github.com/parzh/express-allow-methods#readme
- Issues: https://github.com/parzh/express-allow-methods/issues
- npm.io page: https://npm.io/package/express-allow-methods

## Dependencies (1)

- [@types/express](https://npm.io/package/@types/express.md) 4.17.11

## Alternatives

- [lodash.assign](https://npm.io/package/lodash.assign.md) — 2.3M weekly downloads
- [lodash.chunk](https://npm.io/package/lodash.chunk.md) — 1.8M weekly downloads
- [react-native-ios-utilities](https://npm.io/package/react-native-ios-utilities.md) — 138.5K weekly downloads
- [@technically/lodash](https://npm.io/package/@technically/lodash.md) — 50.9K weekly downloads
- [@fluid-topics/ft-icon](https://npm.io/package/@fluid-topics/ft-icon.md) — 20.6K weekly downloads

## Recent versions

- 0.3.1 (latest) — 2021-06-14
- 0.3.0 — 2021-06-14
- 0.2.3 — 2021-06-14
- 0.2.2 — 2021-05-10
- 0.2.1 — 2021-05-10
- 0.1.0 — 2021-04-21

## README

# `express-allow-methods`

Express middleware for sending [`HTTP 405 Method Not Allowed`](https://httpstatuses.com/405) response. Due to the specification requirements, it also responds with the `Allow` header with comma-separated list of allowed methods.

<center>
	<img src="demo.gif" alt="Package demo using cUrl terminal command" />
</center>

## Prerequisites

- Node.JS v0.11.8+
- (optionally) TypeScript v3.8.2+

## Installation

```sh
npm i express-allow-methods

# can be skipped for non-TypeScript projects
npm i --save-dev typescript
```

### In a TypeScript file:

```ts
import allowMethods from "express-allow-methods";
```

### In a JavaScript (CommonJS) file:

```ts
const allowMethods = require("express-allow-methods").default;
```

## Usage

```ts
import express from "express";
import allowMethods from "express-allow-methods";

const app = express();

app.route("/")
	.all(allowMethods("GET", "POST"))
	.get((req, res) => {
		// GET /
	})
	.post((req, res) => {
		// POST /
	})
	.patch((req, res) => {
		// PATCH /
		// the code here will never run
	});
```

---
_Source: https://npm.io/package/express-allow-methods · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
