shubhamp-sf / loopback-http2-proxy

HTTP2 proxy for loopback using two ways, native node:http2 and fastify http2 server.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Checkout this blog for http2 support in lb4 app: https://blog.shubhamp.dev/how-to-use-http2-in-loopback-4-applications Related Thread: loopbackio/loopback-next#9067

http/2 proxy for loopback

Proxy code for forwarding HTTP2 requests to loopback, in two ways:

  1. Internal node:http2
  2. Fastify's http2 server
Check Out the Request Flow

Request Flow

image

Directory Structure

.
├── loopback-http2-proxy/ (• this repository)
│   └── src
│       ├── native-http2.ts
|           └── H2 Server having requests forwarded to lb4 app using node's internal http2.
│       └── fastify-http2.ts
|           └── H2 Server having requests forwarded to lb4 app using fastify.
└── default-app/ (loopback app to forward requests to)
    └── (...normal loopback app)

Changes required in Loopback App

TODO

Current Supoprt

  • GET routes with returned responses
  • GET routes with responses send() directly to http by loopback.
  • Translated http/1 Headers
  • Cookies
  • Status Codes
  • Static Responses (to support this.static('/', "index.html"))
  • Streamed Responses (Readable streams)
  • ...(more to come)

What has been tested?

An lb4 app sourced here is being used to test different routes and responses.

  • REST Controller with CRUD functions (Datasource: Postgres) source

    • @post('/users')
    • @get('/users')
    • @get('/users/count')
    • @patch('/users')
    • @get('/users/{id}')
    • @patch('/users/{id}')
    • @put('/users/{id}')
    • @del('/users/{id}')
  • Default Ping Controller

About

HTTP2 proxy for loopback using two ways, native node:http2 and fastify http2 server.


Languages

Language:TypeScript 100.0%