BackendStack21 / fast-gateway

Fast-gateway is an easy to use Node.js API gateway framework built to handle large scale API traffic with great performance and scalability. Written with JavaScript, it is a framework for the masses!
MIT License
311 stars 35 forks source link

app.use compatibility (with monitoring middleware like Airbrake or Sentry) #57

Closed enricodeleo closed 3 years ago

enricodeleo commented 3 years ago

Some middleware requires app.use api to be installed. For example Airbrake Express middleware use them in order to log performances and errors.

Using the same functions within middlewares causes an error res.get is not a function.

Any ideas?

EDIT Apparently the culprit was exactly the lack of res.get function. I could patch this method with https://github.com/schamberg97/restana-express which I would suggest considering as a base point for restana official express compatibility.

EDIT 2 https://github.com/schamberg97/restana-express reimplements all needed methods but it also causes a weird behaviour: the gateway always returns status code 200 even when target is not found. I had to remove it and reimplement the only and exact method I needed in order to get back my 404s.

jkyberneees commented 3 years ago

Hi @enricodeleo, thanks for reaching out. Unfortunately restana lacks some express compatibility. In case the restana-express module bring new issues, you can simply replace restana by express as HTTP application server. Please see an example here: https://github.com/jkyberneees/fast-gateway/blob/master/demos/basic-express.js

Also consider submitting an issue to the restana-express repository ;)

If performance is a MOST in your case, I would consider to simply extend restana functionally using a custom middleware, please let me know. (UPDATE: you already figure it out)

Best Regards

enricodeleo commented 3 years ago

@jkyberneees thank you for your feedback. Indeed, I did extended what I needed in order to keep best performances at least as far as I am not forced to switch to express.

Thanks also for this tool, really loving it!