PR 2/6: React Migration — API Layer & Auth Context#43
Open
devanshi-gpta wants to merge 1 commit into
Open
Conversation
- Port Angular services to plain async fetch functions in src/api/ - agent.ts: base request helper with JWT auth headers - articles.ts: CRUD operations, favorite/unfavorite - comments.ts: get, add, delete comments - tags.ts: fetch all tags - profile.ts: get profile, follow/unfollow - auth.ts: login, register, getCurrentUser, updateUser - Create AuthContext (src/context/AuthContext.tsx): - AuthProvider with useState for user/authState - Auto-retry with exponential backoff on 5XX errors - Exposes useAuth() hook - window.__conduit_debug__ interface for e2e tests - Port Angular pipes as utility functions (src/utils/): - defaultImage, formatDate, renderMarkdown Co-Authored-By: Devanshi Gupta <devanshi.gupta@cognition.ai>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
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
Second PR in the 6-part Angular→React migration. Ports all Angular services to plain async fetch functions and creates a React Context for authentication state management.
API layer (
src/api/):agent.ts— baserequest()helper wrappingfetchwith JWT auth header injection and error normalization (matches Angular'sapiInterceptor+tokenInterceptor+errorInterceptor)articles.ts—queryArticles,getArticle,createArticle,updateArticle,deleteArticle,favoriteArticle,unfavoriteArticlecomments.ts—getComments,addComment,deleteCommenttags.ts—getTagsprofile.ts—getProfile,followUser,unfollowUserauth.ts—login,register,getCurrentUser,updateUserAuth context (
src/context/AuthContext.tsx):UserService+JwtServicesingleton pairloading → authenticated | unauthenticated | unavailablewindow.__conduit_debug__for e2e test compatibilityuseAuth()hook for consuming componentsUtilities (
src/utils/):defaultImage()— replacesDefaultImagePipeformatDate()— replaces AngularDatePipeusagerenderMarkdown()— replacesMarkdownPipe(lazy-importsmarked)Link to Devin session: https://app.devin.ai/sessions/6215127f80d4463cad3055cf81b87f0c
Requested by: @devanshi-gpta
Devin Review