From 7226e90fdc61a3c6cad5ccab18b6707d55cf0992 Mon Sep 17 00:00:00 2001 From: lutangar Date: Wed, 24 Nov 2021 14:33:14 +0100 Subject: 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. --- support/doc/plugins/guide.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'support/doc/plugins') diff --git a/support/doc/plugins/guide.md b/support/doc/plugins/guide.md index 072c7c6ca..acf4718e4 100644 --- a/support/doc/plugins/guide.md +++ b/support/doc/plugins/guide.md @@ -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: -- cgit v1.2.3