forked from MergeFi/backend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgithub-account.entity.ts
More file actions
52 lines (41 loc) · 1.15 KB
/
Copy pathgithub-account.entity.ts
File metadata and controls
52 lines (41 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import {
Column,
CreateDateColumn,
Entity,
JoinColumn,
OneToOne,
PrimaryGeneratedColumn,
UpdateDateColumn,
} from 'typeorm';
import { User } from './user.entity';
@Entity('github_accounts')
export class GithubAccount {
@PrimaryGeneratedColumn('uuid')
id: string;
@Column({ unique: true })
githubId: string;
@Column()
login: string;
@Column({ type: 'varchar', nullable: true })
profileUrl: string | null;
@Column({ type: 'varchar', nullable: true })
avatarUrl: string | null;
/**
* OAuth access token used for GitHub API calls made on the user's behalf.
* TODO: encrypt at rest (e.g. KMS envelope encryption) before production use.
* Never returned via API responses — excluded at the DTO/serialization layer.
*/
@Column({ type: 'varchar', nullable: true, select: false })
accessToken: string | null;
@Column({ type: 'varchar', nullable: true, select: false })
refreshToken: string | null;
@OneToOne(() => User, (user) => user.githubAccount, { onDelete: 'CASCADE' })
@JoinColumn()
user: User;
@Column()
userId: string;
@CreateDateColumn()
createdAt: Date;
@UpdateDateColumn()
updatedAt: Date;
}