Files
kittyBE/src/entities/Link.ts
sherl 41f3b0f0f2
All checks were successful
Update changelog / changelog (push) Successful in 27s
feat: major code refactor, add login and register endpoints with swagger
2025-12-29 18:26:50 +01:00

50 lines
1.3 KiB
TypeScript

import { Entity, PrimaryGeneratedColumn, Column, ManyToOne, JoinTable } from 'typeorm'
import { User } from './User'
@Entity("links")
export class Link {
// Unique link id.
@PrimaryGeneratedColumn()
id: number;
// Experimental: subdomain which should be a part of the short url.
// For instance in the URL "abc.example.com/def", abc is the subdomain.
// "def.example.com/def" won't resolve to the URL that "abc.example.com/def" does.
// https://stackoverflow.com/a/67535817
@Column({ type: 'varchar', nullable: true })
subdomain: string | null;
// Shortened Uri.
@Column()
shortUri: string;
// URL to which the user should be redirected
@Column()
fullUrl: string;
// Unix timestamp of link creation date.
@Column('bigint')
createDate: number;
// Unix timestamp of when the link should expire.
// If null, the link will never expire unless deleted.
@Column('bigint', { nullable: true })
expiryDate: number | null;
// Aggregated amount of visits.
@Column('bigint')
visits: number;
// Link privacy:
// - true, if link is private
// - false, if link can be shown in a list of recent links publicly.
@Column()
privacy: boolean;
// User to which the shortened URL belongs.
@ManyToOne(() => User, (user) => user.links, { nullable: true })
@JoinTable()
author: User | null;
}