initial commit

This commit is contained in:
Ken Yasue
2025-06-01 22:21:33 +02:00
commit 5149012dcf
30 changed files with 6346 additions and 0 deletions

View File

@ -0,0 +1,59 @@
import { Column, Entity, ManyToOne, PrimaryGeneratedColumn, type Relation } from "typeorm"
import { UserEntity } from "./UserEntity"
import { transformer } from "../utils/transformers"
// import UserEntity from "./UserEntity"
// import { transformer } from "../utils/transformers"
@Entity({ name: "accounts" })
export default class AccountEntity {
@PrimaryGeneratedColumn("uuid")
id!: string
@Column({ type: "uuid" })
userId!: string
@Column()
type!: string
@Column()
provider!: string
@Column()
providerAccountId!: string
@Column({ type: "varchar", nullable: true })
refresh_token!: string | null
@Column({ type: "varchar", nullable: true })
access_token!: string | null
@Column({
nullable: true,
type: "bigint",
transformer: transformer.bigint,
})
expires_at!: number | null
@Column({ type: "varchar", nullable: true })
token_type!: string | null
@Column({ type: "varchar", nullable: true })
scope!: string | null
@Column({ type: "varchar", nullable: true })
id_token!: string | null
@Column({ type: "varchar", nullable: true })
session_state!: string | null
@Column({ type: "varchar", nullable: true })
oauth_token_secret!: string | null
@Column({ type: "varchar", nullable: true })
oauth_token!: string | null
@ManyToOne(() => UserEntity, (user) => user.accounts, {
createForeignKeyConstraints: true,
})
user!: Relation<UserEntity>
}

View File

@ -0,0 +1,22 @@
import { Column, Entity, ManyToOne, PrimaryGeneratedColumn, type Relation } from "typeorm"
import { UserEntity } from "./UserEntity"
import { transformer } from "../utils/transformers"
@Entity({ name: "sessions" })
export default class SessionEntity {
@PrimaryGeneratedColumn("uuid")
id!: string
@Column({ unique: true })
sessionToken!: string
@Column({ type: "uuid" })
userId!: string
@Column({ transformer: transformer.date })
expires!: string
@ManyToOne(() => UserEntity, (user) => user.sessions)
user!: Relation<UserEntity>
}

View File

@ -0,0 +1,9 @@
import { Column, Entity } from "typeorm"
import { UserEntity } from "./UserEntity"
import AbstractBaseEntity from "./abstract/AbstractBaseEntity"
@Entity({ name: "haha" })
export default class TestMigrationEntity extends AbstractBaseEntity{
@Column()
provider!: string
}

View File

@ -0,0 +1,33 @@
import { Column, Entity, OneToMany, PrimaryGeneratedColumn, type Relation } from "typeorm"
import SessionEntity from "./SessionEntity"
import AccountEntity from "./AccountEntity"
import { transformer } from "../utils/transformers"
import AbstractBaseEntity from "./abstract/AbstractBaseEntity"
@Entity({ name: "users" })
export class UserEntity extends AbstractBaseEntity {
@Column({ type: "varchar", nullable: true })
name!: string | null
// @Column({ type: "varchar", nullable: true })
// password!: string | null
@Column({ type: "varchar", nullable: true, unique: true })
email!: string | null
// @Column({ type: "varchar", nullable: true, transformer: transformer.date })
// emailVerified!: string | null
@Column({ type: "varchar", nullable: true })
image!: string | null
// @Column({ type: "varchar", nullable: true })
// role!: string | null
@OneToMany(() => SessionEntity, (session) => session.userId)
sessions!: Relation<SessionEntity>[]
@OneToMany(() => AccountEntity, (account) => account.userId)
accounts!: Relation<AccountEntity>[]
}

View File

@ -0,0 +1,17 @@
import { Column, Entity, PrimaryGeneratedColumn } from "typeorm"
import { transformer } from "../utils/transformers"
@Entity({ name: "verification_tokens" })
export default class VerificationTokenEntity {
@PrimaryGeneratedColumn("uuid")
id!: string
@Column()
token!: string
@Column()
identifier!: string
@Column({ transformer: transformer.date })
expires!: string
}

View File

@ -0,0 +1,6 @@
import { PrimaryGeneratedColumn } from "typeorm";
export default abstract class AbstractBaseEntity {
@PrimaryGeneratedColumn("uuid")
id!: string
}