Add req and res as controllers hooks parameters

Hooks prefixed by `action:api` now give access the original express req and res.
Checkout guide.md for possible usage.
This commit is contained in:
lutangar
2021-11-25 09:54:22 +01:00
committed by Chocobozzz
parent 5098098d96
commit 7226e90fdc
12 changed files with 41 additions and 23 deletions
+14
View File
@@ -108,6 +108,20 @@ async function register ({
}
```
Hooks prefixed by `action:api` also give access the original **express** [Request](http://expressjs.com/en/api.html#req) and [Response](http://expressjs.com/en/api.html#res):
```js
async function register ({
registerHook,
peertubeHelpers: { logger }
}) {
registerHook({
target: 'action:api.video.updated',
handler: ({ req, res }) => logger.debug('original request parameters', { params: req.params })
})
}
```
On client side, these hooks are registered by the `clientScripts` files defined in `package.json`.
All client scripts have scopes so PeerTube client only loads scripts it needs: