GoogleChrome / rendertron

A Headless Chrome rendering solution

Home Page:https://render-tron.appspot.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add Koa middleware

glen-84 opened this issue · comments

commented

It would be great if Rendertron included Koa middleware.

I understand that it's not practical to include middleware for every available framework, but Rendertron just so happens to depend on multiple Koa packages anyway, so it seems like it would be a good fit.

I think now is a good time to retire the express middleware and move to koa. Would you be interested in doing that?

commented

@AVGP,

I'm in the process of writing Koa middleware, so I might be able to contribute that here.

I had started using Axios instead of the deprecated request, because I thought that node-fetch only supported timeouts using the awkward AbortController, but I see now (in your PR and in the docs), that there is in fact a timeout option, even though it does state "Signal is recommended instead". Do you still prefer node-fetch? (see also node-fetch/node-fetch#523 (comment))

I'm not sure about replacing the Express middleware though, as there are many users using that framework (as dead as it appears to be). That's obviously your call though.

commented

@AVGP Do you have a moment to respond to the questions above? 🙂

commented

Koa middleware for Rendertron (using Axios).

Usage:

app.use(
    makeMiddleware({
        proxyUrl: "http://my-rendertron-instance/render"
    })
);

In general, as we're deprecating the project, you should look into alternative approaches to rendering on the web.