Description
Hello,
I realize after using this library that using global variables is suboptimal for what I'm using it for.
In my case, I have a Node.js application. I need to run multiple processes with different auth (API tokens) for each, and having a global scope would limit my performance quite a bit (i have to run all in sequence to make sure that the right token is used for the request).
For quite some time, I used another library to generate code. However, that had classes for each service (like yours), but not with singletons. You had to construct each class and pass auth. E.g. new PostService('token')
.
Code that handled more than one service would have to construct a few classes. Also sub-optimal. IMO, for the best possible API, I'd like to have one class that reference others.
Example:
class MyApi {
private auth;
constructor(... some auth thing ...) {}
postService() {
return new PostService(auth);
}
}
In summary, I'd love to see a way where this library could a) generate classes without singletons and b) have a class that exports constructed services.
I realize looking at your code that this isn't much work to do. Would you accept a pull request with that? I could also fork, but I would much rather help out :)