jkyberneees / fastify-gateway

A Node.js API gateway that just works!
https://www.npmjs.com/package/k-fastify-gateway
MIT License
107 stars 14 forks source link

Service groupings ? #25

Closed parthibd closed 5 years ago

parthibd commented 5 years ago

I think it will be better from an architectural standpoint to give services endpoints with each service having its own configuration . Then instead of assigning endpoints in each route we can assign service name as key . Also it'd be great if we can have the provision for flexible service endpoints which will get rid of the 1:1 mapping and make the gateway more robust . Any thoughts ? :)

jkyberneees commented 5 years ago

Hi @parthibd, thanks for your motivation! Could you also attach a proper example to your proposal for a better understanding?

parthibd commented 5 years ago

Say I have two services

{
    "service1":{
    "endpoint":"xyz.com",
    "maxRetries":"3",
    .....
    },
    "service2":{
    "endpoint":"abc.com",
    "maxRetries":"5",
    .....
    }
}

Now when I am defining routes I can do something like this

"routes:{
    "route1":{
    "localEndpoint":"/user"
    "service":"service1",
    "serviceEndpoint":"/userdetails"
    },
    ....
}
jkyberneees commented 5 years ago

I get your idea and I like it! It will make life more easy for situations where you need to do a lot of endpoint level proxy. However, I would propose you to implement such configuration strategies as a separate module. It should not land into this core.

I would be happy to support you on that development as well.

parthibd commented 5 years ago

I want to go ahead and try out implementing it . How do you suggest I should proceed ?

jkyberneees commented 5 years ago

Create a new module, add k-fastify-gateway as a reference. Then create an interface where a more abstracted configuration like you propose can be translated into the low level interface...

jkyberneees commented 5 years ago

Hi @parthibd any update here?