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

Is there something of http gateway? #137

Open
zhaoyao91 opened this issue Nov 14, 2018 · 8 comments
Open

Is there something of http gateway? #137

zhaoyao91 opened this issue Nov 14, 2018 · 8 comments

Comments

@zhaoyao91
Copy link

zhaoyao91 commented Nov 14, 2018

Cote is great, but the communications are enclosed in its own system. Other apps of different framework or language are difficult to chat with them.

Is there or planning to build an out-of-box http gateway component to proxy the in-out communications?

@dashersw
Copy link
Owner

Hi! In fact there was a pull request earlier to streamline this — #27. However we weren't satisfied with the API and stopped working on it. I'd love to help more contributors on this.

@mikield
Copy link

mikield commented Jan 20, 2019

I think that out of the box API gateway is not needed.
It's based on application.

For example, my app doesn't not use API Gateway, I am using cote for my many-platforms chat bot.

@robodude666
Copy link

I'm with @mikield on this.

I don't know how much value an out-of-the-box http gateway would add. You'd likely want some sort of auth/middleware in the mix or ability to customize the end points, perform validation, etc.

Users are better off taking their favorite REST framework and building a wrapper around a Requester.

@dashersw
Copy link
Owner

That’s right. That’s also partially why we didn’t merge this. However, cote could still provide an easier interface for —for example— Express apps to hook into. Currently it requires a lot of boilerplate that gets repetitive and error prone.

@robodude666
Copy link

How much simpler could you get than this?

app.get('/product', function(req, res) {
    productRequester.send({type: 'list'}, function(err, products) {
        res.send(products);
    });
});

Perhaps I could see cote returning a handler that accepts req/res to narrow it down to a single line:

app.get('/product', productRequester.httpHandler({type: 'list'}));

But... there are many different frameworks out there. Most of them have express-compatibility so perhaps this may be enough, but could be limiting if you use a library that breaks away from that norm.

@dashersw
Copy link
Owner

dashersw commented Jul 3, 2019

This is route/event based match up. There are multiple other ways possible, including having a single URL and then forwarding to different events based on POST parameters, or configuration when you instantiate a responder:

const responder = new cote.Responder({
  name: 'Products responder', 
  http: {
    server: existingExpressApp, 
    path: '/products/:type'
  }
})

@mikield
Copy link

mikield commented Jul 3, 2019

As I already mentioned - I think that should be created as a separated wrapper.
Cote is not a Http framework, am I right? @dashersw

Thats why I love to use it. It's not forcing me to follow Http Microframework style, but just to use simple tcp messaging.

Of course I can be wrong.

@dashersw
Copy link
Owner

dashersw commented Jul 3, 2019

You don't have to use any http microframework style — this would just be an addition to how cote operates on its own. A separate wrapper or a plugin can still provide this functionality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants