Qpoint
Intelligence at the edge - an edge router framework
Compose powerful edge capabilities to analyze, transform, reject, or proxy traffic as it passes through the edge to your apps.
Designed to run within worker runtimes, a qpoint router can be deployed trivially to edge networks like Cloudflare Workers and Deno Deploy, or with the help of Qpoint, deploy to any platform including your own servers.
Example
import Router from '@qpoint/router'
import proxy from '@qpoint/proxy'
import maskUrls from '@qpoint/mask-urls'
import replaceContent from '@qpoint/replace-content'
import rewriteHtml from '@qpoint/rewrite-html'
export default new Router()
.use(proxy({ appUrl:"https://qdemo.io" }))
.use(maskUrls())
.use(replaceContent({ rules: [{ from: 'qdemo', to: 'qpoint' }] }))
.use(rewriteHtml())
Composable adapters
Adapters are middleware functions to be executed in a chain, each potentially modifying the request/response until finally returning the response.
Example: Reject the request (at the edge) if no auth is provided
router.use((ctx: Context, next: Function) => {
if (!ctx.request.headers.has("Authorization")) {
ctx.response = new Response(null, { status: 401 });
return
}
return next();
})
Context, Request and Response
Each adapter receives a Qpoint Context object that wraps an incoming request and the corresponding response. ctx
is often used as the parameter name for the context object.
router.use(async (ctx: Context, next: Function) => { await next(); });
After each of the adapters have run, the response as set on the context will be returned.
Proxies and Load Balancers
A very common case for Qpoint is building intelligent proxies and load balancers, and since the original Request object cannot be modified, the proxy
is a copy of the original request that can be fetch
ed by a proxy or load-balancer adapter.
In such a scenario, adapters that need to modify the request before a proxy fetch occurs will sequencially modify or replace the proxy
instance as the chain progresses.