Socket
Socket
Sign inDemoInstall

@mashroom/mashroom-storage

Package Overview
Dependencies
2
Maintainers
1
Versions
90
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @mashroom/mashroom-storage

A storage service with a configurable provider


Version published
Weekly downloads
22
decreased by-31.25%
Maintainers
1
Created
Weekly downloads
 

Changelog

Source

1.1.0 (September 19, 2019)

  • Portal: Added two new (optional) security related properties to the default config of portal apps:
    • defaultRestrictViewToRoles: Same as the previous defaultRestrictedToRoles but renamed to make its purpose clearer. These roles can be overwritten via Admin App per App instance in the UI.
    • restProxy.restrictToRoles: If this is set only users with one of the given roles can access the rest proxy. In contrast to all other permissions the Administrator role has not automatically access.
  • Added a provider plugin to support MQTT as external messaging system
  • Added a demo portal app to demonstrate remote messaging
  • Portal: Added support for remote messaging. Portal apps can now subscribe to server side topics (prefixed with :remote) and communicate with apps on other pages and browser tabs. If the service side messaging is connected to an external messaging system (e.g. MQTT) it is also possible to subscribe and publish messages to the external system.
  • Added a Service plugin for server-side messaging that comes with a WebSocket interface which allows sending messages across clients (and browser tabs). Furthermore it be connected to an external messaging system (such as MQTT) via provider plugin.
  • Core: Added the possibility to listen on Plugin load and unload events via MashroomPluginService. Useful if you want to cleanup when your plugin unloads or in the rare case where you have to hold a plugin instance and want to get notified about an unload or reload.
  • Added a Service plugin to handle WebSocket connections (mashroom-websocket)
  • Core: web-app Plugins can now additionally have handlers for upgrade requests (WebSocket support) and for unload
  • Core: The Middleware tab in the Admin UI shows now the actual order of the stack (until now the order was just calculated)

Readme

Source

Mashroom Storage

Plugin for Mashroom Server, a Integration Platform for Microfrontends.

This plugin adds a storage service.

Usage

If node_modules/@mashroom is configured as plugin path just add this package as dependency.

Then use the security service like this:

// @flow

import type {MashroomStorageService} from '@mashroom/mashroom-storage/type-definitions';

export default async (req: ExpressRequest, res: ExpressResponse) => {
    const storageService: MashroomStorageService = req.pluginContext.services.storage.service;
    
    const pagesCollection = await storageService.getCollection('mashroom-portal-pages');
    
    const page = await pagesCollection.findOne({pageId});

    // ...
}

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

{
  "plugins": {
       "Mashroom Storage Services": {
           "provider": "Mashroom Storage Filestore Provider"
       }
    }
}
  • provider: The storage-provider plugin that implements the actual storage (Default: Mashroom Storage Filestore Provider)
Services
MashroomStorageService

The exposed service is accessible through pluginContext.services.storage.service

Interface:

export interface MashroomStorageService {
    /**
     * Get (or create) the MashroomStorageCollection with given name.
     */
    getCollection<T: {}>(name: string): Promise<MashroomStorageCollection<T>>;
}

export interface MashroomStorageCollection<T: Object> {
    /**
     * Find all items that match given filter (e.g. { name: 'foo' }).
     */
    find(filter?: StorageObjectFilter<T>, limit?: number): Promise<Array<StorageObject<T>>>;
    /**
     * Return the first item that matches the given filter or null otherwise.
     */
    findOne(filter: StorageObjectFilter<T>): Promise<?StorageObject<T>>;
    /**
     * Insert one item
     */
    insertOne(item: T): Promise<StorageObject<T>>;
    /**
     * Update the first item that matches the given filter.
     */
    updateOne(filter: StorageObjectFilter<T>, propertiesToUpdate: $Shape<StorageObject<T>>): Promise<StorageUpdateResult>;
    /**
     * Replace the first item that matches the given filter.
     */
    replaceOne(filter: StorageObjectFilter<T>, newItem: T): Promise<StorageUpdateResult>;
    /**
     * Delete the first item that matches the given filter.
     */
    deleteOne(filter: StorageObjectFilter<T>): Promise<StorageUpdateResult>;
    /**
     * Delete all items that matches the given filter.
     */
    deleteMany(filter: StorageObjectFilter<T>): Promise<StorageUpdateResult>;
}
Plugin type
storage-provider

Registers a Storage Provider that can be used by this plugin.

To register a storage-provider plugin add this to package.json:

{
    "mashroom": {     
        "plugins": [
            {
                "name": "My Storage Provider",
                "type": "storage-provider",
                "bootstrap": "./dist/mashroom-bootstrap.js",
                "defaultConfig": {
                    "myProperty": "test"
                }
            }
        ]
    }
}

The bootstrap returns the provider:

// @flow

import MyStorage from './MyStorage';

import type {MashroomStoragePluginBootstrapFunction} from '@mashroom/mashroom-storage/type-definitions';

const bootstrap: MashroomStoragePluginBootstrapFunction = async (pluginName, pluginConfig, pluginContextHolder) => {
   
    return new MyStorage(/* .... */);
};

export default bootstrap;

Which has to implement the following interface:

export interface MashroomStorage {
    /**
     * Get (or create) the MashroomStorageCollection with given name.
     */
    getCollection<T: {}>(name: string): Promise<MashroomStorageCollection<T>>;
}

FAQs

Last updated on 19 Sep 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc