Repository: freeCodeCamp/freeCodeCamp
File: api/src/routes/protected/settings.ts (TypeScript)

Code before:
          const pictureIsValid = isValidPictureUrl(req.body.picture);
          if (!pictureIsValid) {
            logger.warn(`Invalid picture URL: ${req.body.picture}`);
            void reply.code(400);
            return { message: 'flash.wrong-updating', type: 'danger' } as const;
          }
        }
      }

      try {
        // Build update data object, only including fields that are provided
        const updateData: {
          about?: string;
          name?: string;
          location?: string;
          picture?: string;
        } = {};
        
        if (req.body.about !== undefined) updateData.about = req.body.about;
        if (req.body.name !== undefined) updateData.name = req.body.name;
        if (req.body.location !== undefined) updateData.location = req.body.location;
        if (req.body.picture !== undefined) updateData.picture = req.body.picture;

        await fastify.prisma.user.update({
          where: { id: req.user?.id },
          data: updateData
        });

        return {
          message: 'flash.updated-about-me',
          type: 'success'
        } as const;
      } catch (err) {
        logger.error(err);
        fastify.Sentry.captureException(err);
        void reply.code(500);
        return { message: 'flash.wrong-updating', type: 'danger' } as const;
      }
    }
  );

  fastify.put(
    '/update-my-keyboard-shortcuts',
    {
      schema: schemas.updateMyKeyboardShortcuts
    },
    async (req, reply) => {
      const logger = fastify.log.child({ req, res: reply });
      try {
        await fastify.prisma.user.update({
          where: { id: req.user?.id },

Review comment (suggestion):
```suggestion
          data: {
            about: req.body.about,
            name: req.body.name,
            location: req.body.location,
            picture: req.body.picture
          }
```
This was fine.

Code after:
      }

      try {
        await fastify.prisma.user.update({
          where: { id: req.user?.id },
          data: {
            about: req.body.about,
            name: req.body.name,
            location: req.body.location,
            picture: req.body.picture
          }
        });

        return {
          message: 'flash.updated-about-me',
          type: 'success'
        } as const;
      } catch (err) {
        logger.error(err);
        fastify.Sentry.captureException(err);
        void reply.code(500);
        return { message: 'flash.wrong-updating', type: 'danger' } as const;
      }
    }
  );

  fastify.put(
    '/update-my-keyboard-shortcuts',
    {
      schema: schemas.updateMyKeyboardShortcuts
    },
    async (req, reply) => {
      const logger = fastify.log.child({ req, res: reply });
      try {
        await fastify.prisma.user.update({
          where: { id: req.user?.id },
          data: {
            keyboardShortcuts: req.body.keyboardShortcuts
          }
        });

        return {
          message: 'flash.keyboard-shortcut-updated',
          type: 'success'
        } as const;
      } catch (err) {
        logger.error(err);
        fastify.Sentry.captureException(err);
        void reply.code(500);
        return { message: 'flash.wrong-updating', type: 'danger' } as const;
      }