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