Skip to content
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

docs: add link to FileRoute API in copy-pasteable code block #1060

Merged
merged 4 commits into from
Nov 20, 2024

Conversation

juliusmarminge
Copy link
Collaborator

@juliusmarminge juliusmarminge commented Nov 19, 2024

Since we've concluded people don't read the docs and just copy-paste the snippets (the link to the API referncce is literally the last word before the code block), including it in the actual code seems like a good shout to perhaps increase the chance they'll click it when they wanna make some changes - who knows...

Summary by CodeRabbit

Release Notes

  • Documentation Enhancements
    • Updated documentation for the UTApi TypeScript SDK, including constructor options and detailed property descriptions.
    • Clarified configuration for Express, Fastify, Fetch, H3, Astro, Nuxt, and other backend adapters, emphasizing the new maxFileCount limit of 1 for file uploads and optional input validation.
    • Expanded guidance on setting up UploadThing in various frameworks, including Next.js, Remix, SolidStart, and SvelteKit, with improved clarity on the onUploadComplete callback and middleware options.

Copy link

changeset-bot bot commented Nov 19, 2024

⚠️ No Changeset found

Latest commit: 00c1d81

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

coderabbitai bot commented Nov 19, 2024

Walkthrough

The changes involve extensive updates to the documentation for the UTApi TypeScript SDK and various backend adapters. Key modifications include enhancements to the UTApi constructor, clarifications on configuration options, and the introduction of a maxFileCount property across multiple documentation files. These updates aim to improve the clarity and usability of the documentation for developers integrating UploadThing into their applications.

Changes

File Path Change Summary
docs/src/app/(docs)/api-reference/ut-api/page.mdx Updated UTApi constructor to accept options; clarified configuration process; expanded properties section with detailed descriptions; documented methods and deprecations.
docs/src/app/(docs)/backend-adapters/express/page.mdx Updated maxFileCount from 4 to 1; added comments for FileRoutes configuration; clarified input validation options.
docs/src/app/(docs)/backend-adapters/fastify/page.mdx Updated maxFileCount from 4 to 1; added comments for FileRoutes configuration; highlighted input validation and middleware options.
docs/src/app/(docs)/backend-adapters/fetch/page.mdx Updated maxFileCount from 4 to 1; added comments for FileRoutes configuration; expanded section on Cloudflare Workers compatibility.
docs/src/app/(docs)/backend-adapters/h3/page.mdx Updated maxFileCount from 4 to 1; added comments for FileRoutes configuration; emphasized unique route slugs and options reference.
docs/src/app/(docs)/getting-started/appdir/page.mdx Added maxFileCount to imageUploader; emphasized onUploadComplete callback; expanded setup instructions and SSR guidance.
docs/src/app/(docs)/getting-started/astro/page.mdx Added maxFileCount to imageUploader; emphasized client-side validation; refined documentation structure.
docs/src/app/(docs)/getting-started/expo/page.mdx Added maxFileCount to imageUploader; updated route slug; clarified FileRoute options.
docs/src/app/(docs)/getting-started/nuxt/page.mdx Introduced maxFileCount for imageUploader; emphasized exporting the router; clarified input validation and middleware sections.
docs/src/app/(docs)/getting-started/pagedir/page.mdx Added maxFileCount and input validation to imageUploader; emphasized middleware function and upload completion callback.
docs/src/app/(docs)/getting-started/remix/page.mdx Added maxFileCount to imageUploader; emphasized optional input validation; updated code snippets for clarity.
docs/src/app/(docs)/getting-started/solid/page.mdx Added maxFileCount to imageUploader; emphasized input validation and middleware; refined documentation structure.
docs/src/app/(docs)/getting-started/svelte/page.mdx Added maxFileCount to imageUploader; emphasized onUploadComplete callback and middleware; enhanced clarity in setup instructions.
docs/src/app/(docs)/getting-started/tanstack-start/page.mdx Added maxFileCount to imageUploader; included optional input validation; improved formatting and organization of content.

Possibly related PRs

Suggested labels

examples

🐰 In the meadow, where the code does play,
New options sprout, brightening the way.
With maxFileCount now set to one,
Documentation shines, oh what fun!
Hop along, dear devs, to explore and delight,
With clearer paths, your projects take flight! 🌼✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between d3899fe and 00c1d81.

📒 Files selected for processing (1)
  • docs/src/app/(docs)/api-reference/ut-api/page.mdx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • docs/src/app/(docs)/api-reference/ut-api/page.mdx

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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

vercel bot commented Nov 19, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs-uploadthing ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 20, 2024 3:32pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
legacy-docs-uploadthing ⬜️ Ignored (Inspect) Visit Preview Nov 20, 2024 3:32pm

Copy link
Contributor

github-actions bot commented Nov 19, 2024

📦 Bundle size comparison

Bundle Size (gzip) Visualization
Main 27.59KB See Treemap 📊
PR (828493c) 27.59KB See Treemap 📊
Diff No change

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 (4)
docs/src/app/(docs)/getting-started/remix/page.mdx (1)

65-74: LGTM! Well-documented configuration with API reference.

The code example effectively demonstrates the FileRoute configuration with proper documentation links. Consider making the API reference link more prominent by adding a dedicated comment line:

  imageUploader: f({
    image: {
      /**
       * For full list of options and defaults, see the File Route API reference
       * @see https://docs.uploadthing.com/file-routes#route-config
+      * 
+      * 👉 See API Reference: https://docs.uploadthing.com/file-routes#route-config
       */
      maxFileSize: "4MB",
      maxFileCount: 1,
    },
  })
docs/src/app/(docs)/api-reference/ut-api/page.mdx (3)

35-37: Consider enhancing the example with common configuration options

The current example shows an empty options object. To make it more practical and educational, consider showing common configuration options that users typically need.

 export const utapi = new UTApi({
-  // ...options,
+  // Configure logging level for better debugging
+  logLevel: "Info",
+  // Override default key type if using custom IDs
+  defaultKeyType: "fileKey",
+  // See FileRoute API docs for more configuration options:
+  // https://docs.uploadthing.com/api-reference/file-routes
 });

43-43: Fix grammar: "variables follows" should be "variables follow"

There's a subject-verb agreement issue in this sentence.

-Environment variables follows the naming convention
+Environment variables follow the naming convention
🧰 Tools
🪛 LanguageTool

[grammar] ~43-~43: It seems that the correct verb form here is “follow”.
Context: ...onment variables. Environment variables follows the naming convention of `UPLOADTHING_<...

(AGREEMENT_SENT_START_2)


42-46: Consider clarifying environment variable precedence

The current text states that "If both are set, the config object takes precedence" but it might be helpful to provide an example demonstrating this precedence.

 You can configure the SDK either by passing them as options to the constructor,
 or by setting them as environment variables. Environment variables follow the
 naming convention of `UPLOADTHING_<NAME>`, where `<NAME>` is the name of the
 config option in constant case, e.g. `UPLOADTHING_LOG_LEVEL`. If both are set,
-the config object takes precedence.
+the config object takes precedence. For example:
+
+```ts
+// Environment: UPLOADTHING_LOG_LEVEL=Error
+
+// This will use "Debug" level despite the environment variable
+const utapi = new UTApi({ logLevel: "Debug" });
+```
🧰 Tools
🪛 LanguageTool

[grammar] ~43-~43: It seems that the correct verb form here is “follow”.
Context: ...onment variables. Environment variables follows the naming convention of `UPLOADTHING_<...

(AGREEMENT_SENT_START_2)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between a9b6559 and d3899fe.

📒 Files selected for processing (14)
  • docs/src/app/(docs)/api-reference/ut-api/page.mdx (1 hunks)
  • docs/src/app/(docs)/backend-adapters/express/page.mdx (2 hunks)
  • docs/src/app/(docs)/backend-adapters/fastify/page.mdx (2 hunks)
  • docs/src/app/(docs)/backend-adapters/fetch/page.mdx (2 hunks)
  • docs/src/app/(docs)/backend-adapters/h3/page.mdx (2 hunks)
  • docs/src/app/(docs)/getting-started/appdir/page.mdx (2 hunks)
  • docs/src/app/(docs)/getting-started/astro/page.mdx (2 hunks)
  • docs/src/app/(docs)/getting-started/expo/page.mdx (3 hunks)
  • docs/src/app/(docs)/getting-started/nuxt/page.mdx (2 hunks)
  • docs/src/app/(docs)/getting-started/pagedir/page.mdx (2 hunks)
  • docs/src/app/(docs)/getting-started/remix/page.mdx (2 hunks)
  • docs/src/app/(docs)/getting-started/solid/page.mdx (2 hunks)
  • docs/src/app/(docs)/getting-started/svelte/page.mdx (2 hunks)
  • docs/src/app/(docs)/getting-started/tanstack-start/page.mdx (2 hunks)
🧰 Additional context used
🪛 LanguageTool
docs/src/app/(docs)/api-reference/ut-api/page.mdx

[grammar] ~43-~43: It seems that the correct verb form here is “follow”.
Context: ...onment variables. Environment variables follows the naming convention of `UPLOADTHING_<...

(AGREEMENT_SENT_START_2)

🔇 Additional comments (29)
docs/src/app/(docs)/backend-adapters/fastify/page.mdx (2)

43-44: LGTM! Clear and concise documentation.

The added bullet point about file count limits enhances the FileRoute configuration documentation, making it more comprehensive.


57-65: Excellent addition of the API reference link!

The changes effectively address the PR's objective by:

  1. Adding a clear TSDoc comment with the API reference link
  2. Making it easily discoverable within the code block
  3. Setting a consistent maxFileCount value

This improves the documentation's usability, especially for users who copy-paste code snippets.

docs/src/app/(docs)/backend-adapters/express/page.mdx (2)

43-44: LGTM! Clear and concise documentation addition

The added line about file count limitations provides important information about FileRoute configuration options.


60-63: Excellent documentation enhancement!

The added JSDoc comment effectively implements the PR's objective by:

  1. Making the API reference link visible in the copy-pasteable code block
  2. Using proper JSDoc format for better IDE integration
  3. Providing a clear pointer to comprehensive documentation

The maxFileCount: 1 update aligns with the standardization across other adapters.

Also applies to: 65-65

docs/src/app/(docs)/backend-adapters/h3/page.mdx (2)

47-48: LGTM! Clear and informative documentation addition.

The added documentation clearly explains the optional features available in FileRoutes.


61-69: Excellent documentation improvements!

The changes effectively enhance the code block with:

  1. Clear guidance about unique route slugs
  2. A well-formatted JSDoc comment with the API reference link
  3. Consistent configuration values

This aligns perfectly with the PR objective of making API documentation more accessible within copy-pasteable code blocks.

docs/src/app/(docs)/getting-started/solid/page.mdx (3)

41-42: LGTM: Clear documentation addition

The new bullet point about file count limits is a valuable addition to the FileRoute feature list, providing users with important information about upload constraints.


59-68: Excellent addition of API reference link in the code block

The changes successfully implement the PR objective by:

  1. Adding a well-formatted JSDoc comment with the API reference link
  2. Placing it where users are most likely to see it when copying the code
  3. Including the maxFileCount configuration as a practical example

This improves the documentation's usefulness for copy-paste scenarios.


63-64: Verify documentation consistency

Let's ensure the API reference link and maxFileCount configuration are consistent across all documentation files.

✅ Verification successful

Documentation is consistent across all files

The verification shows that:

  • The API reference link @see https://docs.uploadthing.com/file-routes#route-config is consistently used across all framework-specific documentation files
  • The maxFileCount: 1 configuration is uniformly applied in all getting-started guides and backend adapter documentation
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for consistency of API reference links and maxFileCount configurations

# Check for API reference links in code blocks
echo "Checking API reference links in code blocks..."
rg -U '@see https://docs\.uploadthing\.com/file-routes#route-config' docs/

# Check for maxFileCount configurations
echo "Checking maxFileCount configurations..."
rg -U 'maxFileCount: 1' docs/

Length of output: 3046

docs/src/app/(docs)/getting-started/pagedir/page.mdx (3)

45-46: Documentation additions look good!

The new entries about file count limits and input validation enhance the completeness of the FileRoute description.


66-75: Excellent documentation enhancement!

The addition of the JSDoc comment with the API reference link is a great practice as it:

  1. Makes the documentation accessible right in the code
  2. Will be visible in IDEs during copy-paste
  3. Helps users find the complete API reference when needed

70-70: Verify the documentation link

Let's ensure the File Route API documentation link is valid and accessible.

docs/src/app/(docs)/getting-started/remix/page.mdx (1)

44-45: LGTM! Clear documentation addition.

The added bullet point about file count limits provides important context for the FileRoute configuration options.

docs/src/app/(docs)/getting-started/tanstack-start/page.mdx (2)

41-42: LGTM! Clear and helpful additions to the FileRoute capabilities list.

The new bullet points effectively document the maxFileCount parameter and input validation feature.


60-69: Excellent documentation enhancement!

The added JSDoc comment with the API reference link is a great solution for making documentation more accessible in copy-pasteable code blocks. The example also correctly demonstrates the maxFileCount parameter usage.

docs/src/app/(docs)/getting-started/expo/page.mdx (3)

57-58: LGTM: Clear documentation of file count limits

The addition clearly explains that FileRoutes can specify how many files are allowed to be uploaded.


74-82: Excellent documentation improvements!

The changes enhance the code example by:

  1. Clarifying that multiple FileRoutes can be defined
  2. Adding a helpful link to the API reference directly in the code comments
  3. Demonstrating the maxFileCount configuration consistently with the documentation

159-159: LGTM: Consistent usage example

The example correctly demonstrates using the imageUploader route, maintaining consistency with the FileRoute definition shown earlier.

docs/src/app/(docs)/getting-started/nuxt/page.mdx (2)

86-87: LGTM: Clear documentation addition

The new bullet point about file count limits is well-placed and clearly explains this configuration option.


112-121: Excellent documentation enhancement!

The changes effectively address the PR objective by:

  1. Adding the API reference link in a JSDoc comment, making it visible when code is copied
  2. Providing helpful context about available options
  3. Demonstrating the maxFileCount usage with a practical example

This is a great example of documentation that stays with the code even after copy-pasting.

docs/src/app/(docs)/backend-adapters/fetch/page.mdx (3)

45-46: LGTM: Clear documentation addition

The added bullet point about file count limitations is clear and helpful for users understanding FileRoute constraints.


59-67: Excellent documentation improvements!

The changes effectively enhance the code example by:

  1. Adding a clear reference to the File Route API documentation
  2. Including the maxFileCount configuration
  3. Providing context about multiple FileRoutes capability

This is particularly valuable since users often copy-paste code examples, and the embedded API link increases the likelihood they'll find the complete documentation.


Line range hint 45-67: Documentation maintains high quality and achieves PR objectives

The changes successfully integrate the API reference link into the code block while maintaining clear structure and readability. The additions about file count limitations and multiple FileRoutes provide valuable context exactly where users need it.

docs/src/app/(docs)/getting-started/astro/page.mdx (2)

50-51: LGTM! Clear documentation addition.

The new bullet point about file count limits is a valuable addition that helps users understand the available configuration options for FileRoutes.


68-77: Well-implemented API reference link in the code block!

The addition of the JSDoc comment with the API reference link is strategically placed where users are most likely to need it when configuring their FileRoute. This effectively achieves the PR's goal of making the API documentation more accessible to users who copy-paste code.

The maxFileCount configuration is also clearly documented with a practical example.

docs/src/app/(docs)/getting-started/appdir/page.mdx (2)

44-45: LGTM! Clear documentation about file count limits.

The addition clearly documents that FileRoutes can specify how many files are allowed to be uploaded.


63-72: Great addition of the API reference link in the code block!

The JSDoc comment with the link to the File Route API reference is a good practice as it:

  1. Makes the documentation accessible within copy-pasteable code
  2. Follows proper JSDoc conventions
  3. Provides immediate access to detailed API information

This aligns perfectly with the PR objective of improving documentation accessibility.

docs/src/app/(docs)/getting-started/svelte/page.mdx (2)

41-42: LGTM! Clear and concise documentation additions.

The new bullet points effectively explain the maxFileCount and input validation features of FileRoutes.


60-69: Excellent implementation of the API reference link!

The changes effectively achieve the PR's objective by:

  1. Adding the API reference link in a JSDoc comment that will be preserved when users copy the code
  2. Using the @see tag which is a standard documentation practice
  3. Providing a practical example of the maxFileCount configuration

Co-authored-by: Mark R. Florkowski <mark.florkowski@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants