static-router

Express/Connect middleware to server static files based on glob-like routes.

MIT 13 个版本
安装
npm install static-router
yarn add static-router
pnpm add static-router
bun add static-router
README

static-router

Express/Connect middleware to server static files based on glob-like routes.

Install

npm install static-router --save

Usage

var http = require('http');
var connect = require('connect');
var router = require('static-router');

var app = connect();

app.use(router({
  '**': '/index.html'
}));

http.createServer(app).listen(3000, function () {
  
});

Ensure order of routes

var http = require('http');
var connect = require('connect');
var router = require('static-router');

var app = connect();

app.use(router([
  {'/some-route': '/some-file.html'},
  {'**': '/index.html'}
}));

http.createServer(app).listen(3000, function () {
  
});

router(routes[, options])

  • routes - object or array containing globs as keys and target static files and values. Use of an array ensures the order in which the routes are parsed.
  • options
    • root - the root directory of the static files.
    • index - name of the default directory index file. Defaults to index.html.

Run Tests

npm install
npm test
版本列表
1.1.0 2015-02-24
1.0.5 2015-02-24
1.0.4 2014-11-18
1.0.3 2014-11-18
1.0.2 2014-11-17
1.0.1 2014-09-17
1.0.0 2014-09-11
0.3.1 2014-09-11
0.3.0 2014-08-29
0.2.3 2014-07-31
0.2.2 2014-07-31
0.2.1 2014-07-18
0.2.0 2014-07-18