From e2dcb1874b9dec8d85692b7bff5e27839c31582a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samy=20Pess=C3=A9?= Date: Thu, 11 Feb 2016 09:20:50 +0100 Subject: [PATCH] Add documentation for hooks --- docs/module.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/docs/module.md b/docs/module.md index f8fd3657..effcd6b6 100644 --- a/docs/module.md +++ b/docs/module.md @@ -39,3 +39,25 @@ GitHub specific configuration: - `refreshSecret`: (string) Secret for the GitHub webhook +### Hooks + +You can bind interceptors (i.e. hooks) to certain asynchronous actions using `nuts.before(fn)` and `nuts.after(fn)`: + +- `download`: When an user is downloading a version +- `api`: when an user is accessing the API + +```js +nuts.before('download', function(download, next) { + console.log('user is downloading', download.platform.filename, "for version", download.version.tag, "on channel", download.version.channel, "for", download.platform.type); + + next(); +}); + +nuts.after('download', function(download, next) { + console.log('user downloaded', download.platform.filename, "for version", download.version.tag, "on channel", download.version.channel, "for", download.platform.type); + + next(); +}); +``` + +