Skip to content

Conversation

@nickbar01234
Copy link

Issue

See #76

Overview

  • Use zod schema for /:username/contest route
  • Note that error handling is barebone currently. We return whatever is thrown by zod validation
  • The diff is a bit larger due to prettier reformatting the code. If preferred, I can revert the diff added by prettier.

Testing

  • Failed parsing
http://localhost:3000/numb3r5/contest

[
    {
        "code": "invalid_type",
        "expected": "string",
        "received": "undefined",
        "path": [
            "userContestRanking",
            "badge",
            "icon"
        ],
        "message": "Required"
    }
]
  • Success parsing
http://localhost:3000/numb3r5/contest

{
    "contestAttend": 100,
    "contestRating": 3589.337,
    "contestGlobalRanking": 6,
    "totalParticipants": 791535,
    "contestTopPercentage": 0.01,
    "contestBadges": {
        "name": "Guardian"
    },
    "contestParticipation": [
        {
            "attended": true,
            "rating": 1717.921,
            "ranking": 377,
            "trendDirection": "UP",
            "problemsSolved": 4,
            "totalProblems": 4,
            "finishTimeInSeconds": 7012,
            "contest": {
                "title": "Biweekly Contest 52",
                "startTime": 1621089000
            }
        },
       ...
}

@nickbar01234
Copy link
Author

As a followup @alfaarghya, may be we can consider

  1. Husky for consistent formatting
  2. Running tests on CI/CD. I notice that tests for /calendar is failing on develop already

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant