WIP: Get tests passing for github oauth, almost fully implement it

This commit is contained in:
2024-09-14 00:36:37 -04:00
parent b2a0cafe6e
commit 64edba3cf8
19 changed files with 690 additions and 143 deletions

View File

@@ -17,12 +17,21 @@ export class User {
@Column({ length: 100 })
@MaxLength(100)
@Required()
serviceUsername: string;
serviceIdentifier: string;
@OneToMany(() => Link, (link) => link.user)
@CollectionOf(() => Link)
links: Link[];
@Column({ length: 100, nullable: true })
username: string;
@Column("simple-json", { nullable: true })
emails: string[];
@Column({ nullable: true })
accessToken: string;
@BeforeInsert()
generateId() {
if (!this.id) {

View File

@@ -1,13 +1,14 @@
import { Property, Required, MaxLength } from "@tsed/schema";
import { Property, Required, MaxLength, Enum } from "@tsed/schema";
export class CreateLinkDto {
@Property()
@Required()
@MaxLength(100)
@Enum("github")
service: string;
@Property()
@Required()
@MaxLength(100)
serviceUsername: string;
serviceIdentifier: string;
}

View File

@@ -1,8 +1,10 @@
import { MaxLength, Property, Required } from "@tsed/schema";
import { Enum, MaxLength, Property, Required } from "@tsed/schema";
import { Column, Entity, ManyToOne, PrimaryColumn, JoinColumn, BeforeInsert } from "typeorm";
import { User } from "../User";
import { v4 as uuidv4 } from "uuid";
export type Service = "github";
@Entity()
export class Link {
@PrimaryColumn("uuid")
@@ -12,12 +14,17 @@ export class Link {
@Column({ length: 100 })
@MaxLength(100)
@Required()
@Enum("github")
service: string;
@Column({ length: 100 })
@MaxLength(100)
@Required()
serviceUsername: string;
serviceIdentifier: string;
@Column({ nullable: true })
@Required()
text: string;
@ManyToOne(() => User, (user) => user.links, { onDelete: "SET NULL", onUpdate: "CASCADE" })
@JoinColumn({ name: "userId" })