Refactor Docker setup for frontend-only builds by removing server-side API files, creating mock APIs, and updating health check notes. Adjusted Vite configuration for browser compatibility and refined API handling in various components to improve user experience and maintainability.

This commit is contained in:
2025-08-15 22:35:15 +01:00
parent f7dc75d514
commit 7d100e7e0f
16 changed files with 224 additions and 124 deletions

View File

@ -24,20 +24,22 @@ export async function createUser(data: CreateUserData) {
const userId = generateId();
const now = new Date();
const [user] = await db.insert(users).values({
const userData = {
id: userId,
email: data.email,
username: data.username,
displayName: data.displayName,
avatarUrl: data.avatarUrl,
bio: data.bio,
avatarUrl: data.avatarUrl || null,
bio: data.bio || null,
isAdmin: false,
isModerator: false,
passwordHash: '', // This should be set by auth layer
createdAt: now,
updatedAt: now,
}).returning();
};
return user;
await db.insert(users).values(userData);
return userData;
} catch (error) {
throw new ApiError(`Failed to create user: ${error}`, 500);
}
@ -95,17 +97,19 @@ export async function getUserByUsername(username: string) {
// Update user
export async function updateUser(id: string, data: UpdateUserData) {
try {
const user = await getUserById(id);
const updateData = {
...data,
updatedAt: new Date(),
};
const [updatedUser] = await db
await db
.update(users)
.set(updateData)
.where(eq(users.id, id))
.returning();
.where(eq(users.id, id));
const updatedUser = { ...user, ...updateData };
return updatedUser;
} catch (error) {
throw new ApiError(`Failed to update user: ${error}`, 500);
@ -118,17 +122,19 @@ export async function updateUserPermissions(
permissions: { isAdmin?: boolean; isModerator?: boolean }
) {
try {
const user = await getUserById(id);
const updateData = {
...permissions,
updatedAt: new Date(),
};
const [updatedUser] = await db
await db
.update(users)
.set(updateData)
.where(eq(users.id, id))
.returning();
.where(eq(users.id, id));
const updatedUser = { ...user, ...updateData };
return updatedUser;
} catch (error) {
throw new ApiError(`Failed to update user permissions: ${error}`, 500);