-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
Description
Motivation
A typed API client prevents integration bugs and gives all frontend devs autocomplete and type safety when fetching data. Defining types now (mirroring the backend DTOs) means frontend and backend development can proceed in parallel.
Deliverables
- Create
src/types/index.ts(or split by domain) with TypeScript interfaces for all public DTOs:Senator,CommitteeAssignment,Committee,Leadership,News,Legislation,LegislationAction,CalendarEvent,CarouselSlide,FinanceHearingConfig,FinanceHearingDate,Staff,District,BudgetData,StaticPage
- Create
src/types/api.tsfor pagination wrapper:PaginatedResponse<T> { items: T[], total: number, page: number, limit: number } - Build typed API client in
src/lib/api.tswith:- Configurable base URL from
NEXT_PUBLIC_API_URLenv var getNews(page?, limit?)→PaginatedResponse<News>getNewsById(id)→NewsgetSenators(params?)→Senator[]getSenatorById(id)→SenatorgetLeadership(session?)→Leadership[]getCommittees()→Committee[]getCommitteeById(id)→CommitteegetLegislation(params?)→PaginatedResponse<Legislation>getLegislationById(id)→LegislationgetRecentLegislation(limit?, type?)→Legislation[]getEvents(params?)→CalendarEvent[]getCarousel()→CarouselSlide[]getFinanceHearings()→FinanceHearingConfiggetStaff()→Staff[]getDistricts()→District[]getBudget(fiscalYear?)→BudgetData[]getStaticPage(slug)→StaticPage
- Configurable base URL from
- All functions should handle errors consistently (throw or return error type)
- Verify the module compiles with
npx tsc --noEmit
Important Notes
- No dependencies — can be built in parallel with FE-1
- Use
fetch(not axios) to keep dependencies minimal - The base URL defaults to
http://localhost:8000for local dev - Do NOT add admin/mutation API functions yet — those come with admin dashboard tickets
BudgetData.childrenis recursive (children: BudgetData[])
Reactions are currently unavailable