improve route generation

This commit is contained in:
SrGooglo 2023-05-31 19:37:22 +00:00
parent 11963ad33c
commit b4aead86d8

View File

@ -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,