Can we decouple API routes from file based routing #24968
francisashley
started this conversation in
Ideas
Replies: 2 comments 1 reply
-
I have also posted about this in the nitro repo unjs/nitro#2042 |
Beta Was this translation helpful? Give feedback.
0 replies
-
do you need define routing like this? import { createRouter, useBase } from 'h3';
import test from '~~/server/controllers/test.ts';
const router = createRouter();
router.get('/test', test.get);
export default useBase('/api', router.handler); |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The current approach is verbose and frustrating to use for advanced projects. Ideally we have the option to register all API routes in a single roots file and pass in handler functions ourselves.
Currently the closest thing we can do to is register custom paths to files to handle the response (file based routing):
If the handler field can be changed to also support a function, this would be so much cleaner to work with:
Beta Was this translation helpful? Give feedback.
All reactions