Add endpoint to retrieve posts by tag with validation

This commit is contained in:
Adolfo Reyna
2025-02-27 23:45:17 -05:00
parent 56cb8b4caa
commit 46a2fc5c2b
2 changed files with 32 additions and 1 deletions

View File

@@ -95,6 +95,18 @@ DB.getDB.then((DB) => {
return res.json(posts);
});
router.get("/tag/:tag", async (req, res) => {
const profileid = getProfileId(req);
const tag = req.params.tag;
if(!tag) {
return res.json({
status: "Tag is required",
});
}
let posts = await DB.getPostsByTag(tag, profileid);
return res.json(posts);
});
router.get("/usr/:id", async (req, res) => {
const profileId = req.params.id;
const viewerProdileId = getProfileId(req);