Skip to content

Conversation

@kevinkim-ogp
Copy link
Contributor

@kevinkim-ogp kevinkim-ogp commented Nov 5, 2025

TL;DR

This PR adds the foundation for REST API endpoints with proper authentication and rate limiting:

  • Creates a new /api route structure with middleware for authentication and rate limiting
  • Extracts client IP detection into a reusable getClientIp helper with comprehensive tests
  • Adds authentication middleware that reuses existing GraphQL auth logic
  • Implements rate limiting for API endpoints (10 requests per minute per user/IP)
  • Adds extensive test coverage for all new middleware components
  • Updates Vite config to proxy /api requests during development

Why make this change?

  • Subsequent PR adds an /api/chat route for streaming the chat response from Pair for the AI Builder
  • Why not GraphQL with SSE?
    • Requires installing more packages
    • Need to add subscriptions
    • More config changes that this current approach

How to test?

  • All existing graphql APIs work as intended
  • API calls to /api adhere to authentication and rate-limits requirements
    • Rate limit is 10/user/second (very conservative approach since there is only 1 route, and we don't want to spam the LLM)

@kevinkim-ogp kevinkim-ogp changed the title chore: setup api route for chat streaming [AI-7]: setup api route for chat streaming Nov 5, 2025
@kevinkim-ogp kevinkim-ogp force-pushed the ai-builder/frontend-deps branch from ee96ac2 to b8659cc Compare November 6, 2025 03:55
@kevinkim-ogp kevinkim-ogp force-pushed the ai-builder/setup-api-route branch from 20cca9f to dd8d019 Compare November 6, 2025 03:55
@kevinkim-ogp kevinkim-ogp marked this pull request as ready for review November 6, 2025 04:04
@kevinkim-ogp kevinkim-ogp requested a review from a team as a code owner November 6, 2025 04:04
@kevinkim-ogp kevinkim-ogp force-pushed the ai-builder/setup-api-route branch from dd8d019 to e3456fc Compare November 13, 2025 01:50
@kevinkim-ogp kevinkim-ogp force-pushed the ai-builder/frontend-deps branch from b8659cc to 5ab0df2 Compare November 13, 2025 01:50
@kevinkim-ogp kevinkim-ogp force-pushed the ai-builder/setup-api-route branch from e3456fc to d33fa06 Compare November 14, 2025 02:55
@kevinkim-ogp kevinkim-ogp force-pushed the ai-builder/frontend-deps branch 2 times, most recently from 442f5b7 to 7b39796 Compare November 14, 2025 07:47
@kevinkim-ogp kevinkim-ogp force-pushed the ai-builder/setup-api-route branch from d33fa06 to 4c95a8a Compare November 14, 2025 07:47
@kevinkim-ogp kevinkim-ogp marked this pull request as draft November 27, 2025 01:27
@kevinkim-ogp kevinkim-ogp force-pushed the ai-builder/frontend-deps branch from 7b39796 to 88cb33b Compare December 1, 2025 13:48
@kevinkim-ogp kevinkim-ogp force-pushed the ai-builder/setup-api-route branch from 4c95a8a to ed9c60d Compare December 1, 2025 13:48
@kevinkim-ogp kevinkim-ogp force-pushed the ai-builder/setup-api-route branch from ed9c60d to 7a93f79 Compare December 1, 2025 14:35
@kevinkim-ogp kevinkim-ogp force-pushed the ai-builder/frontend-deps branch from 88cb33b to 9488bb6 Compare December 1, 2025 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants