2.1.2 • Published 6 years ago

feathers-hooks v2.1.2

Weekly downloads
3,454
License
MIT
Repository
github
Last release
6 years ago

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

Build Status Code Climate Test Coverage Dependency Status Download Status Slack Status

Middleware for Feathers service methods

Documentation

Please refer to the Feathers hooks documentation 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, run:

$ npm install feathers-hooks --save

Then, to use the plugin in your Feathers app:

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

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

Then, you can register a hook for a service:

// 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

Licensed under the MIT license.

2.1.2

6 years ago

2.1.1

6 years ago

2.1.0

7 years ago

2.0.4

7 years ago

2.0.3

7 years ago

2.0.2

7 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.8.1

7 years ago

1.8.0

7 years ago

1.7.1

7 years ago

1.7.0

7 years ago

1.6.1

7 years ago

1.6.0

7 years ago

1.5.8

8 years ago

1.5.7

8 years ago

1.5.6

8 years ago

1.5.5

8 years ago

1.5.4

8 years ago

1.5.3

8 years ago

1.5.2

8 years ago

1.5.1

8 years ago

1.5.0

8 years ago

1.4.0

8 years ago

1.3.0

8 years ago

1.2.0

8 years ago

1.1.2

8 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.0

8 years ago

1.0.0-pre.4

8 years ago

1.0.0-pre.3

8 years ago

1.0.0-pre.2

8 years ago

1.0.0-pre.1

8 years ago

0.6.0

8 years ago

0.5.1

8 years ago

0.5.0

9 years ago

0.4.0

10 years ago

0.3.2

10 years ago

0.3.1

10 years ago

0.3.0

10 years ago

0.2.0

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago