Spaces:
Runtime error
Runtime error
Download apps/server/src/modules/users/users.service.js from moustafa7/flwo: direct link, hf CLI and curl.
- Browser
- Download file 835 Bytes
-
https://huggingface.co/spaces/moustafa7/flwo/resolve/main/apps/server/src/modules/users/users.service.js
- Command line
-
hf download hf://spaces/moustafa7/flwo/apps/server/src/modules/users/users.service.js
-
curl -L -o users.service.js https://huggingface.co/spaces/moustafa7/flwo/resolve/main/apps/server/src/modules/users/users.service.js
835 Bytes
| import { prisma } from '../../config/database.js' | |
| import { AppError } from '../../lib/AppError.js' | |
| export async function updateProfile(userId, data, avatarUrl) { | |
| const updateData = { ...data } | |
| if (avatarUrl) updateData.avatarUrl = avatarUrl | |
| const user = await prisma.user.update({ | |
| where: { id: userId }, | |
| data: updateData, | |
| select: { id: true, firstName: true, lastName: true, email: true, phone: true, role: true, avatarUrl: true } | |
| }) | |
| return user | |
| } | |
| export async function getUserById(userId) { | |
| const user = await prisma.user.findUnique({ | |
| where: { id: userId }, | |
| select: { id: true, firstName: true, lastName: true, email: true, phone: true, role: true, avatarUrl: true, createdAt: true } | |
| }) | |
| if (!user) throw new AppError('المستخدم غير موجود', 404, 'USER_NOT_FOUND') | |
| return user | |
| } | |