Code Monkey home page Code Monkey logo

Comments (12)

parthibd avatar parthibd commented on June 7, 2024 1

I got you . So basically you mean the new module should be a layer above the gateway . I get the idea, but can you just give me some sample so that I will know I am going into the right direction ?

Thanks .

from fastify-gateway.

jkyberneees avatar jkyberneees commented on June 7, 2024

Hi @parthibd, there are many ways to pre/post process requests using this library.
Can you describe with an example you particular use case so I can offer you a proper solution?

Thanks.

from fastify-gateway.

parthibd avatar parthibd commented on June 7, 2024

Say I have two endpoints in two different services /custdetails & /orders . I want to call /user/1/details . What I really want is to call there two endpoints ,get the response and merge them . Is this possible ?

from fastify-gateway.

jkyberneees avatar jkyberneees commented on June 7, 2024

It is possible, I will get back to you with an example ASAP.

from fastify-gateway.

parthibd avatar parthibd commented on June 7, 2024

Thanks a lot . I am planning to add features like loading config from a file ( most probably json/yml?) , adding a service discovery manager .

from fastify-gateway.

parthibd avatar parthibd commented on June 7, 2024

Any updates ? :)

from fastify-gateway.

jkyberneees avatar jkyberneees commented on June 7, 2024

Hi @parthibd, all contributions are welcome here. Of course it would be great to have proper examples and details on your proposals before you actually start working on it.

Thanks for collaborating!

from fastify-gateway.

parthibd avatar parthibd commented on June 7, 2024

Say I have a local endpoint like this "/user/:id/details"

Now I want to aggregate I over two service endpoints

{
	"path":"/user/:id/details",
	"aggregate":true,
	"aggregations":[
		{
		"service":"service1",
		"endpoint":"/userdetails/:id"
		},
		{
		"service":"service2",
		"endpoint":"/orders/:id"
		}
	]
}

Is this possible ?

from fastify-gateway.

parthibd avatar parthibd commented on June 7, 2024

How should I go about implementing it ?

from fastify-gateway.

jkyberneees avatar jkyberneees commented on June 7, 2024

I think you missed the target property names on the aggregations endpoints ;)

Such developments can be plug-in into the the proxy hooks:

  hooks: {
      async onRequest (req, reply) {
      //   // we can optionally reply from here if required
      //   reply.send('Hello World!')
      //
      //   return true // truthy value returned will abort the request forwarding
      },
      onResponse (req, reply, res) {  
        // do some post-processing here
        // ...
        // forward response to origin client once finished
        reply.send(res) 
      }
 
      // other options allowed https://github.com/fastify/fastify-reply-from#replyfromsource-opts
    }

Here I also believe that such extensions should not land into the core, build them as separated modules. Afterward those will be properly referenced in here.

Thanks.

from fastify-gateway.

parthibd avatar parthibd commented on June 7, 2024

Sorry , my bad :) . How should I go ahead to implementing it ? Your guidance will be immensely helpful.

from fastify-gateway.

jkyberneees avatar jkyberneees commented on June 7, 2024

Create a new module that is able to transform high level routes configurations like you propose into low level k-fastify-gateway compatibility.
I can create an initial implementation here if you like, as soon as I get some free time.

Regards

from fastify-gateway.

Related Issues (19)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.