mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-10 19:14:16 +00:00
improve route generation
This commit is contained in:
parent
bfdad744a4
commit
75adbc0c96
@ -48,18 +48,20 @@ function createRoutesFromDirectory(startFrom, directoryPath, router) {
|
|||||||
route = route.replace(".ts", "")
|
route = route.replace(".ts", "")
|
||||||
route = route.replace(".tsx", "")
|
route = route.replace(".tsx", "")
|
||||||
|
|
||||||
if (route === "index") {
|
if (route.endsWith("/index")) {
|
||||||
route = "/"
|
route = route.replace("/index", "")
|
||||||
} else {
|
|
||||||
route = `/${route}`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
route = `/${route}`
|
||||||
|
|
||||||
let handler = require(filePath)
|
let handler = require(filePath)
|
||||||
|
|
||||||
handler = handler.default || handler
|
handler = handler.default || handler
|
||||||
|
|
||||||
router[method](route, createRouteHandler(route, handler))
|
router[method](route, createRouteHandler(route, handler))
|
||||||
|
|
||||||
|
//console.log(`[ROUTE] ${method.toUpperCase()} [${route}]`, handler)
|
||||||
|
|
||||||
router.routes.push({
|
router.routes.push({
|
||||||
method,
|
method,
|
||||||
path: route,
|
path: route,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user