peer-cdn

peer-cdn

  • Docs
  • Help
  • GitHub

›Router

Quick Start

  • Installation
  • Service Worker
  • Browser Client

Plugins

  • Peer Plugin
  • Network Plugin
  • Delegate Plugin

Router

  • Router
  • Middleware
  • Strategies

Server

  • Server

Example

  • Example

Router

peer-cdn allows you to register all assets or pick only specific one. Currently only available methods are GET, other request will not be handled.

    cdn.GET("/css/main.css", ordered,
      cachePlugin.getMiddleware,
      delegatePlugin.getMiddleware,
      networkPlugin.getMiddleware
    );

peer-cdn creates nodes tree for request paths. All middleware will be applied to the children nodes for a given path as well. Meaning: Router will automatically handle all children routes. For example if you register /js route and browser will try to fetch /js/main.js this will match its parent route's handler.

const middleware = []; // array of your middleware

// invoked for any requests passed to this router
PeerCDN.GET("/", ordered, ...middleware);

// will handle any request that match pattern
PeerCDN.get("/static/:wildcard", ordered, ...);

You can use regexp as path value. For more details please see source code on GitHub

← Delegate PluginMiddleware →
peer-cdn
Docs
Documentation
Community
Support
More
rafallorenz.comGitHubStar
Copyright © 2022 Rafał Lorenz