koa-static-security
v0.0.11
Published
koa static security
Downloads
4
Readme
koa-static-security
拦截静态文件恶意路径
更好的静态文件中间件
Installation
$ npm install koa-static-security
API
var koa = require('koa');
var app = koa();
app.use(require('koa-static-security')(root, opts));
opts
options object.
Options
maxage
Browser cache max-age in milliseconds. defaults to 0hidden
Allow transfer of hidden files. defaults to falseindex
Default file name, defaults to noneifModifiedSinceSupport
by sending a 304 (not modified) response. Defaults to trueformat
Allow trailing slashes for directories (e.g. /directory and /directory. Defaults to true
Example
var serve = require('koa-static-security');
var koa = require('koa');
var app = koa();
// $ GET /package.json
app.use(serve('.'));
// $ GET /hello.txt
app.use(serve('test/fixtures'));
// or use absolute paths
app.use(serve(__dirname + '/test/fixtures'));
app.listen(3000);
console.log('listening on port 3000');
License
MIT