fix: align frontend API client with actual backend API - #89
Merged
Nabeelahh merged 1 commit intoJul 29, 2026
Merged
Conversation
- Fix API base URL from port 8000 to 3000 with /api/v1 prefix - Add typed auth methods (register, login, refresh, logout, profile) - Add typed vault methods (CRUD, deposit, withdraw, lock, unlock, close) - Add typed transaction methods (submit, getStatus) - Add auth state management to Zustand store with token sync - Add useAuth hook with auto-refresh on 401 - Connect useVault hook to real API endpoints - Update .env.example with new NEXT_PUBLIC_API_URL var - Add API response wrapper types (ApiResponse, PaginatedResponse) - Add proper error parsing with backend error codes
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.
Closes #14
Summary
Aligns the frontend API client with the actual backend API that runs on port 3000 with the /api/v1 prefix.
Changes
API Base URL
http://localhost:8000/apitohttp://localhost:3000/api/v1NEXT_PUBLIC_API_URLenv var (replaces oldNEXT_PUBLIC_BACKEND_API_URL).env.exampleTypes (
Frontend/src/types/index.ts)ApiResponse<T>andPaginatedResponse<T>response wrapper typesUser,RegisterInput,LoginInput,LoginResponse, etc.currentAmountas string,status,type)VaultTransaction,VaultTransactionType,VaultTransactionStatusApiValidationErrorfor structured error handlingDeposit/WithdrawalinterfacesAPI Client (
Frontend/src/lib/api.ts)setAccessToken/getAccessTokenAuthorization: Bearerheader injection on all requestsX-Idempotency-Keyheader support for idempotent operationsregister,login,refreshToken,logout,logoutAll,forgotPassword,resetPassword,verifyEmail,getProfile,updateProfilegetVaults,getVault,createVault,depositToVault,withdrawFromVault,lockVault,unlockVault,closeVault,getVaultHistorysubmitTransaction,getTransactionStatusApiErrorclass with backend error code parsingApiResponseunwrapping for{success, data}envelopeState Management (
Frontend/src/stores/index.ts)accessToken,refreshToken,usersetTokens,setUser,clearAuthactionssetAccessToken/setRefreshTokenHooks
fetchVaults,fetchVault,initiateFunding,initiateWithdrawal,lockVault,unlockVault,closeVaultTesting
CreateVault.tsx(corrupted file) are unrelated