open-index/open-npm huggingface dataset:
npm package: @mashoor-tech/core-prisma
Description: Shared Prisma schemas and clients for Mashoor microservices
Author: MashoorTech
Latest version: 1.1.5

# @mashoor/core-prisma

> **Shared Prisma schemas and clients for Mashoor microservices architecture.**

---

## 🚀 Installation


```bash
npm install @mashoor/core-prisma
```

---

## ⚡ Quick Start

### 1. Set Environment Variables

You can use a `.env` file (recommended) or set variables in your shell:

```env
DATABASE_URL="postgresql://username:password@localhost:5432/mashoor"
```

### 2. Initialize Databases

```bash
mashoor-core-prisma init
```

---

## 🛠️ Common CLI Commands

All commands are run directly with `mashoor-core-prisma`. Replace `COMMAND` with one of the options below:

| Command   | Description                        |
|-----------|------------------------------------|
| check     | Check environment and status        |
| init      | Initialize database and migrations  |
| migrate   | Run all migrations                  |
| generate  | Generate Prisma client              |
| studio    | Open Prisma Studio                  |
| reset     | Reset database (dev only!)          |
| push      | Push schema changes                 |
| format    | Format Prisma schema                |
| deploy    | Deploy migrations (production)      |
| status    | Check migration status              |
| help      | Show help message                   |

**Example:**

```bash
mashoor-core-prisma migrate
```

---


## 🌱 Usage Examples

### Usage

```typescript
import { PrismaClient } from '@mashoor-tech/core-prisma';

async function main() {
  const client = new PrismaClient();
  const users = await client.user.findMany();
  console.log(users);
}
main();
```

---


## 🧑‍💻 Development

### Prerequisites

- Node.js 18+
- A PostgreSQL database

### CLI Usage Only

All database and schema operations are performed using the CLI:

```bash
mashoor-core-prisma generate   # Generate Prisma client
mashoor-core-prisma migrate    # Run all migrations
mashoor-core-prisma deploy     # Deploy migrations (production)
mashoor-core-prisma status     # Check migration status
mashoor-core-prisma reset      # Reset database (dev only!)
mashoor-core-prisma push       # Push schema (no migration)
mashoor-core-prisma studio     # Open Prisma Studio
mashoor-core-prisma format     # Format Prisma schema
mashoor-core-prisma check      # Check environment setup
mashoor-core-prisma init       # Initialize database and migrations
```

---


## 🏛️ Architecture

This package contains the main Prisma schema and generates a Prisma client accessible via `generated/index.js`. You can use this client for all your database operations.

---

## 📄 License

MIT
npm package: @mashroom-content/mashroom-content-asset-processing
Description: Mashroom Content Asset services
Latest version: 1.0.4


# Mashroom Content Assets

Plugin for [Mashroom Server](https://www.mashroom-server.com), a **Microfrontend Integration Platform**.
Part of the [Mashroom Content](https://github.com/nonblocking/mashroom) extension.

This plugin adds a service to fetch and process assets (e.g. image conversion).

## Usage

If *node_modules/@mashroom* is configured as plugin path just add **@mashroom-content/mashroom-content-asset-processing** as *dependency*.

You can override the default config in your Mashroom config file like this:

```json
{
    "plugins": {
        "Mashroom Content Asset Processing Services": {
            "scaleUp": false,
            "defaultQuality": 75,
            "cacheEnable": true,
            "cacheDefaultTTLSec": 31536000,
            "cacheFolder": "./data/asset-proc-cache"
        }
    }
}
```

* _scaleUp_: Scale images up (Default: false)
* _defaultQuality_: Default image conversion quality (Default: 75)
* _cacheEnable_: Enable asset cache (Default: true)
* _cacheDefaultTTLSec_: Asset cache TTL in seconds (Default: 31536000)
* _cacheFolder_: Cache folder (Default: ./data/asset-proc-cache)

### Service

On the Server side you can use the following new service accessible through _pluginContext.services.assetProc.service_:

```ts
export interface MashroomContentAssetProcService {
    /**
     * Process and return given asset from URI - result will be cached
     */
    processAssetFromUri(assetUri: string, resize?: MashroomContentAssetProcImageResize, convert?: MashroomContentAssetProcImageConvert): Promise<MashroomContentAssetProc>;

    /**
     * Process given asset
     */
    processAsset(asset: Readable, resize?: MashroomContentAssetProcImageResize, convert?: MashroomContentAssetProcImageConvert): Promise<Readable>;
}
```
npm package: @mashroom-content/mashroom-content-markdown-renderer-app
Description: Mashroom Content Simple Markdown Renderer App
Latest version: 1.0.4


# Mashroom Content Markdown Renderer App

Plugin for [Mashroom Server](https://www.mashroom-server.com), a **Microfrontend Integration Platform**.
Part of the [Mashroom Content](https://github.com/nonblocking/mashroom) extension.

This Portal App renders Markdown content from a Headless CMS
and also provides the possibility to update/create content directly as Administrator.

### Features

 * Images are automatically optimized for the target devices (and converted to webp/avif if possible)
 * Server-side rendering for SEO
 * Simple integration of Videos from the local media library, Youtube or Vimeo
 * Extra CSS per instance which will only be applied to the content

#### Markdown extensions

 * Supports [Github Flavored Markdown](https://github.github.com/gfm/) (e.g. tables)
 * Supports [Markdown Directives](https://talk.commonmark.org/t/generic-directives-plugins-syntax/444):

```markdown
:::div{class=my-class}

her my text

:::
```

Or:

```markdown
::a[My Link]{href=/goto target=_blank}
```

 * A bunch of custom extensions such as:

```markdown
::vimeo{id=612710291 privateKey=dba51808e0}
::youtube{id=z9eoubnO-pE}
::video{src=/url-to-my-video}
::button{href=/url-to-navigate-to target=_blank}
```

 * And the built-in possibility to jump to specific elements like this:

```markdown
::h2[My header]{id=myHeader}

Jump to it with:

::a[Jump]{gotoId=myHeader}

or

::button[Jump]{gotoId=myHeader}
```

## Usage

If *node_modules/@mashroom* is configured as plugin path just add **@mashroom-content/mashroom-content-markdown-renderer-app** as *dependency*.

After that you can Drag the App _Mashroom Display_ onto any page via Admin Toolbar.

**Important note**: This App assumes a content type _markdown_ exists and has the following structure:

```json
{
    "title": "My content",
    "content": "Here some **markdown** content"
}
```

If you need to change that globally you can override it in your Mashroom config file like this:

```json
{
    "plugins": {
        "Mashroom Content Markdown Renderer App": {
            "appConfig": {
                "contentType": "markdown",
                "contentProp": "content",
                "titleProp": "title"
            }
        }
    }
}
```

* _contentType_: The content type (Default: markdown)
* _contentProp_: The property that contains the actual content (Default: content)
* _titleProp_: The property that contains the title (Default: title)
npm package: @mashroom-content/mashroom-content-media-library-app
Description: Mashroom Content Media Library App
Latest version: 1.0.4


# Mashroom Content Media Library App

Plugin for [Mashroom Server](https://www.mashroom-server.com), a **Microfrontend Integration Platform**.
Part of the [Mashroom Content](https://github.com/nonblocking/mashroom) extension.

This Portal App allows it to manage a Media Library (Images, Videos).

## Usage

If *node_modules/@mashroom* is configured as plugin path just add **@mashroom-content/mashroom-content-media-library-app** as *dependency*.

After that you can Drag the App _Mashroom Content Media Library App_ onto any page via Admin Toolbar.

And you can also use it in your custom Portal Apps to lookup assets like this:

```typescript
const responseChannelTopic = `__selected_image_${randomId()}__`;
const mediaLibraryAppConfig = {
    modalMode: true,
    typeFilter: 'image',
    responseChannelTopic,
};
portalAppService.loadAppModal('Mashroom Content Media Library App', 'Select Image', mediaLibraryAppConfig).then((portalApp) => {
    messageBus.subscribeOnce(responseChannelTopic, (asset: MashroomContentAsset) => {
        console.debug('Received asset:', asset);
        // TODO: process received asset
        portalAppService.unloadApp(portalApp.id);
    });
});
```
npm package: @mashroom-content/mashroom-content-provider-internal-storage
Description: Mashroom Content Internal Storage Provider
Latest version: 1.0.4


# Mashroom Content Internal Storage Provider

Plugin for [Mashroom Server](https://www.mashroom-server.com), a **Microfrontend Integration Platform**.
Part of the [Mashroom Content](https://github.com/nonblocking/mashroom) extension.

This plugin adds a content provider which uses the internal Mashroom storage (e.g. Mongo).

## Usage

If *node_modules/@mashroom* is configured as plugin path just add **@mashroom-content/mashroom-content-provider-internal-storage** as *dependency*.

You can override the default config in your Mashroom config file like this:

```json
{
    "plugins": {
        "Mashroom Content Internal Storage Provider": {
           "assetsFolder": "./data/assets"
        }
    }
}
```

* _assetsFolder_: The folder where uploads should be stored (absolute or relative to the server config file)
  ***NOTE***: This needs to be a shared folder among all Mashroom instances.
npm package: @mashroom-content/mashroom-content-provider-strapi
Description: Mashroom Content Internal Storage Provider
Latest version: 1.0.4


# Mashroom Content Strapi Provider

Plugin for [Mashroom Server](https://www.mashroom-server.com), a **Microfrontend Integration Platform**.
Part of the [Mashroom Content](https://github.com/nonblocking/mashroom) extension.

This plugin adds a content provider which uses the [Strapi Headless CMS](https://strapi.io/) as backend.

Only tested with Strapi 4.x. Supports internationalization but no versioning and also not the draft mechanism.

## Usage

If *node_modules/@mashroom* is configured as plugin path just add **@mashroom-content/mashroom-content-provider-strapi** as *dependency*.

You can override the default config in your Mashroom config file like this:

```json
{
    "plugins": {
        "Mashroom Content Strapi Provider": {
            "strapiVersion": 5,
            "strapiUrl": "http://localhost:1337",
            "apiToken": "xxxxxxx"
        }
    }
}
```

* _strapiVersion_: The Strapi version, possible values: 5, 4 (Default: 5)
* _strapiUrl_: Strapi server base URL
* _apiToken_: Strapi API token

### Preparing the Strapi instance

Your Strapi instance needs at least an activated Internationalization Plugin with the same languages as configured in _Mashroom_

Also, if you want to use the _Mashroom Content Markdown Renderer App_ you need to create a content type _markdown_ with two properties: _title_ (string), _content_ (rich text).
npm package: @mashroom/mashroom
Description: Mashroom Server. Supports out of the box the following plugin types: 'web-app', 'api', 'middleware', 'static', 'services' and 'plugin-loader'.
Latest version: 2.9.4


# Mashroom Server

[Mashroom Server](https://www.mashroom-server.com) is a *Node.js* based **Microfrontend Integration Platform**.

This package contains the core of _Mashroom Server_. It contains core services for managing plugins and default plugin loaders
for *Express* middleware, *Express* webapps and shared code as _services_. It also provides a common logging infrastructure.

From a technical point of view this is s a plugin loader that scans npm packages (_package.json_) for plugin definitions and loads them at runtime.
Such a plugin could be an *Express* webapp or a *SPA* or more generally all kind of code it knows how to load,
which is determined by the available plugin loaders.
Plugin loaders itself are also just plugins, so it is possible to extend the list of known plugin types.

## Usage

The easiest way to start is to clone one of the quickstart repositories:
 * [mashroom-quickstart](https://github.com/nonblocking/mashroom-quickstart)
 * [mashroom-portal-quickstart](https://github.com/nonblocking/mashroom-portal-quickstart)

You can find a full documentation with a setup and configuration guide here: [https://www.mashroom-server.com/documentation](https://www.mashroom-server.com/documentation)
npm package: @mashroom/mashroom-browser-cache
Description: Mashroom services to control browser caching
Latest version: 2.9.4


# Mashroom Browser Cache

Plugin for [Mashroom Server](https://www.mashroom-server.com), a **Microfrontend Integration Platform**.

This plugin adds a Service to manage cache control headers. It also allows to disable the cache globally.

## Usage

If *node_modules/@mashroom* is configured as plugin path just add **@mashroom/mashroom-browser-cache** as *dependency*.

After that you can use the service like this:

```ts
import type {MashroomCacheControlService} from '@mashroom/mashroom-browser-cache/type-definitions';

export default async (req: Request, res: Response) => {

    const cacheControlService: MashroomCacheControlService = req.pluginContext.services.browserCache.cacheControl;
    await cacheControlService.addCacheControlHeader('ONLY_FOR_ANONYMOUS_USERS', req, res);

    // ..
};
```

You can override the default config in your Mashroom config file like this:

```json
{
  "plugins": {
        "Mashroom Cache Control Services": {
            "disabled": false,
            "maxAgeSec": 31536000
        }
    }
}
```
 * _disabled_: Disable browser caching (default: false)
 * _maxAgeSec_: Max age in seconds (default: 31536000 (30d))

## Services

### MashroomCacheControlService

The Cache Control service is accessible through _pluginContext.services.browserCache.cacheControl_

**Interface:**

```ts
export interface MashroomCacheControlService {
    /**
     * Add the Cache-Control header based on the policy and authentication status.
     */
     addCacheControlHeader(cachingPolicy: CachingPolicy, request: Request, response: Response): void;

    /**
     * Remove a previously set Cache-Control header
     */
     removeCacheControlHeader(response: Response): void;
}
```

Caching Policies are:

```ts
export type CachingPolicy =  'SHARED' | 'PRIVATE_IF_AUTHENTICATED' | 'NEVER' | 'ONLY_FOR_ANONYMOUS_USERS';
```
npm package: @mashroom/mashroom-cdn
Description: A Mashroom service to manage CDN hosts
Latest version: 2.9.4


# Mashroom CDN

Plugin for [Mashroom Server](https://www.mashroom-server.com), a **Microfrontend Integration Platform**.

This plugin adds a Service to manage CDN hosts.
It basically just returns a host from a configurable list, which can be used to access an asset via CDN.

<span class="panel-info">
**NOTE**: The *mashroom-cdn* plugin requires a CDN that works like a transparent proxy, which forwards an identical request to
the *origin* (in this case Mashroom) if does not exist yet.
</span>

## Usage

If *node_modules/@mashroom* is configured as plugin path just add **@mashroom/mashroom-cdn** as *dependency*.

After that you can use the service like this:

```ts
import type {MashroomCDNService} from '@mashroom/mashroom-cdn/type-definitions';

export default async (req: Request, res: Response) => {

    const cdnService: MashroomCDNService = req.pluginContext.services.cdn.service;

    const cdnHost = cdnService.getCDNHost();
    const resourceUrl = `${cdnHost}/<the-actual-path>`;

    // ..
};
```

You can override the default config in your Mashroom config file like this:

```json
{
  "plugins": {
        "Mashroom CDN Services": {
            "cdnHosts": [
                "//cdn1.myhost.com",
                "//cdn2.myhost.com"
            ]
        }
    }
}
```
 * _cdnHosts_: A list of CDN hosts (default: [])

## Services

### MashroomCDNService

The CDN service is accessible through _pluginContext.services.cdn.cacheControl_

**Interface:**

```ts
export interface MashroomCDNService {
    /**
     * Return a CDN host or null if there is none configured.
     */
    getCDNHost(): string | null;
}
```
npm package: @mashroom/mashroom-csrf-protection
Description: Mashroom CSRF protection middleware and services
Latest version: 2.9.4


# Mashroom CSRF Protection

Plugin for [Mashroom Server](https://www.mashroom-server.com), a **Microfrontend Integration Platform**.

If you add this plugin all updating HTTP methods (such as POST, PUT and DELETE) must contain a CSRF token automatically generated for the session.
Otherwise, the request will be rejected.

There are two ways to pass the token:

* As HTTP header _X-CSRF-Token_
* As query parameter _csrfToken_

You can use the _MashroomCSRFService_ to get the current token.

_Mashroom Portal_ automatically uses this plugin to secure all requests if available.

## Usage

If *node_modules/@mashroom* is configured as plugin path just add **@mashroom/mashroom-csrf-protection** as *dependency*.

After that you can use the service like this:

```ts
import type {MashroomCacheControlService} from '@mashroom/mashroom-csrf-protection/type-definitions';

export default (req: Request, res: Response) => {

    const csrfService: MashroomCacheControlService = req.pluginContext.services.csrf.service;
    const token = csrfService.getCSRFToken(req);

    // ...
}
```

You can override the default config in your Mashroom config file like this:

```json
{
  "plugins": {
        "Mashroom CSRF Middleware": {
            "safeMethods": ["GET", "HEAD", "OPTIONS"]
        },
        "Mashroom CSRF Services": {
            "saltLength": 8,
            "secretLength": 18
        }
    }
}
```

 * _safeMethods_: List of HTTP methods that require no CSRF token check (Default: ["GET", "HEAD", "OPTIONS"]).
 * _saltLength_ and _secretLength_ are passed to the [csrf](https://www.npmjs.com/package/csrf) package.

## Services

### MashroomCSRFService

The exposed service is accessible through _pluginContext.services.csrf.service_

**Interface:**

```ts
export interface MashroomCSRFService {

    /**
     * Get the current CSRF token for this session
     */
    getCSRFToken(request: Request): string;

    /**
     * Check if the given token is valid
     */
    isValidCSRFToken(request: Request, token: string): boolean;
}
```
npm package: @mashroom/mashroom-demo-webapp
Description: Demo express webapp that will be available at /demo/webapp
Latest version: 2.9.4


# Mashroom Demo Webapp

Plugin for [Mashroom Server](https://www.mashroom-server.com), a **Microfrontend Integration Platform**.

This a simple demo Express webapp which can be developed and run standalone, but also be integrated into _Mashroom Server_
on an arbitrary (configurable) path.

## Usage

If *node_modules/@mashroom* is configured as plugin path just add **@mashroom/mashroom-demo-webapp** as *dependency*.

After that the webapp will be available at _/demo/webapp_

You can change the path by overriding it in your Mashroom config file like this:

```json
{
  "plugins": {
        "Mashroom Demo Webapp": {
            "path": '/my/path'
        }
    }
}
```
npm package: @mashroom/mashroom-dll-webpack-plugin
Description: Webpack plugin that adds DLLs as shared resources to a Mashroom Portal App configuration
Latest version: 2.0.0


# Mashroom DLL Webpack Plugin

Webpack plugin that adds *DLLs* as shared resources to [Mashroom Server](https://www.mashroom-server.com) Portal Apps.

This is useful to share vendor libraries (e.g. React) between multiple Apps, which drastically reduces the bundle sizes.

## Usage

### Bundling the DLL

There is nothing specific here, just follow the [DLLPlugin](https://webpack.js.org/plugins/dll-plugin/) documentation.

To bundle React and Redux the *webpack* config in the DLL module would look like this:

```js
const path = require('path');
const webpack = require('webpack');

module.exports = {
    entry: ['react', 'react-dom', 'redux', 'react-redux'],
    output: {
        path: __dirname + '/dist',
        filename: "my_dll.js",
        // MUST contain the hash!
        library: "my_dll_[hash]"
    },
    plugins: [
        new webpack.DllPlugin({
            path: path.join(__dirname, "dist", "my_dll_manifest.json"),
            // MUST be the same as output.library!
            name: "my_dll_[hash]"
        })
    ]
};
```

### Using the DLL

In your App module add this plugin to the dependencies:

```json
{
    "devDependencies": {
        "@mashroom/mashroom-dll-webpack-plugin": "^1.0.3"
    }
}
```

And use the *webpack* *DllReferencePlugin* and this plugin to add the library as *sharedResource* to
the Portal App:

```js
const webpack = require('webpack');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const MashroomWDLLWebpackPlugin = require('@mashroom/mashroom-dll-webpack-plugin');

module.exports = {
    // ...
    plugins: [
        new CleanWebpackPlugin(),
        new MashroomWDLLWebpackPlugin({
            manifest: require("my-dll-module/dist/my_dll_manifest.json"),
            dllPath: require.resolve("my-dll-module/dist/my_dll.js")
        }),
        new webpack.DllReferencePlugin({
            manifest: require("my-dll-module/dist/my_dll_manifest.json"),
        })
    ],
}
```

This configuration is going to copy the DLL (my_dll.js) to the output path and adds it to the *Mashroom* config in *package.json* like this:

```json
    "mashroom": {
        "plugins": [
            {
                "name": "Demo Shared DLL App",
                "type": "portal-app",
                "bootstrap": "startupDemoSharedDLLApp",
                "sharedResources": {
                    "js": [
                        "my_dll_910502a6fce2f139eff8.js"
                    ]
                },
                "resources": {
                    "js": [
                        "bundle.js"
                    ]
                },
                "defaultConfig": {
                    "resourcesRoot": "./dist",
                    "appConfig": {}
                }
            }
        ]
    }
```

## Demo

See [Mashroom Demo Shared DLL](https://github.com/nonblocking/mashroom-demo-shared-dll)
npm package: @mashroom/mashroom-docs-static
Description: Mashroom documentation. Will be available at /mashroom-docs
Latest version: 2.9.4


# Mashroom Documentation

Plugin for [Mashroom Server](https://www.mashroom-server.com), a **Microfrontend Integration Platform**.

This plugin contains the Mashroom documentation. It will be generated from the markup file in the /docs folder and
the README files of the plugins.

This plugin also integrates into the Admin UI and makes the documentation available under _/mashroom/admin/ext/documentation_.
npm package: @mashroom/mashroom-error-pages
Description: Mashroom middleware to show proper HTML pages for arbitrary HTTP status codes (e.g. 404)
Latest version: 2.9.4


# Mashroom Error Pages

Plugin for [Mashroom Server](https://www.mashroom-server.com), a **Microfrontend Integration Platform**.

This plugin allows it to show proper HTML pages for arbitrary HTTP status codes.
It delivers error pages only if the request accept header contains text/html. So, typically not for AJAX requests.

## Usage

If *node_modules/@mashroom* is configured as plugin path just add **@mashroom/mashroom-error-pages** as *dependency*.

You can override the default config in your Mashroom config file like this:

```json
{
  "plugins": {
        "Mashroom Error Pages Middleware": {
            "mapping": {
                "404": "./pages/404.html",
                "403": "./pages/403.html",
                "400": "http://my.server-com/bad_request.html",
                "500": "/some/server/path/500.html",
                "default": "./pages/default.html"
            }
        }
    }
}
```

 * _mapping_: Maps status codes to error pages. The target files can be file paths or HTTP/S urls.
   If the file path is not absolute the plugin will expect it to be relative to the plugin folder or the Mashroom server config file.
   If a status code is not defined in the mapping or no default exists, no error page will be shown.

### HTML Files

 * The HTML files should not reference _local_ resources (Images, CSS, JavaScript) because they cannot be loaded
 * They may contain the following placeholders:
     * _$REQUEST_URL_: The original request URL
     * _$STATUS_CODE_: The status code
     * _$MASHROOM_VERSION_: The _Mashroom Server_ version
     * _$MESSAGE\[messageKey(,Default text if i18n not yet available)\]_: A translated message from the _mashroom-i18n_ package
npm package: @mashroom/mashroom-helmet
Description: Adds the Helmet middleware which sets a bunch of protective HTTP headers
Latest version: 2.9.4


# Mashroom Helmet

Plugin for [Mashroom Server](https://www.mashroom-server.com), a **Microfrontend Integration Platform**.

This plugin adds the [Helmet](https://helmetjs.github.io/) middleware which sets a bunch of protective HTTP headers on each response.

## Usage

If *node_modules/@mashroom* is configured as plugin path just add **@mashroom/mashroom-helmet** as *dependency*.

You can override the default config in your Mashroom config file like this:

```json
{
    "plugins": {
        "Mashroom Helmet Middleware": {
            "helmet": {
                "contentSecurityPolicy": false,
                "crossOriginEmbedderPolicy": false,
                "crossOriginOpenerPolicy": {
                    "policy": "same-origin"
                },
                "crossOriginResourcePolicy": {
                    "policy": "same-site"
                },
                "expectCt": false,
                "referrerPolicy": false,
                "hsts": {
                    "maxAge": 31536000
                },
                "noSniff": true,
                "originAgentCluster": false,
                "dnsPrefetchControl": {
                    "allow": false
                },
                "frameguard": {
                    "action": "sameorigin"
                },
                "permittedCrossDomainPolicies": {
                    "permittedPolicies": "none"
                },
                "hidePoweredBy": false,
                "xssFilter": true
            }
        }
    }
}
```

* _helmet_: The configuration will directly be passed to _Helmet_ middelware. Checkout the [Helmet Documentation](https://helmetjs.github.io/docs/)
for available options.

<span class="panel-info">
**NOTE**: You shouldn't enable the _noCache_ module because this would significantly decrease the performance of the _Mashroom Portal_.
</span>
npm package: @mashroom/mashroom-http-proxy-add-access-token
Description: Mashroom Http Proxy interceptor that adds the OpenID access token to every backend call
Latest version: 2.9.4


# Mashroom Add Access Token Http Proxy Interceptor

Plugin for [Mashroom Server](https://www.mashroom-server.com), a **Microfrontend Integration Platform**.

If you add this plugin it will add the access token from the OpenId Connect plugin to every backend call.

## Usage

If *node_modules/@mashroom* is configured as plugin path just add **@mashroom/mashroom-csrf-protection** as *dependency*.

You can override the default config in your Mashroom config file like this:

```json
{
  "plugins": {
        "Mashroom Http Proxy Add Access Token Interceptor": {
            "addBearer": false,
            "accessTokenHeader": "X-USER-ACCESS-TOKEN",
            "targetUris": [".*"]
        }
    }
}
```

 * _addBearer_: Add the token as authorization bearer header (Default: true)
 * _accessTokenHeader_: The HTTP header for the access token - has no effect if _addBearer_ is true (Default: X-USER-ACCESS-TOKEN)
 * _targetUris_: A list of regular expressions that match URIs that should receive the headers (Default: [.*])
npm package: @mashroom/mashroom-http-proxy-add-id-token
Description: Mashroom Http Proxy interceptor that adds the OpenID ID/JWT token to every backend call
Latest version: 2.1.3


# Mashroom Add ID Token Http Proxy Interceptor

Plugin for [Mashroom Server](https://www.mashroom-server.com), a **Microfrontend Integration Platform**.

If you add this plugin it will add the ID/JWT token from the OpenId Connect plugin to every backend call.

## Usage

If *node_modules/@mashroom* is configured as plugin path just add **@mashroom/mashroom-csrf-protection** as *dependency*.

You can override the default config in your Mashroom config file like this:

```json
{
  "plugins": {
        "Mashroom Http Proxy Add ID Token Interceptor": {
            "addBearer": false,
            "idTokenHeader": "X-USER-ID-TOKEN",
            "targetUris": [".*"]
        }
    }
}
```

 * _addBearer_: Add the token as authorization bearer header (Default: false)
 * _idTokenHeader_: The HTTP header for the ID token - has no effect if _addBearer_ is true (Default: X-USER-ID-TOKEN)
 * _targetUris_: A list of regular expressions that match URIs that should receive the headers (Default: [.*])
npm package: @mashroom/mashroom-http-proxy-add-user-headers
Description: Mashroom Http Proxy interceptor that adds user data to every backend call
Latest version: 2.9.4


# Mashroom Add User Header Http Proxy Interceptor

Plugin for [Mashroom Server](https://www.mashroom-server.com), a **Microfrontend Integration Platform**.

If you add this plugin it will add HTTP headers with user information to all proxy backend calls. By default, it adds:

 * X-USER-NAME
 * X-USER-DISPLAY-NAME
 * X-USER-EMAIL

## Usage

If *node_modules/@mashroom* is configured as plugin path just add **@mashroom/mashroom-csrf-protection** as *dependency*.

You can override the default config in your Mashroom config file like this:

```json
{
  "plugins": {
        "Mashroom Http Proxy Add User Headers Interceptor": {
            "userNameHeader": "X-USER-NAME",
            "displayNameHeader": "X-USER-DISPLAY-NAME",
            "emailHeader": "X-USER-EMAIL",
            "extraDataHeaders": {},
            "targetUris": [".*"]
        }
    }
}
```

 * _userNameHeader_: The HTTP header for the username (Default: X-USER-NAME)
 * _displayNameHeader_: The HTTP header for the display name (Default: X-USER-DISPLAY-NAME)
 * _emailHeader_: The HTTP header for the email address (Default: X-USER-EMAIL)
 * _extraDataHeaders_: A mapping of *user.extraData* properties to headers (Default: {})
 * _targetUris_: A list of regular expressions that match URIs that should receive the headers (Default: [.*])
npm package: @mashroom/mashroom-i18n
Description: Mashroom internationalization service
Latest version: 2.9.4


# Mashroom I18N

Plugin for [Mashroom Server](https://www.mashroom-server.com), a **Microfrontend Integration Platform**.

This plugin adds a service for internationalization. It determines the language from the HTTP headers and supports translation of messages.

## Usage

If *node_modules/@mashroom* is configured as plugin path just add **@mashroom/mashroom-i18n** as *dependency*.

After that you can use the service like this:

```ts
import type {MashroomI18NService} from '@mashroom/mashroom-i18n/type-definitions';

export default (req: Request, res: Response) => {
    const i18nService: MashroomI18NService = req.pluginContext.services.i18n.service;

    const currentLang = i18nService.getLanguage(req);
    const message =  i18nService.getMessage('username', 'de');
    // message will be 'Benutzernamen'

    // ...
}
```

You can override the default config in your Mashroom config file like this:

```json
{
    "plugins": {
        "Mashroom Internationalization Services": {
            "availableLanguages": ["en", "de", "fr"],
            "defaultLanguage": "en",
            "messages": "./messages"
        }
    }
}
```

 * _availableLanguages_: A list of available languages (Default: ["en"])
 * _defaultLanguage_: The default language if it can not be determined from the request (Default: en)
 * _messages_: The folder with custom i18n messages (Default: ./messages). There are default messages
   in the *messages* folder of this package.

The lookup for message files works like this:

 * &lt;messages_folder&gt;/messages.&lt;lang&gt;.json
 * &lt;built_in_messages_folder&gt;/messages.&lt;lang&gt;.json
 * &lt;messages_folder&gt;/messages.json
 * &lt;built_in_messages_folder&gt;/messages.json

And a messages file (e.g. _messages.de.json_) looks like this:

```json
{
    "message_key": "Die Nachricht"
}
```

## Services

### MashroomI18NService

The exposed service is accessible through _pluginContext.services.i18n.service_

**Interface:**

```ts
export interface MashroomI18NService {
    /**
     * Get the currently set language (for current session)
     */
    getLanguage(req: Request): string;

    /**
     * Set session language
     */
    setLanguage(language: string, req: Request): void;

    /**
     * Get the message for given key and language
     */
    getMessage(key: string, language: string): string;

    /**
     * Get the message for given key and language
     */
    getMessageIfExists(key: string, language: string): string | null;

    /**
     * Get plain string in the current users language from a I18NString
     */
    translate(req: Request, str: I18NString): string;

    /**
     * Get available languages
     */
    readonly availableLanguages: Readonly<Array<string>>;

    /**
     * Get the default languages
     */
    readonly defaultLanguage: string;
}
```
npm package: @mashroom/mashroom-json-schemas
Description: JSON schemas for Mashroom config files
Latest version: 2.9.4


# Mashroom JSON Schemas

JSON schemas for most configuration files used in [Mashroom Server](https://www.mashroom-server.com), a **Microfrontend Integration Platform**.

The schemas are also available as TypeScript definitions under /type-definitions.

## Available schemas

  * *package.json*: schemas/mashroom-packagejson-extension.json
  * *mashroom.json* (Server config): schemas/mashroom-server-config.json
  * *acl.json*: schemas/mashroom-security-acl.json
  * *groupToRoleMapping.json*: schemas/mashroom-security-ldap-provider-group-to-role-mapping.json
  * *userToRoleMapping.json*: schemas/mashroom-security-ldap-provider-user-to-role-mapping.json
  * *users.json*: schemas/mashroom-security-simple-provider-users.json
  * *topicACL.json*: schemas/mashroom-security-topic-acl.json
  * *remotePortalApps.json*: schemas/mashroom-portal-remote-apps.json
npm package: @mashroom/mashroom-memory-cache-provider-redis
Description: A Redis implementation for mashroom-memory-cache
Latest version: 2.9.4


# Mashroom Memory Cache Redis Provider

Plugin for [Mashroom Server](https://www.mashroom-server.com), a **Microfrontend Integration Platform**.

This plugin adds a *Redis* based provider for the *mashroom-memory-cache*.

## Usage

If *node_modules/@mashroom* is configured as plugin path just add **@mashroom/mashroom-memory-cache-provider-redis** as *dependency*.

To activate this provider configure the _Mashroom Memory Cache_ plugin like this:

```json
{
    "plugins": {
          "Mashroom Memory Cache Redis Provider": {
              "provider": "Mashroom Memory Cache Redis Provider",
              "defaultTTLSec": 10
          }
    }
}
```

And configure this plugin like this in the Mashroom config file:

```json
{
  "plugins": {
        "Mashroom Memory Cache Redis Provider": {
            "redisOptions": {
                "host": "localhost",
                "port": "6379",
                "keyPrefix": "mashroom:cache:"
           }
        }
    }
}
```

* *redisOptions*: Passed to the *Redis* constructor of [ioredis](https://github.com/luin/ioredis)

Checkout out the [ioredis](https://github.com/luin/ioredis) documentation for all available options.

### Usage with Sentinel

For a high availability cluster with [Sentinel](https://redis.io/topics/sentinel) the configuration would look like this:

```json
{
  "plugins": {
      "Mashroom Memory Cache Redis Provider": {
          "redisOptions": {
              "sentinels": [
                  { "host": "localhost", "port": 26379 },
                  { "host": "localhost", "port": 26380 }
               ],
              "name": "myMaster",
              "keyPrefix": "mashroom:cache:"
          }
      }
  }
}
```

* *sentinels*: List of sentinel nodes to connect to
* *name*: Identifies a group of Redis instances composed of a master and one or more slaves

Checkout out the *Sentinel* section of the [ioredis](https://github.com/luin/ioredis) documentation for all available options.

### Usage with a cluster

For a [sharding cluster](https://redis.io/topics/cluster-spec) configure the plugin like this:

```json
{
  "plugins": {
      "Mashroom Memory Cache Redis Provider": {
          "cluster": true,
          "clusterNodes": [
              {
                  "host": "redis-node1",
                  "port": "6379"
              },
              {
                  "host": "redis-node2",
                  "port": "6379"
              }
          ],
          "clusterOptions": {
              "maxRedirections": 3
          },
          "redisOptions": {
              "keyPrefix": "mashroom:cache:"
          }
      }
  }
}
```

* *cluster*: Enables cluster support, must be true
* *clusterNodes*: Cluster start nodes
* *clusterOptions*: Passed as second argument of the *Redis.Cluster* constructor of *ioredis*
* *redisOptions*: Passed as *redisOptions* in the *clusterOptions*

Checkout out the *Cluster* section of the [ioredis](https://github.com/luin/ioredis) documentation for all available options.
npm package: @mashroom/mashroom-messaging-external-provider-amqp
Description: Mashroom plugin that can use an AMQP 1.0 compliant broker as external messaging provider for service side messaging
Latest version: 2.9.4


# Mashroom Messaging External Provider AMQP

Plugin for [Mashroom Server](https://www.mashroom-server.com), a **Microfrontend Integration Platform**.

This plugin allows to use an AMQP 1.0 compliant broker as external messaging provider for server side messaging.
This enables cluster support for server side messaging and also allows communication with 3rd party systems.

## Usage

If *node_modules/@mashroom* is configured as plugin path just add **@mashroom/mashroom-messaging-external-provider-amqp** as *dependency*.

To activate this provider configure the _Mashroom Messaging_ plugin like this:

```json
{
    "plugins": {
        "Mashroom Messaging Services": {
            "externalProvider": "Mashroom Messaging External Provider AMQP"
        }
    }
}
```

And configure this plugin like this in the Mashroom config file:

```json
{
  "plugins": {
        "Mashroom Messaging External Provider MQTT": {
              "internalRoutingKey": "mashroom",
              "brokerTopicExchangePrefix": "/topic/",
              "brokerTopicMatchAny": "#",
              "brokerHost": "localhost",
              "brokerPort": 5672,
              "brokerUsername": null,
              "brokerPassword": null
        }
    }
}
```

 * _internalRoutingKey_: The base routing key the server should use for internal messages. E.g. if the value is *mashroom.test*
    all messages published internally are prefixed with *mashroom.test* before published to the broker and at the same time
    this provider listens to *mashroom.test.#* for messages (Default: mashroom)
 * _brokerTopicExchangePrefix_: The prefix for the topic exchange (default: /topic/ (RabbitMQ))
 * _brokerTopicMatchAny_: The wildcard for match any words (default: # (RabbitMQ))
 * _brokerHost_: AMQP broker host (Default: localhost)
 * _brokerPort_: AMQP broker port (Default: 5672)
 * _brokerUsername_: AMQP broker username (optional)
 * _brokerPassword_: AMQP broker password (optional)

### Broker specific configuration

*RabbitMQ*

     "brokerTopicExchangePrefix": "/topic/",
     "brokerTopicMatchAny": "#",

*ActiveMQ*

     "brokerTopicExchangePrefix": "topic://",
     "brokerTopicMatchAny": ">",

*Qpid Broker*

     "brokerTopicExchangePrefix": "amq.topic/",
     "brokerTopicMatchAny": "#",
npm package: @mashroom/mashroom-messaging-external-provider-mqtt
Description: Mashroom plugin that can use a MQTT server as external messaging provider for service side messaging
Latest version: 2.9.4


# Mashroom Messaging External Provider MQTT

Plugin for [Mashroom Server](https://www.mashroom-server.com), a **Microfrontend Integration Platform**.

This plugin allows to use a MQTT server as external messaging provider for server side messaging.
This enables cluster support for server side messaging and also allows communication with 3rd party systems.

## Usage

If *node_modules/@mashroom* is configured as plugin path just add **@mashroom/mashroom-messaging-external-provider-mqtt** as *dependency*.

To activate this provider configure the _Mashroom Messaging_ plugin like this:

```json
{
    "plugins": {
        "Mashroom Messaging Services": {
            "externalProvider": "Mashroom Messaging External Provider MQTT"
        }
    }
}
```

And configure this plugin like this in the Mashroom config file:

```json
{
  "plugins": {
        "Mashroom Messaging External Provider MQTT": {
            "internalTopic": "mashroom",
            "mqttConnectUrl": "mqtt://localhost:1883",
            "mqttProtocolVersion": 4,
            "mqttQoS": 1,
            "mqttUser": null,
            "mqttPassword": null,
            "rejectUnauthorized": true
        }
    }
}
```

 * _internalTopic_: The base topic the server should use for internal messages. E.g. if the value is *mashroom/test*
    all messages published internally are prefixed with *mashroom/test* before published to MQTT and at the same time
    this provider listens to *mashroom/test/#* for messages (Default: mashroom)
 * _mqttConnectUrl_: MQTT connect URL (Default: mqtt://localhost:1883)
 * _mqttProtocolVersion_: MQTT protocol version (3, 4 or 5) (Default: 4)
 * _mqttQoS_: Quality of service level (0, 1, or 2) (Default: 1)
 * _mqttUser_: Optional MQTT username (Default: null)
 * _mqttPassword_: Optional MQTT password (Default: null)
 * _rejectUnauthorized_: If you use mqtts or wss with a self-signed certificate set it to false (Default: true)
npm package: @mashroom/mashroom-messaging-external-provider-redis
Description: Mashroom plugin that can use a Redis server as external messaging provider for service side messaging
Latest version: 2.9.4


# Mashroom Messaging External Provider Redis

Plugin for [Mashroom Server](https://www.mashroom-server.com), a **Microfrontend Integration Platform**.

This plugin allows to use a Redis server as external messaging provider for server side messaging.
This enables cluster support for server side messaging and also allows communication with 3rd party systems.

## Usage

If *node_modules/@mashroom* is configured as plugin path just add **@mashroom/mashroom-messaging-external-provider-redis** as *dependency*.

To activate this provider configure the _Mashroom Messaging_ plugin like this:

```json
{
    "plugins": {
        "Mashroom Messaging Services": {
            "externalProvider": "Mashroom Messaging External Provider Redis"
        }
    }
}
```


And configure this plugin like this in the Mashroom config file:

```json
{
  "plugins": {
        "Mashroom Messaging External Provider Redjs": {
            "internalTopic": "mashroom",
            "client": {
                "redisOptions": {
                    "host": "localhost",
                    "port": "6379",
                    "maxRetriesPerRequest": 3,
                    "enableOfflineQueue": false
                },
                "cluster": false,
                "clusterNodes": null,
                "clusterOptions": null
            }
        }
    }
}
```

 * _internalTopic_: The base topic the server should use for internal messages. E.g. if the value is *mashroom/test*
   all messages published internally are prefixed with *mashroom/test* before published to MQTT and at the same time
   this provider listens to *mashroom/test/#* for messages (Default: mashroom)
 * _client_: Options for the Redis client. *redisOptions* are just to the *Redis* constructor of [ioredis](https://github.com/luin/ioredis
   Checkout out the [ioredis](https://github.com/luin/ioredis) documentation for all available options.
npm package: @mashroom/mashroom-portal-admin-app
Description: Mashroom Portal default Admin Toolbar
Latest version: 2.9.4


# Mashroom Portal Admin App

Plugin for [Mashroom Server](https://www.mashroom-server.com), a **Microfrontend Integration Platform**.

This plugin contains the default Admin Toolbar for the _Mashroom Portal_.

## Usage

If *node_modules/@mashroom* is configured as plugin path just add **@mashroom/mashroom-portal-admin-app** as *dependency*.

To enable it add the following to the _Mashroom Portal_ config:

```json
{
  "plugins": {
        "Mashroom Portal WebApp": {
            "adminApp": "Mashroom Portal Admin App"
        }
    }
}
```
npm package: @mashroom/mashroom-portal-app-gallery-app
Description: An App that shows all available Portal Apps with screenshots and some basic information
Latest version: 2.9.4


# Mashroom App Gallery

Plugin for [Mashroom Server](https://www.mashroom-server.com), a **Microfrontend Integration Platform**.

This plugin provides an App that shows all available Portal Apps with screenshots and some basic information.

## Usage

If *node_modules/@mashroom* is configured as plugin path just add **@mashroom/mashroom-portal-app-gallery-app** as *dependency*.

Then you can place it on any page via Portal Admin Toolbar.
npm package: @mashroom/mashroom-portal-app-user-extradata
Description: A Mashroom Portal plugin that copies the property 'extraData' from the server user object to the Portal App user
Latest version: 2.9.4


# Mashroom Portal App User ExtraData

Plugin for [Mashroom Server](https://www.mashroom-server.com), a **Microfrontend Integration Platform**.

This plugin copies the property *extraData" from the server user object to the Portal App user.
This is useful if the security provider adds some extra information (such as the phone number) and you want to use it in a Portal App.

## Usage

If *node_modules/@mashroom* is configured as plugin path just add **@mashroom/mashroom-portal-app-user-extradata** as *dependency*.
npm package: @mashroom/mashroom-portal-default-layouts
Description: Default Portal layouts
Latest version: 2.9.4


# Mashroom Portal Default Layouts

Plugin for [Mashroom Server](https://www.mashroom-server.com), a **Microfrontend Integration Platform**.

This plugin adds some default layouts to the _Mashroom Portal_.

## Usage

If *node_modules/@mashroom* is configured as plugin path just add **@mashroom/mashroom-portal-default-layouts** as *dependency*.
npm package: @mashroom/mashroom-portal-default-theme
Description: Default Portal Theme
Latest version: 2.9.4


# Mashroom Portal Default Theme

Plugin for [Mashroom Server](https://www.mashroom-server.com), a **Microfrontend Integration Platform**.

This plugin adds the default theme for the _Mashroom Portal_.

## Usage

If *node_modules/@mashroom* is configured as plugin path just add **@mashroom/mashroom-portal-default-theme** as *dependency*.

You can override the default config in your Mashroom config file like this:

```json
{
    "plugins": {
        "Mashroom Portal Default Theme": {
            "spaMode": true,
            "darkMode": "auto",
            "styleFile": null,
            "logoImageUrl": null,
            "showPortalAppHeaders": true,
            "showEnvAndVersions": true
        }
    }
}
```

 * _spaMode_: The theme will try to operate like an SPA and loads new page content via AJAX and replaces the DOM.
   This only works until the user does not navigate on a page with a different theme or different page enhancements,
   in that case a full page load is triggered (Default: true)
 * _darkMode_: Possible values: *true*, *false*, *"auto"* (Default: "auto")
 * _styleFile_: Custom CSS that can be used to overwrite CSS variables and to customize the theme (relative to Mashroom config file, default: null)
 * _logoImageUrl_: Optional logo image URL (Default: null)
 * _showPortalAppHeaders_: Show or hide Portal App headers (Default: true)
 * _showEnvAndVersions_: Show the environment (_NODE_ENV_) and version information in the header (Default: false)