GiovanniCardamone / fastify-autoroutes

fastest way to map directories to URLs in fastify
https://giovannicardamone.github.io/fastify-autoroutes/
MIT License
85 stars 12 forks source link

Plugin won't take status.ts as a route #196

Closed mgara closed 1 year ago

mgara commented 1 year ago

Versions

List all the routes in the subdir

Actual Behavior

The route is missing from the list of available routes

Steps to Reproduce

I just added a new file to the directory with the same content as health.ts

Screenshots (Optional)

Screenshot 2022-11-18 at 10 18 38 AM
mgara commented 1 year ago

Ok I added a new one .. it worked .. it looks like it doesn't like the "status.ts" as a route

GiovanniCardamone commented 1 year ago

That's very strange, I need to investigate, thank you for the report

GiovanniCardamone commented 1 year ago

i can confirm there is a problem with route /status I think is something related to glob, because is not extracted from files

mgara commented 1 year ago

I think you might as well put it as a "known bug" and close this one ? it's up to you ...

GiovanniCardamone commented 1 year ago

I think is better if I can solve this. Also I want to investigate if there are more names who fall in the same scenario.

mgara commented 1 year ago

@GiovanniCardamone I'm running into glob issues again, now I'm not sure if your expression is wrong or right as this is the first time for me I deep dive into it. When I remove the [!.test] In your glob expression... everything works perfectly except it adds the .test files .. :/ else I'm getting an empty array of routes: the [!.test] doesn't match anything that starts with a t or an e or an s this is a single-character matching... According to glob documentation :

[...] Matches a range of characters, similar to a RegExp range. If the first character of the range is ! or ^ then it matches any character not in the range.

We should be using !(.test) but I can't make it to work :/

FYI : https://www.digitalocean.com/community/tools/glob?comments=false&glob=.%2F%2A%2A%2F%5B%21._%5D%2A%21%28.test%29.%7Bts%2Cjs%7D&matches=false&tests=.%2Fapp%2Ftags.ts&tests=.%2Fapp%2Ftag.ts&tests=.%2Fapp%2Fstatus.ts&tests=.%2Fapp%2Fbar%2F%7Bfoo%7D%2Fbaz.ts&tests=.%2Fapp%2F.hidden.ts&tests=.%2Fapp%2F_hidden.ts&tests=.%2Fapp%2Ffoo_dir%2F.hidden.ts&tests=.%2Fapp%2Fsome%2Ftesting_should_be_hidden.test.ts

this is my best bet so far :

./**/[!._]!(*.test).{ts,js}
mgara commented 1 year ago

I added the required changes to my PR : #197

GiovanniCardamone commented 1 year ago

sorry for the delayed response, i also have a lot of work and almost no time for personal project! :( I hope I can have more free time soon so I can contribute with the open source!

Thank you a lot for the report and the PR. I have merged and released v3.0.2 with your fix