Integrated the new link controller into the shortener server

This commit is contained in:
Mathias Wagner 2022-09-09 15:14:51 +02:00
parent eb5e070fac
commit f1a52d3c90
Signed by: Mathias
GPG Key ID: B8DC354B0A1F5B44

View File

@ -1,5 +1,5 @@
import express, {Express, Request, Response} from 'express'; import express, {Express, Request, Response} from 'express';
import {ShortenedLink} from "../models/ShortenedLink"; import {getLinkObjectById} from "../controller/links";
const app: Express = express(); const app: Express = express();
@ -8,7 +8,7 @@ app.get("*", async (req: Request, res: Response) => {
let redirect_url = "https://sheepstar.xyz"; let redirect_url = "https://sheepstar.xyz";
// Search provided link // Search provided link
const found = await ShortenedLink.findOne({shortenedId: link}); const found = await getLinkObjectById(link);
if (found != null) { if (found != null) {
// Update redirect url // Update redirect url
redirect_url = found.originalUrl; redirect_url = found.originalUrl;