inmemory to postgres

This commit is contained in:
2025-12-29 18:34:12 +01:00
parent 9e17d0752a
commit f5639a367f
176 changed files with 10175 additions and 468 deletions

View File

@@ -52,6 +52,37 @@ export class User {
return new User(props);
}
public static rehydrate(props: {
id: string;
displayName: string;
email?: string;
passwordHash?: PasswordHash;
iracingCustomerId?: string;
primaryDriverId?: string;
avatarUrl?: string;
}): User {
const email =
props.email !== undefined
? (() => {
const result: EmailValidationResult = validateEmail(props.email);
if (!result.success) {
throw new Error(result.error);
}
return result.email;
})()
: undefined;
return new User({
id: UserId.fromString(props.id),
displayName: props.displayName,
...(email !== undefined ? { email } : {}),
...(props.passwordHash !== undefined ? { passwordHash: props.passwordHash } : {}),
...(props.iracingCustomerId !== undefined ? { iracingCustomerId: props.iracingCustomerId } : {}),
...(props.primaryDriverId !== undefined ? { primaryDriverId: props.primaryDriverId } : {}),
...(props.avatarUrl !== undefined ? { avatarUrl: props.avatarUrl } : {}),
});
}
public static fromStored(stored: StoredUser): User {
const passwordHash = stored.passwordHash
? PasswordHash.fromHash(stored.passwordHash)