first commit

This commit is contained in:
Mateusz Gruszczyński
2026-04-05 13:40:27 +02:00
commit 9a6e77a5fc
89 changed files with 18276 additions and 0 deletions

47
api/src/entities/User.ts Normal file
View File

@@ -0,0 +1,47 @@
import { Column, CreateDateColumn, Entity, OneToMany, PrimaryGeneratedColumn } from 'typeorm';
import { Category } from './Category.js';
import { Expense } from './Expense.js';
export type UserRole = 'ADMIN' | 'USER';
@Entity('users')
export class User {
@PrimaryGeneratedColumn('uuid')
id!: string;
@Column({ type: 'varchar', length: 120 })
fullName!: string;
@Column({ type: 'varchar', unique: true, length: 160 })
email!: string;
@Column({ type: 'varchar', length: 255 })
passwordHash!: string;
@Column({ type: 'varchar', length: 20, default: 'USER' })
role!: UserRole;
@Column({ type: 'boolean', default: true })
isActive!: boolean;
@Column({ type: 'varchar', length: 8, default: 'PLN' })
defaultCurrency!: string;
@Column({ type: 'simple-json', nullable: true })
reportPreferences!: {
enabled?: boolean;
frequency?: 'monthly' | 'yearly' | 'threshold';
thresholdAmount?: number;
sendToEmail?: string | null;
categoryIds?: string[];
} | null;
@CreateDateColumn({ type: 'datetime' })
createdAt!: Date;
@OneToMany(() => Category, (category) => category.user)
categories!: Category[];
@OneToMany(() => Expense, (expense) => expense.user)
expenses!: Expense[];
}