Skip to content

Commit

Permalink
Add documentation for hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
SamyPesse committed Feb 11, 2016
1 parent 73330da commit e2dcb18
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions docs/module.md
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
```


0 comments on commit e2dcb18

Please sign in to comment.