This repository has been archived by the owner on Apr 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
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
Showing
20 changed files
with
5,305 additions
and
492 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
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,14 @@ | ||
import { DataSource, EntitySchema } from "typeorm"; | ||
import dataSourceOptions from "./options"; | ||
import { AccountEntity, SessionEntity, UserEntity } from "../models/entities"; | ||
|
||
export const AppDataSource = new DataSource({ | ||
...dataSourceOptions, | ||
entities: [UserEntity, AccountEntity, SessionEntity, EntitySchema] | ||
}) | ||
|
||
AppDataSource.initialize() | ||
.then(() => { | ||
// here you can start to work with your database | ||
}) | ||
.catch((error) => console.log(error)) |
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,15 @@ | ||
export class Sandbox { | ||
|
||
public host: string; | ||
public port: number; | ||
public password: string; | ||
public create_time: Date; | ||
|
||
constructor(host: string, port: number, password: string, create_time: Date) { | ||
this.host = host; | ||
this.port = port; | ||
this.password = password; | ||
this.create_time = create_time; | ||
} | ||
} | ||
//# sourceMappingURL=sandbox.js.map |
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,172 @@ | ||
import { | ||
Entity, | ||
PrimaryGeneratedColumn, | ||
Column, | ||
ManyToOne, | ||
OneToMany, | ||
ValueTransformer, | ||
} from "typeorm" | ||
|
||
const transformer: Record<"date" | "bigint", ValueTransformer> = { | ||
date: { | ||
from: (date: string | null) => date && new Date(parseInt(date, 10)), | ||
to: (date?: Date) => date?.valueOf().toString(), | ||
}, | ||
bigint: { | ||
from: (bigInt: string | null) => bigInt && parseInt(bigInt, 10), | ||
to: (bigInt?: number) => bigInt?.toString(), | ||
}, | ||
} | ||
|
||
@Entity({ name: "users" }) | ||
export class UserEntity { | ||
@PrimaryGeneratedColumn("uuid") | ||
id!: string | ||
|
||
@Column({ type: "varchar", nullable: true }) | ||
name!: 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!: SessionEntity[] | ||
|
||
@OneToMany(() => AccountEntity, (account) => account.userId) | ||
accounts!: AccountEntity[] | ||
|
||
@Column({ type: "varchar", nullable: true }) | ||
db_host!: string | null | ||
|
||
@Column({ type: "int", nullable: true }) | ||
db_port!: number | null | ||
|
||
@Column({ type: "varchar", nullable: true }) | ||
db_password!: string | null | ||
|
||
@Column({ type: "varchar", nullable: true }) | ||
db_create_time!: string | ||
|
||
@Column({ type: "varchar", nullable: true, transformer: transformer.date }) | ||
created!: string | null | ||
|
||
@Column({ type: "varchar", nullable: true }) | ||
task_arn!: string | null | ||
|
||
// @OneToMany(() => DatabaseEntity, (database) => database.userId) | ||
// databases!: DatabaseEntity[] | ||
} | ||
|
||
@Entity({ name: "accounts" }) | ||
export 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!: UserEntity | ||
} | ||
|
||
@Entity({ name: "sessions" }) | ||
export 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!: UserEntity | ||
} | ||
|
||
// @Entity({ name: "databases" }) | ||
// export class DatabaseEntity { | ||
// @PrimaryGeneratedColumn("uuid") | ||
// id!: string | ||
|
||
// @Column({ type: "uuid" }) | ||
// userId!: string | ||
|
||
// @Column({ type: "varchar", nullable: true }) | ||
// host!: string | ||
|
||
// @Column({ type: "number", nullable: true }) | ||
// port!: number | ||
|
||
// @ManyToOne(() => UserEntity, (user) => user.databases) | ||
// user!: UserEntity | ||
// } | ||
|
||
@Entity({ name: "verification_tokens" }) | ||
export class VerificationTokenEntity { | ||
@PrimaryGeneratedColumn("uuid") | ||
id!: string | ||
|
||
@Column() | ||
token!: string | ||
|
||
@Column() | ||
identifier!: string | ||
|
||
@Column({ transformer: transformer.date }) | ||
expires!: string | ||
} |
Oops, something went wrong.