open-index/open-npm huggingface dataset:
npm package: @forrestjs/service-apollo
Description: ForrestJS service which adds an Apollo GraphQL client to the App's context.
Author: Marco Pegoraro
Latest version: 5.2.2

# @forrestjs/service-apollo

ForrestJS service which adds an Apollo GraphQL client to the App's context.

DEMO:  
https://codesandbox.io/s/service-fastify-apollo-80oug
npm package: @forrestjs/service-env
Description: [deprecated] ForrestJS feature which helps importing environment variables from .env.* files.
Author: Marco Pegoraro
Latest version: 5.0.3
Deprecated: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

# @forrestjs/service-env (deprecated)

**🚧 DEPRECATED 🚧**  
The environment should be managed explicitly from the App manifest.

ForrestJS service which helps importing environment variables from `.env.*` files:

- .env
- .env.local
- .env.{NODE_ENV}
- .env.{NODE_ENV}.local

We suggest you write your safe default values in a `.env` file which gets committed into
your version control, then gitignore the `*.local` files and use them to store variables
that are bound to the execution context (your laptop, a production server).

> When things work in the best possible way, `.env.development` should contain all the info
> that allow a new developer to **boot the app in development mode** on her machine.

## Usage

This service injects a `getEnv()` method into the Hooks App execution context:

```js
const forrestjs = require('@forrestjs/core');

forrestjs.run({
  services: [require('@forrestjs/service-env')],
  features: [
    {
      target: '$FINISH',
      handler: (args, ctx) => console.log(getEnv('FOO'), 'default for "foo"'),
    },
  ],
});
```

After the Hooks App gets initialized, you can also directly import `getEnv()`:

```js
const { getEnv } = require('@forrestjs/service-env');
```
npm package: @forrestjs/service-express
Description: ForrestJS service which helps setting up an ExpressJS server.
Author: Marco Pegoraro
Latest version: 3.19.0
Deprecated: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

# @forrestjs/service-express

ForrestJS service which helps setting up an ExpressJS server.

## Install & Setup

```bash
npm install --save @forrestjs/service-express
```

set it up in your ExpressJS App:

```js
// index.js
const { runHookApp } = require('@forrestjs/hooks')
const { EXPRESS_ROUTE, ...expressService } = require('@forrestjs/service-express')

// Create an Home Page for the Web App
const homePageRoute = (req, res) => res.send('Hello World')
const homePageAction = ({ registerRoute }) => registerRoute.get('/', homePageRoute)

// Run the app:
runHookApp({
    settings: {
        express: {
            port: 8080,
        },
    },
    services: [
        expressService,
    ],
    features: [
        [ EXPRESS_ROUTE, homePageAction ],
    ],
})
```

## Configuration & ENVs

### port

`express.port: 5000` sets up the port on which the server runs.

It falls back to environment variables:

- process.env.REACT_APP_PORT
- process.env.PORT
- 8080 (default value)

## Hooks

All the hooks exposed by `service-express` are _asynchronous_ and executes in _serie_.

### EXPRESS_HACKS_BEFORE

This hook fires before any other step.<br>
It receives a direct referenct to the `app` and the `server`.

### EXPRESS_MIDDLEWARE

This hook is good to inject custom App level middleware.

```js
const { EXPRESS_MIDDLEWARE } = require('@forrestjs/service-express')

registerAction({
    hook: EXPRESS_MIDDLEWARE,
    handler: ({ registerMiddleware }) =>
        registerMiddleware((req, res, next) => {
            req.data = 'foo'
            next()
        })
})
```

### EXPRESS_ROUTE

```js
const { EXPRESS_ROUTE } = require('@forrestjs/service-express')

registerAction({
    hook: EXPRESS_ROUTE,
    handler: ({ registerRoute }) =>
        registerRoute('get', '/', (req, res) => {
            res.send('Hello World')
        })
})
```

### EXPRESS_HANDLER

This hook is good to inject custom handlers or fallback routes that you
want to be sure fire after any other.

```js
const { EXPRESS_HANDLER } = require('@forrestjs/service-express')

registerAction({
    hook: EXPRESS_HANDLER,
    handler: ({ registerHandler }) =>
        registerHandler((err, req, res, next) => {
            req.send(err)
        })
})
```

### EXPRESS_HACKS_AFTER

This hook fires after any other step.<br>
It receives a direct referenct to the `app` and the `server`.
npm package: @forrestjs/service-express-device
Description: ForrestJS service which helps identifying the same device among different HTTP requests.
Author: Marco Pegoraro
Latest version: 3.19.0
Deprecated: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

# @forrestjs/service-express-device

ForrestJS service which helps identifying the same device among different HTTP requests.
npm package: @forrestjs/service-express-graphql
Description: ForrestJS service which sets up a GraphQL endpoint in your ExpressJS App.
Author: Marco Pegoraro
Latest version: 3.19.0
Deprecated: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

# @forrestjs/service-express-graphql

ForrestJS service which sets up a _GraphQL_ endpoint in your _ExpressJS_ App.

```js
const { runHookApp } = require('@forrestjs/hooks')
const { GraphQLString } = require('graphql')

runHookApp({
    settings: {
        expressGraphql: {
            mountPoint: '/api',
            queries: {
                info: {
                    type: GraphQLString,
                    resolve: () => 'Hello World Query',
                },
            },
            mutations: {
                info: {
                    type: GraphQLString,
                    resolve: () => 'Hello World Mutation',
                },
            },
        },
    },
    services: [
        require('@forrestjs/service-express'),
        require('@forrestjs/service-express-graphql'),
    ],
});
```

## Configuration

### mountPoint

String, where to mount the GraphQL api. Defaults to `/api`.

### middlewares

Array, a list of middlewares to run before the `express-graphql`.
This is useful if you wish to customize the `body-parser` or stuff like that.

### queries, mutations

Objects, provide the queries and mutations for the GraphQL schema. You can also
use a hook to do so, it's explained later on in this file.

### config

Object, provide custom configuration to `express-graphql`.

## Add a query/mutation to the graph:

Here is an example of a feature that extends the GraphQL schema and provides a really
advances page counter (really old school):

```js
const { GraphQLString } = require('graphql');

const pageViews = ({ registerQuery, registerMutation }) => {
    let hits = 0
    registerQuery('getPageView', {
        type: GraphQLInt,
        resolve: () => hits,
    })
    registerMutation('logPageView', {
        type: GraphQLInt,
        resolve: () => (hits += 1),
    })
};

export default [ '$EXPRESS_GRAPHQL', pageViews ];
```

## Regenerate the GraphQL Schema on the fly

The entire `express-graphql` middleware is cached in memory to boost performances, but
you can force a full rebuild of it by bumping its cache key using a middleware:

```js
(req, res, next) => {
  if (isNeeded) {
    req.bumpGraphqlETAG();
  }
  next();
};
```

You can also control the specific ETAG value by setting it:

```js
(req, res, next) => {
  if (isNeeded) {
    req.bumpGraphqlETAG(33);
  }
  next();
};
```
npm package: @forrestjs/service-express-graphql-test
Description: ForrestJS service which sets up a GraphQL endpoint in your ExpressJS App.
Author: Marco Pegoraro
Latest version: 3.19.0
Deprecated: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

# @forrestjs/service-express-graphql-test

ForrestJS service which helps injecting some protected queries into the GraphQL Schema.
It is a simple form of protection and should be carefully used,
**it is intended for testing purpose only**.

```js
const { runHookApp } = require('@forrestjs/hooks')
const { GraphQLString, GraphQLInt } = require('graphql')

runHookApp({
    settings: {
        expressGraphqlTest: {
            isEnabled: () => process.env.NODE_ENV === 'development',
            isValid: ({ token }) => token === 'xxx',
        }
    },
    services: [
        require('@forrestjs/service-express'),
        require('@forrestjs/service-express-graphql'),
        require('@forrestjs/service-express-graphql-test'),
    ],
    features: [
        ['$EXPRESS_GRAPHQL_TEST', ({ registerQuery }) => {
            registerQuery('info', {
                type: GraphQLString,
                resolve: () => 'Hello World Query'
            })
            registerMutation('info', {
                type: GraphQLString,
                resolve: () => 'Hello World Mutation'
            })
        }],
    ]
})
```

Try now to query:

```gql
query q1 {
    test( token: "xxx" ) {
        info
    }
}

mutation m1 {
    test( token: "xxx" ) {
        info
    }
}
```

## Settings

### wrapperName

default: `test`

### wrapperDescription

### queryName

default: `TestQuery`

### mutationName

default: `TestMutation`

### isValidError

### queries, mutations

Same mechanism as the GraphQL service.

### isEnabled(hooksContext)

Async function (boolean), defines whether the test queries and mutations should be injected into
the App's GraphQL schema or not.

By default it returns true if `process.env.NODE_ENV` is set to either `development` or `test`,
but this setting is here for you to provide your custom logic.

**NOTE:** this function is fired during the booting of your application, and then avery time
the GraphQL schema cache is flushed.

### isValid(ctx, graphqlContext, hooksContext)

Async function (boolean), it runs at every request and should return `false` or `throw new Error`
in case access to the testing queries should be denied.

## Add a query/mutation to the graph:

```js
const { GraphQLString } = require('graphql');

const testQueries = ({ registerQuery, registerMutation }) => {
    registerQuery('foo', {
        type: GraphQLString,
        resolve: () => 'Hello World Query'
    })
    registerMutation('foo', {
        type: GraphQLString,
        resolve: () => 'Hello World Mutation'
    })
}

export default [ '$EXPRESS_GRAPHQL_TEST', welcomeQuery ];
```
npm package: @forrestjs/service-express-locale
Description: ForrestJS service which helps handling localized requests in ExpressJS.
Author: Marco Pegoraro
Latest version: 0.0.29-alpha.0
Deprecated: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

# @forrestjs/feature-express-locale

ForrestJS feature which helps handling localized requests in ExpressJS.
npm package: @forrestjs/service-express-request
Description: ForrestJS service which a unique id to each different HTTP requests.
Author: Marco Pegoraro
Latest version: 3.19.0
Deprecated: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

# @forrestjs/service-express-request

> ForrestJS service which a unique id to each different HTTP requests.

Assigns a `uuid` to each request and make id available to:
- `req.id`
- `X-Request-Id` header
- GraphQL `{ request { id } }` (optional)

This service uses [express-request-id](https://www.npmjs.com/package/express-request-id)
under the hood and can be configured as described in that documentation page:

```js
setConfig('express.request.attributeName', 'foo')
setConfig('express.request.headerName', 'X-FOO')
```
npm package: @forrestjs/service-express-ssr
Description: ForrestJS service which helps setting up a route for handling server side rendering.
Author: Marco Pegoraro
Latest version: 3.19.0
Deprecated: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

# @forrestjs/service-express-ssr

ForrestJS service which helps setting up a route for handling server side rendering.
npm package: @forrestjs/service-fastify-apollo
Description: ForrestJS service which adds Apollo GraphQL Client to a Fastify server.
Author: Marco Pegoraro
Latest version: 3.20.6
Deprecated: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

# @forrestjs/service-fastify-apollo

DEMO:  
https://codesandbox.io/s/service-fastify-apollo-80oug
npm package: @forrestjs/service-fastify-cookie
Description: ForrestJS service which adds cookie management capabilities to a Fastify server.
Author: Marco Pegoraro
Latest version: 5.2.2

# @forrestjs/service-fastify-cookie

https://github.com/fastify/fastify-cookie

DEMO:  
https://codesandbox.io/s/service-fastify-cookie-pq2m0

Options:

```js
setConfig('fastify.cookie', {
  ...options here
});
```
npm package: @forrestjs/service-fastify-cors
Description: ForrestJS service which adds CORS management capabilities to a Fastify server.
Author: Marco Pegoraro
Latest version: 5.2.2

# @forrestjs/service-fastify-cors

https://github.com/fastify/fastify-cors

Options:

```js
setConfig('fastify.cors', {
  ...options here
});
```
npm package: @forrestjs/service-fastify-healthz
Description: ForrestJS service which adds a healthcheck route to a Fastify server.
Author: Marco Pegoraro
Latest version: 5.2.2

# @forrestjs/service-fastify-healthz

ForrestJS service which helps setting up an Fastify healthcheck route.

DEMO:  
https://codesandbox.io/s/service-fastify-healthz-4g3my

## Install & Setup

```bash
npm add @forrestjs/core @forrestjs/service-fastify @forrestjs/service-fastify-healthz
```

set it up in your FastifyJS App:

```js
// index.js
const forrestjs = require('@forrestjs/core');
const fastifyService = require('@forrestjs/service-fastify');
const fastifyHealthzService = require('@forrestjs/service-fastify-healthz');

// Run the app:
forrestjs.run({
  services: [fastifyService, fastifyHealthzService],
});
```

## Configuration & ENVs

### fastify.healthz.method

default: `GET`

### fastify.healthz.url

default: `/healthz`

## Extensions

### 🧩 $FASTIFY_HEALTHZ_HANDLER

This hooks allows to override the default healthcheck route.  
It is useful in case you want to perform rich logic during a healthcheck.

```js
// Create a custom healthcheck response
const HEALTHZ_MSG = 'This is a custom healthcheck response';
const customHealthz = ({ registerHandler }) =>
  registerHandler(async () => HEALTHZ_MSG);

forrestjs.run({
  features: [
    {
      target: '$FASTIFY_HEALTHZ_HANDLER',
      handler: customHealthz,
    },
  ],
});
```
npm package: @forrestjs/service-fastify-static
Description: ForrestJS service which adds static content serving to a Fastify server.
Author: Marco Pegoraro
Latest version: 5.2.2

# @forrestjs/service-fastify-static

ForrestJS wrapper to the [Fastify Static](https://github.com/fastify/fastify-static) plugin.

## Live Demo

https://codesandbox.io/s/service-fastify-static-6u8mm

## Install & Setup

Install the dependency:

```bash
npm add @forrestjs/service-fastify-static
```

Add it to your App:

```js
// index.js
const path = require('path');
const forrestjs = require('@forrestjs/core');
const serviceFastify = require('@forrestjs/service-fastify');
const serviceFastifyStatic = require('@forrestjs/service-fastify-static');

// Run the app:
forrestjs.run({
  services: [serviceFastify, serviceFastifyStatic],
  settings: {
    fastify: {
      static: {
        root: path.join(__dirname, 'public'),
      },
    },
  },
});
```

## Options

```js
setConfig('fastify.static', {
  ...options here
});
```
npm package: @forrestjs/service-fetchq
Description: ForrestJS service which helps setting up a Fetchq node.
Author: Marco Pegoraro
Latest version: 5.2.2

# @forrestjs/service-fetchq

## ForrestJS FetchQ Service

Minimalist FetchQ wrapper that sets up a FetchQ client and injects it into
the app's context.

```js
const forrestjs = require('@forrestjs/core');
const serviceEnv = require('@forrestjs/service-env');
const serviceLogger = require('@forrestjs/service-logger');
const serviceFetchq = require('./service/service-fetchq');

const settingsHandler = ({ setConfig, getEnv }) =>
  setConfig('fetchq', {
    logLevel: 'info',
    connectionString: 'postgres://user:pass@host:port/db',
    skipExtension: true,
    queues: [
      {
        name: 'queue_name',
        isActive: true,
        enableNotifications: true,
      },
    ],
  });

forrestjs.run({
  trace: 'compact',
  settings: settingsHandler,
  services: [serviceEnv, serviceLogger, serviceFetchq],
});
```
npm package: @forrestjs/service-hash
Description: [deprecated] ForrestJS service which helps hashing stuff with bcrypt.
Author: Marco Pegoraro
Latest version: 5.0.3
Deprecated: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

# @forrestjs/service-hash (deprecated)

**🚧 DEPRECATED 🚧**

ForrestJS service which helps hashing stuff with bcrypt.

## Usage

`service-hash` decorates the _Hooks App Context_ with a `hash.encode()` and `hash.compare()` helpers:

```js
const hooks = require('@forrestjs/core');
hooks.registerAction({
  hook: hooks.FINISH,
  handler: async (args, ctx) => {
    const encoded = await ctx.hash.encode('foo');
    console.log(encoded);

    const isValid = await ctx.hash.compare('foo', encoded);
    console.log(isValid);
  },
});
```

After the _Hooks App_ initializes, you can simply import the helpers and use it straight:

```js
const { encode, compare } = require('@forrestjs/service-jwt');

const encoded = await ctx.hash.encode('foo');
const isValid = await ctx.hash.compare('foo', encoded);
```

## Configuration

**NOTE:** the `salt` setting is optional, if not provided, a new salt will be generated at boot time
and logged out as "info" message.

## Environment

**NOTE:** it is important to list `service-hash` _AFTER_ `service-env` so that any kind of environment
configuration is available to be used.

```bash
HASH_ROUNDS=5
HASH_SALT=xxx
```

## Config

```js
registerAction({
  hook: SETTINGS,
  handler: ({ setConfig }) => {
    setConfig('jwt.rounds', 5);
    setConfig('jwt.salt', '$2a$05$EWFE8/77wXdbYuzyx9Golu');
  },
});
```

## Fastify integration

```js
const feature = {
  hook: '$FASTIFY_GET',
  handler: {
    url: '/hash/encode/:input',
    handler: async (request) => request.hash.encode(request.params.input),
  },
};
```
npm package: @forrestjs/service-hasura-cqrs
Description: NodeJS client to issue GraphQL queries towards an Hasura endpoint, and Hasura admin APIs
Author: Marco Pegoraro
Latest version: 5.2.2

# Hasura CQRS

Facilitates the management of CQRS pattern using Hasura as database abstraction, Fetchq as orchestrator, and a REST backend as logical executor for the commands.

The Service offers new Extensions to perform different CQRS logic.

Dependencies:

- [service-fetchq](../service-fetchq/)
- [service-fetchq-task](../service-fetchq-task/)
- [service-hasura-client](../service-hasura-client/)

## $HASURA_CQRS_SOURCE

Ingest commands from a CQRS Hypertable into a Fetchq queue.

[Schema](./src/utils/validate-source.js)

## $HASURA_CQRS_ROUTER

Moves documents from one queue to one (or more) target queues, effectively routing documents towards independent streams.

[Schema](./src/utils/validate-router.js)

## $HASURA_CQRS_SHARD

Moves documents from one queue to another target queue, effectively helping to shard a queue into many independent streams.

[Schema](./src/utils/validate-shard.js)

## $HASURA_CQRS_RESTIFY

It consumes one or more queues and makes REST requests in order to process the document.

It also facilitates the writing of the Command response or error into the CQRS Hypertable.

[Schema](./src/utils/validate-restify.js)
npm package: @forrestjs/service-jwt
Description: ForrestJS service which helps handling jwt activities.
Author: Marco Pegoraro
Latest version: 5.2.2

# @forrestjs/service-jwt

ForrestJS service which helps handling jwt activities. More or less it provides
a _Promise_ wrapped `jsonwebtoken` module.

## Usage

`service-jwt` decorates the _App's Context_ with a `jwt.sign()` and `jwt.verify()` helpers:

```js
registerAction({
  target: 'myHook',
  handler: async (args, ctx) => {
    const token = await ctx.jwt.sign({ foo: 123 });
    console.log(token);

    const data = await ctx.jwt.verify(token);
    console.log(data);
  },
});
```

After the App initializes, you can simply import the helpers and use it straight:

```js
const { sign, verify } = require('@forrestjs/service-jwt');

const token = await sign({ foo: 123 });
const isValid = await verify(token);
```

## Configuration

## Environment

**NOTE:** it is important to list `service-jwt` _AFTER_ `service-env` so that any kind of environment
configuration is available to be used.

```bash
JWT_SECRET=xxx
JWT_DURATION=1y
```

## Config

```js
registerAction({
  target: '$SETTINGS',
  handler: ({ setConfig }) => {
    setConfig('jwt.secret', 'your-safe-secret');
    setConfig('jwt.duration', '1y');
  },
});
```

## Methods

### sign(payload, [ settings{}, customSecret ])

`settings` can use whatever you would pass to `jsonwebtoken`. The property
`expiresIn` is defaulted to the global `duration` setting.

`customSecret` is defaulted to the global `secret` setting.

### verify(token, [ customSecret ])

`customSecret` is defaulted to the global `secret` setting.

It resolves with the token's decoded content or throws an error in case it it
not valid.
npm package: @forrestjs/service-meta
Description: Loads configuration from text files in _JSON_ format
Author: Marco Pegoraro
Latest version: 5.2.2

# Service Meta

Loads configuration from text files in _JSON_ format.  
<small>(_YAML_ will come)</small>

- {file_name}.{env_name}.json
- {file_name}.{suffix_name}.json
- {file_name}.json

The sourced content will be available in the App's context in a key that reflects the file name without the extension:

```js
getContext('meta.{fileName}.key.key');
```

## Config

### meta.path

Change the source for the meta files that should be sourced.

Default: `/var/lib/meta`

### meta.local

Change the local suffix to look for when sourcing the file.

Default: `local`

### meta.source

List of the files to source. Use full name with extension (.json) but without suffix.

Default: `[]`

## Extensions

### $META_SOURCE

```js
const f1 = {
  target: '$META_SOURCE',
  handler: () => 'file_name.json',
};
```
npm package: @forrestjs/service-pg
Description: ForrestJS service which keeps a pooled connection to a PostgreSQL database
Author: Marco Pegoraro
Latest version: 5.2.2

# @forrestjs/service-pg

ForrestJS service which keeps a pooled connection to a PostgreSQL database. It's a wrapper around [pg](https://www.npmjs.com/package/pg) library.

## Usage

You can run the `$PG_READY` extension to execute SQL logic at boot time:

```js
const myFeature = {
  target: '$PG_READY',
  handler: async ({ query }) => {
    const res = await query('SELECT NOW()');
    console.log(res.rows);
  },
};
```

Or you can get a reference to the `query` function or the `pool` object from the context:

```js
const myFeature = {
  target: '$START_FEATURE',
  handler: async ({ getContext }) => {
    const query = getContext('pg.query');
    await query('CREATE TABLE IF NOT EXISTS...');
  },
};
```

---

## Configuration

### pg.connectionString

Falls back on env `PGSTRING`.

### pg.exitOnError

Falls back on env `SERVICE_PG_EXIT_ON_ERROR`.

### pg.maxConnections

Falls back on env `SERVICE_PG_MAX_CONNECTIONS`.

### pg.poolConfig

Any configuration that you can give to the library `pg`.

---

## Environment

### PGSTRING

Standard connectivity string for PostgreSQL

```
PGSTRING=postgres://postgres:postgres@localhost:5432/postgres
```

### SERVICE_PG_EXIT_ON_ERROR

If set to `true` the library will crash the project in case connectivity is lost. Default is `false`.

### SERVICE_PG_MAX_CONNECTIONS

Max number of pooled connections to the database server. Default is `10`.
npm package: @forrestjs/service-pg-schema
Description: ForrestJS service helps building a small PostgreSQL Schema
Author: Marco Pegoraro
Latest version: 5.2.2

# pgSchema

Facilitates the maintenance of a simple PostgreSQL schema by running queries at boot time or in case of a TDD reset event.

> This service depends on [pg-service](https://www.npmjs.com/package/@forrestjs/service-pg).

## Configuration

### pgSchema.build

Default: `{}`

Provide configuration to the _build_ extension.

### pgSchema.seed

Default: `{}`

Provide configuration to the _seed_ extension.

### pgSchema.reset

Default: `{}`

Provide configuration to the _reset_ extension.

## Extensions

### $PG_SCHEMA_BUILD

```js
const f1 = {
  target: "$PG_SCHEMA_BUILD",
  handler: async ({ query, config }) => {
    await query("CREATE TABLE ...");
    await query("CREATE TABLE ...");
  }
};
```

### $PG_SCHEMA_SEED

```js
const f1 = {
  target: "$PG_SCHEMA_SEED",
  handler: async ({ query, config }) => {
    await query("INSERT INTO ... ON CONFLICT DO NOTHING");
    await query("INSERT INTO ... ON CONFLICT DO NOTHING");
  }
};
```

### $PG_SCHEMA_RESET

```js
const f1 = {
  target: "$PG_SCHEMA_RESET",
  handler: async ({ query, config }) => {
    await query("DROP TABLE ...");
    await query("DROP TABLE ...");
  }
};
```
npm package: @forrestjs/service-postgres-pubsub
Description: ForrestJS service which helps turning a Postgres db into a pub/sub facility.
Author: Marco Pegoraro
Latest version: 4.7.2
Deprecated: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

# @forrestjs/service-postgres-pubsub

**🚧 DEPRECATED 🚧**
service-pg-pubsub will come soon!

This service leverages a _Postgres_ database to implement a pub/sub mechanism
that can scale across multiple instances of a web service.

It implements [node-pg-pubsub](https://github.com/voxpelli/node-pg-pubsub) that
is a library that works just fine.

## Usage

```js
import { addChannel, publish, once } from '@forrestjs/service-postgres-pubsub'

// create a persistent channel, the return value is a function that
// you can call to cleanup the subscription
const removeChannel = addChannel('channelName', msh => {
    console.log('channel was called with', msh)
});

// you do not need to cleanup this, it's going to be fired just once
once('channelName', () => { ... })

publish('channelName', { some: 'data' })
// -> expect the console log here
```

All the methods above take a 3rd argument called `connectionName` that allows to target
a specific _Postgres_ instance in case your app is connected to multiple ones.

## Configuration

You can provide multiple _Postgres_ connections, they should be identified by
a `connectionName` property. If omitted it's going to be `default`.

```js
registerAction({
  hook: SETTINGS,
  name: '♦ boot',
  handler: async ({ settings }) => {
    settings.postgresPubsub = [
      {
        connectionName: 'default',
        host: config.get('PG_HOST'),
        port: config.get('PG_PORT'),
        database: config.get('PG_DATABASE'),
        username: config.get('PG_USERNAME'),
        password: config.get('PG_PASSWORD'),
      },
    ];
  },
});
```
npm package: @forresto/svg-to-cnc
Description: Compiles SVG shapes and transforms for CNC software down to basic paths. Each combination of stroke and fill becomes one path element. This makes it easier to attach them in CAM software (like Cricut Designer), and then set the tool for each layer.
Author: Forrest Oliphant
Latest version: 0.0.2

# svg-to-cnc

Compiles SVG shapes and transforms for CNC software down to basic paths. Each combination of stroke and fill becomes one path element. This makes it easier to attach them in CAM software (like Cricut Designer), and then set the tool for each layer.

Demo, with SVG file input: https://observablehq.com/@forresto/svg-to-cnc

## Features

* Converts all shapes to paths
* Bakes all nested transformations into the path
* Removes grouping
* Combines all paths with the same stroke/stroke-width/fill into one path

## Why

Cricut's software chokes with some indeterminate combination of element count, groups, and transforms. Issues that I've noticed:

- With ~100 groups of elements: "attach" action makes the app freeze
- With many cut and draw elements: there is no way to maintain those on import(?), so it's a pain to select each one to set the pen color / tool
- \`transform="translate(-10, 0)"\` switches x and y, moving elements up instead of left 😶
- Some combination of \`translate\` and \`scale\` gets... lost... in _translation_ 😏

Cricut's software and file format are closed-source, so I was losing hope that I could work with my generative designs. Then, I got this idea. It seems like it can handle small numbers of big paths. What if I brute-force the design down to one path per tool?

~~File size is much larger.~~ _(Edit: fixed that with smarter flattening.)_ Cricut doesn't choke. Success! (Seems like they could make this an option when importing. 🤔)

Tested with a [moderately complex SVG](https://observablehq.com/@forresto/moon-grid), and it's much easier to work with.

## Cricut/SVG Tips

1 inch = 72px, so you can design with a function like this:

~~~js
function inch (n) { return n * 72 };

inch(8.5); // 612
inch(2); // 144
inch(1/2); // 36
inch(1/4); // 18
~~~

If designing for a specific size paper, make **registration marks** in a color that you won't use. Make them 1/4 inch from each corner. This should make the output centered as you expect. When Cricut asks you to insert that color pen, press "Go" without a pen in the holder.

Set SVG width and height to inches, and viewBox to pixels:

~~~svg
<svg width="8.5in" height="11in" viewBox="0 0 612 792">
~~~

## Todo

- [x] Close circle, rect
- [x] Support more shapes
- [x] UI
- [x] Be smarter about how to compile the paths 🤷‍♀️
- [x] Fix \`viewBox\` breaks measuring
- [ ] Fix unneeded penup / pendown (\`M\`)
- [x] Option to not consolidate paths (only group by "tool")
- [ ] Nix fills?
npm package: @forsakringskassan/commitlint-config
Description: FK commitlint shareable config
Author: Försäkringskassan
Latest version: 3.3.10

# @forsakringskassan/commitlint-config

Based on [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) with additional checks for JIRA.

> <type>[optional scope]: <subject> (<reference>)
>
> [optional body]
>
> [optional footer(s)]

1. `fix: ` fixes a bug and results in a `PATCH` release.
2. `feat: ` introduces a new feature and results in a `MINOR` release.
3. `BREAKING CHANGE: ` in the footer followed by a description results in a `MAJOR` release. The description is added to the changelog.
4. `types` other than `fix` and `feat` is allowed, see list at [@commitlint/config-conventional](https://github.com/conventional-changelog/commitlint/tree/master/%40commitlint/config-conventional#type-enum)
5. `(fixes XYZ-123)` or `(refs XYZ-123)` JIRA reference must be included after subject.

## Install

```bash
$ npm install --save-dev @forsakringskassan/commitlint-config
```

This package bundles `@commitlint/cli` so it does not have to be installed separately.

## Configuration

This package provides two variants:

- `@forsakringskassan/commitlint-config/default`
- `@forsakringskassan/commitlint-config/no-jira`

The default configuration enforces a JIRA reference at the end of the header.
The `no-jira` variant does not enforce it.

```bash
npm pkg set commitlint.extends=@forsakringskassan/commitlint-config/default
```

or manually edit `package.json`:

```json
{
    "commitlint": {
        "extends": "@forsakringskassan/commitlint-config/default"
    }
}
```

## Git hooks

This package uses a postinstall script to automatically add Git hooks to your application.

- Prettier and Esbuild will run before commit is created (if packages exist in your application
- The commit message will be validated.

If you already have `husky`, `simple-git-hooks` or `lint-staged` in your `package.json` you need uninstall them first:

```bash
npm rm lint-staged husky simple-git-hooks
```
npm package: @forsakringskassan/sass-module-importer
Description: sass module importer
Author: Försäkringskassan
Latest version: 2.0.0

# @forsakringskassan/sass-module-importer

Import sass files from packages in `node_modules/`, works with and without webpack (`~`)-prefix.

```scss
@import "@fkui/design/fil.scss";
@import "~@fkui/design/anotherFile";
```

This plugin can also be used to include Sass files from a library's `main` or `exports` field.

## Installation

`npm install --save-dev @forsakringskassan/sass-module-importer`

## Usage (esm only)

In your sass compile script, add the importer:

```javascript
import { compileStringAsync } from "sass";
import { moduleImporter } from "@forsakringskassan/sass-module-importer";

const result = await compileStringAsync(mySCSS, {
    importers: [moduleImporter()],
});
```
npm package: @forsakringskassan/semantic-release-cloneman-config
Description: Försäkringskassan semantic-release cloneman configuration
Author: Försäkringskassan
Latest version: 3.9.5

# `@forsakringskassan/semantic-release-config`

> Försäkringskassan semantic-release config for [Cloneman](https://github.com/Forsakringskassan/clonemans) templates.

## Usage

```bash
npm install --save-dev @forsakringskassan/semantic-release-cloneman-config
```

In `package.json`:

```json
{
    "release": {
        "extends": "@forsakringskassan/semantic-release-cloneman-config"
    }
}
```
npm package: @forsakringskassan/semantic-release-cloneman-plugin
Description: Försäkringskassan semantic-release cloneman plugin
Author: Försäkringskassan
Latest version: 3.9.5

# `@forsakringskassan/semantic-release-cloneman-plugin`

A semantic-release plugin that publishes your [Cloneman](https://github.com/Forsakringskassan/cloneman) template to the npm registry.

## Usage

The recommended way to use this plugin is via the [`@forsakringskassan/semantic-release-cloneman-config`](../semantic-release-cloneman-config) package, which includes this plugin.

To use it standalone, install it manually and append it to your semantic config.

```bash
npm install --save-dev @forsakringskassan/semantic-release-cloneman-plugin
```

Semantic release config

```javascript
{
    "plugins": [
        ...
        ["@forsakringskassan/semantic-release-cloneman-plugin"],
        ...
    ]
}
```

## Environment Variables read by the plugin

| Variable           | Required | Description                                                      |
| ------------------ | -------- | ---------------------------------------------------------------- |
| `NPM_TOKEN`        | No       | Authentication token used to publish to the npm registry.        |
| `NPM_REGISTRY_URL` | No       | The npm registry URL. Defaults to `https://registry.npmjs.org/`. |
npm package: @forsakringskassan/semantic-release-config
Description: Försäkringskassan semantic-release base configuration
Author: Försäkringskassan
Latest version: 3.9.2

# `@forsakringskassan/semantic-release-config`

> Försäkringskassan semantic-release shared config for NPM packages.

## Usage

```bash
npm install --save-dev @forsakringskassan/semantic-release-config
```

In `package.json`:

```json
{
    "release": {
        "extends": "@forsakringskassan/semantic-release-config"
    }
}
```
npm package: @forsakringskassan/semantic-release-monorepo-config
Description: Försäkringskassan semantic-release monorepo configuration
Author: Försäkringskassan
Latest version: 3.9.4

# `@forsakringskassan/semantic-release-monorepo-config`

> Försäkringskassan semantic-release shared config for NPM packages in a monorepo setup.

## Usage

```bash
npm install --save-dev @forsakringskassan/semantic-release-monorepo-config
```

In `package.json`:

```json
{
    "release": {
        "extends": "@forsakringskassan/semantic-release-monorepo-config"
    }
}
```
npm package: @forsakringskassan/semantic-release-script-portlet-config
Description: Försäkringskassan semantic-release script-portlet configuration
Author: Försäkringskassan
Latest version: 2.5.0
Deprecated: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

# `@forsakringskassan/semantic-release-script-portlet-config`

> Försäkringskassan semantic release shared config for script portlets.

## Usage

```bash
npm install --save-dev @forsakringskassan/semantic-release-script-portlet-config
```

In `package.json`:

```json
{
    "release": {
        "extends": "@forsakringskassan/semantic-release-script-portlet-config"
    }
}
```
npm package: @forsakringskassan/semantic-release-sitevision-config
Description: Försäkringskassan semantic-release sitevision configuration
Author: Försäkringskassan
Latest version: 2.5.0
Deprecated: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

# `@forsakringskassan/semantic-release-sitevision-config`

> Försäkringskassan semantic-release shared config for Sitevision webapps and restapps.

## Usage

```bash
npm install --save-dev @forsakringskassan/semantic-release-sitevision-config
```

In `package.json`:

```json
{
    "release": {
        "extends": "@forsakringskassan/semantic-release-sitevision-config"
    }
}
```
npm package: @forsakringskassan/stylelint-config
Description: Försäkringskassans stylelint-konfiguration
Author: Försäkringskassan
Latest version: 3.3.6

# @forsakringskassan/stylelint-config

> Försäkringskassan [Stylelist shareable](https://stylelint.io) konfiguration.

## Användning

`npm install --save-dev @forsakringskassan/stylelint-config`

Notera att du inte behöver ha `stylelint` installerat i ditt repo, `stylelint` följer med som beroende till detta paketet.

Uppdatera sedan din `package.json` med följande:

```json
{
    "scripts": {
        "lint": "stylelint src/**/*.scss"
    },
    "stylelint": {
        "extends": ["@forsakringskassan/stylelint-config"]
    }
}
```
npm package: @forsakringskassan/vite-lib-config
Description: Försäkringskassan toolchain to build libraries with Vite
Author: Försäkringskassan
Latest version: 4.6.2

# `@forsakringskassan/vite-lib-config`

Toolchain for building Vue framework libraries.

- Hybrid ESM/CJS packages.
- Transpiled with Babel.
- Supports monorepo.

## Configuration

### Bundled dependencies

By default all dependencies (`dependencies` and `peerDependencies`) are marked as external and not bundled in output files.
This can be overriden by setting `externalDependencies` in `package.json`:

```diff
     "dependencies": {
         "lodash": "^4.17.20"
     },
+    "externalDependencies": [
+        "lodash"
+    ],
```

## Usage

### `babel.config.js`

```js
module.exports = {
    presets: ["@forsakringskassan/vite-lib-config/babel"],
};
```

### `vite.config.ts`

```ts
import { defineConfig } from "@forsakringskassan/vite-lib-config/vite";

export default defineConfig();
```

In addition to the regular Vite configuration you can also pass the optional `fk` property:

```
export interface FKConfig {
    /** path to component to mount by default (default `src/dev-vite/app.vue`) */
    entrypoint?: string;
    /** mocks to configure with apimock-express (default `[]`) */
    mocks?: MockEntry[];
}
```

### `package.json`

```json
{
    "scripts": {
        "build": "fk-build-vue-lib"
    }
}
```

### Optional: API Extractor

```diff
 {
     "scripts": {
         "build": "fk-build-vue-lib",
+        "postbuild": "fk-api-extractor api-extractor.json",
     }
 }
```

Multiple files or globs can be given:

> fk-api-extractor api-extractor.\*.json

To fix global module augmentations use:

> fk-api-extractor --patch-augmentations

Use `--help` to see full description.

### Dev-server

```json
{
    "scripts": {
        "start": "vite"
    }
}
```

Create `src/local.{ts,mts,mjs,js}` exporting a single function `setup`:

```
import { createApp } from "vue";
import { type SetupOptions } from "@forsakringskassan/vite-lib-config";

export function setup(options: SetupOptions): void {
    const { rootComponent, selector } = options;
    const app = createApp(rootComponent);
    app.mount(selector);
}
```

If the `setup` function is async (i.e. returns a `Promise`) it will be awaited before continuing.

Create `src/vite-dev/app.vue` containing the root component you want to serve as a development environment.

When running in dev mode an optional filename (or part of filename) can be given to run instead of default `src/vite-dev/app.vue`:

```
vite -- MyAwesomeExample
```

would search for any `.vue` file matching the given pattern (fuzzy).

### Appending Plugins

If you need to use custom plugins in your library, remember to also include the default plugins, these will otherwise by overwritten.

#### `vite.config.ts`

```ts
import {
    defineConfig,
    defaultPlugins,
} from "@forsakringskassan/vite-lib-config/vite";

export default defineConfig({
    plugins: [...defaultPlugins, myFancyPlugin],
});
```
npm package: @forsakringskassan/vitest-config
Description: Försäkringskassan shareable config for Vitest
Author: Föräkringskassan
Latest version: 2.2.5

# @forsakringskassan/vitest-config

> Forsakringskassan shareable config for Vitest

Vitest preset for Försäkringskassan.

This preset is for using with NodeJS projects.
If you need JSDOM use `@forsakringskassan/vitest-config-jsdom`.

## Installation

Install Vitest and this preset:

```bash
npm install --save-dev vitest @forsakringskassan/vitest-config
```

`vitest` must be also installed in your project; we do not support [global mode](https://vitest.dev/config/globals).

## Usage

`vite.config.mts`

```diff
 import { defineConfig } from "vitest/config";
+import { defineTestConfig } from "@forsakringskassan/vitest-config";

 export default defineConfig({
+    test: defineTestConfig(),
});
```

### Override defaults

You can pass your own config to `defineTestConfig` to override defaults:

`vite.config.mts`

```diff
 import { defineConfig } from "vitest/config";
 import { defineTestConfig } from "@forsakringskassan/vitest-config";

 export default defineConfig({
     test: defineTestConfig({
+        environment: "node",
     }),
 });
```
npm package: @forsakringskassan/vitest-config-jsdom
Description: Försäkringskassan shareable config for Vitest
Author: Föräkringskassan
Latest version: 2.2.5

# @forsakringskassan/vitest-config-jsdom

> Forsakringskassan shareable config for Vitest

Vitest preset for Försäkringskassan.

This preset is for using with browser projects.
If you do not need JSDOM use `@forsakringskassan/vitest-config`.

## Installation

Install Vitest and this preset:

```bash
npm install --save-dev vitest @forsakringskassan/vitest-config-jsdom
```

`vitest` must be also installed in your project; we do not support [global mode](https://vitest.dev/config/globals).

## Usage

`vite.config.mts`

```diff
 import { defineConfig } from "vitest/config";
+import { defineTestConfig } from "@forsakringskassan/vitest-config-jsdom";

 export default defineConfig({
+    test: defineTestConfig(),
 });
```

### Override defaults

You can pass your own config to `defineTestConfig` to override defaults:

`vite.config.mts`

```diff
 import { defineConfig } from "vitest/config";
 import { defineTestConfig } from "@forsakringskassan/vitest-config-jsdom";

 export default defineConfig({
     test: defineTestConfig({
+        environment: "node",
     }),
 });
```
npm package: @forsigner/egg-typeorm
Description: Typeorm for egg
Author: forsigner
Latest version: 1.5.1

# egg-typeorm

[TypeORM](https://typeorm.io/#/) plugin for Egg.js.

[![NPM version][npm-image]][npm-url]
[![npm download][download-image]][download-url]

[npm-image]: https://img.shields.io/npm/v/@forsigner/egg-typeorm.svg?style=flat-square
[npm-url]: https://npmjs.org/package/@forsigner/egg-typeorm
[download-image]: https://img.shields.io/npm/dm/@forsigner/egg-typeorm.svg?style=flat-square
[download-url]: https://npmjs.org/package/@forsigner/egg-typeorm

<!--
Description here.
-->

## Install

```bash
$ yarn add @forsigner/egg-typeorm mysql
```

## Usage

### Plugin

```ts
// {app_root}/config/plugin.ts
const plugin: EggPlugin = {
  typeorm: {
    enable: true,
    package: '@forsigner/egg-typeorm',
  },
}
```

### Configuration

```ts
// {app_root}/config/config.default.ts
config.typeorm = {
  type: 'mysql',
  host: 'localhost',
  port: 3306,
  username: 'root',
  password: '123456',
  database: 'test',
  synchronize: true,
  logging: false,
  entities: ['app/entity/**/*.ts'],
  migrations: ['app/migration/**/*.ts'],
  subscribers: ['app/subscriber/**/*.ts'],
  cli: {
    entitiesDir: 'app/entity',
    migrationsDir: 'app/migration',
    subscribersDir: 'app/subscriber',
  },
}
```

### Create entity files

```bash
├── controller
│   └── home.ts
├── entity
    ├── Post.ts
    └── User.ts
```

### Entity file

```ts
// app/entity/User.ts

import { Entity, PrimaryGeneratedColumn, Column } from 'typeorm'

@Entity()
export class User {
  @PrimaryGeneratedColumn()
  id: number

  @Column()
  name: string
}
```

### Use with FindOptions

```ts
// in controller
export default class UserController extends Controller {
  public async index() {
    const { ctx } = this
    ctx.body = await ctx.repo.User.find()
  }
}
```

### Use with QueryBuilder

```ts
// in controller
export default class UserController extends Controller {
  public async index() {
    const { ctx } = this
    const firstUser = await ctx.repo.User.createQueryBuilder('user')
      .where('user.id = :id', { id: 1 })
      .getOne()
    ctx.body = firstUser
  }
}
```

## Example

[example](https://github.com/forsigner/egg-typeorm/tree/master/example)

## Questions & Suggestions

Please open an issue [here](https://github.com/forsigner/egg-typeorm/issues).

## License

[MIT](LICENSE)
npm package: @forsigner/react-native-trtc
Description: trtc
Author: forsigner
Latest version: 0.0.2

# react-native-trtc

trtc

## Installation

```sh
npm install react-native-trtc
```

## Usage

```js
import Trtc from "react-native-trtc";

// ...

const result = await Trtc.multiply(3, 7);
```

## Contributing

See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.

## License

MIT