Alert about not loaded files in routes folder
monolithed opened this issue · 5 comments
First of all, I want to say thank you for your work!
It's a bit unclear from the logs why there are no routes when they actually exist.
I suggest adding a check for the presence of TS files, so that the reason for the issue can be understood immediately.
Hi @monolithed , I suppose that you have no routes because you didn't configure TypeScript properly, so there is an error when trying to load them. I think that adding a check to infere the cause of the reason of any possible error in route files may not be possible, or at least it may not worth. Currently you can see warnings in the server logs, in the CLI, and even in the admin REST API when there are errors loading routes, so I think it could be enough to deduce why there are no routes loaded. In order to improve it, maybe the warning message could include a clearer notice informing that the routes in the file won't be loaded because of the error.
And maybe we can also add a link below the documentation TypeScript examples to the "Configuring TypeScript" chapter.
@javierbrea I created this issue due to my own inattentiveness. From the examples in the documentation, I got the impression that TypeScript support is built-in. That's not the case, and I realized that upon revisiting the documentation. Nevertheless, I believe this issue is relevant because there is no explanation in the logs for people who make the same mistake. What I mean is that the routing files exist, but the server acts as if they don't. Why not add information stating that the files exist, but an adapter needs to be included for the server to pull them?
Hi again @monolithed , the problem is that the server doesn't look for .ts
files until it is explicitly configured to do so, so, in fact, for it there are no route files... I suppose that it could search for ts files when typescript is disabled, and print a warning in that case, but in my opinion it would be too much "coupled"...what would happen if you have js files and one ts file? It would load the js files, but also print a warning about enabling TypeScript.
@javierbrea hi, I got it, what if you add this information about the possible absence of a TS adapter only to the --verbose log output?
I'm not sure about that. As I said, searching only for .ts files is too much coupled to a specific usage. Maybe it could be implemented as a generic search for any type of not loaded files in the routes folder, and, in that case, add a warning about them. I suppose that it may be helpful in case you are trying to use TypeScript without enabling it, because you'll see that the files are not loaded, and it also may be helpful in any other case.
I'll let the issue opened and I'll rename it into "Add warning about not loaded files in routes folder", if you don't mind.
If you need this feature right now, you can implement it in a plugin or you could even implement it in the core and open a PR, that are always welcome 😃