{
  "name": "st",
  "version": "0.2.4",
  "description": "A module for serving static files.  Does etags, caching, etc.",
  "main": "st.js",
  "bin": {
    "st": "bin/server.js"
  },
  "dependencies": {
    "mime": "~1.2.7",
    "negotiator": "~0.2.5",
    "async-cache": "~0.1.2",
    "fd": "~0.0.2",
    "graceful-fs": "~1.2"
  },
  "optionalDependencies": {
    "graceful-fs": "~1.2"
  },
  "devDependencies": {
    "tap": "~0.3.1",
    "request": "~2.11.4"
  },
  "scripts": {
    "test": "tap test/*.js"
  },
  "repository": {
    "type": "git",
    "url": "git://github.com/isaacs/st"
  },
  "keywords": [
    "static",
    "file",
    "serve",
    "etag",
    "autoindex",
    "cache"
  ],
  "author": {
    "name": "Isaac Z. Schlueter",
    "email": "i@izs.me",
    "url": "http://blog.izs.me/"
  },
  "license": "BSD",
  "readme": "# st\n\nA module for serving static files.  Does etags, caching, etc.\n\n## USAGE\n\nHere are some very simple usage examples.\n\nJust serve the files in the cwd at the root of the http server url:\n\n```javascript\nvar st = require('st')\nvar http = require('http')\n\nhttp.createServer(\n  st(process.cwd())\n).listen(1337)\n```\n\n\nServe the files in static under the /static url.  Otherwise do a\ndifferent thing:\n\n```javascript\nvar mount = st({ path: __dirname + '/static', url: '/static' })\nhttp.createServer(function(req, res) {\n  var stHandled = mount(req, res);\n  if (stHandled)\n    return\n  else\n    res.end('this is not a static file')\n}).listen(1338)\n```\n\nThe same sort of thing, but using an express middleware style:\n\n```javascript\nvar mount = st({ path: __dirname + '/static', url: '/static' })\nhttp.createServer(function(req, res) {\n  mount(req, res, function() {\n    res.end('this is not a static file')\n  })\n}).listen(1339)\n```\n\n\nServe the files in static under the / url, but only if not some doing\nother thing:\n\n```javascript\nvar mount = st({ path: __dirname + '/static', url: '/' })\nhttp.createServer(function(req, res) {\n  if (shouldDoThing(req)) {\n    doTheThing(req, res)\n  } else {\n    mount(req, res)\n  }\n}).listen(1340)\n```\n\nServe the files in static under the / url, but don't serve a 404 if\nthe file isn't found, so that the rest of the app can handle it:\n\n```javascript\nvar mount = st({ path: __dirname + '/static', url: '/', passthrough: true })\nhttp.createServer(function(req, res) {\n  mount(req, res, function() {\n    res.end('this is not a static file');\n  });\n}).listen(1341);\n```\n\n\nPass some options to the `st` function, and it returns a handler\nfunction.\n\nThat handler function will return `true` if it handles the static\nrequest, or `false` if it doesn't.  (This is so that you can only\nserve static files if they're in `/static` for example.)\n\nHere are some options if you want to configure stuff.  All of these\nare optional except `path` which tells it where to get stuff from.\n\nIf you pass a string instead of an object, then it'll use the string\nas the path.\n\nIf you don't specify a `url`, then it'll mount on the `'/'` url, so\n`st({ path: './static/' })` will try to serve `./static/foo.html` when\nthe user goes to `http://example.com/foo.html`.  (Note: This behavior\nchanged in st 0.2.0.)\n\nHere are all the options described with their defaults values and a\nfew possible settings you might choose to use:\n\n```javascript\nvar st = require('st')\nvar mount = st({\n  path: 'resources/static/', // resolved against the process cwd\n  url: 'static/', // defaults to '/'\n\n  cache: { // specify cache:false to turn off caching entirely\n    fd: {\n      max: 1000, // number of fd's to hang on to\n      maxAge: 1000*60*60, // amount of ms before fd's expire\n    },\n\n    stat: {\n      max: 5000, // number of stat objects to hang on to\n      maxAge: 1000 * 60, // number of ms that stats are good for\n    },\n\n    content: {\n      max: 1024*1024*64, // how much memory to use on caching contents\n      maxAge: 1000 * 60 * 10, // how long to cache contents for\n    },\n\n    index: { // irrelevant if not using index:true\n      max: 1024 * 8, // how many bytes of autoindex html to cache\n      maxAge: 1000 * 60 * 10, // how long to store it for\n    },\n\n    readdir: { // irrelevant if not using index:true\n      max: 1000, // how many dir entries to cache\n      maxAge: 1000 * 60 * 10, // how long to cache them for\n    }\n  },\n\n  // indexing options\n  index: true, // auto-index, the default\n  index: 'index.html', // use 'index.html' file as the index\n  index: false, // return 404's for directories\n\n  dot: false, // default: return 403 for any url with a dot-file part\n  dot: true, // allow dot-files to be fetched normally\n\n  passthrough: true, // calls next/returns instead of returning a 404 error\n  passthrough: false, // returns a 404 when a file or an index is not found\n})\n\n// with bare node.js\nhttp.createServer(function (req, res) {\n  if (mount(req, res)) return // serving a static file\n  myCustomLogic(req, res)\n}).listen(PORT)\n\n// with express\napp.use(mount)\n// or\napp.route('/static/:fooblz', function (req, res, next) {\n  mount(req, res, next) // will call next() if it doesn't do anything\n})\n```\n\nOn the command line:\n\n```\n$ st -h\nst\nStatic file server in node\n\nOptions:\n\n-h --help             Show this help\n\n-p --port PORT        Listen on PORT (default=1337)\n\n-d --dir DIRECTORY    Serve the contents of DIRECTORY (default=cwd)\n\n-i --index [INDEX]    Use the specified INDEX filename as the result\n                      when a directory is requested.  Set to \"true\"\n                      to turn autoindexing on, or \"false\" to turn it\n                      off.  If no INDEX is provided, then it will turn\n                      autoindexing on.  (default=true)\n\n-ni --no-index        Same as \"--index false\"\n\n-. --dot [DOT]        Allow .files to be served.  Set to \"false\" to\n                      disable.\n\n-n. --no-dot          Same as \"--dot false\"\n\n-nc --no-cache        Turn off all caching.\n\n-a --age AGE          Max age (in ms) of cache entries.\n```\n\n## Range Requests\n\nRange requests are not supported.\n\nI'd love a patch to add support for them, but the spec is kind of\nconfusing, and it's not always a clear win if you're not serving very\nlarge files, so it should come with some very comprehensive tests.\n\nThankfully, as far as I can tell, it's always safe to serve the entire\nfile to a request with a range header, so st does behave correctly, if\nnot ideally in those situations.  It'd be great to be able to do the\nbetter thing if the contents are cached, but still serve the full file\nif it's not in cache (so that it can be cached for subsequent\nrequests).\n\n## Memory Caching\n\nTo make things go as fast as possible, it is a good idea to set the\ncache limits as high as you can afford, given the amount of memory on\nyour server.  Serving buffers out of process memory will generally\nalways be faster than hitting the file system.\n\n## Client Caching\n\nAn etag header and last-modified will be attached to every request.\nIf presented with an `if-none-match` or `if-modified-since`, then\nit'll return a 304 in the appropriate conditions.\n\nThe etag is generated based on the dev, ino, and last modified date.\nStat results are cached.\n\n## Compression\n\nIf the request header claims to enjoy gzip encoding, and the filename\ndoes not end in '.gz' or '.tgz', then the response will be gzipped.\n\nGzipped bytes are not included in the calculation of cache sizes, so\nthis utility will use a bit more memory than the cache.content.max and\ncache.index.max bytes would seem to allow.  This will be less than\ndouble, and usually insignificant for normal web assets, but is\nimportant to consider if memory is at a premium.\n\n## Filtering Output\n\nIf you want to do some fancy stuff to the file before sending it, you\ncan attach a `res.filter = myFilterStream` thing to the response\nobject before passing it to the mount function.\n\nThis is useful if you want to get the benefits of caching and gzipping\nand such, but serve stylus files as css, for example.\n",
  "readmeFilename": "README.md",
  "bugs": {
    "url": "https://github.com/isaacs/st/issues"
  },
  "homepage": "https://github.com/isaacs/st",
  "_id": "st@0.2.4",
  "_from": "st@0.2.4"
}
