You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
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
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,StaticPagesrc/types/api.tsfor pagination wrapper:PaginatedResponse<T> { items: T[], total: number, page: number, limit: number }src/lib/api.tswith:NEXT_PUBLIC_API_URLenv vargetNews(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)→StaticPagenpx tsc --noEmitImportant Notes
fetch(not axios) to keep dependencies minimalhttp://localhost:8000for local devBudgetData.childrenis recursive (children: BudgetData[])