Skip to content

docs: improve jsdocs#4199

Open
RihanArfan wants to merge 9 commits intomainfrom
docs/jsdocs
Open

docs: improve jsdocs#4199
RihanArfan wants to merge 9 commits intomainfrom
docs/jsdocs

Conversation

@RihanArfan
Copy link
Copy Markdown
Member

❓ Type of change

  • 📖 Documentation (updates to the documentation, readme, or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

Adds additional jsdocs and links to docs pages.

Also corrects some old jsdocs @see links to point to new docs routes.

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@RihanArfan RihanArfan requested a review from pi0 as a code owner April 10, 2026 16:27
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 10, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
nitro.build Ready Ready Preview, Comment Apr 16, 2026 9:10pm

Request Review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 10, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR adds comprehensive JSDoc documentation to Nitro's exported type definitions across src/types/, including configuration, handler, module, routing, OpenAPI, and runtime types. One structural change removes an index signature from NitroMeta; all other modifications are documentation-only.

Changes

Cohort / File(s) Summary
Configuration Documentation
src/types/config.ts
Added extensive JSDoc for NitroOptions (fully resolved/normalized options) and NitroConfig (input config) interfaces; documented new exported partial types including LoadConfigOptions, CompressOptions, StorageMounts, DatabaseConnection\*, and NitroRuntimeConfig variants.
Handler & Module Types
src/types/handler.ts, src/types/module.ts
Expanded JSDoc for NitroRouteMeta, refined field comments on NitroHandlerCommon; added documentation for EventHandlerFormat, NitroEventHandler, NitroDevEventHandler, NitroErrorHandler, and NitroModule configuration shapes.
Core Nitro Type
src/types/nitro.ts
Removed catch-all index signature from NitroMeta (restricting to version/majorVersion only); added JSDoc for Nitro instance, NitroDynamicConfig, NitroFrameworkInfo, and NitroBuildInfo.
OpenAPI & Routing Configuration
src/types/openapi.ts, src/types/route-rules.ts
Updated JSDoc for SwaggerUIConfig and NitroOpenAPIConfig with default route values and expanded enum descriptions; added documentation for HTTPstatus type and NitroRouteConfig/NitroRouteRules normalization semantics.
Runtime Types
src/types/runtime/cache.ts, src/types/runtime/nitro.ts
Added JSDoc documentation for CachedEventHandlerOptions; documented NitroApp, NitroAppPlugin, CapturedErrorContext, CaptureError, and NitroRuntimeHooks with lifecycle and error handling context.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'docs: improve jsdocs' follows conventional commits format with type 'docs' and a clear, specific description of the changes.
Description check ✅ Passed The description clearly relates to the changeset, detailing JSDoc additions, documentation links, and corrections to outdated references across multiple type files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch docs/jsdocs

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
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: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/types/config.ts`:
- Line 455: Update the cron expression in the scheduledTasks example to the
correct syntax by replacing the invalid string "**​/5 * * * *" with "*/5 * * *
*" in the scheduledTasks documentation or example (search for the scheduledTasks
constant/type or the doc block containing that cron example in
src/types/config.ts and update the example string).

In `@src/types/nitro.ts`:
- Around line 18-21: The removal of the index signature from the NitroMeta
interface breaks assignability for consumers that add arbitrary keys; restore
backward compatibility by reintroducing the index signature (e.g., add [key:
string]: any to NitroMeta) or, if you intend this as a breaking change,
explicitly mark it in the changelog/release notes and add migration guidance
explaining how callers should migrate off storing extra keys; locate NitroMeta
in the src/types/nitro.ts file to apply one of these two remedies.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: fc91ea1a-75db-4cc9-9f60-37ac3fa50912

📥 Commits

Reviewing files that changed from the base of the PR and between 896186a and d427adc.

📒 Files selected for processing (8)
  • src/types/config.ts
  • src/types/handler.ts
  • src/types/module.ts
  • src/types/nitro.ts
  • src/types/openapi.ts
  • src/types/route-rules.ts
  • src/types/runtime/cache.ts
  • src/types/runtime/nitro.ts

Comment thread src/types/config.ts Outdated
Comment thread src/types/nitro.ts
Comment thread src/types/runtime/cache.ts Outdated
Comment thread src/types/config.ts
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 10, 2026

Open in StackBlitz

npm i https://pkg.pr.new/nitro@4199

commit: c712ee1

Comment thread src/types/config.ts Outdated
Comment thread src/types/config.ts
Comment thread src/types/config.ts
Copy link
Copy Markdown
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: 4

🧹 Nitpick comments (2)
docs/1.docs/50.websocket.md (1)

113-147: Consider varying repeated “Called …” hook descriptions.

The lifecycle hook section reads a bit repetitive; rephrasing one or two lead sentences would improve flow.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/1.docs/50.websocket.md` around lines 113 - 147, The lifecycle hook
descriptions for open, message, close, and error are repetitive — change one or
two lead sentences to vary wording while keeping meaning; for example, rephrase
the `open(peer)` intro to "Invoked when a connection is established" and the
`message(peer, message)` intro to "Triggered on incoming messages", leaving
`close(peer, details)` and `error` as-is (or similarly vary them) so the hooks
`open`, `message`, `close`, and `error` are clearer and the section reads less
repetitive.
src/presets/vercel/runtime/queue-handler.ts (1)

10-11: Avoid console.error here to match source logging rules.

On Line 10, console.error is used in src/presets/...; this violates the repo logging guideline for src/**/*.

Proposed patch
 export default defineHandler((event) => {
   return handleCallback(async (message, metadata) => {
     try {
       await useNitroHooks().callHook("vercel:queue", { message, metadata, send });
     } catch (error) {
-      console.error("[vercel:queue]", error);
       useNitroApp().captureError?.(error as Error, { event, tags: ["vercel:queue"] });
       throw error;
     }
   })(event.req as Request);
 });
As per coding guidelines: `src/**/*.{ts,js}`: Use `console` only in `src/runtime/` code; use `nitro.logger` in build/dev code or `consola` as fallback.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/presets/vercel/runtime/queue-handler.ts` around lines 10 - 11, Replace
the direct console.error call with the repo-approved logger: get the Nitro
logger (via useNitroApp()/nitro?.logger) or fall back to consola and call
logger.error with the same context; specifically, where
console.error("[vercel:queue]", error) currently appears in queue-handler.ts,
change it to use the Nitro/logger error method and preserve passing the error
and contextual tags (the surrounding code uses
useNitroApp().captureError?.(error as Error, { event, tags: ["vercel:queue"] })
so ensure the logger message includes the "[vercel:queue]" tag and the error
object and only use consola if nitro.logger is not available).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/2.deploy/20.providers/vercel.md`:
- Around line 151-169: The example uses defineNitroConfig but should use
defineConfig for consistency with the rest of the docs; update the example in
the nitro.config.ts snippet to replace defineNitroConfig with defineConfig and
ensure the snippet imports defineConfig from "nitro" (or uses the same import
style as other examples on the page) so the config block uses defineConfig({
vercel: { queues: { ... } } });.

In `@package.json`:
- Around line 175-185: Update the zephyr-agent version alignment in package.json
so peerDependencies matches what we test in devDependencies: either widen the
peer range from "zephyr-agent": "^0.2.0" to include 1.x (e.g., "^1.0.0" or
"^1.0.0 || ^0.2.0") inside the peerDependencies block, or instead pin
devDependencies' zephyr-agent back to the advertised "^0.2.0"; adjust the
"zephyr-agent" entry in peerDependencies (and devDependencies if you choose to
change that) so both entries are consistent.

In `@src/runtime/internal/routes/dev-tasks.ts`:
- Around line 9-10: The payload construction uses
Object.fromEntries(event.url.searchParams.entries()) which drops duplicate query
keys; change the logic that builds payload (the const payload in this handler)
to iterate over event.url.searchParams.keys() or entries and use
event.url.searchParams.getAll(key) so that keys with multiple values become
arrays (and single values remain scalars), ensuring ?array=1&array=2 yields
["1","2"] instead of "2"; update the payload assembly to map each key to either
a single value or the array returned by getAll().
- Around line 8-12: The current parsing uses event.req.json().catch(() => ({}))
which hides malformed JSON and allows POST tasks to run; change this in the
handler that builds body/payload so JSON syntax errors return a 400 response
instead of falling back to {}: explicitly try to parse event.req.json(), on a
SyntaxError (or JSON parse failure) return a 400 with an explanatory message,
but preserve the empty-object fallback only when the request has no body (e.g.,
Content-Length === 0 or missing body), and then continue building payload from
the validated body and event.url.searchParams as before.

---

Nitpick comments:
In `@docs/1.docs/50.websocket.md`:
- Around line 113-147: The lifecycle hook descriptions for open, message, close,
and error are repetitive — change one or two lead sentences to vary wording
while keeping meaning; for example, rephrase the `open(peer)` intro to "Invoked
when a connection is established" and the `message(peer, message)` intro to
"Triggered on incoming messages", leaving `close(peer, details)` and `error`
as-is (or similarly vary them) so the hooks `open`, `message`, `close`, and
`error` are clearer and the section reads less repetitive.

In `@src/presets/vercel/runtime/queue-handler.ts`:
- Around line 10-11: Replace the direct console.error call with the
repo-approved logger: get the Nitro logger (via useNitroApp()/nitro?.logger) or
fall back to consola and call logger.error with the same context; specifically,
where console.error("[vercel:queue]", error) currently appears in
queue-handler.ts, change it to use the Nitro/logger error method and preserve
passing the error and contextual tags (the surrounding code uses
useNitroApp().captureError?.(error as Error, { event, tags: ["vercel:queue"] })
so ensure the logger message includes the "[vercel:queue]" tag and the error
object and only use consola if nitro.logger is not available).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7574b6ff-9ab4-454c-9874-b8adfac24e2b

📥 Commits

Reviewing files that changed from the base of the PR and between 68d06e1 and d561fa0.

⛔ Files ignored due to path filters (2)
  • docs/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (46)
  • .github/workflows/ci.yml
  • .github/workflows/npm-publish.yml
  • docs/.config/docs.yaml
  • docs/1.docs/2.quick-start.md
  • docs/1.docs/4.renderer.md
  • docs/1.docs/5.routing.md
  • docs/1.docs/50.assets.md
  • docs/1.docs/50.configuration.md
  • docs/1.docs/50.database.md
  • docs/1.docs/50.lifecycle.md
  • docs/1.docs/50.openapi.md
  • docs/1.docs/50.plugins.md
  • docs/1.docs/50.tasks.md
  • docs/1.docs/50.websocket.md
  • docs/1.docs/6.server-entry.md
  • docs/1.docs/7.cache.md
  • docs/1.docs/8.storage.md
  • docs/1.docs/99.migration.md
  • docs/2.deploy/0.index.md
  • docs/2.deploy/20.providers/aws-amplify.md
  • docs/2.deploy/20.providers/aws.md
  • docs/2.deploy/20.providers/cloudflare.md
  • docs/2.deploy/20.providers/iis.md
  • docs/2.deploy/20.providers/vercel.md
  • docs/2.deploy/20.providers/zephyr.md
  • docs/3.config/0.index.md
  • docs/4.examples/plugins.md
  • docs/package.json
  • examples/plugins/README.md
  • examples/plugins/server.ts
  • package.json
  • scripts/update-deps.ts
  • src/presets/deno/runtime/deno-deploy.ts
  • src/presets/vercel/preset.ts
  • src/presets/vercel/runtime/queue-handler.ts
  • src/presets/vercel/types.ts
  • src/presets/vercel/utils.ts
  • src/runtime/internal/routes/dev-tasks.ts
  • src/runtime/internal/routes/swagger.ts
  • src/types/config.ts
  • src/types/nitro.ts
  • src/types/openapi.ts
  • src/types/route-rules.ts
  • src/types/runtime/nitro.ts
  • test/presets/nitro-dev.test.ts
  • test/presets/vercel.test.ts
✅ Files skipped from review due to trivial changes (25)
  • docs/2.deploy/20.providers/zephyr.md
  • docs/2.deploy/0.index.md
  • .github/workflows/npm-publish.yml
  • docs/1.docs/50.plugins.md
  • docs/2.deploy/20.providers/iis.md
  • docs/1.docs/6.server-entry.md
  • docs/2.deploy/20.providers/aws-amplify.md
  • docs/1.docs/7.cache.md
  • docs/1.docs/50.assets.md
  • examples/plugins/server.ts
  • docs/1.docs/8.storage.md
  • docs/1.docs/4.renderer.md
  • docs/1.docs/50.configuration.md
  • docs/2.deploy/20.providers/aws.md
  • src/presets/vercel/utils.ts
  • docs/package.json
  • docs/1.docs/50.database.md
  • src/types/runtime/nitro.ts
  • docs/4.examples/plugins.md
  • docs/2.deploy/20.providers/cloudflare.md
  • docs/1.docs/50.openapi.md
  • src/types/nitro.ts
  • examples/plugins/README.md
  • docs/.config/docs.yaml
  • src/types/route-rules.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/types/config.ts

Comment thread docs/2.deploy/20.providers/vercel.md
Comment thread package.json
Comment on lines +175 to +185
"zephyr-agent": "^1.0.1"
},
"peerDependencies": {
"@vercel/queue": "^0.1.4",
"dotenv": "*",
"giget": "*",
"jiti": "^2.6.1",
"rollup": "^4.60.1",
"vite": "^7 || ^8",
"xml2js": "^0.6.2",
"zephyr-agent": "^0.1.15"
"zephyr-agent": "^0.2.0"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# First, locate and read the package.json file
find . -name "package.json" -type f | head -5

Repository: nitrojs/nitro

Length of output: 232


🏁 Script executed:

# Read the relevant sections of package.json around lines 175-185
head -200 package.json | tail -50

Repository: nitrojs/nitro

Length of output: 1161


🏁 Script executed:

# Get a better view of the entire devDependencies and peerDependencies sections
rg '"(devDependencies|peerDependencies)"' -A 30 package.json

Repository: nitrojs/nitro

Length of output: 1734


Align the zephyr-agent peer range with the version this repo tests against.

devDependencies specifies ^1.0.1, but peerDependencies advertises only ^0.2.0. This excludes the version being tested locally and will produce unnecessary peer-version conflicts for consumers on 1.x. Widen the peer range to ^1.0.0 or pin devDependencies back to the advertised 0.2.0 range.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@package.json` around lines 175 - 185, Update the zephyr-agent version
alignment in package.json so peerDependencies matches what we test in
devDependencies: either widen the peer range from "zephyr-agent": "^0.2.0" to
include 1.x (e.g., "^1.0.0" or "^1.0.0 || ^0.2.0") inside the peerDependencies
block, or instead pin devDependencies' zephyr-agent back to the advertised
"^0.2.0"; adjust the "zephyr-agent" entry in peerDependencies (and
devDependencies if you choose to change that) so both entries are consistent.

Comment thread src/runtime/internal/routes/dev-tasks.ts
Comment thread src/runtime/internal/routes/dev-tasks.ts
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