# feathers-hooks

> Before and after service method call hooks for easy authorization and processing.

Latest version **2.1.2** (published 2017-10-31) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install feathers-hooks
pnpm add feathers-hooks
yarn add feathers-hooks
bun add feathers-hooks
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 2.1.2 |
| Published | 2017-10-31 |
| First published | 2014-05-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >= 4.0 |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 60 |
| Author | David Luecke |
| Maintainers | daffl, ekryski, marshallswain |
| Keywords | feathers-plugin, feathers |

## Links

- npm: https://www.npmjs.com/package/feathers-hooks
- Repository: https://github.com/feathersjs/feathers-hooks
- Issues: https://github.com/feathersjs/feathers-hooks/issues
- npm.io page: https://npm.io/package/feathers-hooks

## Dependencies (2)

- [uberproto](https://npm.io/package/uberproto.md) ^1.2.0
- [feathers-commons](https://npm.io/package/feathers-commons.md) ^0.8.6

## Alternatives

- [@fortawesome/react-fontawesome](https://npm.io/package/@fortawesome/react-fontawesome.md) — 2.2M weekly downloads
- [roboto-fontface](https://npm.io/package/roboto-fontface.md) — 196.0K weekly downloads
- [@react-native-vector-icons/common](https://npm.io/package/@react-native-vector-icons/common.md) — 150.4K weekly downloads
- [@procore/core-icons](https://npm.io/package/@procore/core-icons.md) — 4.6K weekly downloads
- [@react-md/material-icons](https://npm.io/package/@react-md/material-icons.md) — 1.6K weekly downloads

## Recent versions

- 2.1.2 (latest) — 2017-10-31
- 2.1.1 — 2017-10-22
- 2.1.0 — 2017-09-27
- 2.0.4 — 2017-09-25
- 2.0.3 — 2017-09-25
- 2.0.2 — 2017-07-11
- 2.0.1 — 2017-04-28
- 2.0.0 — 2017-04-17
- 1.8.1 — 2017-03-02
- 1.8.0 — 2017-03-01
- 1.7.1 — 2016-12-16
- 1.7.0 — 2016-11-25
- 1.6.1 — 2016-11-02
- 1.6.0 — 2016-10-31
- 1.5.8 — 2016-09-27
- … 29 more at https://npm.io/package/feathers-hooks/versions

## README

# Feathers Hooks

> _Important:_ `feathers-hooks` is included in Feathers (`@feathersjs/feathers`) v3 and later and does not have to be loaded and configured separately anymore.

[![Greenkeeper badge](https://badges.greenkeeper.io/feathersjs/feathers-hooks.svg)](https://greenkeeper.io/)

[![Build Status](https://travis-ci.org/feathersjs/feathers-hooks.png?branch=master)](https://travis-ci.org/feathersjs/feathers-hooks)
[![Code Climate](https://codeclimate.com/github/feathersjs/feathers-hooks/badges/gpa.svg)](https://codeclimate.com/github/feathersjs/feathers-hooks)
[![Test Coverage](https://codeclimate.com/github/feathersjs/feathers-hooks/badges/coverage.svg)](https://codeclimate.com/github/feathersjs/feathers-hooks/coverage)
[![Dependency Status](https://img.shields.io/david/feathersjs/feathers-hooks.svg?style=flat-square)](https://david-dm.org/feathersjs/feathers-hooks)
[![Download Status](https://img.shields.io/npm/dm/feathers-hooks.svg?style=flat-square)](https://www.npmjs.com/package/feathers-hooks)
[![Slack Status](http://slack.feathersjs.com/badge.svg)](http://slack.feathersjs.com)

> Middleware for Feathers service methods

## Documentation

Please refer to the [Feathers hooks documentation](https://docs.feathersjs.com/api/hooks.html) for more details on:

- The philosophy behind hooks
- How you can use hooks
- How you can chain hooks using Promises
- Params that are available in hooks
- Hooks that are bundled with feathers and feathers plugins

## Quick start

`feathers-hooks` allows to register composable middleware functions when a Feathers service method executes. This makes it easy to decouple things like authorization and pre- or post processing and error handling from your service logic.

To install from [npm](https://www.npmjs.com/package/feathers-hooks), run:

```bash
$ npm install feathers-hooks --save
```

Then, to use the plugin in your Feathers app:

```javascript
const feathers = require('feathers');
const hooks = require('feathers-hooks');

const app = feathers().configure(hooks());
```

Then, you can register a hook for a service:

```javascript
// User service
const service = require('feathers-memory');

module.exports = function(){
  const app = this;

  let myHook = function(options) {
    return 
  }

  // Initialize our service
  app.use('/users', service());

  // Get our initialize service to that we can bind hooks
  const userService = app.service('/users');

  // Set up our before hook
  userService.hooks({
    before(hook){
      console.log('My custom before hook ran!');
    }
  });
}
```

## License

Copyright (c) 2016 [Feathers contributors](https://github.com/feathersjs/feathers-hooks/graphs/contributors)

Licensed under the [MIT license](LICENSE).

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