Skip to content

feat: implement GitHub platform auto-discovery from GitHub API#506

Open
udaycodespace wants to merge 3 commits into
Dev-Card:mainfrom
udaycodespace:feat/github-auto-discovery-32
Open

feat: implement GitHub platform auto-discovery from GitHub API#506
udaycodespace wants to merge 3 commits into
Dev-Card:mainfrom
udaycodespace:feat/github-auto-discovery-32

Conversation

@udaycodespace

Copy link
Copy Markdown
Contributor

Summary

Implements GitHub Platform Auto-Discovery (#32).

This PR adds a new authenticated endpoint, GET /api/connect/github/autodiscover, which uses the user's connected GitHub account to discover platform links from their GitHub profile. The endpoint returns suggestions only and does not create any links automatically.

To reduce unnecessary GitHub API requests, discovery results are cached in Redis for one hour. The implementation also handles missing, expired, or revoked GitHub tokens gracefully.

Closes #32


Type of Change

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

What Changed

  • Added GET /api/connect/github/autodiscover.
  • Reused the existing github_follow OAuth token flow to fetch GitHub profile data.
  • Added platform suggestion mapping from GitHub profile metadata.
  • Added Redis caching with a 1-hour TTL.
  • Added tests covering successful discovery, caching, token failures, Redis failures, and URL-based platform inference.

How to Test

  1. Connect a GitHub account using the existing GitHub connect flow.
  2. Send an authenticated request to GET /api/connect/github/autodiscover.
  3. Verify that platform suggestions are returned without creating any platform links.
  4. Repeat the request and verify the cached response is returned.
  5. Verify that revoked or invalid GitHub tokens return an appropriate error response.

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.
  • 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.

Additional Context

Discovery Mapping

  • twitter_usernametwitter (high confidence)
  • dev.to URLs → devto (low confidence)
  • hashnode URLs → hashnode (low confidence)
  • npmjs URLs → npm (low confidence)
  • Other blog URLs → portfolio (high confidence)

Caching

  • Redis key: github:autodiscover:{userId}
  • TTL: 3600 seconds

Tests Added

  • Successful discovery response
  • Cache hit behavior
  • GitHub 401 handling
  • Missing GitHub connection
  • Redis failure fallback
  • Blog URL platform inference

@vercel

vercel Bot commented Jun 8, 2026

Copy link
Copy Markdown

@udaycodespace 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 commented Jun 8, 2026

Copy link
Copy Markdown

CI — Checks Failed

Backend — FAIL

Check Result
Lint FAIL
Test PASS
Typecheck PASS

Mobile — SKIP

Check Result
Lint -
Test -

Web — SKIP

Check Result
Check -
Build -

Last updated: Mon, 08 Jun 2026 10:59:11 GMT

@udaycodespace

Copy link
Copy Markdown
Contributor Author

Validated locally after the latest changes.

cd apps/backend
pnpm exec vitest run src/__tests__/connect.test.ts

Result: 12/12 tests passing.

The tests cover:

  • Successful discovery response
  • Redis cache hit behavior
  • GitHub API 401 / revoked token handling
  • Missing GitHub connection
  • Redis failure fallback
  • Platform inference from GitHub profile URLs

Attached screenshot of the local test run.

image

Comment thread apps/backend/src/routes/connect.ts Outdated
@udaycodespace

Copy link
Copy Markdown
Contributor Author

@Harxhit Fixed and pushed.

  1. I've restored the reply parameter in the route handler as requested.
  2. Please take another look.

@udaycodespace udaycodespace requested a review from Harxhit June 8, 2026 10:59
@Harxhit Harxhit added gssoc:approved Required label for every approved PR. Gives the base +50 points and enables contribution tracking. backend labels Jun 8, 2026
@udaycodespace

Copy link
Copy Markdown
Contributor Author

Hi @Harxhit,

I noticed the backend CI is failing with:

'reply' is defined but never used. Allowed unused args must match /^_/u

The failure points to the line that was restored during the review:

async (request: FastifyRequest, reply: FastifyReply) => {

Would it be okay if I update it to:

async (request: FastifyRequest, _reply: FastifyReply) => {

This would keep the parameter in the handler signature while satisfying the lint rule.

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.

backend: implement GitHub platform auto-discovery from GitHub API

2 participants