Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Sync the api docs with the new rate limiting backend feature #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

@fulleni
Copy link
Member

@fulleni fulleni commented Jul 29, 2025

No description provided.

fulleni added 7 commits July 29, 2025 19:36
- Describe the built-in rate limiting system to ensure API stability and security
- Explain how it works, including the use of IP address as identifier
- Detail two rate-limiting configurations: Sensitive Endpoint and General Data API
- Mention admin and publisher role exemptions
- Provide information on configuration via environment variables
- Include example error response for exceeded rate limits
- Add rate limiting description to data route middleware
- Explain admin exemption and 429 error for rate limit exceeded
- Add documentation for RATE_LIMIT_REQUEST_CODE_LIMIT, RATE_LIMIT_REQUEST_CODE_WINDOW_HOURS, RATE_LIMIT_DATA_API_LIMIT, and RATE_LIMIT_DATA_API_WINDOW_MINUTES environment variables.
- Include default values and descriptions for each new variable.
...mentation
- Add `429 forbidden` error code to the list of common error codes
- Explain that this error occurs when a client exceeds the rate limit
- Include new card for rate limiting feature
- Describe how API prevents abuse with built-in request rate limiting
- Add "Read more" link to rate limiting documentation
- Add Rate Limiting link to the features list in astro.config.mjs
- Update JWT_EXPIRY_HOURS default to 720 hours (1 month)
- Add caution Aside about cost and user experience implications of lowering JWT expiry
- Add security and cost implications warning for allowing more than 3 sign-in code requests
@fulleni fulleni merged commit efd8142 into main Jul 29, 2025
@fulleni fulleni deleted the sync_the-api-docs-with-the-new-rate-limiting-backend-feature branch July 29, 2025 19:02
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary of Changes

Hello @fulleni, I'm Gemini Code Assist1 ! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request primarily focuses on synchronizing the API documentation with the newly implemented rate limiting backend feature. It introduces a dedicated documentation page for rate limiting, updates existing architectural and feature overviews to reference it, and adds new environment variables for its configuration. Additionally, the default JWT expiry duration has been adjusted and documented.

Highlights

  • New Rate Limiting Documentation Page: A comprehensive new documentation page (src/content/docs/api-server/features/rate-limiting.mdx) has been added, detailing the API server's built-in rate limiting feature. This includes an explanation of how it works, the two distinct configurations (sensitive endpoint and general data API limiting), how roles can bypass limits, configuration options, and the error response for exceeding limits.
  • Documentation Updates for Rate Limiting: Existing documentation files have been updated to reflect the new rate limiting feature. This includes adding a navigation link in astro.config.mjs, documenting the 429 Too Many Requests error code in src/content/docs/api-server/architecture/error-handling.mdx, describing the rate limiting middleware in src/content/docs/api-server/architecture/middleware.mdx, and adding a feature card for rate limiting on the main features overview page (src/content/docs/api-server/features/index.mdx).
  • New Rate Limiting Environment Variables: The environment variables guide (src/content/docs/api-server/guides/configure-environment-variables.mdx) has been updated to include new variables for configuring rate limits: RATE_LIMIT_REQUEST_CODE_LIMIT, RATE_LIMIT_REQUEST_CODE_WINDOW_HOURS, RATE_LIMIT_DATA_API_LIMIT, and RATE_LIMIT_DATA_API_WINDOW_MINUTES. Cautionary notes regarding security and cost implications are also included.
  • JWT Expiry Default Update: The default value for JWT_EXPIRY_HOURS in the environment variables guide (src/content/docs/api-server/guides/configure-environment-variables.mdx) has been changed from 1 hour to 720 hours (1 month), along with a new caution note explaining the balance between security, user experience, and email costs.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments or fill out our survey to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the documentation to reflect the new rate-limiting feature. The changes are comprehensive, adding a new feature page, updating related architecture documents, and documenting the new environment variables. My review focuses on ensuring consistency and clarity across all updated documentation. I've identified a few inconsistencies and one case of incomplete documentation that should be addressed to improve the quality of the docs.


3. **Data Route Middleware (`/routes/api/v1/data/_middleware.dart`)**
- **Require Authentication:** Checks if a `User` object exists in the context. If not, it immediately aborts the request with a `401 Unauthorized` error.
- **Rate Limiting:** If the user is not an admin, it applies a rate limit based on the user's ID. If the limit is exceeded, it aborts with a `429 Too Many Requests` error.
Copy link

@gemini-code-assist gemini-code-assist bot Jul 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

There's an inconsistency in the documentation regarding which roles bypass rate limiting. This file states that only admin users bypass the limit, while the new rate-limiting.mdx page says that both admin and publisher roles bypass it.

Assuming rate-limiting.mdx has the correct information, this line should be updated to include the publisher role for consistency.

 - **Rate Limiting:** If the user is not an admin or publisher, it applies a rate limit based on the user's ID. If the limit is exceeded, it aborts with a `429 Too Many Requests` error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

1 more reviewer

@gemini-code-assist gemini-code-assist[bot] gemini-code-assist[bot] left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

AltStyle によって変換されたページ (->オリジナル) /