0.5.2 • Published 9 years ago

toa-static v0.5.2

Weekly downloads
32
License
MIT
Repository
github
Last release
9 years ago

toa-static

A static server module for toa.

NPM version Build Status Downloads

toa

Demo

'use strict';

var Toa = require('toa')
var toaStatic = require('toa-static')('examples/static')

use as middleware:

var app = Toa()
app.use(toaStatic)
app.listen(3000)

Installation

npm install toa-static

API

var ToaStatic = require('toa-static')

ToaStatic(options)

Return a thunk function.

  • options.root (String) - The directory you wish to serve, default to process.cwd.
  • options.index (String) - By default this module will send "index.html" files in response to a request on a directory. To disable this set false or to supply a new index pass a string.
  • options.etag (Boolean) - Enable or disable etag generation, defaults to true.
  • options.maxAge (Number) - Cache control max age (ms) for the files, default to 24 * 60 * 60 * 30 * 1000.
  • options.cacheControl (String) - Optional cache control header. Overrides options.maxAge.
  • options.compress (Boolean) - When request's accept-encoding include gzip or deflate, files will compressed.
  • options.fileMap (Object) - Object map of aliases.
  • options.prefix (String) - The url prefix you wish to serve as static request, default to '/'.
  • options.prunePrefix (Boolean) - Prune the prefix from URL path, default to false.
  • options.files (Array) - files path you wish to serve.
  • options.staticPath (Function) - Function to return a custom static file path. the context of this function is toa's context.
  • options.maxCacheLength (Number) - The maximum length of the files cache in bytes. if cache's size > maxCacheLength, then the least recently used (LRU) file will be removed. if maxCacheLength === -1, cache will not be used. if maxCacheLength === 0, there is no limit. , default to 0.

License

The MIT License (MIT)

0.5.2

9 years ago

0.5.1

9 years ago

0.5.0

10 years ago

0.4.0

10 years ago

0.3.2

10 years ago

0.3.1

11 years ago

0.3.0

11 years ago

0.2.0

11 years ago

0.1.1

11 years ago

0.1.0

11 years ago