diff --git a/api/routes/links.ts b/api/routes/links.ts index 8683074..625ed47 100644 --- a/api/routes/links.ts +++ b/api/routes/links.ts @@ -7,6 +7,15 @@ import {ShortenedLink} from "../../models/ShortenedLink"; const app = Router(); +app.get("/:code", hasRank(Rank.TEAM_MEMBER), async (req: AuthenticatedRequest, res: Response) => { + if (!req.params.code) return res.status(400).json({message: "You need to provide the shorten id"}); + + const link = await ShortenedLink.findOne({shortenedId: req.params.code}, {_id: 0, __v: 0}); + if (link == null) return res.status(404).json({message: "The provided link does not exist"}); + + res.json(link); +}); + app.put("/", hasRank(Rank.TEAM_MEMBER), async (req: AuthenticatedRequest, res: Response) => { const validationError = validateSchema(shortUrl, req.body); if (validationError) return res.status(400).json({message: validationError});