Take HTTP methods from files names #5
Replies: 2 comments 2 replies
-
@angelhdzmultimedia Hi! 👋🏻 Wow, your idea is brilliant!! 🔥 Thank you so much. It will definitely become a part of the functionality. I'll do it on this Tuesday or Wednesday :) And notify you when it's ready. Also, if you suddenly have the time and desire, I can help you with MR. I’m ready to provide guidance on the code as to what is needed and how it could be roughly implemented. It has several nuances: the library works not only with http but with any other protocols. |
Beta Was this translation helpful? Give feedback.
-
@angelhdzmultimedia Hi! I've released a new version with this functionality. https://github.com/Danilqa/node-file-router/releases/tag/v0.3.0 |
Beta Was this translation helpful? Give feedback.
-
Hello, congrats on the library!
I played with it a bit, but missed Nuxt's way of defining the routes, specifying the HTTP method on the files names like this:
/api/auth/login.post.ts
.I couldn't find if that was possible with this library.
So I made my own!
Wrote a function that parses the request, using
node:fs
of course to read recursively the folders and files,and then parsed the HTTP method from the files names, and it works beautifully.
Obviously it's very raw, maybe I polish it a bit later, work on performance, and make the paths work with other operating systems (currently made it for Windows!).
You can implement this feature if you want, it would be cool.
Wishing you health, peace, and success. 🔥☕😊🤝
Beta Was this translation helpful? Give feedback.
All reactions