open-index/open-npm huggingface dataset:
npm package: @qpoint/dlp
Description: A Qpoint adapter for detecting and optionally scrubbing content from externally traveling API calls.
Author: Jon Friesen
Latest version: 0.0.3

# qpoint-dlp

A Qpoint adapter for detecting and optionally scrubbing content from externally traveling API calls.

## Usage

```ts
import { Context, Endpoint } from '@qpoint/endpoint';
import processDLP from '@qpoint/dlp';

export default new Endpoint()
  .use(processDLP({
    rules: [
      {
        label: 'CREDIT CARD NUMBER',
        expression: /\b(?:\d[ -\.]*?){13,16}\b/g,
        scrub: true,
        report: true,
        record: true,
        failOnDetect: false,
      }
    ],
  }));
```

## Installation

```bash
npm add @qpoint/dlp
```
npm package: @qpoint/endpoint
Description: Qpoint - an intelligent edge endpoint framework
Author: Tyler Flint
Latest version: 0.1.0

# Qpoint

Intelligence at the edge - an edge endpoint 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](https://workers.js.org/), a qpoint endpoint can be deployed trivially to edge networks like [Cloudflare Workers](https://workers.cloudflare.com/) and [Deno Deploy](https://deno.com/deploy), or with the help of [Qpoint](https://qpoint.io), deploy to any platform including your own servers.

## Example

```ts
import Endpoint from '@qpoint/endpoint'
import proxy from '@qpoint/proxy'
import maskUrls from '@qpoint/mask-urls'
import replaceContent from '@qpoint/replace-content'
import rewriteHtml from '@qpoint/rewrite-html'

// initialize and export the endpoint
export default new Endpoint()

  // proxy request to app
  .use(proxy({ appUrl:"https://qdemo.io" }))

  // mask urls in html response
  .use(maskUrls())

  // replace occurrences of qdemo with qpoint
  .use(replaceContent({ rules: [{ from: 'qdemo', to: 'qpoint' }] }))

  // rewrite html (trigger htmlrewriter rules)
  .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
```ts
endpoint.use((ctx: Context, next: Function) => {
  
  // check for the Authorization header
  if (!ctx.request.headers.has("Authorization")) {
    // set the response to unauthorized
    ctx.response = new Response(null, { status: 401 });

    // return without calling next() to terminate the chain
    return
  }

  // continue the chain to the next
  return next();
})

```

## Context, Request and Response

Each adapter receives a Qpoint [Context](https://github.com/qpoint-io/qpoint/blob/main/src/context.ts) object that wraps an incoming request and the corresponding response. `ctx` is often used as the parameter name for the context object.

```ts
endpoint.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.

## Releasing New Versions
To release a new version create a `New Release` in GitHub with an incremented tag in the format of `v#.#.#`. GitHub will automatically generate the changelog since the last release version. After creation, a GitHub action will be kicked off to build, tests, set the npm version, and publish.
npm package: @qpoint/mask-urls
Description: A Qpoint adapter for masking URLs behind a reverse proxy
Author: Tyler Flint
Latest version: 0.2.1

# qpoint-mask-urls

A Qpoint adapter for masking URLs behind a reverse proxy

## Overview

When proxying requests upstream, html links are generated for the upstream location.

Consider the following:

An app hosted on vercel would likely produce html with a link URL: https://qpoint-site.vercel.app/about-us

The proxy needs to mask the url to match the outer domain URL: https://qpoint.io/about-us

## Usage

```ts
import Endpoint from "@qpoint/endpoint";
import proxy from "@qpoint/proxy";
import maskUrls from "@qpoint/mask-urls";
import rewriteHtml from "@qpoint/rewrite-html";

export default new Endpoint()
  // proxy to qpoint.io
  .use(proxy({ appUrl: "https://qpoint.io" }))

  // mask the urls to match the proxy endpoint
  .use(maskUrls())

  // activate the rewrite
  .use(rewriteHtml())
```

## Installation

```bash
npm add @qpoint/mask-urls
```

## Advanced

`basePath` can be provided with the config if the upstream app is nested within the path.
npm package: @qpoint/proxy
Description: A Qpoint adapter for proxying requests from the edge
Author: Tyler Flint
Latest version: 0.2.7

# qpoint-proxy

A Qpoint adapter for proxying requests from the edge

## Usage

```ts
import Endpoint from "@qpoint/endpoint";
import proxy from "@qpoint/proxy";

export default new Endpoint()
  .use(proxy({ appUrl: "https://qpoint.io" }))
```

## Installation

```bash
npm add @qpoint/proxy
```

## Config

`appUrl` sets the upstream app url to forward requests

`redirect` will indicate to redirect the request instead of proxy by default

`urlStrategy` determines how to construct the proxy request url (see below)

## Url Strategy

The URL Strategy determines how to construct the proxy request URL. The following modes are supported:

`mask` takes the incoming url and replaces only the origin domain from the `appUrl`. This is the default settings and the most likely strategy you'll want to use when proxying.

`mirror` uses the `appUrl` directly and doesn't do any modifications. This is mostly beneficial if using this adapter as a redirect, and you want all requests to be redirected to the same location. It can also be used during proxy but beware that all requests will end up at the same upstream url regardless of the incoming path which may be confusing behavior.
npm package: @qpoint/replace-content
Description: A Qpoint adapter for replacing content in the response html
Author: Tyler Flint
Latest version: 0.2.1

# qpoint-replace-content

A Qpoint adapter for replacing content in the response html

## Usage

```ts
import Endpoint from "@qpoint/endpoint";
import proxy from "@qpoint/proxy";
import replaceContent from "@qpoint/replace-content";
import rewriteHtml from "@qpoint/rewrite-html";

export default new Endpoint()
  // proxy to deno.land
  .use(proxy({ appUrl: "https://deno.land" }))

  // replace text occurrences
  .use(replaceContent({ 
    rules: [
      { from: "Deno", to: "Deyes" },
      { from: "deno", to: "deyes" },
      { from: "JavaScript", to: "FunnyScript" },
      { from: "TypeScript", to: "StrictScript" }
    ] 
  }))

  // activate the rewrite
  .use(rewriteHtml({}))
```

## Installation

```bash
npm add @qpoint/replace-content
```
npm package: @qpoint/rewrite-html
Description: A Qpoint adapter for rewriting the response html using the HtmlRewriter rules
Author: Tyler Flint
Latest version: 0.2.1

# qpoint-rewrite-html

A Qpoint adapter for rewriting the response html using the HtmlRewriter rules

## Usage

Note: This adapter is useless without registered HtmlRewriter rules. Usually this adapter is added after other adapters that register rules.

```ts
import Endpoint from "@qpoint/endpoint";
import rewriteHtml from "@qpoint/rewrite-html";

export default new Endpoint()
  .use(rewriteHtml())
```

## Installation

```bash
npm add @qpoint/rewrite-html
```
npm package: @qpoint/router
Description: Qpoint - an intelligent edge router framework
Author: Tyler Flint
Latest version: 0.2.1

# 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](https://workers.js.org/), a qpoint router can be deployed trivially to edge networks like [Cloudflare Workers](https://workers.cloudflare.com/) and [Deno Deploy](https://deno.com/deploy), or with the help of [Qpoint](https://qpoint.io), deploy to any platform including your own servers.

## Example

```ts
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'

// initialize and export the router
export default new Router()

  // proxy request to app
  .use(proxy({ appUrl:"https://qdemo.io" }))

  // mask urls in html response
  .use(maskUrls())

  // replace occurrences of qdemo with qpoint
  .use(replaceContent({ rules: [{ from: 'qdemo', to: 'qpoint' }] }))

  // rewrite html (trigger htmlrewriter rules)
  .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
```ts
router.use((ctx: Context, next: Function) => {
  
  // check for the Authorization header
  if (!ctx.request.headers.has("Authorization")) {
    // set the response to unauthorized
    ctx.response = new Response(null, { status: 401 });

    // return without calling next() to terminate the chain
    return
  }

  // continue the chain to the next
  return next();
})

```

## Context, Request and Response

Each adapter receives a Qpoint [Context](https://github.com/qpoint-io/qpoint/blob/main/src/context.ts) object that wraps an incoming request and the corresponding response. `ctx` is often used as the parameter name for the context object.

```ts
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.