pnxtech / hydra

A light-weight library for building distributed applications such as microservices
https://www.hydramicroservice.com
MIT License
645 stars 54 forks source link

add an option to register a service as https and call https services #202

Open krysalead opened 5 years ago

krysalead commented 5 years ago

Hi,

Sorry for the formatting it seems that some space were missing in front of the comments and I don't know how to remove this indentation from Visual Studio Code. Changes are not that big, only a new config key serviceProtocol which could be http or https (default is http) The other change is that if the service was registered as https it will be called with https.

krysalead commented 5 years ago

Hi,

I had to change the eslintrc to make it work from command line, tell me if it is breaking on your side. I am using VS code

krysalead commented 5 years ago

Documentation

HTTPS

If you build your microservice not behing a firewall but using different hosting service you will like to run it in HTTPS for security reason. This is doable in Hydra as simply as setting the service protocol to https.

{
    "serviceName": "echo-service",
    "serviceIP": "127.0.0.1",
    "servicePort": 3000,
    "serviceType": "",
    "serviceDescription": "",
    "serviceProtocol": "https",
    "redis": {
      "url": "127.0.0.1",
      "port": 6379,
      "db": 1
    }
  }
}

Your service will be registered in redis as secured and will be called using HTTPS. Nothing additional to do in your call to the service.

If you are not using a revers-proxy handeling the SSL encryption you will need to use hydra-express for instance that is starting a server in HTTPS if you specify https in protocol see hydra-express documentation for more information.

cjus commented 5 years ago

@krysalead thanks for this PR. In reviewing it there seems to be a lot of formatting changes. I do agree that those format changes should be done - but I'd rather do that in another PR. Can you branch and only apply your core changes in a new PR?

krysalead commented 5 years ago

Hi,

I am really struggling to make it properly, there is inconsistency everywhere, spaces sometimes added, sometimes not. Isn't simpler to do the review with comparison without white space activated?

cjus commented 5 years ago

@krysalead No worries about the spaces - I can cleanup after if necessary. See my questions and comment. Thanks again.

JustusFluegel commented 3 years ago

maybe consider using the modern ?? syntax instead of || like a ?? "default"

see https://dev.to/hereisnaman/logical-or-vs-nullish-coalescing-operator-in-javascript-3851 for details