website refactor
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import type { Logger } from '@core/shared/application';
|
||||
import type { Logger } from '@core/shared/domain';
|
||||
import type { UserAchievement } from '@core/identity';
|
||||
import { InMemoryAchievementRepository } from './InMemoryAchievementRepository';
|
||||
|
||||
|
||||
@@ -6,11 +6,11 @@
|
||||
|
||||
import { Achievement, AchievementCategory, IAchievementRepository, UserAchievement } from "@core/identity";
|
||||
import { ADMIN_ACHIEVEMENTS, COMMUNITY_ACHIEVEMENTS, DRIVER_ACHIEVEMENTS, STEWARD_ACHIEVEMENTS } from "@core/identity/domain/AchievementConstants";
|
||||
import { Logger } from "@core/shared/application";
|
||||
import { Logger } from "@core/shared/domain";
|
||||
|
||||
|
||||
|
||||
export class InMemoryAchievementRepository implements IAchievementRepository {
|
||||
export class InMemoryAchievementRepository implements AchievementRepository {
|
||||
private achievements: Map<string, Achievement> = new Map();
|
||||
private userAchievements: Map<string, UserAchievement> = new Map();
|
||||
private readonly logger: Logger;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import type { Logger } from '@core/shared/application';
|
||||
import type { Logger } from '@core/shared/domain';
|
||||
import { UserId } from '@core/identity';
|
||||
import { User } from '@core/identity/domain/entities/User';
|
||||
import { InMemoryUserRepository } from './InMemoryUserRepository';
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { User } from '@core/identity/domain/entities/User';
|
||||
import { IAuthRepository } from '@core/identity/domain/repositories/IAuthRepository';
|
||||
import { IUserRepository, StoredUser } from '@core/identity/domain/repositories/IUserRepository';
|
||||
import { IPasswordHashingService } from '@core/identity/domain/services/PasswordHashingService';
|
||||
import { AuthRepository } from '@core/identity/domain/repositories/AuthRepository';
|
||||
import { UserRepository, StoredUser } from '@core/identity/domain/repositories/UserRepository';
|
||||
import { PasswordHashingService } from '@core/identity/domain/services/PasswordHashingService';
|
||||
|
||||
import { EmailAddress } from '@core/identity/domain/value-objects/EmailAddress';
|
||||
import { Logger } from '@core/shared/application';
|
||||
import { Logger } from '@core/shared/domain';
|
||||
|
||||
export class InMemoryAuthRepository implements IAuthRepository {
|
||||
export class InMemoryAuthRepository implements AuthRepository {
|
||||
constructor(
|
||||
private readonly userRepository: IUserRepository,
|
||||
private readonly passwordHashingService: IPasswordHashingService,
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { Company } from '@core/identity/domain/entities/Company';
|
||||
import { ICompanyRepository } from '@core/identity/domain/repositories/ICompanyRepository';
|
||||
import { CompanyRepository } from '@core/identity/domain/repositories/CompanyRepository';
|
||||
|
||||
/**
|
||||
* In-memory implementation of ICompanyRepository for testing
|
||||
*/
|
||||
export class InMemoryCompanyRepository implements ICompanyRepository {
|
||||
export class InMemoryCompanyRepository implements CompanyRepository {
|
||||
private companies: Map<string, Company> = new Map();
|
||||
|
||||
create(company: Pick<Company, 'getName' | 'getOwnerUserId' | 'getContactEmail'>): Company {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { IExternalGameRatingRepository, PaginatedQueryOptions, PaginatedResult } from '@core/identity/domain/repositories/IExternalGameRatingRepository';
|
||||
import { ExternalGameRatingRepository, PaginatedQueryOptions, PaginatedResult } from '@core/identity/domain/repositories/ExternalGameRatingRepository';
|
||||
import { ExternalGameRatingProfile } from '@core/identity/domain/entities/ExternalGameRatingProfile';
|
||||
|
||||
/**
|
||||
@@ -6,7 +6,7 @@ import { ExternalGameRatingProfile } from '@core/identity/domain/entities/Extern
|
||||
*
|
||||
* For testing and development purposes.
|
||||
*/
|
||||
export class InMemoryExternalGameRatingRepository implements IExternalGameRatingRepository {
|
||||
export class InMemoryExternalGameRatingRepository implements ExternalGameRatingRepository {
|
||||
private profiles: Map<string, ExternalGameRatingProfile> = new Map();
|
||||
|
||||
private getKey(userId: string, gameKey: string): string {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { IMagicLinkRepository, PasswordResetRequest } from '@core/identity/domain/repositories/IMagicLinkRepository';
|
||||
import { Result } from '@core/shared/application/Result';
|
||||
import { Logger } from '@core/shared/application';
|
||||
import { MagicLinkRepository, PasswordResetRequest } from '@core/identity/domain/repositories/MagicLinkRepository';
|
||||
import { Result } from '@core/shared/domain/Result';
|
||||
import { Logger } from '@core/shared/domain';
|
||||
|
||||
export class InMemoryMagicLinkRepository implements IMagicLinkRepository {
|
||||
export class InMemoryMagicLinkRepository implements MagicLinkRepository {
|
||||
private resetRequests: Map<string, PasswordResetRequest> = new Map();
|
||||
private rateLimitStore: Map<string, { count: number; lastRequest: Date }> = new Map();
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import type { Logger } from '@core/shared/application';
|
||||
import type { Logger } from '@core/shared/domain';
|
||||
import { UserId, type SponsorAccount } from '@core/identity';
|
||||
import { InMemorySponsorAccountRepository } from './InMemorySponsorAccountRepository';
|
||||
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
* In-memory implementation of ISponsorAccountRepository for development/testing.
|
||||
*/
|
||||
|
||||
import { ISponsorAccountRepository, SponsorAccount, UserId } from '@core/identity';
|
||||
import { Logger } from '@core/shared/application';
|
||||
import { SponsorAccountRepository, SponsorAccount, UserId } from '@core/identity';
|
||||
import { Logger } from '@core/shared/domain';
|
||||
|
||||
export class InMemorySponsorAccountRepository implements ISponsorAccountRepository {
|
||||
export class InMemorySponsorAccountRepository implements SponsorAccountRepository {
|
||||
private accounts: Map<string, SponsorAccount> = new Map();
|
||||
private readonly logger: Logger;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import type { Logger } from '@core/shared/application';
|
||||
import type { Logger } from '@core/shared/domain';
|
||||
import type { UserRating } from '@core/identity';
|
||||
import { InMemoryUserRatingRepository } from './InMemoryUserRatingRepository';
|
||||
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
* In-memory implementation of IUserRatingRepository
|
||||
*/
|
||||
|
||||
import { IUserRatingRepository, UserRating } from '@core/identity';
|
||||
import { Logger } from '@core/shared/application';
|
||||
import { UserRatingRepository, UserRating } from '@core/identity';
|
||||
import { Logger } from '@core/shared/domain';
|
||||
|
||||
export class InMemoryUserRatingRepository implements IUserRatingRepository {
|
||||
export class InMemoryUserRatingRepository implements UserRatingRepository {
|
||||
private ratings: Map<string, UserRating> = new Map();
|
||||
private readonly logger: Logger;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import type { Logger } from '@core/shared/application';
|
||||
import type { StoredUser } from '@core/identity/domain/repositories/IUserRepository';
|
||||
import type { Logger } from '@core/shared/domain';
|
||||
import type { StoredUser } from '@core/identity/domain/repositories/UserRepository';
|
||||
import { InMemoryUserRepository } from './InMemoryUserRepository';
|
||||
|
||||
describe('InMemoryUserRepository', () => {
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
* Stores users in memory for demo/development purposes.
|
||||
*/
|
||||
|
||||
import { Logger } from '@core/shared/application';
|
||||
import type { IUserRepository, StoredUser } from '@core/identity/domain/repositories/IUserRepository';
|
||||
import { Logger } from '@core/shared/domain';
|
||||
import type { UserRepository, StoredUser } from '@core/identity/domain/repositories/UserRepository';
|
||||
|
||||
export class InMemoryUserRepository implements IUserRepository {
|
||||
export class InMemoryUserRepository implements UserRepository {
|
||||
private users: Map<string, StoredUser> = new Map();
|
||||
private emailIndex: Map<string, string> = new Map(); // email -> userId
|
||||
private readonly logger: Logger;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { User } from '@core/identity/domain/entities/User';
|
||||
import type { StoredUser } from '@core/identity/domain/repositories/IUserRepository';
|
||||
import type { StoredUser } from '@core/identity/domain/repositories/UserRepository';
|
||||
import { PasswordHash } from '@core/identity/domain/value-objects/PasswordHash';
|
||||
|
||||
import { UserOrmEntity } from '../entities/UserOrmEntity';
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import type { DataSource } from 'typeorm';
|
||||
|
||||
import { User } from '@core/identity/domain/entities/User';
|
||||
import type { IAuthRepository } from '@core/identity/domain/repositories/IAuthRepository';
|
||||
import type { AuthRepository } from '@core/identity/domain/repositories/AuthRepository';
|
||||
import type { EmailAddress } from '@core/identity/domain/value-objects/EmailAddress';
|
||||
|
||||
import { UserOrmEntity } from '../entities/UserOrmEntity';
|
||||
import { UserOrmMapper } from '../mappers/UserOrmMapper';
|
||||
|
||||
export class TypeOrmAuthRepository implements IAuthRepository {
|
||||
export class TypeOrmAuthRepository implements AuthRepository {
|
||||
constructor(
|
||||
private readonly dataSource: DataSource,
|
||||
private readonly mapper: UserOrmMapper,
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import type { DataSource } from 'typeorm';
|
||||
|
||||
import { Company } from '@core/identity/domain/entities/Company';
|
||||
import type { ICompanyRepository } from '@core/identity/domain/repositories/ICompanyRepository';
|
||||
import type { CompanyRepository } from '@core/identity/domain/repositories/CompanyRepository';
|
||||
|
||||
import { CompanyOrmEntity } from '../entities/CompanyOrmEntity';
|
||||
import { CompanyOrmMapper } from '../mappers/CompanyOrmMapper';
|
||||
|
||||
export class TypeOrmCompanyRepository implements ICompanyRepository {
|
||||
export class TypeOrmCompanyRepository implements CompanyRepository {
|
||||
constructor(
|
||||
private readonly dataSource: DataSource,
|
||||
private readonly mapper: CompanyOrmMapper,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Repository } from 'typeorm';
|
||||
import { IExternalGameRatingRepository, PaginatedQueryOptions, PaginatedResult } from '@core/identity/domain/repositories/IExternalGameRatingRepository';
|
||||
import { ExternalGameRatingRepository, PaginatedQueryOptions, PaginatedResult } from '@core/identity/domain/repositories/ExternalGameRatingRepository';
|
||||
import { ExternalGameRatingProfile } from '@core/identity/domain/entities/ExternalGameRatingProfile';
|
||||
import { ExternalGameRatingProfileOrmEntity } from '../entities/ExternalGameRatingProfileOrmEntity';
|
||||
import { ExternalGameRatingProfileOrmMapper } from '../mappers/ExternalGameRatingProfileOrmMapper';
|
||||
@@ -10,7 +10,7 @@ import { ExternalGameRatingProfileOrmMapper } from '../mappers/ExternalGameRatin
|
||||
* Repository for external game rating profiles using TypeORM.
|
||||
* Implements store/display operations only, no compute.
|
||||
*/
|
||||
export class TypeOrmExternalGameRatingRepository implements IExternalGameRatingRepository {
|
||||
export class TypeOrmExternalGameRatingRepository implements ExternalGameRatingRepository {
|
||||
constructor(
|
||||
private readonly repository: Repository<ExternalGameRatingProfileOrmEntity>
|
||||
) {}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import type { DataSource } from 'typeorm';
|
||||
import { IMagicLinkRepository, PasswordResetRequest } from '@core/identity/domain/repositories/IMagicLinkRepository';
|
||||
import { Result } from '@core/shared/application/Result';
|
||||
import { Logger } from '@core/shared/application';
|
||||
import { MagicLinkRepository, PasswordResetRequest } from '@core/identity/domain/repositories/MagicLinkRepository';
|
||||
import { Result } from '@core/shared/domain/Result';
|
||||
import { Logger } from '@core/shared/domain';
|
||||
import { PasswordResetRequestOrmEntity } from '../entities/PasswordResetRequestOrmEntity';
|
||||
|
||||
export class TypeOrmMagicLinkRepository implements IMagicLinkRepository {
|
||||
export class TypeOrmMagicLinkRepository implements MagicLinkRepository {
|
||||
// Rate limit: max 3 requests per 15 minutes
|
||||
private readonly RATE_LIMIT_MAX = 3;
|
||||
private readonly RATE_LIMIT_WINDOW = 15 * 60 * 1000; // 15 minutes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { DataSource } from 'typeorm';
|
||||
|
||||
import type { IRatingEventRepository, FindByUserIdOptions, PaginatedQueryOptions, PaginatedResult } from '@core/identity/domain/repositories/IRatingEventRepository';
|
||||
import type { RatingEventRepository, FindByUserIdOptions, PaginatedQueryOptions, PaginatedResult } from '@core/identity/domain/repositories/RatingEventRepository';
|
||||
import type { RatingEvent } from '@core/identity/domain/entities/RatingEvent';
|
||||
import type { RatingEventId } from '@core/identity/domain/value-objects/RatingEventId';
|
||||
|
||||
@@ -13,7 +13,7 @@ import { RatingEventOrmMapper } from '../mappers/RatingEventOrmMapper';
|
||||
* Persists rating events in the ledger with efficient querying by userId
|
||||
* and ordering for snapshot computation.
|
||||
*/
|
||||
export class TypeOrmRatingEventRepository implements IRatingEventRepository {
|
||||
export class TypeOrmRatingEventRepository implements RatingEventRepository {
|
||||
constructor(private readonly dataSource: DataSource) {}
|
||||
|
||||
async save(event: RatingEvent): Promise<RatingEvent> {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { DataSource } from 'typeorm';
|
||||
|
||||
import type { IUserRatingRepository } from '@core/identity/domain/repositories/IUserRatingRepository';
|
||||
import type { UserRatingRepository } from '@core/identity/domain/repositories/UserRatingRepository';
|
||||
import type { UserRating } from '@core/identity/domain/value-objects/UserRating';
|
||||
|
||||
import { UserRatingOrmEntity } from '../entities/UserRatingOrmEntity';
|
||||
@@ -11,7 +11,7 @@ import { UserRatingOrmMapper } from '../mappers/UserRatingOrmMapper';
|
||||
*
|
||||
* Persists and retrieves UserRating snapshots for fast reads.
|
||||
*/
|
||||
export class TypeOrmUserRatingRepository implements IUserRatingRepository {
|
||||
export class TypeOrmUserRatingRepository implements UserRatingRepository {
|
||||
constructor(private readonly dataSource: DataSource) {}
|
||||
|
||||
async findByUserId(userId: string): Promise<UserRating | null> {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import type { DataSource } from 'typeorm';
|
||||
|
||||
import type { IUserRepository, StoredUser } from '@core/identity/domain/repositories/IUserRepository';
|
||||
import type { UserRepository, StoredUser } from '@core/identity/domain/repositories/UserRepository';
|
||||
|
||||
import { UserOrmEntity } from '../entities/UserOrmEntity';
|
||||
import { UserOrmMapper } from '../mappers/UserOrmMapper';
|
||||
|
||||
export class TypeOrmUserRepository implements IUserRepository {
|
||||
export class TypeOrmUserRepository implements UserRepository {
|
||||
constructor(
|
||||
private readonly dataSource: DataSource,
|
||||
private readonly mapper: UserOrmMapper,
|
||||
|
||||
Reference in New Issue
Block a user