@wyze/koa-file-server

3.2.2 • Public • Published

Koa File Server

NPM version build status Test coverage Gittip

An opinionated file server. Designed to sit behind a CDN.

  • sha256 etags and consequential 304s
  • Caches fs.stat() calls
  • Caches etag calculations
  • OPTIONS and 405 support
  • index.html files
  • Optionally serve hidden files
  • Caches gzipped versions of files
  • SPDY Push support

Does not support:

  • Dynamic files - assumes static files never change. You will have to delete files from the cache yourself if files change.
  • Directory listing
  • Path decoding

API

var Koa = require('koa')
var app = new Koa()
app.use(require('compress')())
app.use(require('koa-file-server')(options))

Options are:

  • root <process.cwd()> - root directory. nothing above this root directory can be served
  • maxage - cache control max age
  • etag - options for etags
    • algorithm - hashing algorithm to use
    • encoding - encoding to use
  • index - serve index.html files
  • hidden - show hidden files which leading .s
  • push - will automatically try and use server push
  • files [] - array of files (relative to root) to be server pushed
  • pushOptions {} - options to be passed to spdy push method (e.g. priority)
    • The only pushOption is priority: 1-7.
  • link - will set link headers based on files option

Readme

Keywords

Package Sidebar

Install

npm i @wyze/koa-file-server

Weekly Downloads

0

Version

3.2.2

License

MIT

Last publish

Collaborators

  • wyze