This directory explains each API endpoint in the front end React app and the purposes they serve. Each function name is linked to the /Controller file that it executes.
Each category is a link to its Routes or relevant folder.
refreshToken- JWT token refresh endpoint that validates HTTP-only cookies and issues new access tokensauthorizeRequest- Validates JWT tokens from headers or cookies, handles token verification and rejectionguard- Express middleware for protecting routes with JWT authenticationcreateAccessToken- Generates JWT access tokens with configurable expirationcreateRefreshToken- Generates JWT refresh tokens with 18-day expiration and token version trackinghandleTokenRejection- Clears cookies and logs out users when tokens are invalid
📖 For comprehensive authentication system documentation, see
docs/authentication-system.md
updateUserupdates user documentchangePasswordchanges user password (in-app, during a secure session) and invalidates all existing tokens, issues new JWT tokensresetPasswordchanges user password (outside of a secure session, user is verified via unique URL)confirmResetPasswordHashconfirms a unique link provided to user if they ask to reset their passwordconfirmActivationHashconfirms a unique link provided to user if they create a new accountdeleteUserdeletes user account and stored documentloginlogs user into the appcheckPrivilegechecks if user has viewed the Eligibility requirements and clicked "Agree". (Users cannot make Celebrations without this)givePrivilegeupdates a user's document to TRUE for the abovepromoteDonorupdates a user document to TRUE for the abovegetUserDatareturns any user data that is exposed by the clientforgotPasswordstarts process to allow user to reset their password (if they cannot login)createUsercreates a newUseraccount document,logoutlogs out user
saveCelebrationsends payment to Stripe and creates a new Celebration document in the databasegetCelebrationsByUserIdreturns all Celebration documents from a single userresolveDonationconverts a Celebration into a donation by updating the documentsendReceiptemails Celebration receipt to user (uses refactored email system)getWhatPolsHaveInEscrowsums all donation amounts for each politician from across the userbase- Roster exclusion: HTTP
400withcode: POL_ROSTER_EXCLUDEDwhenpol_idis aPolwithroster_excluded: true— enforced inorchestrationServicebefore create. Seespecs/pol-roster-exclusion.md.
GET /api/congress/— List politicians for the selectable roster (lobby carousel, search).getPols:has_stakes: trueandroster_excludednot true.GET /api/congress/members/:pol— Single politician document (getPol); requires authentication.GET /api/congress/election-dates— Election dates (snapshot / fallbacks).
sendPaymentsends payment toStripe,setupIntentcreates a "payment intent" objectsetPaymentMethodcreates a "payment method" i.e. user's credit card- Roster exclusion:
POST /api/payments/celebrations/:customer_idrejects excludedpol_idwith HTTP400andcode: POL_ROSTER_EXCLUDEDbefore Stripe payment intent creation (seepolRosterEligibility).
📖 For comprehensive payment processing documentation, see
docs/payment-processing.md
📖 For webhook processing details, seedocs/webhooks.md
getPolsByLocationreturns local Representative information (allows user to search by address/ZIP code)
getBTCAddressgenerates a unique Bitcoin address for donations using HD wallet derivation
📖 For comprehensive Bitcoin donations documentation, see
docs/bitcoin-donations.md
notifyImgErr(PUTbody{ pol }, bioguide): may send an internal email when a roster WebP is still missing; suppresses send if{pol}.webpalready exists on the served pfp tree or the same bioguide was alerted within 24 hours (pfp_image_error_alerts)getConstantsretrieves private constant values stored on the server
/api/webhooks/stripehandles Stripe webhook events for payment processing
📖 For comprehensive webhook system documentation, see
docs/webhooks.md
- Authentication System - JWT authentication details
- Payment Processing - Stripe integration and escrow
- Webhook System - Real-time event processing
- Background Jobs - Automated monitoring and updates
- Email System - Email notifications
- Bitcoin Donations - Cryptocurrency support
- Pol roster exclusion - Policy exclusions for selectable roster and new Celebrations