Skip to content

Commit e2dcb18

Browse files
committed
Add documentation for hooks
1 parent 73330da commit e2dcb18

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

docs/module.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,25 @@ GitHub specific configuration:
3939

4040
- `refreshSecret`: (string) Secret for the GitHub webhook
4141

42+
### Hooks
43+
44+
You can bind interceptors (i.e. hooks) to certain asynchronous actions using `nuts.before(fn)` and `nuts.after(fn)`:
45+
46+
- `download`: When an user is downloading a version
47+
- `api`: when an user is accessing the API
48+
49+
```js
50+
nuts.before('download', function(download, next) {
51+
console.log('user is downloading', download.platform.filename, "for version", download.version.tag, "on channel", download.version.channel, "for", download.platform.type);
52+
53+
next();
54+
});
55+
56+
nuts.after('download', function(download, next) {
57+
console.log('user downloaded', download.platform.filename, "for version", download.version.tag, "on channel", download.version.channel, "for", download.platform.type);
58+
59+
next();
60+
});
61+
```
62+
63+

0 commit comments

Comments
 (0)