I am trying to make a Express.js package that automatically generates routes from a object.
For example, if I were to put this in,
info: {
name: "Test",
version: "V1.0.0",
config: {
platform: "express.js"
}
},
users: {
add: async function(firstName,lastName,email) {
return email
}
}
}
then example.com/info/version
would return V1.0.0
.
That part I have already created successfully, but now I want to do the same for functions. I figure that I can pull arguments from query strings or bodies of POST requests and match them up with function arguments.
So now I need to find a way to get a function’s arguments, more specifically the argument names.
What I mean is that for the users.add function, I’d ideally like a array of arguments like ['firstName','lastName','email']
to be returned automatically.