Allow arbitrary route meta
Open
Nobody has claimed this yet.
enhancement
v2
- Dominant language
- TypeScript
- Stars
- 11.2k
- Forks
- 899
- Avg merge
- 2d 24m
- Merged PRs (30d)
- 40
Description
Describe the feature
Expose the route meta in event, so we can do something like mentioned below similar to nuxt middlewares
// server/api/index.ts
defineRouteMeta({
public: true,
});
export default defineEventHandler((event) => {
return "Start by editing <code>server/routes/index.ts</code>.";
});
// middleware/auth.ts
export default defineEventHandler((event) => {
const meta = getRouteMeta(event)
if (meta.public) return
// auth logic
});
Additional information
- Would you be willing to help implement this feature?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the example entry points in server/api/index.ts and middleware/auth.ts, then trace how route definitions and event context are exposed. Determine how arbitrary metadata should be attached to a route and retrieved with getRouteMeta(event). Done means defineRouteMeta({ public: true }) is available and middleware can read that value from the event.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100