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.
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 = ;const hooks = ; const app = ;
Then, you can register a hook for a service:
// User serviceconst service = ; module{ const app = this; let { return } // Initialize our service app; // Get our initialize service to that we can bind hooks const userService = app; // Set up our before hook userService;}
License
Copyright (c) 2016 Feathers contributors
Licensed under the MIT license.