New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

pathologist-middleware

Package Overview
Dependencies
Maintainers
3
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pathologist-middleware

Handling custom static routes since 1967

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
decreased by-50%
Maintainers
3
Weekly downloads
 
Created
Source

Pathologist Middleware

npm tests coverage dependencies devDependencies

Finding the right path since 1967

Note: This project is in early development, and versioning is a little different. Read this for more details.

Why should you care?

Often when building a static app, you want to serve multiple routes with the same static file while keeping the URL structure intact for your app's routing logic. Or perhaps you just want to handle multiple routes for a directory of static files.

Pathologist is an easy to use connect middleware for bringing your single page apps to life. You can define routes with supported globstar matching to serve your static files.

Pathologist simply rewrites the request url to a new static file path. It does not serve the static file for you, so you will need to use your preferred static server middleware with pathologist. We recommend alchemist.

Installation

$ npm install pathologist-middleware --save

Usage

Pathologist accepts an options object which takes globstar-compatible paths as keys and a static file path as values. Routes are matched in the order they are defined in the object. Here's an example that serves an admin client on any URLs starting with /admin, and serves the user client on all other routes.

var http = require('http'),
      connect = require('connect'),
      pathologist = require('pathologist-middleware');

var app = connect().use(
  pathologist({
    '/admin/**/*': '/admin.html',
    '/**': '/index.html'
  })
);

You can also pass a base path to be used with your file path values as the first argument.

var http = require('http'),
    connect = require('connect'),
    path = require('path'),
    pathologist = require('pathologist-middleware');

var app = connect().use(
  pathologist(path.join(__dirname, 'browser'), {
    '/admin/**/*': 'admin.html',
    '/**': 'index.html'
  })
);

Without a base path, the path values passed into pathologist can be either absolute paths, or relative paths from process.cwd().

License & Contributing

FAQs

Package last updated on 17 Jul 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