-
Notifications
You must be signed in to change notification settings - Fork 523
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
chore: add override routes in unkey ratelimit sdk docs #2741
chore: add override routes in unkey ratelimit sdk docs #2741
Conversation
…-add-override-routes-in-unkeyratelimit-sdk-docs
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
📝 Walkthrough📝 WalkthroughWalkthroughThis pull request introduces comprehensive documentation for the rate limiting library's override functionalities, including methods for setting, getting, deleting, and listing overrides. Each new documentation file outlines the required parameters, response structures, and includes TypeScript examples. Additionally, the main Changes
Possibly related PRs
Suggested labels
Suggested reviewers
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (3)
💤 Files with no reviewable changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
🔇 Additional comments (1)apps/docs/mint.json (1)
The navigation structure for The documentation structure follows a clear hierarchical organization:
This structure aligns well with the SDK's architecture and makes it easy for users to find specific functionality. ✅ Verification successfulAll documentation files are present and correctly structured The verification confirms that all documentation files referenced in the navigation structure exist in their expected locations:
🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Description: Verify existence of documentation files for @unkey/ratelimit
# Test: Check if all documentation files mentioned in the navigation exist
echo "Checking for ratelimit documentation files..."
for page in \
"ratelimit" \
"override/overview" \
"override/set-override" \
"override/get-override" \
"override/list-overrides" \
"override/delete-override"; do
# Search for .mdx files in the libraries/ts/ratelimit directory
if ! fd -e mdx "$page" "apps/docs/libraries/ts/ratelimit"; then
echo "Missing documentation file: libraries/ts/ratelimit/$page"
fi
done
# Verify the directory structure
echo -e "\nVerifying directory structure..."
fd . "apps/docs/libraries/ts/ratelimit"
Length of output: 1927 Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Thank you for following the naming conventions for pull request titles! 🙏 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 6
🧹 Outside diff range and nitpick comments (8)
apps/docs/libraries/ts/ratelimit/override/overview.mdx (1)
21-40
: Add error handling to the example codeThe example shows success/error paths but doesn't demonstrate handling of potential exceptions from the API call.
async function handler(request) { const identifier = request.getUserId() // or ip or anything else you want - const override = await unkey.setOverride({ - identifier: identifier, - limit: 10, - duration: 60000, - namespaceName: "email.outbound", - async: true - }) + try { + const override = await unkey.setOverride({ + identifier: identifier, + limit: 10, + duration: 60000, + namespaceName: "email.outbound", + async: true + }) + + if (!override.success){ + return new Response("try again later", { status: 429 }) + } + + // handle the request here + + } catch (error) { + console.error('Failed to set override:', error) + return new Response("internal server error", { status: 500 }) + } - if (!override.success){ - return new Response("try again later", { status: 429 }) - } - // handle the request here }apps/docs/libraries/ts/ratelimit/override/set-override.mdx (1)
9-11
: Use relative links for documentation referencesThe links to wildcard documentation are hardcoded to www.unkey.com. These should be relative links to ensure they work across different environments.
-More info can be found at https://www.unkey.com/docs/ratelimiting/overrides#wildcard-rules +More info can be found in the [Wildcard Rules](/docs/ratelimiting/overrides#wildcard-rules) sectionAlso applies to: 29-31
apps/docs/libraries/ts/ratelimit/override/get-override.mdx (2)
7-9
: Use relative links for documentation referencesThe links to wildcard documentation are hardcoded to www.unkey.com. These should be relative links to ensure they work across different environments.
-More info can be found at https://www.unkey.com/docs/ratelimiting/overrides#wildcard-rules +More info can be found in the [Wildcard Rules](/docs/ratelimiting/overrides#wildcard-rules) sectionAlso applies to: 33-35
29-47
: Use consistent parameter documentation structureThe response parameters are documented using
ParamField
withbody
attribute, which is typically used for request parameters. For response fields, useResponseField
consistently.-<ParamField body="id" type="string" required> +<ResponseField name="id" type="string" required> Identifier of the override requested -</ParamField> +</ResponseField> -<ParamField body="identifier" type="string" required> +<ResponseField name="identifier" type="string" required> Identifier of your user... -</ParamField> +</ResponseField> // Apply similar changes to other response fieldsapps/docs/libraries/ts/sdk/overview.mdx (1)
116-123
: Add version compatibility informationConsider adding version information for each constructor option to help users understand when these features were introduced and which SDK version they need.
Add version tags like this:
### Base Url +<Badge>Since v1.x.x</Badge> Run all requests against your own instance of unkey hosted on your own infrastructure.apps/docs/libraries/ts/ratelimit/ratelimit.mdx (1)
Line range hint
193-204
: Fix incorrect error handling exampleThe example for rejecting requests in the
onError
configuration shows the same response as the example for letting requests pass.Apply this fix:
Example letting requests pass: ```ts onError: ()=> ({ success: true, limit: 0, remaining: 0, reset: 0})Example rejecting the request:
- onError: ()=> ({ success: true, limit: 0, remaining: 0, reset: 0}) + onError: ()=> ({ success: false, limit: 0, remaining: 0, reset: 0})</blockquote></details> <details> <summary>apps/docs/libraries/ts/ratelimit/override/delete-override.mdx (2)</summary><blockquote> `26-26`: **Add comma and expand response documentation.** Consider revising for clarity and proper punctuation: ```diff -No response, but if no error is returned the override has been deleted successfully. +No response body is returned, but if no error occurs, the override has been deleted successfully. In case of errors, appropriate error responses will be returned.
🧰 Tools
🪛 LanguageTool
[uncategorized] ~26-~26: Possible missing comma found.
Context: ...sponse No response, but if no error is returned the override has been deleted successfu...(AI_HYDRA_LEO_MISSING_COMMA)
7-9
: Consider improving the wildcard documentation link.The URL for wildcard documentation is embedded within the parameter description. Consider using MDX components for better formatting and maintainability.
-Identifier of your user, this can be their userId, an email, an ip or anything else. Wildcards ( * ) can be used to match multiple identifiers, More info can be found at https://www.unkey.com/docs/ratelimiting/overrides#wildcard-rules +Identifier of your user, this can be their userId, an email, an ip or anything else. Wildcards ( * ) can be used to match multiple identifiers. + +<Card href="/docs/ratelimiting/overrides#wildcard-rules" title="Learn more about wildcard rules"> + Read our documentation about using wildcards in identifiers +</Card>
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (8)
apps/docs/libraries/ts/ratelimit/override/delete-override.mdx
(1 hunks)apps/docs/libraries/ts/ratelimit/override/get-override.mdx
(1 hunks)apps/docs/libraries/ts/ratelimit/override/list-overrides.mdx
(1 hunks)apps/docs/libraries/ts/ratelimit/override/overview.mdx
(1 hunks)apps/docs/libraries/ts/ratelimit/override/set-override.mdx
(1 hunks)apps/docs/libraries/ts/ratelimit/ratelimit.mdx
(1 hunks)apps/docs/libraries/ts/sdk/overview.mdx
(1 hunks)apps/docs/mint.json
(1 hunks)
🧰 Additional context used
🪛 LanguageTool
apps/docs/libraries/ts/ratelimit/override/delete-override.mdx
[uncategorized] ~26-~26: Possible missing comma found.
Context: ...sponse No response, but if no error is returned the override has been deleted successfu...
(AI_HYDRA_LEO_MISSING_COMMA)
🔇 Additional comments (2)
apps/docs/libraries/ts/ratelimit/ratelimit.mdx (1)
2-3
: LGTM: Clear and concise title update
The title and description changes improve clarity while maintaining accuracy.
apps/docs/libraries/ts/ratelimit/override/delete-override.mdx (1)
11-13
: LGTM! Clear warning about mutually exclusive parameters.
The warning about namespace parameters is clear and prominent.
|
…-add-override-routes-in-unkeyratelimit-sdk-docs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (1)
apps/docs/libraries/ts/ratelimit/override/delete-override.mdx (1)
26-26
: Add missing comma for better readability.-No response, but if no error is returned the override has been deleted successfully. +No response, but if no error is returned, the override has been deleted successfully.🧰 Tools
🪛 LanguageTool
[uncategorized] ~26-~26: Possible missing comma found.
Context: ...sponse No response, but if no error is returned the override has been deleted successfu...(AI_HYDRA_LEO_MISSING_COMMA)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
apps/docs/libraries/ts/ratelimit/override/delete-override.mdx
(1 hunks)apps/docs/libraries/ts/ratelimit/override/overview.mdx
(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- apps/docs/libraries/ts/ratelimit/override/overview.mdx
🧰 Additional context used
🪛 LanguageTool
apps/docs/libraries/ts/ratelimit/override/delete-override.mdx
[uncategorized] ~26-~26: Possible missing comma found.
Context: ...sponse No response, but if no error is returned the override has been deleted successfu...
(AI_HYDRA_LEO_MISSING_COMMA)
🔇 Additional comments (1)
apps/docs/libraries/ts/ratelimit/override/delete-override.mdx (1)
31-42
: Examples look good!
The examples correctly demonstrate both ways to use the API (using either namespaceName
or namespaceId
), and they align with the warning that states only one namespace parameter should be used.
…-add-override-routes-in-unkeyratelimit-sdk-docs
What does this PR do?
Fixes # (issue)
Eng-1597
If there is not an issue for this, please create one first. This is used to tracking purposes and also helps use understand why this PR exists
Type of change
How should this be tested?
Docs show how package works
Checklist
Required
pnpm build
pnpm fmt
console.logs
git pull origin main
Appreciated
Summary by CodeRabbit
@unkey/ratelimit
library.mint.json
configuration to reflect the new documentation structure.