feat: add friend wishlist link

This commit is contained in:
Vaka.pro
2026-04-26 23:29:20 +03:00
parent f8fcda0d13
commit 34179b3f30
4 changed files with 50 additions and 1 deletions

View File

@@ -3,6 +3,7 @@ import { updateProfileSchema } from '@family-wishlist/shared';
import { ConflictError, NotFoundError, ValidationError } from '../../utils/errors.js';
import { Prisma } from '@prisma/client';
import { deleteLocalImageIfAny, saveUploadedAvatar } from '../images/storage.service.js';
import { usersRegistry } from '../../auth/users.registry.js';
const MAX_AVATAR_BYTES = 2 * 1024 * 1024;
@@ -15,6 +16,16 @@ export default async function profileRoutes(app: FastifyInstance) {
return profile;
});
app.get('/friend', async (request) => {
const friend = usersRegistry.all().find((u) => u.id !== request.user.id);
if (!friend) return null;
return app.prisma.user.findUnique({
where: { id: friend.id },
select: { slug: true, displayName: true, avatarUrl: true },
});
});
app.patch('/', async (request) => {
const body = updateProfileSchema.parse(request.body);
try {