// trailing slash is important here, as it enables to use the entire path while building relative URLs. For example, while visiting /users/123, the path ./add-photo leads to /users/add-photo. While visiting /users/123/ (note the trailing slash), the path ./add-photo leads to /users/123/add-photo
url:unescape_url_params(
"/"+
relative(
target_locreq.resolve("src/back/routes"),
resolve(
fullpath,
basename(fullpath).startsWith("index.")
?"../"
:""
)
).replace(/\..+/,"")+
"/"
).replace(/\/\//g,"/"),
}))
);
constroutes_content=`// DO NOT EDIT! This file is generated automaticaly with npm run generate-routes
export default function mountAutoRoutes(router: Router) {
${files
.sort(({url:url1}, { url: url2 }) =>
url1.includes(":") // make sure the parametrized ones come later, so the more concrete ones show up first. This is not a full solution, but works for single-parameter urls