Mesg-js: make it possible to configure server address

proposal

#1

Currently it is only possible to configure Core address for application() with the env vars. I think it would be nice to make application({addr}) accept an options object, that way we can also configure it programatically.

This is also useful to configure addr in browser env.


#2

I agree with you, the library should not rely on env variable but accept a config/option object.

But, we the automatic generation of the core/application library, I think we should not create any wrapper and directly expose the generated code to the dev. If I’m not mistaken, the generated constructor already accept options as parameter.


#3

I think there is no much difference between to initialize gRPC client inside when application() is called or let consumers to do that. One small advantage of doing the initialization internally is, we can use the default ports when no option provided and open the connection right away. And with the Envoy, we can automatically connect to proxy server or Core server by detecting the environment when options.host isn’t provided. Other way, consumers always have to set the host and do their initialization.


#4

If it only for default config and we need to maintain a file, I recommend to directly expose the gRPC generated code to user.


#5

solved by https://github.com/mesg-foundation/mesg-js/pull/48