feat: implement lobby functionality with user and server information retrieval
This commit is contained in:
@@ -12,6 +12,14 @@ export const createInMemoryUserRepository = (
|
||||
const usersByEmail = new Map<string, UserRecord>();
|
||||
|
||||
return {
|
||||
async findById(id: string): Promise<UserRecord | null> {
|
||||
for (const user of usersByName.values()) {
|
||||
if (user.id === id) {
|
||||
return user;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
},
|
||||
async findByUsername(username: string): Promise<UserRecord | null> {
|
||||
return usersByName.get(username) ?? null;
|
||||
},
|
||||
|
||||
@@ -56,6 +56,14 @@ export const createPostgresUserRepository = (
|
||||
hasher: PasswordHasher = createSimplePasswordHasher()
|
||||
): UserRepository => {
|
||||
return {
|
||||
async findById(id: string): Promise<UserRecord | null> {
|
||||
const row = await prisma.appUser.findUnique({
|
||||
where: {
|
||||
id,
|
||||
},
|
||||
});
|
||||
return row ? mapUser(row) : null;
|
||||
},
|
||||
async findByUsername(username: string): Promise<UserRecord | null> {
|
||||
const row = await prisma.appUser.findUnique({
|
||||
where: {
|
||||
|
||||
@@ -51,6 +51,7 @@ export interface CreateUserInput {
|
||||
}
|
||||
|
||||
export interface UserRepository {
|
||||
findById(id: string): Promise<UserRecord | null>;
|
||||
findByUsername(username: string): Promise<UserRecord | null>;
|
||||
findByOauthId(type: 'KAKAO', oauthId: string): Promise<UserRecord | null>;
|
||||
findByEmail(email: string): Promise<UserRecord | null>;
|
||||
|
||||
Reference in New Issue
Block a user