Skip to content

fix(backend): remove any usages from public.ts to improve type safety#588

Open
Satvik-art-creator wants to merge 1 commit into
Dev-Card:mainfrom
Satvik-art-creator:fix/public-ts-types
Open

fix(backend): remove any usages from public.ts to improve type safety#588
Satvik-art-creator wants to merge 1 commit into
Dev-Card:mainfrom
Satvik-art-creator:fix/public-ts-types

Conversation

@Satvik-art-creator

@Satvik-art-creator Satvik-art-creator commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR improves type safety in the public routes by removing the remaining usages of any in apps/backend/src/routes/public.ts. This ensures strict type-checking on query parameters and mapping functions, making future refactoring safer and more predictable.

This issue is solved under GSSoC '26.

Closes #553


Type of Change

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

What Changed

  • apps/backend/src/routes/public.ts: Replaced the (cl: any) cast in the getCardById response mapping with an explicit structural type ({ platformLink: { id: string; platform: string; username: string; url: string } }) to maintain strict typing without IDE export errors.
  • apps/backend/src/routes/public.ts: Replaced (request.query as any).format and (request.query as any).size with properly typed request.query.format and request.query.size, natively inheriting from the route's Querystring schema definition.

How to Test

  1. Check out this branch locally: git checkout fix/public-ts-types
  2. Ensure you have the backend dependencies installed and Prisma generated: cd apps/backend && npm install
  3. Run the TypeScript compiler to ensure there are no implicit any errors: npm run typecheck
  4. Optionally, start the backend and hit the public card/QR endpoints to verify no functional changes were introduced.

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. (N/A - Type updates only)
  • All tests pass locally (pnpm -r run test).
  • I have updated documentation where necessary. (N/A)
  • No new console.log or debug statements left in the code.
  • Breaking changes are documented in this PR description. (N/A)

Additional Context

Used structural inline typing for the mapped platformLink variable to avoid editor/IDE linting complaints related to cached Prisma generated type exports.

Copilot AI review requested due to automatic review settings June 17, 2026 01:07
@vercel

vercel Bot commented Jun 17, 2026

Copy link
Copy Markdown

@Satvik-art-creator 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 17, 2026
@github-actions

Copy link
Copy Markdown

Hi @Satvik-art-creator,

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!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR tightens TypeScript typing in the public routes by removing any casts and introducing more explicit types for request query params and card link mappings.

Changes:

  • Replaced (request.query as any) access with typed request.query.format / request.query.size.
  • Replaced any in card.cardLinks.map(...) with a typed object shape for platformLink.
Files not reviewed (1)
  • apps/backend/package-lock.json: Generated file

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

accentColor: card.user.accentColor,
},
links: card.cardLinks.map((cl: any) => ({
links: card.cardLinks.map((cl: { platformLink: { id: string; platform: string; username: string; url: string } }) => ({
@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
Build -

Last updated: Wed, 17 Jun 2026 01:07:55 GMT

@Satvik-art-creator

Copy link
Copy Markdown
Contributor Author

@Harxhit Kindly review my pr. Let me know if everything is fine

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 public.ts and Remove Remaining any Usage

2 participants