Migrated the links.ts controller
This commit is contained in:
parent
d6476abc92
commit
f270bd9b76
@ -1,16 +1,16 @@
|
|||||||
import {ShortenedLink} from "../models/ShortenedLink";
|
import {IShortenedLink, ShortenedLink} from "../models/ShortenedLink";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a link object from an id
|
* Gets a link object from an id
|
||||||
* @param shortenedId The link id (shortened)
|
* @param shortenedId The link id (shortened)
|
||||||
*/
|
*/
|
||||||
export const getLinkById = (shortenedId: string) => ShortenedLink.findOne({shortenedId}, {_id: 0, __v: 0});
|
export const getLinkById = (shortenedId: string) => ShortenedLink.findOne({where: {shortenedId}});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the complete link object from an id
|
* Gets the complete link object from an id
|
||||||
* @param shortenedId The link id (shortened)
|
* @param shortenedId The link id (shortened)
|
||||||
*/
|
*/
|
||||||
export const getLinkObjectById = (shortenedId: string) => ShortenedLink.findOne({shortenedId});
|
export const getLinkObjectById = (shortenedId: string) => ShortenedLink.findOne({where: {shortenedId}});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shorts a new link
|
* Shorts a new link
|
||||||
@ -18,14 +18,14 @@ export const getLinkObjectById = (shortenedId: string) => ShortenedLink.findOne(
|
|||||||
* @param shortenedId The custom id of the link (optional)
|
* @param shortenedId The custom id of the link (optional)
|
||||||
* @param clientId The client id of the user that created the link
|
* @param clientId The client id of the user that created the link
|
||||||
*/
|
*/
|
||||||
export const shortLink = (originalUrl: string, shortenedId: string | undefined, clientId: Number) =>
|
export const shortLink = (originalUrl: string, shortenedId: string | undefined, clientId: number) =>
|
||||||
ShortenedLink.create({originalUrl, shortenedId, clientId});
|
ShortenedLink.create({originalUrl, shortenedId, clientId});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lists all links created by a specific user
|
* Lists all links created by a specific user
|
||||||
* @param clientId The user to get the links from
|
* @param clientId The user to get the links from
|
||||||
*/
|
*/
|
||||||
export const listLinksByUser = (clientId: Number) => ShortenedLink.find({clientId}, {_id: 0, __v: 0});
|
export const listLinksByUser = (clientId: number) => ShortenedLink.findAll({where: {clientId}});
|
||||||
|
|
||||||
/** Lists all created links from the database */
|
/** Lists all created links from the database */
|
||||||
export const listAllLinks = () => ShortenedLink.find({}, {_id: 0, __v: 0});
|
export const listAllLinks = () => ShortenedLink.findAll({});
|
Loading…
x
Reference in New Issue
Block a user