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

Code before:
          void reply.code(400);
          return formatValidationError(error.validation);
        } else {
          fastify.errorHandler(error, request, reply);
        }
      }
    },
    async (req, reply) => {
      try {
        const { id, files, challengeType } = req.body;

        const user = await fastify.prisma.user.findUniqueOrThrow({
          where: { id: req.session.user.id }
        });
        const RawProgressTimestamp = user.progressTimestamps as
          | ProgressTimestamp[]
          | null;
        const points = getPoints(RawProgressTimestamp);

        const completedChallenge: CompletedChallenge = {
          id,
          files,
          completedDate: Date.now()
        };

        if (challengeType === 14) {
          completedChallenge.isManuallyApproved = true;
          user.needsModeration = true;
        }

        if (
          jsCertProjectIds.includes(id) ||
          multifileCertProjectIds.includes(id)
        ) {
          completedChallenge.challengeType = challengeType;
        }

        const { alreadyCompleted, userSavedChallenges: savedChallenges } =
          await updateUserChallengeData(fastify, user, id, completedChallenge);

        return {
          alreadyCompleted,
          points: alreadyCompleted ? points : points + 1,
          completedDate: completedChallenge.completedDate,
          savedChallenges
        };
      } catch (error) {
        fastify.log.error(error);
        void reply.code(500);
        return {
          message:

Review comment (suggestion):
no need for magic number

```suggestion
        if (challengeType === challengeTypes.multifileCertProject) {
```

Code after:
    '/project-completed',
    {
      schema: schemas.projectCompleted,
      errorHandler(error, request, reply) {
        if (error.validation) {
          void reply.code(400);
          return formatValidationError(error.validation);
        } else {
          fastify.errorHandler(error, request, reply);
        }
      }
    },
    async (req, reply) => {
      const { id: projectId, challengeType, solution, githubLink } = req.body;
      const userId = req.session.user.id;

      try {
        const user = await fastify.prisma.user.findUniqueOrThrow({
          where: { id: userId },
          select: {
            completedChallenges: true,
            partiallyCompletedChallenges: true,
            progressTimestamps: true
          }
        });

        if (
          challengeType === challengeTypes.codeAllyCert &&
          !canSubmitCodeRoadCertProject(projectId, user)
        ) {
          void reply.code(403);
          return {
            type: 'error',
            message:
              'You have to complete the project before you can submit a URL.'
          } as const;
        }

        const completedDate = Date.now();
        const oldChallenge = user.completedChallenges?.find(
          ({ id }) => id === projectId
        );
        const updatedChallenge = {
          challengeType,
          solution,
          githubLink
        };
        const newChallenge = {
          ...updatedChallenge,
          id: projectId,
          completedDate