open-index/open-npm huggingface dataset:
npm package: @lafferty-lounge/api-gateway
Description: An API gateway with dynamic route definitions and SNI termination
Author: Craig Lafferty
Latest version: 0.2.2

# api-gateway

Dynamically route layer 7 traffic based on host/route and dynamically update
and serve certificates for different domains.

### Options

```bash
--route-server-url                # the server to fetch routes from
--route-server-token              # the bearer token to use when connecting to the route server
--route-server-external-host      # the domain that should be routed to the route server
--route-fetch-interval            # the interval to use when fetching the route list
--domain-server-url               # the server to fetch domains and their certificates from
--domain-server-token             # the bearer token to use when connecting to the domain server
--domain-server-external-host     # the domain that should be routed to the domain server
--domain-fetch-interval           # the interval to use when fetching the domain list
--http-port                       # the port to listen on for plain http requests
--https-port                      # the port to listen on for https requests
--key-server-url                  # the url of a key server to use to generate a default certificate
--cert                            # the path the default certificate
--cert-data                       # the content of the default certificate to use
--key                             # the path the default key
--key-data                        # the content of the default key
--cert-bundle                     # the path to a bundle of default certificates
```
npm package: @lafferty-lounge/key-server
Description: Simple self signed key and cert generator
Author: Craig Lafferty craigplafferty@gmail.com
Latest version: 0.5.0

# Key Server

Generate self-signed certificates really quickly.

Ip and DNS sans supported

### `GET` key-server?domains=["a.b.c","192.168.0.1"]

### `POST` key-server/

payload:

```json
{
  "domains": [
    "a.b.c",
    "192.168.0.1"
  ]
}
```
npm package: @lafferty-lounge/letsencrypt-bot
Description: An service that keeps track of the certificates that are needed in a cluster and generates them.
Author: Craig Lafferty
Latest version: 0.0.3

# api-gateway

Dynamically route layer 7 traffic based on host/route and dynamically update
and serve certificates for different domains.

### Options

```bash
--route-server-url                # the server to fetch routes from
--route-server-token              # the bearer token to use when connecting to the route server
--route-server-external-host      # the domain that should be routed to the route server
--route-fetch-interval            # the interval to use when fetching the route list
--domain-server-url               # the server to fetch domains and their certificates from
--domain-server-token             # the bearer token to use when connecting to the domain server
--domain-server-external-host     # the domain that should be routed to the domain server
--domain-fetch-interval           # the interval to use when fetching the domain list
--http-port                       # the port to listen on for plain http requests
--https-port                      # the port to listen on for https requests
--key-server-url                  # the url of a key server to use to generate a default certificate
--cert                            # the path the default certificate
--cert-data                       # the content of the default certificate to use
--key                             # the path the default key
--key-data                        # the content of the default key
--cert-bundle                     # the path to a bundle of default certificates
```
npm package: @lafferty-lounge/logger
Description: A simple logging utility
Author: Craig Lafferty
Latest version: 0.1.0

# lafferty lounge logger

```js
const logger = new Logger('logger-name', {
  length: 25,       // width of the description string in the output
  colors: true,     // use colors in the output
  stdout: stream,   // stream to write to for info
  stderr: stream,   // stream to write to for error/warn
  logLevel: 5       // the log level that should be output
})

let logLevel = 3;
logger.info(logLevel, 'hello'); // 2017:05:17 09:16:57 logger-name----------------- [  3]: hello
```

### TODO

Add some tests :(
npm package: @lafferty-lounge/route-cache
Description: A module for doing hostname:url matching with caching
Author: Craig Lafferty craigplafferty@gmail.com
Latest version: 0.2.1

# The router-cache module

The router cache module takes an list of domains, each with a list of urls.
The domains and urls are defined using regex.

When calling getRoute on a route cache instance the domain will be tested against
all of the hosts in the hosts array that is passed in. If it matches a host regex
then the routes in that host will be tested for a match in order until one is found.
When a host/route match is found then the destination will be returned and the result
will be cached.

Since it's not feasible to cache every single request the domain/url combinations
have a weighted priority. Requests with the lowest entries will not be cleared from
the cache. The weight is based on total number of requests and requests per minute.

Updating the routes will clear the cache for obvious reasons so if you're looking
for super high performance then this may not be the best application to use if
you're going to be updating routes very frequently.

```js
let routes = {
  hosts: [
    {
      name: 'catch-all',
      description: `This is is a high priority catch all for things like letsencrypt`,
      match: '.*',
      routes: [
        {
          name: 'letsencrypt directory',
          match: '/.well_known',
          target: {
            url: 'http://cert-generator',
            ca: 'test-ca',
            protocols: ['http']
          }
        }
      ]
    },
    {
      name: 'lafferty-lounge',
      match: 'lafferty-lounge\\.com',
      description: 'lafferty lounge routes',
      routes: [
        {
          name: 'api-server',
          match: '^/api/v1/*',
          description: 'This is the lafferty lounge api server',
          target: {
            url: 'http://lafferty-lounge-api-server-v1',
            ca: 'test-ca',
            protocols: ['http']
          }
        }
      ]
    }
  ]
};
let cache = new Cache();
cache.updateRoutes(routes);
expect(cache.getRoute('test.com', '/abc/def')).toEqual({
  url: null,
  protocols: ['http', 'https']
});
expect(cache.getRoute('test.com', '/.well_known')).toEqual({
  url: 'http://cert-generator',
  ca: 'test-ca',
  protocols: ['http']
});
expect(cache.getRoute('lafferty-lounge.com', '/abc/def')).toEqual({
  url: null,
  protocols: ['http', 'https']
});
expect(
  cache.getRoute('lafferty-lounge.com', '/api/v1/hello/there')
).toEqual({
  url: 'http://lafferty-lounge-api-server-v1',
  ca: 'test-ca',
  protocols: ['http']
});
```
npm package: @lafferty-lounge/simple-dns
Description: A basic dns server that resolves the public ip address of the dns server for every request
Author: Craig Lafferty craigplafferty@gmail.com
Latest version: 0.3.0

# simple-dns

This is a VERY BASIC dns server that figures out its own public ip address
and just returns that for every request.

## Options

```bash
ll.simple-dns \
  # what port to listen on
  --dns-port 53 \
  # when to expire dns records in seconds
  --ttl 30 \
  # how often to query api.ipify.org in ms
  --refresh-interval 30000 \
  # nameservers that you're acting as
  --nameservers ns1.mydomain.org,ns2.mydomain.org \
  # the zone that you're managing
  --zone somedomain.tld \
  # the email to use for the soa
  --email someemail@somedomain.tld
```