Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unify the servers response #27

Open
3rd-Eden opened this issue Oct 25, 2019 · 0 comments
Open

Unify the servers response #27

3rd-Eden opened this issue Oct 25, 2019 · 0 comments

Comments

@3rd-Eden
Copy link
Collaborator

create-servers allows you to configure a single http server using the object syntax or multiple http server instances using an array with objects where each object the configuration for each server. While that is a nice feature to have it comes with a really painful side effect and that is that the response signature of the module changes based on the configuration. When the servers are configured using just a single object to create a single server the servers response would be:

{
  http: { http server }
}

But when you are providing create-servers with an array of multiple configurations, the response signature magically changes to an array:

{
  http: [
    { http server 1 },
    { http server 2 }
  ]
}

So in order to handle both formats, implementers of this library need to support both cases, and normalise it into workable format for their library. What I like to propose instead is that the create-servers changes it's response signature to be consistent between both configuration modes (array and object).

One way of doing this would be to return an object that is keyed on the address of the server instead of separate distinction between http, https, and then the multiple or single server that is created. So in the case of multiple servers, there would simply be more keys in the object allowing the signature to be the same.

{
  80: { http server },
  8080: { http server },
  443: { http server } 
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant