Add endpoint to retrieve posts by tag with validation
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user