# blvd-methods

> Method combinators for HTTP handlers

Latest version **2.0.0** (published 2015-02-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install blvd-methods
pnpm add blvd-methods
yarn add blvd-methods
bun add blvd-methods
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2015-02-08 |
| First published | 2015-01-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Matt Brennan |
| Maintainers | quarterto |
| Keywords | http, router, boulevard, livewire, handler |

## Links

- npm: https://www.npmjs.com/package/blvd-methods
- Repository: https://github.com/quarterto/blvd-methods
- Issues: https://github.com/quarterto/blvd-methods/issues
- npm.io page: https://npm.io/package/blvd-methods

## Dependencies (4)

- [curry](https://npm.io/package/curry.md) ^1.2.0
- [methods](https://npm.io/package/methods.md) ^1.1.1
- [jalfrezi](https://npm.io/package/jalfrezi.md) ^2.1.0
- [camel-case](https://npm.io/package/camel-case.md) ^1.1.1

## Alternatives

- [express-promise-router](https://npm.io/package/express-promise-router.md) — 736.1K weekly downloads
- [next-usequerystate](https://npm.io/package/next-usequerystate.md) — 29.8K weekly downloads
- [@bitkyc08/opencodex](https://npm.io/package/@bitkyc08/opencodex.md) — 4.6K weekly downloads
- [lynkr](https://npm.io/package/lynkr.md) — 575 weekly downloads
- [baremetal.js](https://npm.io/package/baremetal.js.md) — 42 weekly downloads

## Recent versions

- 2.0.0 (latest) — 2015-02-08
- 1.0.0 — 2015-01-27

## README

<h1 align="center">
  blvd-methods<br>

  <a href="http://badge.fury.io/js/blvd-methods">
    <img src="https://badge.fury.io/js/blvd-methods.svg" alt="npm version">
  </a>
  <a href="https://travis-ci.org/quarterto/blvd-methods">
    <img src="https://travis-ci.org/quarterto/blvd-methods.svg" alt="Build status">
  </a>
</h1>

Combinators to wrap HTTP handlers and filter based on method.

```javascript
http.createServer(methods.put(function(req, res) {
  assert(req.method === 'put');
}));
```

Supports [every method that Node HTTP does](https://github.com/jshttp/methods).

## Custom method getting

If you're using something other than Node HTTP, and `req` isn't the first argument to the handler, or the method is somewhere other than `req.method`, you can override `getMethod` using underscored methods:

```javascript
var get = methods.get_(function getMethod() {
  return this.method; // e.g. Koa
});

get(function *(next) {
  // ...
});
```

Or override them all at once with `withGetMethod`:

```javascript
var methods = require('blvd-methods').withGetMethod(function getMethod() {
  return this.method; // e.g. Koa
});

methods.get(function *(next) {
  // ...
});
```

## Routing
`blvd-methods` is designed to work well with [Boulevard](https://github.com/quarterto/Boulevard) routers:

```javascript
route([
  ['/',  methods.get(function(req, res) { /* ... */})],
  ['/', methods.post(function(req, res) { /* ... */})],
]);
```

## Licence

MIT.

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