-
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.
- Loading branch information
1 parent
f779593
commit f5fa502
Showing
8 changed files
with
75 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import type { Knex } from 'knex'; | ||
|
||
export async function up(knex: Knex): Promise<void> { | ||
await knex.raw('CREATE EXTENSION IF NOT EXISTS "uuid-ossp"'); | ||
await knex.schema.createTable('redirects', (table) => { | ||
table | ||
.uuid('id') | ||
.unique() | ||
.defaultTo(knex.raw('uuid_generate_v4()')) | ||
.primary(); | ||
table.uuid('link_id').references('id').inTable('links'); | ||
table.string('ip').notNullable(); | ||
table.string('user_agent'); | ||
table.string('sec_ch_ua_platform'); | ||
table.string('accept_language'); | ||
|
||
table.timestamps(true, true); | ||
}); | ||
} | ||
|
||
export async function down(knex: Knex): Promise<void> { | ||
await knex.schema.dropTable('redirects'); | ||
} |
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,8 @@ | ||
import type { IRedirect, IRedirectForCreate } from '@linx/shared'; | ||
|
||
export default class Redirect { | ||
static async create(redirect: IRedirectForCreate) { | ||
//todo: complete with the repository | ||
return redirect; | ||
} | ||
} |
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,9 +1,11 @@ | ||
import Auth from './Auth'; | ||
import Link from './Link'; | ||
import Redirect from './Redirect'; | ||
import User from './User'; | ||
|
||
export default class Services { | ||
static auth = Auth; | ||
static user = User; | ||
static link = Link; | ||
static redirect = Redirect; | ||
} |
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,3 +1,4 @@ | ||
export * from './user'; | ||
export * from './server'; | ||
export * from './link'; | ||
export * from './redirect'; |
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,9 @@ | ||
import type { | ||
RedirectForCreateSchema, | ||
RedirectSchema, | ||
} from '../schema/redirect'; | ||
import type { z } from 'zod'; | ||
|
||
export interface IRedirect extends z.infer<typeof RedirectSchema> {} | ||
export interface IRedirectForCreate | ||
extends z.infer<typeof RedirectForCreateSchema> {} |
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,2 +1,3 @@ | ||
export * from './user'; | ||
export * from './link'; | ||
export * from './redirect'; |
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,20 @@ | ||
import { z } from 'zod'; | ||
|
||
export const RedirectSchema = z.object({ | ||
id: z.string(), | ||
link_id: z.string(), | ||
ip: z.string().ip(), | ||
user_agent: z.string().optional(), | ||
accept_language: z.string().optional(), | ||
sec_ch_ua_platform: z.string().optional(), | ||
created_at: z.coerce.date(), | ||
updated_at: z.coerce.date(), | ||
}); | ||
|
||
export const RedirectForCreateSchema = z.object({ | ||
link_id: z.string(), | ||
ip: z.string().ip(), | ||
sec_ch_ua_platform: z.string().optional(), | ||
user_agent: z.string().optional(), | ||
accept_language: z.string().optional(), | ||
}); |