I made a Express.js system where the files in the /routes
folder are acting as a classic route (but with one file per route)
Example: /routes/get/user.js
will be accessible with http://localhost:8080/user
(the /get
is to separate methods, it can be /post
, /put
…)
Here’s my entire index.js
file: https://pastebin.com/ALtSeHXc
But actually, my problem is that I can’t pass params into the url like https://localhost:8080/user/random_id_here
.
With this system, I think the best idea is to find a way to pass params on separated files too, but I don’t know how can it be done…
Here’s an example of one of my separated file:
module.exports = class NameAPI {
constructor(client) {
this.client = client
}
async run(req, res) {
// Code here
}
}
Maybe you’ll have a better system, or a solution for this. Thanks.