fixed single-player tetris games

This commit is contained in:
Tzvetan Trave
2025-10-22 00:20:35 +02:00
parent 24c36564fe
commit 300e5a2b33
9 changed files with 73 additions and 50 deletions

View File

@ -1,10 +1,16 @@
export async function pAvatar(request, reply, fastify, setAvatarId) {
export async function pAvatar(request, reply, fastify, getUserInfo, setAvatarId) {
try {
/* const res = await fetch('http://localhost:3004/images', { method: "POST", headers: { } });
const userId = request.params.userId;
if (!getUserInfo.get(userId)) {
return reply.cose(404).send({ error: "User does not exist" });
}
console.log("====================================\n", request.headers);//==========
const res = await fetch('http://localhost:3004/images', { method: "POST", headers: { "Content-Type": "image/webp" }, body: request.body ? JSON.stringify(request.body) : undefined });
if (!res.ok) {
return reply.code(500).send({ error: "Internal server error" });
}
const data = await res.json();*/
const data = await res.json();
setAvatarId.run(data.imageId, userId);
return reply.code(200).send({ msg: "Avatar uploaded successfully" });
} catch (err) {
fastify.log.error(err);