Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@mrporter/mrp-mod-rewrite

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mrporter/mrp-mod-rewrite

adds reloadable modrewrite functionality to connect/express server

  • 0.0.5
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
6
increased by500%
Maintainers
1
Weekly downloads
 
Created
Source

mod_rewrite with remote config middleware

Middleware to configure an instance of connect-modrewrite which, it turn, rewrites URLs based on this configuration.

  • Comes pre-packaged with a rules snapshot, but should be configured to fetch a more up-to-date instance of the rules from a server.
  • Rules are cached to local disk.
  • The cache-control header of the resource at rulesURL is respected; including the ability to serve stale instances of the rule if problems occur downloading a new instance.

Usage

var opts {
    "rulesURL": "http://s3-eu-west-1.amazonaws.com/mod-rewrite-dev/mod-rewrite-test.conf", 
    "preventFallbackToPrepackagedRules": false, // Optional
    "hostnameForRedirects": "www.mrporter.com" // Optional.  Will revert to relative redirects if not specified
    "cacheFileLocation": "./rules-cache", # Not recommended in clustered setup. If specified, reads and writes cachced rules to the supplied file location
    "logger": winston
};
var modRewriteMiddleware = require('mrp-mod-rewrite').createRewriteMiddleware(opts);
app.use(modRewriteMiddleware);

Important

  • The resource at rulesURL must be returned with a MIME type ("content-type" header) of "text/plain"
  • The resource at rulesURL should be returned with a "cache-control" header that includes a "max-age" and a "stale-while-revalidate" directive
    • If a "cache-control" header is not returned, defaults to 10 mins max age and 7-day stale

TODO

  • Timeouts for HTTP connection
  • Consider connection pool, circuit breaker and retry policy for HTTP requests

Keywords

FAQs

Package last updated on 11 Nov 2015

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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc