-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: update migrations and create the services for the links
- Loading branch information
1 parent
15105d1
commit 8775fe5
Showing
4 changed files
with
28 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import Repository from '../repository'; | ||
import { BadRequestError } from '../utils/errorHandler'; | ||
|
||
import type { ILink, ILinkForCreate } from '@linx/shared'; | ||
|
||
export default class Link { | ||
static async create(link_dto: ILinkForCreate): Promise<string> { | ||
const check = await Repository.link.getByShorterName(link_dto.shorter_name); | ||
if (check) | ||
throw new BadRequestError('Exists the shorter name, please select other'); | ||
|
||
const link = await Repository.link.create(link_dto); | ||
|
||
return link; | ||
} | ||
|
||
static async getAllUserLinks(user_id: string): Promise<ILink[]> { | ||
const links = await Repository.link.getByID(user_id); | ||
return links; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
import Auth from './Auth'; | ||
import Link from './Link'; | ||
import User from './User'; | ||
|
||
export default class Services { | ||
static auth = Auth; | ||
static user = User; | ||
static link = Link; | ||
} |