I am currently creating a library which internally uses axios. Since I'm making use of dependency injection, I can't use the constructor for my services to initialize some data.
There are many ways to solve this in another way, e.g.
serviceWithOptions = container.Resolve(...);
serviceWithOptions.option1 = '';
serviceWithOptions.setOption2('');
..// etc
What I want to do instead, is something like tsconfig.json, webpack.config.js or eslintrc.json
I want users of my library to create a config file, which is parsed by my library and then internally use these things.
Now, I could just create a fileReader that reads a specific file, however, I don't know what will happen if users have my library as a node_module (the default way), since then, the root folder will be different?
Also, I found some libraries
- https://github.com/henrikjoreteg/clientconfig -> However, this one reads it from a cookie and is for the communication between client and node server, whereas I need a config for a library inside another library (like webpack, etc.) and thus, don't have any cookies
- Environment variables, however, Environment Variables TypeScript this doesn't seem to be possible?
- https://github.com/mozilla/node-convict -> Looks like it's only for NodeJS
- https://github.com/lorenwest/node-config -> Like above, looks like it's only for NodeJS
What would be the best way and the best practice to achieve this?