nitrojs / nitrojs/nitro

Allow dynamic code within `defineRouteMeta`

Open
#2,974 15 comments 61 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement v2
Dominant language
TypeScript
Stars
11.2k
Forks
899
Avg merge
2d 24m
Merged PRs (30d)
40

Description

Related:

  • #2641
  • #2912

Experimental route meta (#2102) (docs) only allows static definition like this:

defineRouteMeta({
  openAPI: {
    tags: ["test"],
    description: "Test route description",
    parameters: [{ in: "query", name: "test", required: true }],
  },
});

However, users might want to generate it with other tools like zod.

In order to support this, we need to update handlers-meta rollup plugin to detect defineRouteMeta and actually evaluate (run) the code necessary in place since by-design this information should be statically extracted into the bundle.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with src/rollup/plugins/handlers-meta.ts and the existing defineRouteMeta handling, then review the related issues #2641 and #2912 plus the route-meta documentation. Determine how the plugin can evaluate code such as metadata generated with tools like zod while still extracting the result into the bundle. Done means dynamic defineRouteMeta values are evaluated and included in generated route metadata.

Written by the indexing model from the issue text.

Assessment

Tech stack
rollup, typescript
Domain
build-system, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.