Skip to content

Improve Type Safety in cards.ts and Remove Remaining any Usage#579

Open
Facelessism wants to merge 1 commit into
Dev-Card:mainfrom
Facelessism:card-ts
Open

Improve Type Safety in cards.ts and Remove Remaining any Usage#579
Facelessism wants to merge 1 commit into
Dev-Card:mainfrom
Facelessism:card-ts

Conversation

@Facelessism

Copy link
Copy Markdown

Summary

This PR improves type safety in cards.ts by removing the remaining usages of any and replacing them with existing Fastify/JWT typings that's already available in the codebase. Auth-related type assertions have been eliminated, error handling has been made safer through an explicit type narrowing and a shared Fastify/JWT definitions are now reused where applicable.

Closes #547


Type of Change

  • Bug fix
  • New feature
  • Refactor (no functional change)
  • UI / Design change
  • Tests only
  • Documentation
  • Infrastructure / DevOps
  • Security

What Changed

  • removed all any usages from src/routes/cards.ts
  • replaced request.server as any and (app as any).authenticate with properly typed fastify decorator access
  • reused existing Fastify/JWT type augmentations for request.user and auth related logic
  • replaced catch (error: any) with safer error handling using explicit type narrowing
  • eliminated manual user type assertions by relying on the shared JWT user typing
  • verified the TS compilation without introducing any new type errors

How to Test

  1. go to apps/backend
  2. run npm run typecheck and verify it completes without any errors
  3. start the backend server and run the card routes
  4. verify the authentication protected routes continue to function as expected

Checklist

  • My code follows the project's coding style (pnpm -r run lint passes).
  • TypeScript compiles without errors (pnpm -r run typecheck).
  • I have added or updated tests for the changes I made.
  • All tests pass locally (pnpm -r run test).
  • I have updated documentation where necessary.
  • No new console.log or debug statements left in the code.
  • Breaking changes are documented in this PR description.

Screenshots / Recordings


Additional Context

Signed-off-by: lost_fanatic <bighna2005@gmail.com>
@vercel

vercel Bot commented Jun 14, 2026

Copy link
Copy Markdown

@Facelessism is attempting to deploy a commit to the Prashantkumar Khatri's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added backend gssoc:approved Required label for every approved PR. Gives the base +50 points and enables contribution tracking. labels Jun 14, 2026
@github-actions

Copy link
Copy Markdown

Hi @Facelessism,

Thanks for opening this pull request.

This PR has been automatically classified based on the files modified.

Applied Labels

  • gssoc:approved
  • backend

Primary Review Area

  • backend

Reviewer

@Harxhit has been identified as the primary reviewer for this pull request.

If you have any questions regarding the affected area or implementation details, feel free to reach out to the assigned reviewer.

Thank you for your contribution!

@github-actions

Copy link
Copy Markdown

CI — All Checks Passed

Backend — PASS

Check Result
Lint PASS
Test PASS
Typecheck PASS

Mobile — SKIP

Check Result
Lint -
Test -

Web — SKIP

Check Result
Check -
Build -

Last updated: Sun, 14 Jun 2026 20:31:41 GMT

@Facelessism

Copy link
Copy Markdown
Author

Hey @Harxhit
Do review the attached PR and do let me know if there are further changes needed with it.
Thank you

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

Labels

backend gssoc:approved Required label for every approved PR. Gives the base +50 points and enables contribution tracking.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve Type Safety in cards.ts and Remove Remaining any Usage

1 participant