open-index/open-npm huggingface dataset:
npm package: @florajs/auth-jwt
Description: JSON Web Token authentication for Flora
Author: stock3 AG
Latest version: 5.0.1

# @florajs/auth-jwt

![](https://github.com/florajs/auth-jwt/workflows/ci/badge.svg)
[![NPM version](https://img.shields.io/npm/v/@florajs/auth-jwt.svg?style=flat)](https://www.npmjs.com/package/@florajs/auth-jwt)
[![NPM downloads](https://img.shields.io/npm/dm/@florajs/auth-jwt.svg?style=flat)](https://www.npmjs.com/package/@florajs/auth-jwt)

JSON Web Token authentication for Flora.

## Usage

This plugin for the Flora API framework enables authentication with JSON Web Tokens.

Authenticated requests contain a JSON Web Token either

- in the `Authorization` header field (e.g. `Authorization: Bearer eyJhb...`), or
- in the `access_token` body parameter, or
- in the `access_token` query parameter.

Additionally, when calling `flora` internally (without HTTP), the `access_token` property of the `flora.Request` object is used.

### Optional authentication

If the `credentialsRequired` option is set to `true` (default), an `AuthenticationError` (`ERR_MISSING_TOKEN`) is thrown if no valid token is found. If set to `false` and no token is used, `request._auth` is set to `null` or whatever the `validate` function returns.

### Implementing authorization

By default, the contents of the JSON Web Token are saved to `request._auth`.

When further processing is needed, an async `validate` function can be specified, which may transform the JWT contents to something application specific.

## Example

```js
const flora = require('@florajs/flora');
const floraAuthJwt = require('@florajs/auth-jwt');

const server = new flora.Server('./config.js');

server.register('auth-jwt', floraAuthJwt, {
    secret: 'My Secret Key',
    algorithms: ['HS256'], // optional
    credentialsRequired: false, // default: false
    validate: async (jwt, request) => {
        // return value will go to request._auth
        return { userId: jwt.sub };
    }
});
server.run();
```

## License

[MIT](LICENSE)
npm package: @florajs/cluster
Description: Simple cluster manager module with status tracking for HTTP servers
Author: stock3 AG
Latest version: 4.0.2

# @florajs/cluster

![](https://github.com/florajs/cluster/workflows/ci/badge.svg)
[![NPM version](https://img.shields.io/npm/v/@florajs/cluster.svg?style=flat)](https://www.npmjs.com/package/@florajs/cluster)
[![NPM downloads](https://img.shields.io/npm/dm/@florajs/cluster.svg?style=flat)](https://www.npmjs.com/package/@florajs/cluster)

Simple cluster manager module with status tracking for HTTP servers.

## Features

- Updates in production with zero downtime - *complete worker code is replaceable without shutdown*
- Self-monitoring process-management - *respawn workers on error (as you would expect)*
- Rollback generation if reload fails - *best chances to have a running version everytime*
- Aggregated status with connection-/request-tracking - *see in realtime what happens in production*
- Status extendible (global counters and per-request infos) - *trace your app in realtime - in production*
- Node.js cluster based implementation

## Examples

### master.js

The master process will start 3 workers and restarts them on crashes:

```js
const path = require('path');
const { Master } = require('@florajs/cluster');

const master = new Master({
    exec: path.join(__dirname, 'worker.js'),
    workers: 3 // defaults to os.cpus().length
});

master.run();
```

### worker.js

```js
const { createServer } = require('http');
const { Worker } = require('@florajs/cluster');

const worker = new Worker();

const httpServer = createServer((req, res) => {
    res.writeHead(200, { 'Content-Type': 'text/plain' });
    res.end('Hello World\n');
});

worker.attach(httpServer);

worker.on('close', () => httpServer.close());

httpServer.listen(3000);

httpServer.on('listening', () => worker.ready());
```

### Server status

You can retrieve an aggregated status from all workers from any worker:

```js
console.log(await worker.serverStatus());
```

### Full example

See "example" folder.

## Best practices

### Startup-Tests

You can perform extended tests in your worker on startup - just exit if something fails. On a graceful
reload, the master process will cancel the reload and shutdown all workers of the new generation.
Reload is assumed to be successful when all workers called their ready() function. The old generation
of workers is shutdown not before all new workers are up and running.

### Status

Aggregated status over all workers can be requested from inside a worker and from the master process.
So it is possible to integrate the status into your application. Another possibility is to start a
HTTP server inside the master process on a management port for those requests.

## License

[MIT](LICENSE)
npm package: @florajs/datasource-solr
Description: Solr connection for Flora
Author: stock3 AG
Latest version: 7.0.0

# @florajs/datasource-solr

![](https://github.com/florajs/datasource-solr/workflows/ci/badge.svg)
[![NPM version](https://img.shields.io/npm/v/@florajs/datasource-solr.svg?style=flat)](https://www.npmjs.com/package/@florajs/datasource-solr)
[![NPM downloads](https://img.shields.io/npm/dm/@florajs/datasource-solr.svg?style=flat)](https://www.npmjs.com/package/@florajs/datasource-solr)

Solr connection for [Flora](https://github.com/florajs/flora).

## License

[MIT](LICENSE)
npm package: @florajs/errors
Description: Error definitions for Flora
Author: stock3 AG
Latest version: 4.0.0

# @florajs/errors

![](https://github.com/florajs/errors/workflows/ci/badge.svg)
[![NPM version](https://img.shields.io/npm/v/@florajs/errors.svg?style=flat)](https://www.npmjs.com/package/@florajs/errors)
[![NPM downloads](https://img.shields.io/npm/dm/@florajs/errors.svg?style=flat)](https://www.npmjs.com/package/@florajs/errors)

Error definitions for [Flora](https://github.com/florajs/flora).

This module exposes error classes for different types of errors to be able to determine whether an error should be displayed to the client (such as AuthenticationError) or not (internal errors).

To be able to pass through the error type to clients, a `code` property is also set. The default error codes are listed below.

## Error classes

### RequestError

- Generic request error (the user made an invalid request)
- HTTP status code `400`, the `message` will be displayed
- Error code is `ERR_REQUEST_ERROR`

### AuthenticationError

- The user is either not authenticated, or the credentials are wrong
- HTTP status code `401`
- Error code is `ERR_AUTHENTICATION_ERROR`

### AuthorizationError

- The user may be authenticated, but is not authorized for the requested action
- HTTP status code `403`
- Error code is `ERR_AUTHORIZATION_ERROR`

### NotFoundError

- Either the requested resource could not be found, or a specific entity of the resource.
- HTTP status code `404`, `message` will be displayed
- Error code is `ERR_NOT_FOUND`

### GoneError

- The requested resource is gone, e.g. was deleted
- HTTP status code `410`, `message` will be displayed
- Error code is `ERR_GONE`

### ImplementationError

- There is a problem with the implementation, e.g. of one of the resources. This should not happen
- HTTP status code `500`
- Error code is `ERR_IMPLEMENTATION_ERROR`

### DataError

- There is a problem with the data retrieved by one of the data sources
- HTTP status code `500`
- Error code is `ERR_DATA_ERROR`

### ConnectionError

- There is a problem with the connection to a data source. May work on retry (e.g. temporary network problems)
- HTTP status code `503`.
- Error code is `ERR_CONNECTION_ERROR`

### ValidationError

- There is a problem validating input data. This is a special case of `RequestError`
- HTTP status code `400`
- Error code is `ERR_VALIDATION_ERROR`
- Second parameter of constructor will be added as additional `validation` property.

## License

[MIT](LICENSE)
npm package: @florajs/request-parser
Description: Request parser for Flora
Author: stock3 AG
Latest version: 5.0.1

# @florajs/request-parser

![](https://github.com/florajs/request-parser/workflows/ci/badge.svg)
[![NPM version](https://img.shields.io/npm/v/@florajs/request-parser.svg?style=flat)](https://www.npmjs.com/package/@florajs/request-parser)
[![NPM downloads](https://img.shields.io/npm/dm/@florajs/request-parser.svg?style=flat)](https://www.npmjs.com/package/@florajs/request-parser)

Parse [Flora](https://github.com/florajs/flora) requests into the internal object format.

## Usage

```js
const { parse } = require('@florajs/request-parser');

parse({
    id: 42,
    limit: 100,
    page: 10,
    order: 'lastname:asc',
    search: 'foo',
    select: 'id,firstname,lastname,address[street,zip]',
    filter: 'address.zip=1234',
});
```

### Order syntax

```
lastname:asc
lastname:desc
firstname:asc,lastname:desc
:random
```

### Select syntax

Simple attributes:

```
firstname,lastname
```

Children attributes:

```
firstname,lastname,address.street,address.zip
firstname,lastname,address[street,zip]
```

Additional parameters for children:

```
address(filter=active=true AND zip>10000)[street,zip]
subscriptions(filter=active=true)(order=createdAt:desc)[id,name,product.id]
```

### Filter syntax

Filter by single attribute:

```
type.id=1
```

Filter by multiple values (OR):

```
type.id=1,2,3
```

Filter by multiple attributes (AND):

```
type.id=1 AND categories.id=2
```

Filter by multiple attributes (OR):

```
type.id=1 OR categories.id=2
```

Complex examples with parenthesis:

```
(type.id=1,2,3 OR countries.id=3,23) AND categories.id=2,65'
```

Ranges (10 <= foo <= 20):

```
foo=10..20
```

## License

[MIT](LICENSE)
npm package: @floralink/core
Description: Core library for Floralink
Author: Vincent Ruge
Latest version: 0.1.3

# @floralink/core

A very small library for working with plant occurrence data, taxon specific data and taxon reference data. Contains a simple store for collected data and methods for calculating statistics. A final data structure is yet to be described. This documentation will be enriched when the library has reached a stable concept.

- [@floralink/core](#floralinkcore)
  - [Setup](#setup)
  - [Methods](#methods)
    - [Data sources (Store)](#data-sources-store)
    - [Type Conversions](#type-conversions)
    - [Statistics](#statistics)

## Setup

You can install the Floralink core library with npm:

```
npm install @floralink/core
```

Then, in your project:

```javascript
import * as floralink from "@floralink/core";
```

## Methods

### Data sources (Store)

```javascript
initializePlugin(plugin, credentials);
```

```javascript
getOccurrenceData(provider, query);
```

```javascript
getTaxonDataByID(taxonIDs, pluginID);
```

```javascript
getTaxonSpecific(taxonIDs, pluginID);
```

### Type Conversions

```javascript
convertToTaxonOccurrenceData(occurrenceData);
```

### Statistics

```javascript
getOccurrenceStatistics(occurrenceData);
```

```javascript
getTaxonOccurrenceStatistics(taxonOccurrenceData, occurrenceData);
```

```javascript
getTaxonSpecificStatistics(taxonSpecificPlugin, taxonSpecificData, filterIDs);
```