-
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.
* migrate: to v2 * refactor query filter * fix title of default value empty string * fix ordering column
- Loading branch information
1 parent
09d45d4
commit 92f526b
Showing
17 changed files
with
207 additions
and
83 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
import { ModelStatic, Sequelize } from 'sequelize' | ||
import { ModelStatic, Op, Sequelize } from 'sequelize' | ||
|
||
export type Model = ModelStatic<any> | ||
|
||
export type Schema = { | ||
short_link: Model | ||
// Add other models if needed | ||
Op: typeof Op | ||
} | ||
|
||
export type Connection = Sequelize |
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
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,13 @@ | ||
import Joi from 'joi' | ||
|
||
export const uriWithSpaces = ( | ||
value: string, | ||
helpers: Joi.CustomHelpers<string> | ||
) => { | ||
try { | ||
new URL(value) | ||
return value | ||
} catch (error) { | ||
return helpers.error('string.uri') | ||
} | ||
} |
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
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 |
---|---|---|
@@ -1,5 +1,7 @@ | ||
export interface RequestBody { | ||
export type RequestBody = { | ||
url: string | ||
short_link: string | ||
short_code: string | ||
expired: Date | ||
is_active: boolean | ||
title: string | ||
} |
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,8 +1,11 @@ | ||
import Joi from 'joi' | ||
import { RegexPath } from '../../../helpers/regex' | ||
import { uriWithSpaces } from '../../../helpers/joi' | ||
|
||
export const RequestSchema = Joi.object({ | ||
short_link: Joi.string().regex(RegexPath).optional(), | ||
url: Joi.string().uri().required(), | ||
short_code: Joi.string().min(6).max(255).regex(RegexPath).optional(), | ||
url: Joi.string().custom(uriWithSpaces).required(), | ||
expired: Joi.date().min(new Date()).optional(), | ||
is_active: Joi.boolean().optional(), | ||
title: Joi.string().alphanum().max(255).optional(), | ||
}) |
Oops, something went wrong.