open-index/open-npm huggingface dataset:
npm package: @balena/audit-log-client
Description: An audit log client
Author: Balena Inc.
Latest version: 0.9.0

# Balena Audit Logs

**Experimental Repository**

A TypeScript client library for managing audit logs with support for multiple backend implementations.

```bash
npm install @balena/audit-log-client
```

## Development

```bash
# Install dependencies
npm install

# Run tests
npm test

# Build the project
npm run build

# Run linting
npm run lint
```

## License

Apache-2.0
npm package: @balena/promise-queue
Description: Queue sync or async functions with max concurrency, max size, max age, and fifo/lifo ordering
Author: Pagan Gazzard
Latest version: 1.3.4

promise-queue
===

This module allows you to queue sync/async functions with max concurrency, max size, max-age, and fifo/lifo ordering

### Constructor

```
let q = new PromiseQueue({
  name: 'device_logs',
  concurrency: 40,
  maxSize: 400,
  maxAge: 30 * 1000,
  order: 'fifo'
});
```

### Use

```
export function middleware(
	req: Request,
	res: Response,
	next: NextFunction,
): void {
	q.add(() =>
          new Promise(resolve => {
              res.once('close', resolve);
              res.once('finish', resolve);
              next();
          }),
      )
      .catch(err => {
          if (err instanceof PromiseQueueError) {
              reject(res);
          }
      });
}
```

### Metrics

`PromiseQueue.metrics` is an `EventEmitter` which emits the following events:

- `arrival`, data: `undefined`: a promise arrives at the queue
- `queueLength`, data: `number`: the length of the queue on arrival
- `inFlight`, data: `number`: the number of active promises on arrival

- `dequeue`, data: `undefined`: a promise stops waiting in the queue and starts processing
- `queueTime`, data: `number`: time a promise spent waiting in queue on dequeue

- `completion`, data: `undefined`: a promise completes processing
- `serviceTime`, data: `number`: time a promise spent processing on completion
- `latency`, data: `number`: sum of queueTime and serviceTime on completion

- `rejection`, data: `undefined`: a promise to be added is rejected because `maxSize` is already reached
- `timeout`, data: `undefined`: a promise's latency (queue time + service time) exceeds `maxAge`, and it is rejected
npm package: @balena/proxy-protocol-parser
Description: Encoder and Decoder for proxy protocol v1 text and v2 binary formats
Latest version: 1.0.3

# proxy-protocol-parser

[![npm version](https://badge.fury.io/js/%40balena%2Fproxy-protocol-parser.svg)](http://badge.fury.io/js/%40balena%2Fproxy-protocol-parser)
[![dependencies](https://david-dm.org/balena-io-modules/proxy-protocol-parser.png)](https://david-dm.org/balena-io-modules/proxy-protocol-parser.png)

## Overview

A simple encoder and decoder for proxy protocol headers using the v1 text and v2 binary formats.

See http://www.haproxy.org/download/1.5/doc/proxy-protocol.txt for details.

Supports IPv4 and IPv6, UDP and TCP, but not UNIX sockets.

## install

    npm install @balena/proxy-protocol-parser

## encode

Separate v1 and v2 encoders are provided.

````
var buf = require('@balena/proxy-protocol-parser').v2_encode(socket);
````

or

````
var buf = require('proxy-protocol-parser').v2_encode({
  remoteFamily: 'IPv4',
  remoteAddress: '12.34.56.78',
  remotePort: 1234,
  localAddress: '172.16.0.1,
  localPort: 8080,
  protocol: 'udp'
});
````

`protocol` defaults to `'tcp'` if unspecified.

The `v1_encode` function has the same API but is constrained by the limits of the v1 format, so only the `tcp` protocol is supported.

## decode

A generic decoder is provided that detects the format of any header. If no valid v1 or v2 signature is detected, `null` is returned.

````
var details = require('@balena/proxy-protocol-parser').decode(buf);
if(details === null) {
    console.log('No proxy protocol header detected');
}

var remoteFamily = details.remoteFamily,
    remoteAddress = details.remoteAddress,
    remotePort = details.remotePort,
    localAddress = details.localAddress,
    localPort = details.localPort,
    protocol = details.prototol;
````

Separate decoders are provided for each version if the expected version is known.

````
var v1_details = require('@balena/proxy-protocol-parser').v1_decode(buf);
var v2_details = require('@balena/proxy-protocol-parser').v2_decode(buf);
````

The format-specific functions will assume the presence of a header and may throw an Error or return invalid details if a header is not present.

Each decode operation takes an optional `validate` second argument which causes the header to be validated (with an Error being thrown if invalid) at the minor cost of checking the signature validity an other validity checks on field values.

## test

    nodeunit test