From 007282ef22b219b20ec3d4bf04e4b9f49a2e3da7 Mon Sep 17 00:00:00 2001 From: Yarmo Mackenbach Date: Sat, 1 Oct 2022 09:53:36 +0200 Subject: [PATCH] Add AP proxy endpoint --- src/proxy/api/v2/index.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/proxy/api/v2/index.js b/src/proxy/api/v2/index.js index 18f7a17..674150f 100644 --- a/src/proxy/api/v2/index.js +++ b/src/proxy/api/v2/index.js @@ -246,4 +246,26 @@ router.get( } ) +// ActivityPub route +router.get( + '/get/activitypub', + query('username').isString(), + query('domain').isFQDN(), + async (req, res) => { + const errors = validationResult(req) + if (!errors.isEmpty()) { + return res.status(400).json({ errors: errors.array() }) + } + + fetcher.activitypub + .fn(req.query, opts) + .then((data) => { + return res.status(200).send(data) + }) + .catch((err) => { + return res.status(400).json({ errors: err.message ? err.message : err }) + }) + } +) + module.exports = router