docs: README for @unkey/nextjs #2162#2166
Conversation
📝 WalkthroughWalkthroughThe changes in this pull request introduce a new README file for the Changes
Assessment against linked issues
Possibly related PRs
Suggested reviewers
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 (
|
|
@Ionfinisher is attempting to deploy a commit to the Unkey Team on Vercel. A member of the Team first needs to authorize it. |
|
|
Thank you for following the naming conventions for pull request titles! 🙏 |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Outside diff range and nitpick comments (3)
packages/nextjs/package.json (1)
Line range hint
1-32: Summary: README inclusion addressed, consider adding adescriptionfield.The change to include "README.md" in the
filesarray successfully addresses the PR's main objective. Thepackage.jsonfile is otherwise complete for the package's needs.As a minor suggestion for future improvements:
Consider adding a
descriptionfield to thepackage.json. This would provide a brief explanation of the package's purpose, which is helpful for users browsing npm. For example:{ "name": "@unkey/nextjs", "version": "0.17.7", "description": "Next.js integration for Unkey API key management", // ... other fields }packages/nextjs/README.md (2)
17-35: LGTM: Quickstart guide is informative and easy to follow.The quickstart section effectively demonstrates how to use the
withUnkeyhandler with a clear code example. It also provides a helpful explanation about key verification.Consider adding a brief explanation of what
req.unkeycontains (e.g., the structure of the verification response) to provide more context for users.
51-51: Minor grammatical improvement suggested.Consider adding a comma after "By default" for better readability.
-By default errors will be logged to the console, and ```withUnkey``` will return a NextResponse with status 500. +By default, errors will be logged to the console, and ```withUnkey``` will return a NextResponse with status 500.🧰 Tools
🪛 LanguageTool
[uncategorized] ~51-~51: Did you mean: “By default,”?
Context: ... You can specify custom error handling. By default errors will be logged to the console, a...(BY_DEFAULT_COMMA)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (2)
- packages/nextjs/README.md (1 hunks)
- packages/nextjs/package.json (1 hunks)
🧰 Additional context used
🪛 LanguageTool
packages/nextjs/README.md
[style] ~39-~39: You have already used this phrasing in nearby sentences. Consider replacing it to add variety to your writing.
Context: ... theauthorizationheader. If you want to customize this, you can do so by passin...(REP_WANT_TO_VB)
[uncategorized] ~51-~51: Did you mean: “By default,”?
Context: ... You can specify custom error handling. By default errors will be logged to the console, a...(BY_DEFAULT_COMMA)
🪛 Markdownlint
packages/nextjs/README.md
45-45: Column: 1
Hard tabs(MD010, no-hard-tabs)
57-57: Column: 1
Hard tabs(MD010, no-hard-tabs)
72-72: Column: 1
Hard tabs(MD010, no-hard-tabs)
🔇 Additional comments (6)
packages/nextjs/package.json (1)
16-16: LGTM! README.md correctly added to thefilesarray.The addition of "README.md" to the
filesarray is correct and aligns with the PR objectives. This change ensures that the README file will be included when the package is published to npm, addressing the issue raised in #2162.To verify that the README file exists in the correct location, run the following script:
✅ Verification successful
README.md has been successfully added to the
filesarray and exists in the correct location. This change ensures that the README will be included when the package is published to npm, effectively addressing the issue raised in #2162.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the existence of README.md in the packages/nextjs directory # Test: Check if README.md exists in the packages/nextjs directory if [ -f "packages/nextjs/README.md" ]; then echo "README.md exists in the correct location." else echo "ERROR: README.md is missing from packages/nextjs directory." fiLength of output: 131
packages/nextjs/README.md (5)
1-10: LGTM: Header section is well-structured and informative.The header section provides a clear introduction to the @unkey/nextjs SDK, including its purpose and a link to the full documentation. This aligns well with the PR objectives.
11-15: LGTM: Installation instructions are clear and concise.The installation section provides a simple npm command to install the package, which is sufficient for most users.
79-89: LGTM: Telemetry information is transparent and provides opt-out instructions.The section clearly explains the default telemetry behavior and provides an easy way for users to disable it if desired. This transparency is appreciated.
91-93: LGTM: Documentation link is provided as required.The README concludes with a clear link to the full documentation, which satisfies the PR objective of including documentation links.
1-93: Overall, excellent README that meets PR objectives.This README file for the @unkey/nextjs SDK successfully addresses the requirements outlined in the PR objectives. It provides a comprehensive guide including installation instructions, a quickstart section, customization options, and links to full documentation. The content is well-structured and informative, making it easy for users to get started with the SDK.
A few minor improvements have been suggested regarding formatting consistency and grammar, but these do not detract from the overall quality of the document. Great job on creating this helpful resource for users of the @unkey/nextjs package!
🧰 Tools
🪛 LanguageTool
[style] ~39-~39: You have already used this phrasing in nearby sentences. Consider replacing it to add variety to your writing.
Context: ... theauthorizationheader. If you want to customize this, you can do so by passin...(REP_WANT_TO_VB)
[uncategorized] ~51-~51: Did you mean: “By default,”?
Context: ... You can specify custom error handling. By default errors will be logged to the console, a...(BY_DEFAULT_COMMA)
🪛 Markdownlint
45-45: Column: 1
Hard tabs(MD010, no-hard-tabs)
57-57: Column: 1
Hard tabs(MD010, no-hard-tabs)
72-72: Column: 1
Hard tabs(MD010, no-hard-tabs)
| If you want to customize how withUnkey processes incoming requests, you can do so as follows: | ||
|
|
||
| ## ```getKey``` | ||
| By default, withUnkey will look for a bearer token located in the ```authorization``` header. If you want to customize this, you can do so by passing a getter in the configuration object: | ||
|
|
||
| ```ts | ||
| export const GET = withUnkey(async (req) => { | ||
| // ... | ||
| }, { | ||
| getKey: (req) => new URL(req.url).searchParams.get("key"), | ||
| }); | ||
| ``` | ||
|
|
||
| ## ```onError``` | ||
|
|
||
| You can specify custom error handling. By default errors will be logged to the console, and ```withUnkey``` will return a NextResponse with status 500. | ||
|
|
||
| ```ts | ||
| export const GET = withUnkey(async (req) => { | ||
| // ... | ||
| }, { | ||
| onError: async (req, res) => { | ||
| await analytics.trackEvent(`Error ${res.code}: ${res.message}`) | ||
| return new NextResponse("Unkey error", { status: 500 }) | ||
| } | ||
| }); | ||
| ``` | ||
|
|
||
| ## ```handleInvalidKey``` | ||
|
|
||
| Specify what to do if Unkey reports that your key is invalid. | ||
|
|
||
| ```ts | ||
| export const GET = withUnkey(async (req) => { | ||
| // ... | ||
| }, { | ||
| handleInvalidKey: (req, res) => { | ||
| return new Response("Unauthorized", { status: 401 }) | ||
| } | ||
| }); | ||
| ``` |
There was a problem hiding this comment.
💡 Codebase verification
Issues Found: Inconsistent Indentation in README.md
The README.md file exhibits inconsistent indentation, using both tabs and spaces within the code examples and documentation. Specifically:
-
Uses Tabs:
getKey: (req) => new URL(req.url).searchParams.get("key"),onError: async (req, res) => {handleInvalidKey: (req, res) => {
-
Uses Spaces:
- Various lines in the documentation sections and other parts of the file.
Recommendation:
- Standardize Indentation: Adopt a single indentation style, preferably spaces, across all code examples and documentation to enhance readability and maintain consistency.
🔗 Analysis chain
LGTM: Customization options are well-explained with clear examples.
The customization section covers important options like getKey, onError, and handleInvalidKey, providing users with the flexibility to adapt the SDK to their needs.
- Consider using consistent indentation throughout the code examples. Some lines use tabs (e.g., lines 45, 57, 72) while others use spaces.
- In the
onErrorexample, consider adding a comment explaining whatres.codeandres.messagerepresent.
To check for consistent indentation across the file, run:
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check for consistent indentation in the README.md file
# Test: Look for lines with tabs
rg '\t' packages/nextjs/README.md
# Test: Look for lines with spaces at the beginning
rg '^ +' packages/nextjs/README.md
Length of output: 874
🧰 Tools
🪛 LanguageTool
[style] ~39-~39: You have already used this phrasing in nearby sentences. Consider replacing it to add variety to your writing.
Context: ... theauthorizationheader. If you want to customize this, you can do so by passin...(REP_WANT_TO_VB)
[uncategorized] ~51-~51: Did you mean: “By default,”?
Context: ... You can specify custom error handling. By default errors will be logged to the console, a...(BY_DEFAULT_COMMA)
🪛 Markdownlint
45-45: Column: 1
Hard tabs(MD010, no-hard-tabs)
57-57: Column: 1
Hard tabs(MD010, no-hard-tabs)
72-72: Column: 1
Hard tabs(MD010, no-hard-tabs)
|
Awarding Ionfinisher: 150 points 🕹️ Well done! Check out your new contribution on oss.gg/Ionfinisher |
What does this PR do?
This PR adds a README file for the
@unkey/nextjspackage on npm.Fixes #2162
Type of change
Checklist
Required
pnpm buildpnpm fmtconsole.logsgit pull origin mainAppreciated
Summary by CodeRabbit
@unkey/nextjsSDK, detailing installation, quickstart usage, and customization options.package.jsonto include the README file in the package distribution.