🚀 DAY 5 OF LAUNCH WEEK: Introducing Socket Firewall Enterprise.Learn more →
Socket
Book a DemoInstallSign in
Socket

@mashroom/mashroom-cdn

Package Overview
Dependencies
Maintainers
1
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mashroom/mashroom-cdn

A Mashroom service to manage CDN hosts

latest
Source
npmnpm
Version
2.9.2
Version published
Maintainers
1
Created
Source

Mashroom CDN

Plugin for Mashroom Server, 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.

**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.

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:

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:

{
  "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:

export interface MashroomCDNService {
    /**
     * Return a CDN host or null if there is none configured.
     */
    getCDNHost(): string | null;
}

FAQs

Package last updated on 29 Aug 2025

Did you know?

Socket

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