From 5dacd265b822fe89b308c1d10f635593f873cbac Mon Sep 17 00:00:00 2001 From: Mathias Wagner Date: Sat, 9 Jul 2022 17:37:14 +0200 Subject: [PATCH] Created a route to get an addon by id --- routes/addon.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/routes/addon.js b/routes/addon.js index 3cfe34b..1bba95a 100644 --- a/routes/addon.js +++ b/routes/addon.js @@ -12,6 +12,14 @@ const { const {isAuthenticatedUser} = require('../middlewares/authenticate'); const {removeAllReleases} = require('../controller/release'); +// Gets the addon object by id +app.get("/:addonId", async (req, res) => { + const addon = await getAddonById(req.params.addonId); + if (addon === null) return res.status(404).json({message: "The provided addon does not exist"}); + + res.json(addon); +}); + // Gets a list of all addons by an author app.get("/:authorName/list", async (req, res) => { const addons = await listAddonsByAuthorName(req.params.authorName);