Refactor 4 with bugfixes

This commit is contained in:
2026-03-04 03:56:23 +01:00
parent be91b6dfe8
commit 0ed9ca93d3
51 changed files with 1552 additions and 996 deletions

View File

@@ -0,0 +1,46 @@
import { AuthUserEntity } from '../entities/AuthUserEntity';
import { ServerEntity } from '../entities/ServerEntity';
import { JoinRequestEntity } from '../entities/JoinRequestEntity';
import {
AuthUserPayload,
ServerPayload,
JoinRequestPayload
} from './types';
export function rowToAuthUser(row: AuthUserEntity): AuthUserPayload {
return {
id: row.id,
username: row.username,
passwordHash: row.passwordHash,
displayName: row.displayName,
createdAt: row.createdAt
};
}
export function rowToServer(row: ServerEntity): ServerPayload {
return {
id: row.id,
name: row.name,
description: row.description ?? undefined,
ownerId: row.ownerId,
ownerPublicKey: row.ownerPublicKey,
isPrivate: !!row.isPrivate,
maxUsers: row.maxUsers,
currentUsers: row.currentUsers,
tags: JSON.parse(row.tags || '[]'),
createdAt: row.createdAt,
lastSeen: row.lastSeen
};
}
export function rowToJoinRequest(row: JoinRequestEntity): JoinRequestPayload {
return {
id: row.id,
serverId: row.serverId,
userId: row.userId,
userPublicKey: row.userPublicKey,
displayName: row.displayName,
status: row.status as JoinRequestPayload['status'],
createdAt: row.createdAt
};
}