Migrate Conduit from Angular to React (Vite + React + react-router)#37
Draft
milind-cognition wants to merge 4 commits into
Draft
Migrate Conduit from Angular to React (Vite + React + react-router)#37milind-cognition wants to merge 4 commits into
milind-cognition wants to merge 4 commits into
Conversation
- Replace Angular app with React: types, fetch-based apiClient (replaces 3 interceptors), AuthContext (replaces UserService incl. 4XX/5XX auth states + retry), jwt + debug interface, services, shared utils (ListErrors, defaultImage, Markdown w/ DOMPurify). - Components: ArticleMeta, FavoriteButton, FollowButton, ArticlePreview, ArticleList, ArticleComment; layout Header/Footer. - Pages: Home, Auth, Settings, Editor, Article, Profile (+articles/favorites). - Tooling: Vite (port 4200) + vitest + tsconfig; index.html at root; public/ for favicon + _redirects; submodule SVGs copied to /assets. - Preserves the framework-agnostic e2e contract (selectors, routes, jwtToken, window.__conduit_debug__).
… with 422); chore: modernize husky hook
… like Angular canActivate)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR migrates the Conduit RealWorld app from Angular 21 to React, while keeping it a drop-in RealWorld implementation. The migration was driven by the framework-agnostic Playwright e2e suite in
e2e/— that suite is the contract and passes unchanged.Stack
src/api/apiClient.ts— replicates the 3 Angular HTTP interceptors (API base URL,Authorization: Tokenheader, error normalization + global 401 logout)src/auth/AuthContext.tsx— replacesUserService, including the exactloading / authenticated / unauthenticated / unavailablestates, 4XX→logout vs 5XX→retry semantics, and exponential backoffmarked+DOMPurifyfor sanitized markdown (XSS contract)What was preserved (the e2e contract)
nameattributes, button/heading text, and routes frome2e/SELECTORS.mdlocalStoragekeyjwtTokenwindow.__conduit_debug__debug interface (src/auth/debug.ts)realworldgit submodule (copied to/assetsbyvite-plugin-static-copy)e2e/, Playwright configs,.prettierrc,.editorconfigare untouchedSource → target mapping
app.configinitAuth /UserServicesrc/auth/AuthContext.tsxsrc/api/apiClient.tsJwtServicesrc/auth/jwt.tssrc/auth/guards.tsxarticles/comments/tags/profile)src/services/*defaultImage/markdown),list-errorssrc/shared/*src/components/*src/layout/*src/pages/*Notable behavioral fixes
passwordfield (the live API returns422for a blank password).RequireAuthis point-in-time (like Angular'scanActivate): once you're on a protected page, a mid-session401shows an error instead of redirecting you away.Tooling / CI
index.htmlmoved to project root;public/holdsfavicon.ico+_redirects.baseURL).deploy.ymlzip path updated for the newdist/output.README.md/CLAUDE.mdupdated for React.Test evidence
bun run test:e2e):121 passed, 1 flaky— the single flaky is the existingarticles › should view article from home feed, a live-demo-backend timing issue that passes on retry.bun run test:e2e:security):16 passed(XSS image/markdown/description sanitization).bun run test):25 passed(jwt, apiClient, articles service, defaultImage, ListErrors).bun run buildandbun run format:checkpass.Screenshots
Home (global feed, tags, avatars, favorite counts):
Home page
Article detail (meta + Follow/Favorite, sanitized markdown body, tags):
Article page
Login page:
Login page
Notes for reviewers
To show artifacts inline, enable in settings.
Devin Review