Add new page module and services; refactor existing entities

- Introduced a new page module with associated services.
- Refactored TypeORM entities in user and workspace modules.
This commit is contained in:
Philipinho
2023-08-22 19:48:57 +01:00
parent c0b2bc1f57
commit f11f9f6210
14 changed files with 282 additions and 52 deletions
+12 -12
View File
@@ -10,16 +10,17 @@ import {
import * as bcrypt from 'bcrypt';
import { Workspace } from '../../workspace/entities/workspace.entity';
import { WorkspaceUser } from '../../workspace/entities/workspace-user.entity';
import { Page } from '../../page/entities/page.entity';
@Entity('users')
export class User {
@PrimaryGeneratedColumn('uuid')
id: string;
@Column()
@Column({ length: 255, nullable: true })
name: string;
@Column({ unique: true })
@Column({ length: 255, unique: true })
email: string;
@Column({ nullable: true })
@@ -29,12 +30,12 @@ export class User {
password: string;
@Column({ nullable: true })
avatar_url: string;
avatarUrl: string;
@Column({ nullable: true })
@Column({ length: 100, nullable: true })
locale: string;
@Column({ nullable: true })
@Column({ length: 300, nullable: true })
timezone: string;
@Column({ type: 'jsonb', nullable: true })
@@ -43,7 +44,7 @@ export class User {
@Column({ nullable: true })
lastLoginAt: Date;
@Column({ nullable: true })
@Column({ length: 100, nullable: true })
lastLoginIp: string;
@CreateDateColumn()
@@ -52,16 +53,15 @@ export class User {
@UpdateDateColumn()
updatedAt: Date;
@OneToMany(() => Workspace, (workspace) => workspace.creator, {
createForeignKeyConstraints: false,
})
@OneToMany(() => Workspace, (workspace) => workspace.creator)
workspaces: Workspace[];
@OneToMany(() => WorkspaceUser, (workspaceUser) => workspaceUser.user, {
createForeignKeyConstraints: false,
})
@OneToMany(() => WorkspaceUser, (workspaceUser) => workspaceUser.user)
workspaceUser: WorkspaceUser[];
@OneToMany(() => Page, (page) => page.creator)
createdPages;
toJSON() {
delete this.password;
return this;