From 4918618aad3e430539a6801d78d7094b7ebb723c Mon Sep 17 00:00:00 2001 From: adjoly Date: Thu, 23 Oct 2025 19:18:09 +0200 Subject: [PATCH] =?UTF-8?q?=E3=80=8C=F0=9F=94=A8=E3=80=8D=20fix:=20fixed?= =?UTF-8?q?=20some=20things.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/user/default.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/api/user/default.js b/src/api/user/default.js index 8072895..13d81b3 100644 --- a/src/api/user/default.js +++ b/src/api/user/default.js @@ -143,6 +143,10 @@ const querySchemaMatchHistory = { type: 'object', required: ['game', 'iStart', ' const bodySchemaMatchHistory = { type: 'object', required: ['game', 'date', 'myScore'], properties: { game: { type: 'string' }, date: { type: 'integer', minimum: 0 }, opponent: { type: 'string' }, myScore: { type: 'integer', minimum: 0 }, opponentScore: { type: 'integer', minimum: 0 } } }; const querySchemaMatchHistoryGame = { type: 'object', required: ['game'], properties: { game: { type: 'string' } } }; +/** + * @param {import('fastify').FastifyInstance} fastify + * @param {import('fastify').FastifyPluginOptions} options + */ export default async function(fastify, options) { fastify.register(fastifyJWT, { secret: process.env.JWT_SECRET || '123456789101112131415161718192021', @@ -163,7 +167,6 @@ export default async function(fastify, options) { async (request, payload) => payload ); - fastify.decorate('authenticate', async function(request, reply) { try { const jwt = await request.jwtVerify(); @@ -224,7 +227,7 @@ export default async function(fastify, options) { fastify.post('/users/:userId/matchHistory', { preHandler: [fastify.authenticate], schema: { body: bodySchemaMatchHistory } }, async (request, reply) => { return pMatchHistory(request, reply, fastify, getUserInfo, addMatch, incWinsPong, incLossesPong, incWinsTetris, incLossesTetris); }); - fastify.post('/users/:userId/avatar', { preHandler: [fastify.authenticate] }, async (request, reply) => { + fastify.post('/users/:userId/avatar', { bodyLimit: 5242880, preHandler: [fastify.authenticate] }, async (request, reply) => { return pAvatar(request, reply, fastify, getUserInfo, setAvatarId, postImage); }); fastify.post('/ping', { preHandler: [fastify.authenticate] }, async (request, reply) => {