From a4ab0b4e183f275c5d089ac72b388ec60dfe7adb Mon Sep 17 00:00:00 2001 From: Niraj Nandish Date: Wed, 24 May 2023 22:57:19 +0400 Subject: [PATCH] chore: move update socials schema (#50506) * chore: move update scoials schema * fix: set maxLength value to satisfy tests --- api/src/routes/settings.ts | 19 +------------------ api/src/schemas.ts | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/api/src/routes/settings.ts b/api/src/routes/settings.ts index b2ce3576864..14b3427e773 100644 --- a/api/src/routes/settings.ts +++ b/api/src/routes/settings.ts @@ -80,24 +80,7 @@ export const settingRoutes: FastifyPluginCallbackTypebox = ( fastify.put( '/update-my-socials', { - schema: { - body: Type.Object({ - website: Type.Optional(Type.String({ format: 'url' })), - twitter: Type.Optional(Type.String({ format: 'url' })), - githubProfile: Type.Optional(Type.String({ format: 'url' })), - linkedin: Type.Optional(Type.String({ format: 'url' })) - }), - response: { - 200: Type.Object({ - message: Type.Literal('flash.updated-socials'), - type: Type.Literal('success') - }), - 500: Type.Object({ - message: Type.Literal('flash.wrong-updating'), - type: Type.Literal('danger') - }) - } - } + schema: schemas.updateMySocials }, async (req, reply) => { try { diff --git a/api/src/schemas.ts b/api/src/schemas.ts index 58b7c42789e..0ebb622b895 100644 --- a/api/src/schemas.ts +++ b/api/src/schemas.ts @@ -43,6 +43,26 @@ export const schemas = { }) } }, + updateMySocials: { + body: Type.Object({ + website: Type.Optional(Type.String({ format: 'url', maxLength: 1024 })), + twitter: Type.Optional(Type.String({ format: 'url', maxLength: 1024 })), + githubProfile: Type.Optional( + Type.String({ format: 'url', maxLength: 1024 }) + ), + linkedin: Type.Optional(Type.String({ format: 'url', maxLength: 1024 })) + }), + response: { + 200: Type.Object({ + message: Type.Literal('flash.updated-socials'), + type: Type.Literal('success') + }), + 500: Type.Object({ + message: Type.Literal('flash.wrong-updating'), + type: Type.Literal('danger') + }) + } + }, updateMyKeyboardShortcuts: { body: Type.Object({ keyboardShortcuts: Type.Boolean()