unjs / nitro

Next Generation Server Toolkit. Create web servers with everything you need and deploy them wherever you prefer.
https://nitro.unjs.io
MIT License
5.5k stars 472 forks source link

`.dev.ts` suffix for dev-only routes #1849

Closed manniL closed 2 months ago

manniL commented 8 months ago

Describe the feature

Hey all 👋🏻

An equivalent of e.g. Nuxt's <DevOnly> component for Nitro would be interesting and could be the .dev.ts suffix. All routes having a .dev suffix in the file would only be loaded during development and would not be present in production.

Benefits would be automatic removal on production and being able to define e.g. debug endpoints in your dev environment 🙌

Related: https://github.com/nuxt/nuxt/issues/18730

Additional information

pi0 commented 8 months ago

PR is welcome to implement this feature. We might also introduce a new dev flag to the event handler object type and allow programmatic registration of them.

manniL commented 2 months ago

Resolved via https://github.com/unjs/nitro/pull/2272 (nitro nightly at the moment)