koa-static-security

0.0.11 • Public • Published

koa-static-security

基于koa-better-static修改

  • 拦截静态文件恶意路径

  • 更好的静态文件中间件

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 0
  • hidden Allow transfer of hidden files. defaults to false
  • index Default file name, defaults to none
  • ifModifiedSinceSupport by sending a 304 (not modified) response. Defaults to true
  • format 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

Readme

Keywords

Package Sidebar

Install

npm i koa-static-security

Weekly Downloads

0

Version

0.0.11

License

MIT

Last publish

Collaborators

  • imkelen