denoland / fresh

The next-gen web framework.
https://fresh.deno.dev
MIT License
12.57k stars 649 forks source link

Behavior of `/[dynamic].ext` routes together with `/static.ext` #475

Open synalice opened 2 years ago

synalice commented 2 years ago

Proposing a feature of an error (or a warning) being returned to the developer when trying to create a single /[dynamic].ext route in the same folder with /static.ext routes, or when creating multiple /[dynamic].ext routes in the same folder. Doing this may lead to an unexpected behavior and thus should be discouraged.

Screenshot from 2022-07-08 00-40-35 It should be obvious which file will be returned instead of Fresh choosing one over the other.

Related issue: https://github.com/denoland/fresh/issues/461

iamsahilsonawane commented 2 years ago

@synalice I think it uses the static routes first over the dynamic ones (priority wise).

It works fine creating a new project and adding static routes on the relative path to dynamic ones

Recording example: https://user-images.githubusercontent.com/47249618/177854292-b182fb60-6600-4e48-a962-7afbdf2a79cc.mp4

synalice commented 2 years ago

@iamsahilsonawane, yes, I know it does choose static over the dynamic and works fine. What I'm saying is that most of the time it wouldn't be a wise decision to put dynamic routes together with static, and the developer should be warned about what's he doing.

iamsahilsonawane commented 2 years ago

@iamsahilsonawane, yes, I know it does choose static over the dynamic and works fine. What I'm saying is that most of the time it wouldn't be a wise decision to put dynamic routes together with static, and the developer should be warned about what's he doing.

Yes, I see, I think there should be lints implemented for this

nhc commented 2 years ago

I would be interested in helping with this (and getting involved generally)

@lucacasonato - you tagged good-first-issue

Would you (or anyone) be able to give any pointers as to where and how you would like the warning to be shown? I'm currently thinking it would show in the terminal output where the developer has started the process?

iamsahilsonawane commented 2 years ago

Would you (or anyone) be able to give any pointers as to where and how you would like the warning to be shown? I'm currently thinking it would show in the terminal output where the developer has started the process?

IMO yes, there should be a warning in the terminal. Also, these warnings should be reflected in the docs.

nhc commented 2 years ago

IMO yes, there should be a warning in the terminal. Also, these warnings should be reflected in the docs.

Ok sure I can have a go a figuring this out.