faster
faster copied to clipboard
FR: add prefix option for .use()
Hi, Thanks for giving from your time and creating a small, super-fast server library for Deno!
I'd like to ask for a feature;
In express.js
(and many others) you can set a prefix for the routes you define, in the following way:
import { usersRoute } from "./users.ts"
import { teamsRoute } from "./teams.ts"
import { v2Route } from "./v2.ts"
const route = new Route()
route.use('/users', usersRoute)
route.use('/teams', teamsRoute)
route.use('/api/v2', v2Route)
route.get(
'/',
res('json'),
req('json'),
async (ctx: any, next: any) => { ... } // etc
)
The use-case here is to give a prefix to all the routes in usersRoute
, teamsRoute
..
Then, if in usersRoute
I defined the following route:
route.get(
'/payments',
res('json'),
req('json'),
async (ctx: any, next: any) => { ... } // etc
)
then it will be served in localhost:80/users/payments
.
If you prefer me to work on it and create a PR, I'll be happy to. Thanks in advance
Hello, I will work on this feature. It is simple to implement. Will be available soon.
I added your feature with native JavaScript resources, see: https://github.com/hviana/faster#organizing-routes-in-files