{"_id":"lactate","_rev":"381-fb1f7c672e8a414ac965d08202b416ee","name":"lactate","description":"Simple and featureful assets server","dist-tags":{"latest":"0.13.12"},"versions":{"0.6.0":{"name":"lactate","version":"0.6.0","description":"Simple assets server","keywords":["static","assets","cache"],"repository":{"type":"git","url":"git://github.com/Weltschmerz/Lactate.git"},"author":{"name":"Weltschmerz","email":"chlavois@gmail.com"},"dependencies":{"mime":"1.2.4","suckle":"0.1.0","expire":"0.2.0"},"main":"lib/lactate.js","scripts":{"test":"node test/test.js"},"engines":{"node":">= 0.5.0"},"_npmUser":{"name":"Weltschmerz","email":"chlavois@gmail.com"},"_id":"lactate@0.6.0","devDependencies":{},"optionalDependencies":{},"_engineSupported":true,"_npmVersion":"1.1.21","_nodeVersion":"v0.6.18","_defaultsLoaded":true,"dist":{"shasum":"bd39e093a7fd7349f4677459d0afbfdd639cd11d","tarball":"https://registry.npmjs.org/lactate/-/lactate-0.6.0.tgz","integrity":"sha512-YXGzqFIHW605/WqMBr6gQ6gSPcdcv2GvvnaWkDE4Am+jNmTvrFBFt8RyJDX4ExVhVFWoQC3zeYN1vS08YCUdoA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCZLNMyG1MM/a/Xittyo+5OXCj8g1ofPI0PFpw59rqTcgIhAK9WtbgEdVHlGo7TlRIpATFd703vXjl9OqAEVDSyNqTY"}]},"maintainers":[{"name":"Weltschmerz","email":"chlavois@gmail.com"}],"directories":{}},"0.7.0":{"name":"lactate","version":"0.7.0","description":"Simple assets server","keywords":["static","assets","cache"],"repository":{"type":"git","url":"git://github.com/Weltschmerz/Lactate.git"},"author":{"name":"Weltschmerz","email":"chlavois@gmail.com"},"dependencies":{"mime":"1.2.6","suckle":"0.3.0","expire":"0.4.0","mocha":">=1.3.0","should":">=1.0.0"},"main":"lib/lactate.js","scripts":{"test":"make test"},"engines":{"node":">= 0.5.0"},"readme":"# Lactate\n\nVery simple static file handler, with a few electives.\n\n`npm install lactate`\n\n`npm test lactate`\n\n## Benchmark\n\n[Preliminary benchmarks](https://github.com/Weltschmerz/Lactate/blob/master/benchmark/results.md) show that Lactate has a significant advantage over  most worthy competitors on the [node modules wiki](https://github.com/joyent/node/wiki/Modules#wiki-web-frameworks-static)\n\n*See /benchmarks for details*\n\n## Example\n\nJust pass three arguments to the serve function `path` [optional], `request`, `response`. Lactate will stream your file to the client in the most efficient way, by piping: readFile > gZip > response.\n\n```js\n\nvar express = require('express')\nvar app = express.createServer()\n\nvar Lactate = require('lactate')\nvar lactate = Lactate.Lactate()\n\nlactate.set({\n  root:process.cwd(),\n  expires:'one day and 12 minutes'\n})\n\napp.get('/', function(req, res) {\n  lactate.serve('pages/land.html', req, res)\n})\n\nvar files = Lactate.dir('files', {\n  public:'files',\n  expires:'ten years'\n}).toMiddleware()\n\napp.get('/files/*', files)\n\napp.listen(8080)\n\n```\n\n##The varieties of Lactate experience\n\nIn the general case, the `Lactate` method returns an object with the methods `serve` `set` and `get`, importantly. However, there are more convenient methods exported by Lactate. They follow.\n\n###Serving an individual file\n\nTo serve an individual file, use the `file` method.\n\n```js\n  var Lactate = require('lactate')\n\n  app.get('*', function(req, res) {\n    Lactate.file('images/somn.jpg', req, res)\n  })\n```\n\n###Namespacing a directory\n\nThe `dir` method allows you to namespace a directory, for convenience.\n\n```js\nvar Lactate = require('lactate')\nvar images = Lactate.dir('images', {expires:'one day'})\n\napp.get('/images/:image', function(req, res) {\n  images.serve(req.params.image, req, res)\n})\n```\n\n###Middleware\n\nFor maximum convenience, you may use the `toMiddleware` method on directories.\n\n```js\nvar Lactate = require('lactate')\n\nvar images = Lactate.dir('images', {\n  expires:'one day'\n}).toMiddleware()\n\napp.use(images) //That's it!\n```\n\nYou may also pass additional options to the `toMiddleware` function.\n\n```js\nvar images = Lactate.dir('images', {\n  expires:'one day'\n})\n\nvar middleware = images.toMiddleware({\n  public:'images'\n})\n\napp.use(middleware)\n```\n\n##Options\n\nOptions can be passed to the initialization function or using the `set` method.\n\n### Setting options\n\n```js\n\n//Passing to initialization function\nvar lactate = require('lactate').Lactate({\n  expires:'two days'\n})\n\n//Set method\nlactate.set('expires', null)\n\n//Either function accepts (key, value) or an object.\n\n```\n\n### Options available\n\n+ `root` **string**\n\nLocal directory from which to serve files. By default, the current working directory.\n\n+ `public` **string**\n\nPublic directory exposed to clients. If set, only requests from /*directory* will complete.\n\n+ `cache` **boolean**\n\nKeep files in-memory. Enabled by default, and no great reason to disable.\n\n+ `expires` **number** or **string**\n\nPass this function a number (of seconds) or a string and appropriate headers will be set for client-side caching. Lactate comes with expiration defaults, such as 'two days' or '5 years and sixteen days' See [Expire](https://github.com/Weltschmerz/Expire) for details.\n\n```code\nlactate.set('expires', 87500)\n//87500 seconds\nlactate.set('expires', 'two days')\n//172800 seconds\nlactate.set'expires', 'five weeks and one minute and ten seconds')\n//3024070 seconds\nlactate.set('expires', 'one year and 2 months and seven weeks and 16 seconds')\n//41050028 seconds\n\n```\n\n+ `debug` **boolean** (*optional*) **number** (*optional*) **function** (*optional*) \n\nDebugging in Lactate is level-based (*bases: `0`, `1`*). Level `0` logs completed request information, status codes, etc.. Level `1` provides more details along the service. You may override the default debug function (*console.log*) with your own.\n\n```js\n\nvar lactate = require('lactate')({\n  debug:true // Will use console.log to debug all events\n})\n\nlactate.set('debug', 0, function(level, msg, path, statusCode) {\n  /* \n    Captures all level 0 events\n\n    Note however that statusCode arguments are only\n    given for level 0 listeners\n  */\n})\n\nlactate.set('debug', 1, console.log)\nlactate.set({debug:false})\n\n```\n\n## License\n\nMIT\n","_id":"lactate@0.7.0","dist":{"shasum":"c5ee8c968ba966a46077fbb2c56e6008260f9e99","tarball":"https://registry.npmjs.org/lactate/-/lactate-0.7.0.tgz","integrity":"sha512-pmU4QB+aybX51fSIvwB3Bo13A9cSiUz7w+BnM4r6tREVhOzN1grswPPKGsmO7IiDZkr6gfIuhRyWFB7V0X9kTA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDt5FUtCIN5zDb2GfkXfcSX+UEodm1e0GLpcu8Kvb8kPQIgSERFl5l450B2Ok5pElALIJ6oJqZ0ggl1XGZBPU5NGP0="}]},"maintainers":[{"name":"Weltschmerz","email":"chlavois@gmail.com"}],"directories":{}},"0.8.0":{"name":"lactate","version":"0.8.0","description":"Simple assets server","keywords":["static","assets","cache"],"repository":{"type":"git","url":"git://github.com/Weltschmerz/Lactate.git"},"author":{"name":"Weltschmerz","email":"chlavois@gmail.com"},"dependencies":{"mime":"1.2.7","suckle":"0.3.0","expire":"0.4.0","mocha":"1.3.0","should":"1.0.0"},"main":"lib/lactate.js","scripts":{"test":"make test"},"engines":{"node":">= 0.5.0"},"readme":"# Lactate\n\nVery simple static file handler, with a few electives.\n\n`npm install lactate`\n\n`npm test lactate`\n\n## Benchmark\n\n[Preliminary benchmarks](https://github.com/Weltschmerz/Lactate/blob/master/benchmark/results.md) show that Lactate has a significant advantage over  most worthy competitors on the [node modules wiki](https://github.com/joyent/node/wiki/Modules#wiki-web-frameworks-static)\n\n*See /benchmarks for details*\n\n## Example\n\nJust pass three arguments to the serve function `path` [optional], `request`, `response`. Lactate will stream your file to the client in the most efficient way, by piping: readFile > gZip > response.\n\n```js\n\nvar express = require('express')\nvar app = express.createServer()\n\nvar Lactate = require('lactate')\nvar lactate = Lactate.Lactate()\n\nlactate.set({\n  root:process.cwd(),\n  expires:'one day and 12 minutes'\n})\n\napp.get('/', function(req, res) {\n  lactate.serve('pages/land.html', req, res)\n})\n\nvar files = Lactate.dir('files', {\n  public:'files',\n  expires:'ten years'\n}).toMiddleware()\n\napp.get('/files/*', files)\n\napp.listen(8080)\n\n```\n\n##The varieties of Lactate experience\n\nIn the general case, the `Lactate` method returns an object with the methods `serve` `set` and `get`, importantly. However, there are more convenient methods exported by Lactate. They follow.\n\n###Serving an individual file\n\nTo serve an individual file, use the `file` method.\n\n```js\n  var Lactate = require('lactate')\n\n  app.get('*', function(req, res) {\n    Lactate.file('images/somn.jpg', req, res)\n  })\n```\n\n###Namespacing a directory\n\nThe `dir` method allows you to namespace a directory, for convenience.\n\n```js\nvar Lactate = require('lactate')\nvar images = Lactate.dir('images', {expires:'one day'})\n\napp.get('/images/:image', function(req, res) {\n  images.serve(req.params.image, req, res)\n})\n```\n\n###Middleware\n\nFor maximum convenience, you may use the `toMiddleware` method on directories.\n\n```js\nvar Lactate = require('lactate')\n\nvar images = Lactate.dir('images', {\n  expires:'one day'\n}).toMiddleware()\n\napp.use(images) //That's it!\n```\n\nYou may also pass additional options to the `toMiddleware` function.\n\n```js\nvar images = Lactate.dir('images', {\n  expires:'one day'\n})\n\nvar middleware = images.toMiddleware({\n  public:'images'\n})\n\napp.use(middleware)\n```\n\n##Options\n\nOptions can be passed to the initialization function or using the `set` method.\n\n### Setting options\n\n```js\n\n//Passing to initialization function\nvar lactate = require('lactate').Lactate({\n  expires:'two days'\n})\n\n//Set method\nlactate.set('expires', null)\n\n//Either function accepts (key, value) or an object.\n\n```\n\n### Options available\n\n+ `root` **string**\n\nLocal directory from which to serve files. By default, the current working directory.\n\n+ `public` **string**\n\nPublic directory exposed to clients. If set, only requests from /*directory* will complete.\n\n+ `cache` **boolean**\n\nKeep files in-memory. Enabled by default, and no great reason to disable.\n\n+ `expires` **number** or **string**\n\nPass this function a number (of seconds) or a string and appropriate headers will be set for client-side caching. Lactate comes with expiration defaults, such as 'two days' or '5 years and sixteen days' See [Expire](https://github.com/Weltschmerz/Expire) for details.\n\n```code\nlactate.set('expires', 87500)\n//87500 seconds\nlactate.set('expires', 'two days')\n//172800 seconds\nlactate.set'expires', 'five weeks and one minute and ten seconds')\n//3024070 seconds\nlactate.set('expires', 'one year and 2 months and seven weeks and 16 seconds')\n//41050028 seconds\n\n```\n\n+ `debug` **boolean** (*optional*) **number** (*optional*) **function** (*optional*) \n\nDebugging in Lactate is level-based (*bases: `0`, `1`*). Level `0` logs completed request information, status codes, etc.. Level `1` provides more details along the service. You may override the default debug function (*console.log*) with your own.\n\n```js\n\nvar lactate = require('lactate')({\n  debug:true // Will use console.log to debug all events\n})\n\nlactate.set('debug', 0, function(level, msg, path, statusCode) {\n  /* \n    Captures all level 0 events\n\n    Note however that statusCode arguments are only\n    given for level 0 listeners\n  */\n})\n\nlactate.set('debug', 1, console.log)\nlactate.set({debug:false})\n\n```\n\n## License\n\nMIT\n","_id":"lactate@0.8.0","dist":{"shasum":"ca24e588ab2c0f7d5f6874f50bb3a8d43aa8238a","tarball":"https://registry.npmjs.org/lactate/-/lactate-0.8.0.tgz","integrity":"sha512-+tFUSCTBOXv0h/rhUiMT+3tP10gsuWwzTz0W+PiGyHCUxZwOZp2jDboFLc63Un9TG+TRernE3ilqD93/TTECxA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHpnkCc8pmYD/XF1rds+XxlFfOE5goac0qyZxOwj7JRjAiEA/hUKNL0tVYnuel5kDVHZbcX15m42dYycdNfS/1RMgl0="}]},"maintainers":[{"name":"Weltschmerz","email":"chlavois@gmail.com"}],"directories":{}},"0.9.0":{"name":"lactate","version":"0.9.0","description":"Simple assets server","keywords":["static","assets","cache"],"repository":{"type":"git","url":"git://github.com/Weltschmerz/Lactate.git"},"author":{"name":"Weltschmerz","email":"chlavois@gmail.com"},"dependencies":{"mime":"1.2.7","suckle":"0.3.4","expire":"0.4.4"},"devDependencies":{"mocha":"1.3.0","should":"1.0.0"},"main":"lib/lactate.js","scripts":{"test":"make test"},"engines":{"node":">= 0.5.0"},"readme":"# Lactate\n\n`npm install lactate`\n\nAn exceedingly fast static file handler, with a few electives.\n\n* Automaic gzipping\n* In-memory caching\n* Robust Expires settings\n* Custom 404 pages\n* Middleware\n\n## Benchmark\n\n[Preliminary benchmarks](https://github.com/Weltschmerz/Lactate/blob/master/benchmark/new/results.md) show that Lactate has a significant advantage over  most worthy competitors on the [node modules wiki](https://github.com/joyent/node/wiki/Modules#wiki-web-frameworks-static)\n\n*node version v0.8.0*\n\n![Bench](http://i.imgur.com/MbXJH.jpg)\n\n* `jquery.min.js` ~100kb\n* `santamonica.jpg` ~1mb\n\n*See /benchmark for details*\n\n## Example\n\nJust pass three arguments to the serve function `path` [optional], `request`, `response`. Lactate will stream your file to the client in the most efficient way, by piping node's readStream to gzip, and finally to the response.\n\n```js\n\nvar express = require('express')\nvar app = express.createServer()\n\nvar Lactate = require('lactate')\nvar lactate = Lactate.Lactate()\n\nlactate.set({\n  root:process.cwd(),\n  expires:'one day and 12 minutes'\n})\n\napp.get('/', function(req, res) {\n  lactate.serve('pages/land.html', req, res)\n})\n\nvar files = Lactate.dir('files', {\n  public:'files',\n  expires:'ten years'\n}).toMiddleware()\n\napp.get('/files/*', files)\n\napp.listen(8080)\n\n```\n\n##The varieties of Lactate experience\n\nIn the general case, the `Lactate` method returns an object with the methods `serve` `set` and `get`, importantly. However, there are more convenient methods exported by Lactate. They follow.\n\n###Serving an individual file\n\nTo serve an individual file, use the `file` method.\n\n```js\n  var Lactate = require('lactate')\n\n  app.get('*', function(req, res) {\n    Lactate.file('images/somn.jpg', req, res)\n  })\n```\n\nAn optional fourth argument is for Lactate settings.\n\n```js\n  var Lactate = require('lactate')\n  var options = {\n    cache:true,\n    expires:'two days'\n  }\n\n  app.get('*', function(req, res) {\n    Lactate.file('images/somn.jpg', req, res, options)\n  })\n```\n\n###Namespacing a directory\n\nThe `dir` method allows you to namespace a directory, for convenience.\n\n```js\nvar Lactate = require('lactate')\nvar images = Lactate.dir('images', {expires:'one day'})\n\napp.get('/images/:image', function(req, res) {\n  images.serve(req.params.image, req, res)\n})\n```\n\n###Middleware\n\nFor maximum convenience, you may use the `toMiddleware` method on directories.\n\n```js\nvar Lactate = require('lactate')\n\nvar images = Lactate.dir('images', {\n  expires:'one day'\n}).toMiddleware()\n\napp.use(images) //That's it!\n```\n\nYou may also pass additional options to the `toMiddleware` function.\n\n```js\nvar images = Lactate.dir('images', {\n  expires:'one day'\n})\n\nvar middleware = images.toMiddleware({\n  public:'images'\n})\n\napp.use(middleware)\n```\n\n###Custom 404 pages\n\nUse the `on404` option for defining custom 404 pages or functions.\n\nStrings will be treated as ordinary file paths, and as such will abide rules for gzipping and in-memory caching. Note that on404 paths will be relative to the `root` setting (by default process.cwd()).\n\n```js\nvar lactate = require('lactate').Lactate({\n    notFound:'pages/404.html'\n})\n```\n\nFunctions allow you to fully customize your 404 handling.\n\n```js\nlactate.set('notFound', function(res) {\n    res.writeHead(404)\n    res.end('My custom 404 thingy')\n})\n```\n\n##Options\n\nOptions can be passed to the initialization function or using the `set` method.\n\n### Setting options\n\n```js\n\n//Passing to initialization function\nvar lactate = require('lactate').Lactate({\n  expires:'two days'\n})\n\n//Set method\nlactate.set('expires', null)\n\n//Either function accepts (key, value) or an object.\n\n```\n\n### Options available\n\n+ `root` **string**\n\nLocal directory from which to serve files. By default, the current working directory.\n\n+ `public` **string**\n\nPublic directory exposed to clients. If set, only requests from /*directory* will complete.\n\n+ `subdirs` **boolean**\n\nBy default subdirectories are served. To disable this, set `subdirs` to false.\n\n+ `cache` **boolean**\n\nKeep files in-memory. Enabled by default, and no great reason to disable.\n\n+ `expires` **number** or **string**\n\nPass this function a number (of seconds) or a string and appropriate headers will be set for client-side caching. Lactate comes with expiration defaults, such as 'two days' or '5 years and sixteen days' See [Expire](https://github.com/Weltschmerz/Expire) for details.\n\n```code\nlactate.set('expires', 87500)\n//87500 seconds\nlactate.set('expires', 'two days')\n//172800 seconds\nlactate.set'expires', 'five weeks and one minute and ten seconds')\n//3024070 seconds\nlactate.set('expires', 'one year and 2 months and seven weeks and 16 seconds')\n//41050028 seconds\n\n```\n\n+ `notFound` **string or function**\n\nFor custom 404 handling. Functions are supplied the response for 100% custom response handling. Otherwise, if set to a string, this option will be treated as an ordinary file path and abide rules for gzipping / in-memory cache.\n\n+ `debug` **boolean**\n\n```\n\n## License\n\nMIT\n\n*This module is used internally by [Transmit](https://github.com/Weltschmerz/Transmit)*\n","_id":"lactate@0.9.0","dist":{"shasum":"80ef43c6594bd8e0e0a12bd674c4f21e9e535df4","tarball":"https://registry.npmjs.org/lactate/-/lactate-0.9.0.tgz","integrity":"sha512-eine0qABBCF06K9EMxXge8BhmPak3zcsBlzAosq/VcNyFbl6nRAFtpf7pAz8zsd45qia/qw9HcXl3m40FgygNg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDSi0GY67Y/pTlmV6IgeUQ23kLWVd73gvKXSNszS4jzHwIhAPrdYfAh9tJ237m9wVpGJTpDyuQTQ14wCRVNf+I82QwI"}]},"maintainers":[{"name":"Weltschmerz","email":"chlavois@gmail.com"}],"directories":{}},"0.10.0":{"name":"lactate","version":"0.10.0","description":"Simple assets server","keywords":["static","assets","cache"],"repository":{"type":"git","url":"git://github.com/Weltschmerz/Lactate.git"},"author":{"name":"Weltschmerz","email":"chlavois@gmail.com"},"dependencies":{"mime":"1.2.7","suckle":"0.5.0","expire":"0.4.5","abridge":"0.2.9","lessen":"0.0.4"},"devDependencies":{"mocha":"1.5.0","should":"1.2.0"},"main":"index.js","bin":{"lactate":"bin/lactate"},"scripts":{"test":"make test"},"engines":{"node":">= 0.6.0"},"readme":"# Lactate\n\n`npm install -g lactate`\n\nAn exceedingly fast static file handler, with a few electives.\n\n### Features\n\n* In-memory caching\n* Robust cache-control setting\n* Automatic gzipping\n* Automatic minification\n* Custom 404 pages\n* Custom response headers\n* Middleware export\n* Asset bundling\n\n### Comparison\n\nLactate caches files in memory without hitting the file system for each request, watches files for efficient udpates, and streams gzipped files directly to the response.  [Preliminary benchmarks](https://github.com/Weltschmerz/Lactate/blob/master/benchmark/new/results.md) show that Lactate has a significant advantage over  most worthy competitors on the [node modules wiki](https://github.com/joyent/node/wiki/Modules#wiki-web-frameworks-static)\n\n![Bench](http://i.imgur.com/b3xJU.jpg)\n\n* `ab -c 100 -n 10000`\n* `node` v0.8.7\n* `jquery.min.js` ~100kb\n\n*See /benchmark for details*\n\n## Using Lactate\n\nLactate can be used with either plain node, or with Express. With Express, Lactate is a drop-in replacement for `static` middleware, but with far more ability. The examples below use Express 2.x API for simplicity. See the [examples](https://github.com/Weltschmerz/Lactate/tree/master/example) for various examples.\n\n```js\nvar lactate = require('lactate');\nvar express = require('express');\n\nvar app = express.createServer();\napp.use(lactate.static(__dirname + '/files'));\n```\n\n## Testing Lactate\n\nIf installed locally (without -g flag to npm install):\n\n1. `cd` into `~/node_modules/lactate`\n2. `npm install ./` to install devDependencies\n3. `make test` to run mocha test\n\nIf installed globally, simply run `npm test lactate`.\n\n##The varieties of Lactate experience\n\nIn the general case, the `Lactate` method returns an object with the methods `serve` `set` and `get`, importantly. However, there are more convenient methods exported by Lactate. They follow.\n\n###Serving individual files\n\nTo serve an individual file, use the `file` method.\n\n```js\n\n  app.get('/', function(req, res) {\n    Lactate.file('land.html', req, res)\n  })\n```\n\nAn optional fourth argument is for Lactate settings.\n\n```js\n  var options = {\n    max_age:'two days',\n    minify:true,\n    from:'scripts'\n  }\n\n  app.get('/', function(req, res) {\n    Lactate.file('land.html', req, res, options);\n  })\n```\n\n###Serving directories\n\nThe `dir` method allows you to namespace a directory, for convenience.\n\n```js\nvar images = Lactate.dir('images');\n\napp.get('/images/:image', function(req, res) {\n  images.serve(req.params.image, req, res)\n})\n```\n\nPass a second argument to `dir` for options:\n\n```js\nvar options = { cache:false };\nvar images = Lactate.dir('assets/images', options);\nimages.maxAge('five days');\n```\n\n###Middleware export\n\nFor maximum convenience, you may use the `toMiddleware` method on directories.\n\n```js\nvar images = Lactate.dir('images', {\n  from:'images',\n  cache:false,\n  max_age:'two years',\n  debug:true\n}).toMiddleware()\n\napp.use(images) //That's it!\n```\n\nYou may also pass additional options to the `toMiddleware` function.\n\n```js\nvar images = Lactate.dir('images');\nimages.set('cache', false);\n\nvar middleware = images.toMiddleware({\n  from:'images'\n})\n\napp.use(middleware)\n```\n\n###Custom 404 pages\n\nUse the `not_found` option for defining custom 404 pages or handler functions.\n\nStrings will be treated as ordinary file paths, and as such will abide rules for gzipping and in-memory caching. Note that `notFound` paths will be relative to the `root` setting (by default `process.cwd()`).\n\n```js\nvar lactate = Lactate.Lactate({\n    not_found:'pages/404.html'\n})\n\nlactate.set('not_found', 'pages/not_found.html');\n```\n\nFunctions allow you to fully customize your 404 handling.\n\n```js\nvar lactate = Lactate.Lactate({\n  not_found:function(req, res) { }\n});\n```\n\nA special configuration method is provided:\n\n```js\nlactate.notFound(function(req, res) {\n    res.writeHead(404)\n    res.end('My custom 404 thingy')\n})\n```\n\n###Custom response headers\n\nExtend response headers with `headers` option.\n\n```js\nvar options = {\n    headers: {\n        server:'Lactate'\n    }\n};\n\nlactate.set(options);\nlactate.set('headers', options.headers);\nlactate.headers(options.headers);\nlactate.setHeader('server', options.headers.server);\n\napp.get('/', function(req, res) {\n    lactate.serve('pages/land.html', req, res);\n});\n```\n\nYou may also use a function for dynamic header setting:\n\n```js\n  lactate.setHeader('server', function(req, res) {\n    return 'lactate';\n  });\n```\n\n###Bundling assets for request optimization\n\nLactate directories have an additional method for combining and minifying text assets, to reduce the number of necessary requests.\n\n```js\nvar assets = lactate.dir('assets', {\n    from:'assets',\n    minify:true\n});\n\nassets.bundle('js', 'common.js', function(err, data) { });\n//assets.bundleJS('common.js', function(){});\nassets.bundleCSS('common.css');\napp.use(assets.toMiddleware());\n```\n\nNow, requesting `/assets/common.js` will result with a combined and minified (and by default gzipped) script of all the scripts contained in that directory. This function does actually write the bundled files to disk.\n\n##Global executable\n\nIf lactate is installed globally with `npm install -g` then you will have the 'lactate' command available to you. Issuing an empty 'lactate' will serve the current working directory. This can be convenient for testing and so on. Options are:\n\n+ `--port`, `-p`\n+ `--public`\n+ `--max_age`\n+ `--no-cache`, `-nc`\n\nMore on this later\n\n##Options\n\nOptions can be passed to the initialization function or using the `set` method.\n\n### Setting options\n\n```js\n\n//Passing to initialization function\nvar lactate = require('lactate').Lactate({\n  max_age:'two days'\n})\n\n//Set method\nlactate.set('max_age', null)\n\n//Either function accepts (key, value) or an object.\n\n```\n\n### Options available\n\n+ `root` **string**\n\nLocal directory from which to serve files. By default, the current working directory.\n\n+ `from` **string**\n\nPublic directory exposed to clients. If set, only requests from /*directory* will complete. Contrast this with the `root` option which is the location of files on the serving machine, not necessarily the requested path.\n\n+ `subdirs` **boolean**\n\nBy default subdirectories are served. To disable this, set `subdirs` to false.\n\n+ `cache` **boolean**\n\nKeep files in-memory. Enabled by default, and no great reason to disable, unless you are serving fairly large files or run a low-traffic operation.\n\n+ `gzip` **boolean**\n\nIf false, disables automatic gzipping for text files (HTML, JS, CSS). Enabled by default.\n\n+ `minify` **boolean**\n\nIf true, will automatically minify JavaScript and CSS using [Abridge](https://github.com/Weltschmerz/Abridge). Disabled by default.\n\n+ `watch_files` **boolean**\n\nDetermines whether Lactate will watch files to update its cache. If this is disabled, then your file cache will not update automatically as files are modified on the server.\n\n+ `headers` **object** or **string** or **function**\n\nSets custom response headers. If the option value is a function, it is a callback which is give (req, res) arguments. This function should return the header value; it is a mapping function.\n\n+ `max_age` **number** or **string**\n\nPass this function a number (of seconds) or a string and appropriate headers will be set for client-side caching. Lactate comes with expiration defaults, such as 'two days' or '5 years and sixteen days' See [Expire](https://github.com/Weltschmerz/Expire) for details.\n\n```js\nlactate.set('max_age', 87500)\n//87500 seconds\nlactate.set('max_age', 'two days')\n//172800 seconds\nlactate.set'max_age', 'five weeks and one minute and ten seconds')\n//3024070 seconds\nlactate.set('max_age', 'one year and 2 months and seven weeks and 16 seconds')\n//41050028 seconds\n```\n\n+ `not_found` **string** or **function**\n\nFor custom 404 handling. Functions are supplied the response for 100% custom response handling. Otherwise, if set to a string, this option will be treated as an ordinary file path and abide rules for gzipping / in-memory cache.\n\n+ `debug` **boolean**\n\nColored status / msg / path logging, for debugging purposes.\n\n###Special options methods\n\nLactate has some special methods to reduce visual clutter:\n\n```js\nlactate.maxAge('two days');\n```\n\nis equivalent to:\n\n```js\nlactate.set('max_age', 'two days');\n```\n\nSimilarly, the `headers` method is for setting custom response headers.\n\n## License\n\nMIT License\n\nCopyright 2012 Brandon Wilson\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","_id":"lactate@0.10.0","dist":{"shasum":"cc020fa9a24dea0a5b27e91205620a674a5667aa","tarball":"https://registry.npmjs.org/lactate/-/lactate-0.10.0.tgz","integrity":"sha512-AXwxzxIUjJ/YPKesl4oX1mfwGhlyliObtAKf+shYOtuG/NM4xK+fhIxP8+KvGsXOwQOCJ6q9nNAvzwxhWWk/SQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGTPyC53fRrA671OMWJYZwH3hUMW5LKELFGD4RubEzZ6AiEAyaVy5lRzfNF01zNouqjc5+26duJxVnHfBxLgLe8ggQk="}]},"maintainers":[{"name":"Weltschmerz","email":"chlavois@gmail.com"}],"directories":{}},"0.11.0":{"name":"lactate","version":"0.11.0","description":"Simple and featureful assets server","keywords":["static","file","server","assets","cache"],"repository":{"type":"git","url":"git://github.com/Weltschmerz/Lactate.git"},"author":{"name":"Weltschmerz","email":"chlavois@gmail.com"},"dependencies":{"mime":"1.2.7","suckle":"latest","expire":"latest","abridge":"latest","fraction":"latest","optimist":"0.3.5"},"devDependencies":{"mocha":"1.6.0","should":"1.2.0"},"main":"index.js","bin":{"lactate":"bin/lactate"},"scripts":{"test":"make test"},"engines":{"node":">= 0.6.0"},"readme":"# Lactate\n\n`npm install -g lactate`\n\nAn exceedingly fast static file handler, with a few electives.\n\n### Features\n\n* In-memory caching\n* Robust cache-control setting\n* Automatic gzipping\n* Automatic minification\n* Custom 404 pages\n* Custom response headers\n* Asset bundling and minification\n* Middleware export\n* Express.static replacement\n* Default error pages\n* on(status) listeners\n* Colored log output\n* Global executable\n\n### Comparison\n\nLactate caches files in memory without hitting the file system for each request, watches files for efficient udpates, and streams gzipped files directly to the response. Preliminary benchmarks show that Lactate has a significant advantage over most worthy competitors on the [node modules wiki](https://github.com/joyent/node/wiki/Modules#wiki-web-frameworks-static).\n\n![Bench](http://i.imgur.com/b3xJU.jpg)\n\n* `ab -c 100 -n 10000`\n* `node` v0.8.7\n* `jquery.min.js` ~100kb\n\n*See /benchmark for details*\n\n## Using Lactate\n\n### Global executable\n\nIf installed globally with `npm install -g lactate`, you will have the `lactate` command at your disposal. This will run lactate static file server in the current working directory, utilizing the `cluster` module for multiple CPU cores. All [options](https://github.com/Weltschmerz/Lactate#options) are available.\n\n```code\nwltsmrz@home:~$ lactate --help\nUsage: lactate [options]\n\nOptions:\n--from, -f                        Public path                   [default: \"\"]\n--cache, -c                       Store assets in-memory        [default: true]\n--watch_files, --watch-files, -w  Watch files for cache update  [default: true]\n--subdirs, -s                     Serve subdirectories          [default: true]\n--hidden, -h                      Serve hidden files            [default: false]\n--max_age, --max-age, -M          Client-side caching max-age   [default: 172800]\n--gzip, -g                        Gzip text assets              [default: true]\n--minify, -m                      Minify text assets            [default: false]\n--bundle, -b                      Bundle text assets            [default: false]\n--rebundle, -r                    Rebundle assets if modified   [default: true]\n--headers, -H                     Custom response headers       [default: \"\"]\n--debug, -d                       Log HTTP info                 [default: true]\n--quiet, -q                       Prevent all log output        [default: false]\n```\n\n### Programmatic lactating\n\nLactate can be used with either plain node, or with Express. With Express, Lactate is a drop-in replacement for `static` middleware, but with far more ability. The examples below use Express 2.x API for simplicity. See the [examples](https://github.com/Weltschmerz/Lactate/tree/master/example) for various examples.\n\n```js\nvar lactate = require('lactate');\nvar express = require('express');\n\nvar app = express.createServer();\napp.use(lactate.static(__dirname + '/files'));\n```\n\n## Testing Lactate\n\nIf installed locally (without -g flag to npm install):\n\n1. `cd` into `~/node_modules/lactate`\n2. `npm install ./` to install devDependencies\n3. `make test` to run mocha test\n\nIf installed globally, simply run `npm test lactate`.\n\n##The varieties of Lactate experience\n\nIn the general case, the `Lactate` method returns an object with the methods `serve` `set` and `get`, importantly. However, there are more convenient methods exported by Lactate. They follow.\n\n###Serving individual files\n\nTo serve an individual file, use the `file` method.\n\n```js\n\napp.get('/', function(req, res) {\n  Lactate.file('land.html', req, res)\n})\n```\n\nAn optional fourth argument is for Lactate settings.\n\n```js\nvar options = {\n  max_age:'two days',\n  minify:true,\n  from:'scripts'\n}\n\napp.get('/', function(req, res) {\n  Lactate.file('land.html', req, res, options);\n})\n```\n\n###Serving directories\n\nThe `dir` method allows you to namespace a directory, for convenience.\n\n```js\nvar images = Lactate.dir('images');\n\napp.get('/images/:image', function(req, res) {\n  images.serve(req.params.image, req, res)\n})\n```\n\nPass a second argument to `dir` for options:\n\n```js\nvar options = { cache:false };\nvar images = Lactate.dir('assets/images', options);\nimages.maxAge('five days');\n```\n\n###Middleware export\n\nFor maximum convenience, you may use the `toMiddleware` method on directories.\n\n```js\nvar images = Lactate.dir('images', {\n  from:'images',\n  cache:false,\n  max_age:'two years',\n  debug:true\n}).toMiddleware()\n\napp.use(images) //That's it!\n```\n\nYou may also pass additional options to the `toMiddleware` function.\n\n```js\nvar images = Lactate.dir('images');\nimages.set('cache', false);\n\nvar middleware = images.toMiddleware({\n  from:'images'\n})\n\napp.use(middleware)\n```\n\n###Custom 404 pages\n\nUse the `not_found` option for defining custom 404 pages or handler functions.\n\nStrings will be treated as ordinary file paths, and as such will abide rules for gzipping and in-memory caching. Note that `notFound` paths will be relative to the `root` setting (by default `process.cwd()`).\n\n```js\nvar lactate = Lactate.Lactate({\n    not_found:'pages/404.html'\n})\n\nlactate.set('not_found', 'pages/not_found.html');\n```\n\nFunctions allow you to fully customize your 404 handling.\n\n```js\nvar lactate = Lactate.Lactate({\n  not_found:function(req, res) { }\n});\n```\n\nA special configuration method is provided:\n\n```js\nlactate.notFound(function(req, res) {\n    res.writeHead(404)\n    res.end('My custom 404 thingy')\n})\n```\n\n###Custom response headers\n\nExtend response headers with `headers` option.\n\n```js\nvar options = {\n    headers: {\n        server:'Lactate'\n    }\n};\n\nlactate.set(options);\nlactate.set('headers', options.headers);\nlactate.headers(options.headers);\nlactate.setHeader('server', options.headers.server);\n\napp.get('/', function(req, res) {\n    lactate.serve('pages/land.html', req, res);\n});\n```\n\nYou may also use a function for dynamic header setting:\n\n```js\nlactate.setHeader('server', function(req, res) {\n  return 'lactate';\n});\n```\n\n###Bundling assets\n\nLactate directories have an additional method for combining and minifying text assets, to reduce the number and size of requests.\n\n```js\nvar assets = lactate.dir('assets', {\n    from:'assets'\n});\n\nassets.bundle('js', 'common.js', function(err, data) { });\n//assets.bundleJS('common.js', function(){});\nassets.bundleCSS('common.css');\napp.use(assets.toMiddleware());\n```\n\nNow, requesting `/assets/common.js` will result with a combined and minified (and by default gzipped) script of all the scripts contained in that directory. This function does actually write the bundled files to disk.\n\n###Status listeners\n\nLactate extends EventEmitter for emitting status code events. Codes Lactate is aware of are:\n\n* `200` *OK*\n* `304` *Not Modified*\n* `400` *Bad Request*\n* `403` *Forbidden*\n* `404` *Not Found*\n* `405` *Method Not Allowed*\n* `500` *Internal Error*\n\nCallbacks are given an object which has the following properties:\n\n* `url`\n* `method`\n* `headers`\n* `address`\n* `port`\n* `path`\n* `msg`\n\n```js\nvar files = lactate.dir('files', {});\nfiles.on('404', function(req) {\n  console.log('404', req.url);\n});\n```\n\n##Options\n\n### Setting options\n\nBoolean options may be set using `enable` and `disable` methods. Other options may be set using `set` method with either key/value or an options object.\n\n**Passing to initialization function**\n\n```js\nvar lactate = require('lactate').Lactate({\n  max_age:'two days'\n})\n```\n\n**Using `set` method**\n\n```js\nlactate.set('hidden', true)\n```\n\n**Using enable/disable:**\n\n```js\nlactate.disable('gzip');\nlactate.enable('minify');\n```\n\n**Special options methods**\n\nLactate has some special methods to reduce visual clutter:\n\n```js\nlactate.maxAge('two days');\n```\n\nis equivalent to:\n\n```js\nlactate.set('max_age', 'two days');\n```\n\nSimilarly, the `headers` method is for setting custom response headers.\n\n### Options available\n\n+ `root` **string**\n\nLocal directory from which to serve files. By default, the current working directory.\n\n+ `from` **string**\n\nPublic directory exposed to clients. If set, only requests from /*directory* will complete. Contrast this with the `root` option which is the location of files on the serving machine, not necessarily the requested path.\n\n+ `subdirs` **boolean**\n\nBy default subdirectories are served. To disable this, set `subdirs` to false.\n\n+ `hidden` **boolean**\n\nWhether or not to serve hidden files. Default is false.\n\n+ `cache` **boolean** or **object**\n\nKeep files in-memory. Enabled by default. For caching options and more information about caching strategy, see [Caching Options](https://github.com/Weltschmerz/Lactate#caching-options).\n\n+ `gzip` **boolean**\n\nIf false, disables automatic gzipping for text files (HTML, JS, CSS). Enabled by default.\n\n+ `minify` **boolean**\n\nIf true, will automatically minify JavaScript and CSS using [Abridge](https://github.com/Weltschmerz/Abridge). Disabled by default.\n\n+ `watch_files` **boolean**\n\nDetermines whether Lactate will watch files to update its cache. If this is disabled, then your file cache will not update automatically as files are modified on the server.\n\n+ `headers` **object** or **function**\n\nSets custom response headers. If the option value is a function, it is a callback which is give (req, res) arguments. This function should return the header value; it is a mapping function.\n\n+ `max_age` **number** or **string**\n\nPass this function a number (of seconds) or a string and appropriate headers will be set for client-side caching. Lactate comes with expiration defaults, such as 'two days' or '5 years and sixteen days' See [Expire](https://github.com/Weltschmerz/Expire) for details.\n\n```js\nlactate.set('max_age', 87500)\n//87500 seconds\nlactate.set('max_age', 'two days')\n//172800 seconds\nlactate.set'max_age', 'five weeks and one minute and ten seconds')\n//3024070 seconds\nlactate.set('max_age', 'one year and 2 months and seven weeks and 16 seconds')\n//41050028 seconds\n```\n\n+ `not_found` **string** or **function**\n\nFor custom 404 handling. Functions are supplied the response for 100% custom response handling. Otherwise, if set to a string, this option will be treated as an ordinary file path and abide rules for gzipping / in-memory cache.\n\n+ `debug` **boolean**\n\nColored status / msg / path logging, for debugging purposes.\n\n###Caching options\n\nPass an object to the `cache` option setting. The following fields are accepted and optional:\n\n* `expire` Seconds expiration for cache keys. Keys expire after they are untouched for x-seconds. Default is `15min`.\n* `max_keys` Maximum number of keys to keep in memory. Default is `1000`.\n* `max_size` Maximum size in MB to keep in cache. Default is `100mb`.\n* `seg_threshold` Determines the threshold after which to segment a file for streaming instead of traditional writing. Default is `200kb`.\n\n\n## License\n\nMIT License\n\nCopyright 2012 Brandon Wilson\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","_id":"lactate@0.11.0","dist":{"shasum":"4511fa9a958bb4eead06804af0007d48dd6119b4","tarball":"https://registry.npmjs.org/lactate/-/lactate-0.11.0.tgz","integrity":"sha512-qm8eyI4xAQO6OJxoX02D0ZpnsATsod4v6wg876rN8FcbnfxZq2W7CllcUWWov3wcCooNnTAcIr22XHcmIkxV4w==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBdJUfDxCLtPo1T9Q21AkJAiEkg2vyHKO+EWVDMewBzkAiEA9nFsYW9/2MngS61ADhrtT3PLsYgvnpLvrLItz/+I/1I="}]},"_npmVersion":"1.1.62","_npmUser":{"name":"Weltschmerz","email":"chlavois@gmail.com"},"maintainers":[{"name":"Weltschmerz","email":"chlavois@gmail.com"}],"directories":{}},"0.11.10":{"name":"lactate","version":"0.11.10","description":"Simple and featureful assets server","keywords":["static","file","server","assets","cache"],"repository":{"type":"git","url":"git://github.com/Weltschmerz/Lactate.git"},"author":{"name":"Weltschmerz","email":"chlavois@gmail.com"},"dependencies":{"mime":"1.2.7","suckle":"latest","expire":"latest","abridge":"latest","fraction":"latest","optimist":"0.3.5","redis":"0.8.1"},"devDependencies":{"mocha":"1.6.0","should":"1.2.0"},"main":"index.js","bin":{"lactate":"bin/lactate"},"scripts":{"test":"make test"},"engines":{"node":">= 0.6.0"},"readme":"# Lactate\n\n`npm install -g lactate`\n\nAn exceedingly fast static file handler, with a few electives.\n\n### Features\n\n* In-memory caching\n* Redis caching\n* Robust cache-control setting\n* Automatic gzipping\n* Automatic minification\n* Custom 404 pages\n* Custom response headers\n* Asset bundling and minification\n* Middleware export\n* Default error pages\n* on(status) listeners\n* Colored log output\n* Global executable\n* Directory indexing\n* Express.static API compatibility\n* node-static API compatibility\n\n## Using Lactate\n\n### Global executable\n\nIf installed globally with `npm install -g lactate`, you will have the `lactate` command at your disposal. This will run lactate static file server in the current working directory, utilizing the `cluster` module for multiple CPU cores. All [options](https://github.com/Weltschmerz/Lactate#options) are available.\n\n```code\n$ lactate --help\nUsage: lactate [options]\n\nOptions:\n--root, -r                    Local path                          [default: \"\"]\n--from, -f                    Public path                         [default: \"\"]\n--subdirs, -s                 Serve subdirectories                [default: true]\n--hidden, -h                  Serve hidden files                  [default: false]\n--error_pages, --error-pages  Serve error pages                   [default: true]\n--autoindex, -a               Automatically index directories     [default: true]\n--cache, -c                   Store assets in-memory              [default: true]\n--redis_cache, --rc           Store assets in-memory using Redis  [default: true]\n--watch_files, --watch-files  Watch files for cache update        [default: true]\n--max_age, --max-age, -M      Client-side caching max-age         [default: 172800]\n--gzip, -g                    Gzip text assets                    [default: true]\n--minify, -m                  Minify text assets                  [default: false]\n--bundle, -b                  Bundle text assets                  [default: false]\n--rebundle, --rb              Rebundle assets if modified         [default: true]\n--headers, -H                 Custom response headers             [default: \"\"]\n--debug, -d                   Log HTTP info                       [default: true]\n--quiet, -q                   Prevent all log output              [default: false]\n\n```\n\n### Programmatic lactating\n\nLactate can be used with either plain node, or with Express. With Express, Lactate is a drop-in replacement for `static` middleware, but with far more ability. The examples below use Express 2.x API for simplicity. See the [examples](https://github.com/Weltschmerz/Lactate/tree/master/example) for various examples.\n\n```js\nvar lactate = require('lactate');\nvar express = require('express');\n\nvar app = express.createServer();\napp.use(lactate.static(__dirname + '/files'));\n```\n\n## Testing Lactate\n\nIf installed locally (without -g flag to npm install):\n\n1. `cd` into `~/node_modules/lactate`\n2. `npm install ./` to install devDependencies\n3. `make test` to run mocha test\n\n##The varieties of Lactate experience\n\n###Creating a Lactate server\n\n```js\nvar lactate = require('lactate'); \nvar options = {root:'files'}; \nvar server = lactate.createServer(options); \n\nserver.listen(8080);\n```\n\n###Creating a directory handler\n\n```js\nvar lactate = require('lactate');\nvar options = {from:'public/path/to/files'};\nvar files = lactate.dir('files', options);\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', function(req, res) {\n  files.serve(req, res);\n});\n\nserver.listen(8080);\n```\n\n###Using directory middleware\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files', options);\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', files.toMiddleware());\nserver.listen(8080);\n```\n\n###Integrating with Express\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files', options);\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8080);\n```\n\n###Using Express.static API\n\n```js\nvar lactate = require('lactate');\nvar express = require('express');\nvar app = express();\n\napp.use(lactate.static(__dirname + '/files'));\napp.listen(8000);\n```\n\n###Using node-static API\n\n```js\nvar lactate = require('lactate');\nvar files = new(lactate.Server)('./files');\n\nvar http = require('http');\nvar server = new http.Server;\n\n// You could also pass a .toMiddleware()'d function\n\nserver.addListener('request', function(req, res) {\n  files.serve(req, res);\n});\n\nserver.listen(8000);\n```\n\n###Serving individual files\n\n```js\nvar lactate = require('lactate');\n\nvar fileOptions = {from:'public/directory'};\nvar files = lactate.dir('files', fileOptions);\n\nvar pageOptions = {};\nvar pages = lactate.dir('pages');\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', function(req, res) {\n  if (req.url === '/') {\n    pages.serve('index.html', req, res);\n  } else {\n    files.serve(req, res);\n  };\n});\n```\n\n###Setting options\n\n```js\nvar lactate = require('lactate');\n\nvar fileOptions = {\n  from:'public'\n};\n\nvar files = lactate.dir('files', fileOptions);\n\nfiles.set('cache', false);\nfiles.disable('gzip');\nfiles.maxAge('ten days');\n\nvar express = require('express');\nvar app = express():\n  \napp.get('/public/*', files.toMiddleware());\napp.listen(8080);\n```\n\n###Bundling assets\n\n```js\nvar lactate = require('lactate');\nvar options = {\n  from:'files'\n};\n\nvar files = lactate.dir('files', options);\n\n// Combine and minify all scripts to 'common.js'\nfiles.bundle('js', 'common.js', function(err, data) {\n// Handle errors\n});\n\n// Combine and minify all CSS to 'common.css'\nfiles.bundleCSS('common.css');\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8000);\n```\n\n###Using custom 404 pages\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files');\n\nfiles.notFound('path/to/404/page.html');\n\nfiles.notFound(function(req, res) {\n  res.writeHead(404);\n  res.end('Woops, 404');\n});\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8000);\n```\n\n###Using custom response headers\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files');\n\nfiles.setHeader('x-powered-by', 'Lactate');\nfiles.header('x-timestamp', function(req, res) {\n  return new Date().toUTCString();\n});\n\nvar headers = {};\nfiles.headers(headers);\n```\n\n###Status listeners\n\nLactate extends EventEmitter for emitting status code events. Codes Lactate is aware of are:\n\n* `200` *OK*\n* `304` *Not Modified*\n* `400` *Bad Request*\n* `403` *Forbidden*\n* `404` *Not Found*\n* `405` *Method Not Allowed*\n* `500` *Internal Error*\n\nCallbacks are given an object which has the following properties:\n\n* `url` The requested URL\n* `method` The request method (GET, HEAD)\n* `headers` Request headers\n* `address` Request IP address\n* `port` Request port\n* `path` Absolute file path to the requested file, if it exists\n* `msg` HTTP satus message\n\n```js\nvar files = lactate.dir('files', {});\nfiles.on('404', function(req) {\n  console.log('404', req.url);\n});\n```\n\n##Options\n\n### Setting options\n\nBoolean options may be set using `enable` and `disable` methods. Other options may be set using `set` method with either key/value or an options object.\n\n**Passing to initialization function**\n\n```js\nvar lactate = require('lactate').Lactate({\n  max_age:'two days'\n})\n```\n\n**Using `set` method**\n\n```js\nlactate.set('hidden', true)\n```\n\n**Using enable/disable:**\n\n```js\nlactate.disable('gzip');\nlactate.enable('minify');\n```\n\n**Special options methods**\n\nLactate has some special methods to reduce visual clutter:\n\n```js\nlactate.maxAge('two days');\n```\n\nis equivalent to:\n\n```js\nlactate.set('max_age', 'two days');\n```\n\nSimilarly, the `headers` method is for setting custom response headers. \n\n**Underscores or spaces**\n\nUse spaces instead of underscores if you prefer:\n\n```js\nlactate.disable('max age');\nlactate.enable('watch files');\n```\n\n### Options available\n\n+ `root` **string**\n\nLocal directory from which to serve files. By default, the current working directory.\n\n+ `from` **string**\n\nPublic directory exposed to clients. If set, only requests from /*directory* will complete. Contrast this with the `root` option which is the location of files on the serving machine, not necessarily the requested path.\n\n+ `subdirs` **boolean**\n\nBy default subdirectories are served. To disable this, set `subdirs` to false.\n\n+ `hidden` **boolean**\n\nWhether or not to serve hidden files. Default is false.\n\n+ `error pages` **boolean**\n\nEnabled by default. When disabled, Lactate will not serve error pages for 404 resposes, etc..\n\n+ `autoindex` **boolean**\n\nAutomatically display directory indexes. Disabled by default.\n\n+ `cache` **boolean** or **object**\n\nKeep files in-memory. Enabled by default. For caching options and more information about caching strategy, see [Caching Options](https://github.com/Weltschmerz/Lactate#caching-options).\n\n+ `gzip` **boolean**\n\nIf false, disables automatic gzipping for text files (HTML, JS, CSS). Enabled by default.\n\n+ `minify` **boolean**\n\nIf true, will automatically minify JavaScript and CSS using [Abridge](https://github.com/Weltschmerz/Abridge). Disabled by default.\n\n+ `watch files` **boolean**\n\nDetermines whether Lactate will watch files to update its cache. If this is disabled, then your file cache will not update automatically as files are modified on the server.\n\n+ `headers` **object** or **function**\n\nSets custom response headers. If the option value is a function, it is a callback which is give (req, res) arguments. This function should return the header value; it is a mapping function.\n\n+ `max age` **number** or **string**\n\nPass this function a number (of seconds) or a string and appropriate headers will be set for client-side caching. Lactate comes with expiration defaults, such as 'two days' or '5 years and sixteen days' See [Expire](https://github.com/Weltschmerz/Expire) for details.\n\n```js\nlactate.set('max_age', 87500)\n//87500 seconds\nlactate.set('max_age', 'two days')\n//172800 seconds\nlactate.set'max_age', 'five weeks and one minute and ten seconds')\n//3024070 seconds\nlactate.set('max_age', 'one year and 2 months and seven weeks and 16 seconds')\n//41050028 seconds\n```\n\n+ `not found` **string** or **function**\n\nFor custom 404 handling. Functions are supplied the response for 100% custom response handling. Otherwise, if set to a string, this option will be treated as an ordinary file path and abide rules for gzipping / in-memory cache.\n\n+ `debug` **boolean**\n\nColored status / msg / path logging, for debugging purposes.\n\n###Caching options\n\nPass an object to the `cache` option setting. The following fields are accepted and optional:\n\n* `expire` Seconds expiration for cache keys. Keys expire after they are untouched for x-seconds. Default is `15min`.\n* `max keys` Maximum number of keys to keep in memory. Default is `1000`.\n* `max size` Maximum size in MB to keep in cache. Default is `100mb`.\n* `seg threshold` Determines the threshold after which to segment a file for streaming instead of traditional writing. Default is `200kb`.\n\n\n## License\n\nMIT License\n\nCopyright 2012 Brandon Wilson\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","_id":"lactate@0.11.10","dist":{"shasum":"5bb147576be8f4cdc26ef6ffc0ced491faea5975","tarball":"https://registry.npmjs.org/lactate/-/lactate-0.11.10.tgz","integrity":"sha512-vPLDa+aF18sFYviF0XY7ixXnA6krbtOfbWymTaTOttwMr7/CSK53qgv3kPhBSd9knCkOlDpcvbrDs7HETECjmQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQC7vrNV9+w1FlXdvPY4XN1BsbE3+eaEl0tUC2mqyiecCgIhALgdGDzvugSWG6K3TZdy7VbP+ypDrfvga8jFZDP/w48U"}]},"_npmVersion":"1.1.62","_npmUser":{"name":"Weltschmerz","email":"chlavois@gmail.com"},"maintainers":[{"name":"Weltschmerz","email":"chlavois@gmail.com"}],"directories":{}},"0.11.11":{"name":"lactate","version":"0.11.11","description":"Simple and featureful assets server","keywords":["static","file","server","assets","cache"],"repository":{"type":"git","url":"git://github.com/Weltschmerz/Lactate.git"},"author":{"name":"Weltschmerz","email":"chlavois@gmail.com"},"dependencies":{"mime":"1.2.7","suckle":"latest","expire":"latest","abridge":"latest","fraction":"latest","optimist":"0.3.5","redis":"0.8.1"},"devDependencies":{"mocha":"1.6.0","should":"1.2.0"},"main":"index.js","bin":{"lactate":"bin/lactate"},"scripts":{"test":"make test"},"engines":{"node":">= 0.6.0"},"readme":"# Lactate\n\n`npm install -g lactate`\n\nAn exceedingly fast static file handler, with a few electives.\n\n### Features\n\n* In-memory caching\n* Redis caching\n* Robust cache-control setting\n* Automatic gzipping\n* Automatic minification\n* Custom 404 pages\n* Custom response headers\n* Asset bundling and minification\n* Middleware export\n* Default error pages\n* on(status) listeners\n* Colored log output\n* Global executable\n* Directory indexing\n* Express.static API compatibility\n* node-static API compatibility\n\n## Using Lactate\n\n### Global executable\n\nIf installed globally with `npm install -g lactate`, you will have the `lactate` command at your disposal. This will run lactate static file server in the current working directory, utilizing the `cluster` module for multiple CPU cores. All [options](https://github.com/Weltschmerz/Lactate#options) are available.\n\n```code\n$ lactate --help\nUsage: lactate [options]\n\nOptions:\n--root, -r                    Local path                          [default: \"\"]\n--from, -f                    Public path                         [default: \"\"]\n--subdirs, -s                 Serve subdirectories                [default: true]\n--hidden, -h                  Serve hidden files                  [default: false]\n--error_pages, --error-pages  Serve error pages                   [default: true]\n--autoindex, -a               Automatically index directories     [default: true]\n--cache, -c                   Store assets in-memory              [default: true]\n--redis_cache, --rc           Store assets in-memory using Redis  [default: true]\n--watch_files, --watch-files  Watch files for cache update        [default: true]\n--max_age, --max-age, -M      Client-side caching max-age         [default: 172800]\n--gzip, -g                    Gzip text assets                    [default: true]\n--minify, -m                  Minify text assets                  [default: false]\n--bundle, -b                  Bundle text assets                  [default: false]\n--rebundle, --rb              Rebundle assets if modified         [default: true]\n--headers, -H                 Custom response headers             [default: \"\"]\n--debug, -d                   Log HTTP info                       [default: true]\n--quiet, -q                   Prevent all log output              [default: false]\n\n```\n\n### Programmatic lactating\n\nLactate can be used with either plain node, or with Express. With Express, Lactate is a drop-in replacement for `static` middleware, but with far more ability. The examples below use Express 2.x API for simplicity. See the [examples](https://github.com/Weltschmerz/Lactate/tree/master/example) for various examples.\n\n```js\nvar lactate = require('lactate');\nvar express = require('express');\n\nvar app = express.createServer();\napp.use(lactate.static(__dirname + '/files'));\n```\n\n## Testing Lactate\n\nIf installed locally (without -g flag to npm install):\n\n1. `cd` into `~/node_modules/lactate`\n2. `npm install ./` to install devDependencies\n3. `make test` to run mocha test\n\n##The varieties of Lactate experience\n\n###Creating a Lactate server\n\n```js\nvar lactate = require('lactate'); \nvar options = {root:'files'}; \nvar server = lactate.createServer(options); \n\nserver.listen(8080);\n```\n\n###Creating a directory handler\n\n```js\nvar lactate = require('lactate');\nvar options = {from:'public/path/to/files'};\nvar files = lactate.dir('files', options);\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', function(req, res) {\n  files.serve(req, res);\n});\n\nserver.listen(8080);\n```\n\n###Using directory middleware\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files', options);\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', files.toMiddleware());\nserver.listen(8080);\n```\n\n###Integrating with Express\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files', options);\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8080);\n```\n\n###Using Express.static API\n\n```js\nvar lactate = require('lactate');\nvar express = require('express');\nvar app = express();\n\napp.use(lactate.static(__dirname + '/files'));\napp.listen(8000);\n```\n\n###Using node-static API\n\n```js\nvar lactate = require('lactate');\nvar files = new(lactate.Server)('./files');\n\nvar http = require('http');\nvar server = new http.Server;\n\n// You could also pass a .toMiddleware()'d function\n\nserver.addListener('request', function(req, res) {\n  files.serve(req, res);\n});\n\nserver.listen(8000);\n```\n\n###Serving individual files\n\n```js\nvar lactate = require('lactate');\n\nvar fileOptions = {from:'public/directory'};\nvar files = lactate.dir('files', fileOptions);\n\nvar pageOptions = {};\nvar pages = lactate.dir('pages');\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', function(req, res) {\n  if (req.url === '/') {\n    pages.serve('index.html', req, res);\n  } else {\n    files.serve(req, res);\n  };\n});\n```\n\n###Setting options\n\n```js\nvar lactate = require('lactate');\n\nvar fileOptions = {\n  from:'public'\n};\n\nvar files = lactate.dir('files', fileOptions);\n\nfiles.set('cache', false);\nfiles.disable('gzip');\nfiles.maxAge('ten days');\n\nvar express = require('express');\nvar app = express():\n  \napp.get('/public/*', files.toMiddleware());\napp.listen(8080);\n```\n\n###Bundling assets\n\n```js\nvar lactate = require('lactate');\nvar options = {\n  from:'files'\n};\n\nvar files = lactate.dir('files', options);\n\n// Combine and minify all scripts to 'common.js'\nfiles.bundle('js', 'common.js', function(err, data) {\n// Handle errors\n});\n\n// Combine and minify all CSS to 'common.css'\nfiles.bundleCSS('common.css');\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8000);\n```\n\n###Using custom 404 pages\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files');\n\nfiles.notFound('path/to/404/page.html');\n\nfiles.notFound(function(req, res) {\n  res.writeHead(404);\n  res.end('Woops, 404');\n});\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8000);\n```\n\n###Using custom response headers\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files');\n\nfiles.setHeader('x-powered-by', 'Lactate');\nfiles.header('x-timestamp', function(req, res) {\n  return new Date().toUTCString();\n});\n\nvar headers = {};\nfiles.headers(headers);\n```\n\n###Status listeners\n\nLactate extends EventEmitter for emitting status code events. Codes Lactate is aware of are:\n\n* `200` *OK*\n* `304` *Not Modified*\n* `400` *Bad Request*\n* `403` *Forbidden*\n* `404` *Not Found*\n* `405` *Method Not Allowed*\n* `500` *Internal Error*\n\nCallbacks are given an object which has the following properties:\n\n* `url` The requested URL\n* `method` The request method (GET, HEAD)\n* `headers` Request headers\n* `address` Request IP address\n* `port` Request port\n* `path` Absolute file path to the requested file, if it exists\n* `msg` HTTP satus message\n\n```js\nvar files = lactate.dir('files', {});\nfiles.on('404', function(req) {\n  console.log('404', req.url);\n});\n```\n\n##Options\n\n### Setting options\n\nBoolean options may be set using `enable` and `disable` methods. Other options may be set using `set` method with either key/value or an options object.\n\n**Passing to initialization function**\n\n```js\nvar lactate = require('lactate').Lactate({\n  max_age:'two days'\n})\n```\n\n**Using `set` method**\n\n```js\nlactate.set('hidden', true)\n```\n\n**Using enable/disable:**\n\n```js\nlactate.disable('gzip');\nlactate.enable('minify');\n```\n\n**Special options methods**\n\nLactate has some special methods to reduce visual clutter:\n\n```js\nlactate.maxAge('two days');\n```\n\nis equivalent to:\n\n```js\nlactate.set('max_age', 'two days');\n```\n\nSimilarly, the `headers` method is for setting custom response headers. \n\n**Underscores or spaces**\n\nUse spaces instead of underscores if you prefer:\n\n```js\nlactate.disable('max age');\nlactate.enable('watch files');\n```\n\n### Options available\n\n+ `root` **string**\n\nLocal directory from which to serve files. By default, the current working directory.\n\n+ `from` **string**\n\nPublic directory exposed to clients. If set, only requests from /*directory* will complete. Contrast this with the `root` option which is the location of files on the serving machine, not necessarily the requested path.\n\n+ `subdirs` **boolean**\n\nBy default subdirectories are served. To disable this, set `subdirs` to false.\n\n+ `hidden` **boolean**\n\nWhether or not to serve hidden files. Default is false.\n\n+ `error pages` **boolean**\n\nEnabled by default. When disabled, Lactate will not serve error pages for 404 resposes, etc..\n\n+ `autoindex` **boolean**\n\nAutomatically display directory indexes. Disabled by default.\n\n+ `cache` **boolean** or **object**\n\nKeep files in-memory. Enabled by default. For caching options and more information about caching strategy, see [Caching Options](https://github.com/Weltschmerz/Lactate#caching-options).\n\n+ `gzip` **boolean**\n\nIf false, disables automatic gzipping for text files (HTML, JS, CSS). Enabled by default.\n\n+ `minify` **boolean**\n\nIf true, will automatically minify JavaScript and CSS using [Abridge](https://github.com/Weltschmerz/Abridge). Disabled by default.\n\n+ `watch files` **boolean**\n\nDetermines whether Lactate will watch files to update its cache. If this is disabled, then your file cache will not update automatically as files are modified on the server.\n\n+ `headers` **object** or **function**\n\nSets custom response headers. If the option value is a function, it is a callback which is give (req, res) arguments. This function should return the header value; it is a mapping function.\n\n+ `max age` **number** or **string**\n\nPass this function a number (of seconds) or a string and appropriate headers will be set for client-side caching. Lactate comes with expiration defaults, such as 'two days' or '5 years and sixteen days' See [Expire](https://github.com/Weltschmerz/Expire) for details.\n\n```js\nlactate.set('max_age', 87500)\n//87500 seconds\nlactate.set('max_age', 'two days')\n//172800 seconds\nlactate.set'max_age', 'five weeks and one minute and ten seconds')\n//3024070 seconds\nlactate.set('max_age', 'one year and 2 months and seven weeks and 16 seconds')\n//41050028 seconds\n```\n\n+ `not found` **string** or **function**\n\nFor custom 404 handling. Functions are supplied the response for 100% custom response handling. Otherwise, if set to a string, this option will be treated as an ordinary file path and abide rules for gzipping / in-memory cache.\n\n+ `debug` **boolean**\n\nColored status / msg / path logging, for debugging purposes.\n\n###Caching options\n\nPass an object to the `cache` option setting. The following fields are accepted and optional:\n\n* `expire` Seconds expiration for cache keys. Keys expire after they are untouched for x-seconds. Default is `15min`.\n* `max keys` Maximum number of keys to keep in memory. Default is `1000`.\n* `max size` Maximum size in MB to keep in cache. Default is `100mb`.\n* `seg threshold` Determines the threshold after which to segment a file for streaming instead of traditional writing. Default is `200kb`.\n\n\n## License\n\nMIT License\n\nCopyright 2012 Brandon Wilson\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","_id":"lactate@0.11.11","dist":{"shasum":"3ac10c43e8c885d48fd6938a486b3fe861f2e0d5","tarball":"https://registry.npmjs.org/lactate/-/lactate-0.11.11.tgz","integrity":"sha512-C6bfIxnQ9nCUXOLttda7A3laJtlMe/Qk5fZopN7RbFvog+TtVpwiLWAgViwTsEnzlqTuDLsa2E/TuAJmfeA4xA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDYe3NQ06Ng+MNvxdh6yXZrKT13nSnRvc2Zhh0Pt2vhfAiA7FjlnKqV6KDTBWWK8+ixnwMw5f2YSfCrj+mVNR/UHeQ=="}]},"_npmVersion":"1.1.62","_npmUser":{"name":"Weltschmerz","email":"chlavois@gmail.com"},"maintainers":[{"name":"Weltschmerz","email":"chlavois@gmail.com"}],"directories":{}},"0.11.12":{"name":"lactate","version":"0.11.12","description":"Simple and featureful assets server","keywords":["static","file","server","assets","cache"],"repository":{"type":"git","url":"git://github.com/Weltschmerz/Lactate.git"},"author":{"name":"Weltschmerz","email":"chlavois@gmail.com"},"dependencies":{"mime":"1.2.7","suckle":"latest","expire":"latest","abridge":"latest","fraction":"latest","optimist":"0.3.5","redis":"0.8.1"},"devDependencies":{"mocha":"1.6.0","should":"1.2.0"},"main":"index.js","bin":{"lactate":"bin/lactate"},"scripts":{"test":"make test"},"engines":{"node":">= 0.6.0"},"readme":"# Lactate\n\n`npm install -g lactate`\n\nAn exceedingly fast static file handler, with a few electives.\n\n### Features\n\n* In-memory caching\n* Redis caching\n* Robust cache-control setting\n* Automatic gzipping\n* Automatic minification\n* Custom 404 pages\n* Custom response headers\n* Asset bundling and minification\n* Middleware export\n* Default error pages\n* on(status) listeners\n* Colored log output\n* Global executable\n* Directory indexing\n* Express.static API compatibility\n* node-static API compatibility\n\n## Using Lactate\n\n### Global executable\n\nIf installed globally with `npm install -g lactate`, you will have the `lactate` command at your disposal. This will run lactate static file server in the current working directory, utilizing the `cluster` module for multiple CPU cores. All [options](https://github.com/Weltschmerz/Lactate#options) are available.\n\n```code\n$ lactate --help\nUsage: lactate [options]\n\nOptions:\n--root, -r                    Local path                          [default: \"\"]\n--from, -f                    Public path                         [default: \"\"]\n--subdirs, -s                 Serve subdirectories                [default: true]\n--hidden, -h                  Serve hidden files                  [default: false]\n--error_pages, --error-pages  Serve error pages                   [default: true]\n--autoindex, -a               Automatically index directories     [default: true]\n--cache, -c                   Store assets in-memory              [default: true]\n--redis_cache, --rc           Store assets in-memory using Redis  [default: true]\n--watch_files, --watch-files  Watch files for cache update        [default: true]\n--max_age, --max-age, -M      Client-side caching max-age         [default: 172800]\n--gzip, -g                    Gzip text assets                    [default: true]\n--minify, -m                  Minify text assets                  [default: false]\n--bundle, -b                  Bundle text assets                  [default: false]\n--rebundle, --rb              Rebundle assets if modified         [default: true]\n--headers, -H                 Custom response headers             [default: \"\"]\n--debug, -d                   Log HTTP info                       [default: true]\n--quiet, -q                   Prevent all log output              [default: false]\n\n```\n\n### Programmatic lactating\n\nLactate can be used with either plain node, or with Express. With Express, Lactate is a drop-in replacement for `static` middleware, but with far more ability. The examples below use Express 2.x API for simplicity. See the [examples](https://github.com/Weltschmerz/Lactate/tree/master/example) for various examples.\n\n```js\nvar lactate = require('lactate');\nvar express = require('express');\n\nvar app = express.createServer();\napp.use(lactate.static(__dirname + '/files'));\n```\n\n## Testing Lactate\n\nIf installed locally (without -g flag to npm install):\n\n1. `cd` into `~/node_modules/lactate`\n2. `npm install ./` to install devDependencies\n3. `make test` to run mocha test\n\n##The varieties of Lactate experience\n\n###Creating a Lactate server\n\n```js\nvar lactate = require('lactate'); \nvar options = {root:'files'}; \nvar server = lactate.createServer(options); \n\nserver.listen(8080);\n```\n\n###Creating a directory handler\n\n```js\nvar lactate = require('lactate');\nvar options = {from:'public/path/to/files'};\nvar files = lactate.dir('files', options);\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', function(req, res) {\n  files.serve(req, res);\n});\n\nserver.listen(8080);\n```\n\n###Using directory middleware\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files', options);\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', files.toMiddleware());\nserver.listen(8080);\n```\n\n###Integrating with Express\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files', options);\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8080);\n```\n\n###Using Express.static API\n\n```js\nvar lactate = require('lactate');\nvar express = require('express');\nvar app = express();\n\napp.use(lactate.static(__dirname + '/files'));\napp.listen(8000);\n```\n\n###Using node-static API\n\n```js\nvar lactate = require('lactate');\nvar files = new(lactate.Server)('./files');\n\nvar http = require('http');\nvar server = new http.Server;\n\n// You could also pass a .toMiddleware()'d function\n\nserver.addListener('request', function(req, res) {\n  files.serve(req, res);\n});\n\nserver.listen(8000);\n```\n\n###Serving individual files\n\n```js\nvar lactate = require('lactate');\n\nvar fileOptions = {from:'public/directory'};\nvar files = lactate.dir('files', fileOptions);\n\nvar pageOptions = {};\nvar pages = lactate.dir('pages');\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', function(req, res) {\n  if (req.url === '/') {\n    pages.serve('index.html', req, res);\n  } else {\n    files.serve(req, res);\n  };\n});\n```\n\n###Setting options\n\n```js\nvar lactate = require('lactate');\n\nvar fileOptions = {\n  from:'public'\n};\n\nvar files = lactate.dir('files', fileOptions);\n\nfiles.set('cache', false);\nfiles.disable('gzip');\nfiles.maxAge('ten days');\n\nvar express = require('express');\nvar app = express():\n  \napp.get('/public/*', files.toMiddleware());\napp.listen(8080);\n```\n\n###Bundling assets\n\n```js\nvar lactate = require('lactate');\nvar options = {\n  from:'files'\n};\n\nvar files = lactate.dir('files', options);\n\n// Combine and minify all scripts to 'common.js'\nfiles.bundle('js', 'common.js', function(err, data) {\n// Handle errors\n});\n\n// Combine and minify all CSS to 'common.css'\nfiles.bundleCSS('common.css');\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8000);\n```\n\n###Using custom 404 pages\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files');\n\nfiles.notFound('path/to/404/page.html');\n\nfiles.notFound(function(req, res) {\n  res.writeHead(404);\n  res.end('Woops, 404');\n});\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8000);\n```\n\n###Using custom response headers\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files');\n\nfiles.setHeader('x-powered-by', 'Lactate');\nfiles.header('x-timestamp', function(req, res) {\n  return new Date().toUTCString();\n});\n\nvar headers = {};\nfiles.headers(headers);\n```\n\n###Status listeners\n\nLactate extends EventEmitter for emitting status code events. Codes Lactate is aware of are:\n\n* `200` *OK*\n* `304` *Not Modified*\n* `400` *Bad Request*\n* `403` *Forbidden*\n* `404` *Not Found*\n* `405` *Method Not Allowed*\n* `500` *Internal Error*\n\nCallbacks are given an object which has the following properties:\n\n* `url` The requested URL\n* `method` The request method (GET, HEAD)\n* `headers` Request headers\n* `address` Request IP address\n* `port` Request port\n* `path` Absolute file path to the requested file, if it exists\n* `msg` HTTP satus message\n\n```js\nvar files = lactate.dir('files', {});\nfiles.on('404', function(req) {\n  console.log('404', req.url);\n});\n```\n\n##Options\n\n### Setting options\n\nBoolean options may be set using `enable` and `disable` methods. Other options may be set using `set` method with either key/value or an options object.\n\n**Passing to initialization function**\n\n```js\nvar lactate = require('lactate').Lactate({\n  max_age:'two days'\n})\n```\n\n**Using `set` method**\n\n```js\nlactate.set('hidden', true)\n```\n\n**Using enable/disable:**\n\n```js\nlactate.disable('gzip');\nlactate.enable('minify');\n```\n\n**Special options methods**\n\nLactate has some special methods to reduce visual clutter:\n\n```js\nlactate.maxAge('two days');\n```\n\nis equivalent to:\n\n```js\nlactate.set('max_age', 'two days');\n```\n\nSimilarly, the `headers` method is for setting custom response headers. \n\n**Underscores or spaces**\n\nUse spaces instead of underscores if you prefer:\n\n```js\nlactate.disable('max age');\nlactate.enable('watch files');\n```\n\n### Options available\n\n+ `root` **string**\n\nLocal directory from which to serve files. By default, the current working directory.\n\n+ `from` **string**\n\nPublic directory exposed to clients. If set, only requests from /*directory* will complete. Contrast this with the `root` option which is the location of files on the serving machine, not necessarily the requested path.\n\n+ `subdirs` **boolean**\n\nBy default subdirectories are served. To disable this, set `subdirs` to false.\n\n+ `hidden` **boolean**\n\nWhether or not to serve hidden files. Default is false.\n\n+ `error pages` **boolean**\n\nEnabled by default. When disabled, Lactate will not serve error pages for 404 resposes, etc..\n\n+ `autoindex` **boolean**\n\nAutomatically display directory indexes. Disabled by default.\n\n+ `cache` **boolean** or **object**\n\nKeep files in-memory. Enabled by default. For caching options and more information about caching strategy, see [Caching Options](https://github.com/Weltschmerz/Lactate#caching-options).\n\n+ `gzip` **boolean**\n\nIf false, disables automatic gzipping for text files (HTML, JS, CSS). Enabled by default.\n\n+ `minify` **boolean**\n\nIf true, will automatically minify JavaScript and CSS using [Abridge](https://github.com/Weltschmerz/Abridge). Disabled by default.\n\n+ `watch files` **boolean**\n\nDetermines whether Lactate will watch files to update its cache. If this is disabled, then your file cache will not update automatically as files are modified on the server.\n\n+ `headers` **object** or **function**\n\nSets custom response headers. If the option value is a function, it is a callback which is give (req, res) arguments. This function should return the header value; it is a mapping function.\n\n+ `max age` **number** or **string**\n\nPass this function a number (of seconds) or a string and appropriate headers will be set for client-side caching. Lactate comes with expiration defaults, such as 'two days' or '5 years and sixteen days' See [Expire](https://github.com/Weltschmerz/Expire) for details.\n\n```js\nlactate.set('max_age', 87500)\n//87500 seconds\nlactate.set('max_age', 'two days')\n//172800 seconds\nlactate.set'max_age', 'five weeks and one minute and ten seconds')\n//3024070 seconds\nlactate.set('max_age', 'one year and 2 months and seven weeks and 16 seconds')\n//41050028 seconds\n```\n\n+ `not found` **string** or **function**\n\nFor custom 404 handling. Functions are supplied the response for 100% custom response handling. Otherwise, if set to a string, this option will be treated as an ordinary file path and abide rules for gzipping / in-memory cache.\n\n+ `debug` **boolean**\n\nColored status / msg / path logging, for debugging purposes.\n\n###Caching options\n\nPass an object to the `cache` option setting. The following fields are accepted and optional:\n\n* `expire` Seconds expiration for cache keys. Keys expire after they are untouched for x-seconds. Default is `15min`.\n* `max keys` Maximum number of keys to keep in memory. Default is `1000`.\n* `max size` Maximum size in MB to keep in cache. Default is `100mb`.\n* `seg threshold` Determines the threshold after which to segment a file for streaming instead of traditional writing. Default is `200kb`.\n\n\n## License\n\nMIT License\n\nCopyright 2012 Brandon Wilson\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","_id":"lactate@0.11.12","dist":{"shasum":"c47bb3da176bb53564015d3b8cdf425ddd37a655","tarball":"https://registry.npmjs.org/lactate/-/lactate-0.11.12.tgz","integrity":"sha512-kPn24jdS6PRAkwk1LhrjjsxY2YaHbcMd6qKYhCJJmDKStBMZmuTpBx18Eb5y5kseRNQr5SNNOZwADxaQ3fL6kw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIB62A4dyZJCz9asaKWh8mECn/hfEK33UJQ/u6A8l8B4eAiEAmHQNOVRu6Gu9dtZXbtIV+B1iOxicXfU84kM//Di3JqM="}]},"_npmVersion":"1.1.62","_npmUser":{"name":"Weltschmerz","email":"chlavois@gmail.com"},"maintainers":[{"name":"Weltschmerz","email":"chlavois@gmail.com"}],"directories":{}},"0.11.13":{"name":"lactate","version":"0.11.13","description":"Simple and featureful assets server","keywords":["static","file","server","assets","cache"],"repository":{"type":"git","url":"git://github.com/Weltschmerz/Lactate.git"},"author":{"name":"Weltschmerz","email":"chlavois@gmail.com"},"dependencies":{"mime":"1.2.7","suckle":"latest","expire":"latest","abridge":"latest","fraction":"latest","optimist":"0.3.5","redis":"0.8.1"},"devDependencies":{"mocha":"1.6.0","should":"1.2.0"},"main":"index.js","bin":{"lactate":"bin/lactate"},"scripts":{"test":"make test"},"engines":{"node":">= 0.6.0"},"readme":"# Lactate\n\n`npm install -g lactate`\n\nAn exceedingly fast static file handler, with a few electives.\n\n### Features\n\n* In-memory caching\n* Redis caching\n* Robust cache-control setting\n* Automatic gzipping\n* Automatic minification\n* Custom 404 pages\n* Custom response headers\n* Asset bundling and minification\n* Middleware export\n* Default error pages\n* on(status) listeners\n* Colored log output\n* Global executable\n* Directory indexing\n* Express.static API compatibility\n* node-static API compatibility\n\n## Using Lactate\n\n### Global executable\n\nIf installed globally with `npm install -g lactate`, you will have the `lactate` command at your disposal. This will run lactate static file server in the current working directory, utilizing the `cluster` module for multiple CPU cores. All [options](https://github.com/Weltschmerz/Lactate#options) are available.\n\n```code\n$ lactate --help\nUsage: lactate [options]\n\nOptions:\n--root, -r                    Local path                          [default: \"\"]\n--from, -f                    Public path                         [default: \"\"]\n--subdirs, -s                 Serve subdirectories                [default: true]\n--hidden, -h                  Serve hidden files                  [default: false]\n--error_pages, --error-pages  Serve error pages                   [default: true]\n--autoindex, -a               Automatically index directories     [default: true]\n--cache, -c                   Store assets in-memory              [default: true]\n--redis_cache, --rc           Store assets in-memory using Redis  [default: true]\n--watch_files, --watch-files  Watch files for cache update        [default: true]\n--max_age, --max-age, -M      Client-side caching max-age         [default: 172800]\n--gzip, -g                    Gzip text assets                    [default: true]\n--minify, -m                  Minify text assets                  [default: false]\n--bundle, -b                  Bundle text assets                  [default: false]\n--rebundle, --rb              Rebundle assets if modified         [default: true]\n--headers, -H                 Custom response headers             [default: \"\"]\n--debug, -d                   Log HTTP info                       [default: true]\n--quiet, -q                   Prevent all log output              [default: false]\n\n```\n\n### Programmatic lactating\n\nLactate can be used with either plain node, or with Express. With Express, Lactate is a drop-in replacement for `static` middleware, but with far more ability. The examples below use Express 2.x API for simplicity. See the [examples](https://github.com/Weltschmerz/Lactate/tree/master/example) for various examples.\n\n```js\nvar lactate = require('lactate');\nvar express = require('express');\n\nvar app = express.createServer();\napp.use(lactate.static(__dirname + '/files'));\n```\n\n## Testing Lactate\n\nIf installed locally (without -g flag to npm install):\n\n1. `cd` into `~/node_modules/lactate`\n2. `npm install ./` to install devDependencies\n3. `make test` to run mocha test\n\n##The varieties of Lactate experience\n\n###Creating a Lactate server\n\n```js\nvar lactate = require('lactate'); \nvar options = {root:'files'}; \nvar server = lactate.createServer(options); \n\nserver.listen(8080);\n```\n\n###Creating a directory handler\n\n```js\nvar lactate = require('lactate');\nvar options = {from:'public/path/to/files'};\nvar files = lactate.dir('files', options);\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', function(req, res) {\n  files.serve(req, res);\n});\n\nserver.listen(8080);\n```\n\n###Using directory middleware\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files', options);\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', files.toMiddleware());\nserver.listen(8080);\n```\n\n###Integrating with Express\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files', options);\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8080);\n```\n\n###Using Express.static API\n\n```js\nvar lactate = require('lactate');\nvar express = require('express');\nvar app = express();\n\napp.use(lactate.static(__dirname + '/files'));\napp.listen(8000);\n```\n\n###Using node-static API\n\n```js\nvar lactate = require('lactate');\nvar files = new(lactate.Server)('./files');\n\nvar http = require('http');\nvar server = new http.Server;\n\n// You could also pass a .toMiddleware()'d function\n\nserver.addListener('request', function(req, res) {\n  files.serve(req, res);\n});\n\nserver.listen(8000);\n```\n\n###Serving individual files\n\n```js\nvar lactate = require('lactate');\n\nvar fileOptions = {from:'public/directory'};\nvar files = lactate.dir('files', fileOptions);\n\nvar pageOptions = {};\nvar pages = lactate.dir('pages');\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', function(req, res) {\n  if (req.url === '/') {\n    pages.serve('index.html', req, res);\n  } else {\n    files.serve(req, res);\n  };\n});\n```\n\n###Setting options\n\n```js\nvar lactate = require('lactate');\n\nvar fileOptions = {\n  from:'public'\n};\n\nvar files = lactate.dir('files', fileOptions);\n\nfiles.set('cache', false);\nfiles.disable('gzip');\nfiles.maxAge('ten days');\n\nvar express = require('express');\nvar app = express():\n  \napp.get('/public/*', files.toMiddleware());\napp.listen(8080);\n```\n\n###Bundling assets\n\n```js\nvar lactate = require('lactate');\nvar options = {\n  from:'files'\n};\n\nvar files = lactate.dir('files', options);\n\n// Combine and minify all scripts to 'common.js'\nfiles.bundle('js', 'common.js', function(err, data) {\n// Handle errors\n});\n\n// Combine and minify all CSS to 'common.css'\nfiles.bundleCSS('common.css');\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8000);\n```\n\n###Using custom 404 pages\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files');\n\nfiles.notFound('path/to/404/page.html');\n\nfiles.notFound(function(req, res) {\n  res.writeHead(404);\n  res.end('Woops, 404');\n});\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8000);\n```\n\n###Using custom response headers\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files');\n\nfiles.setHeader('x-powered-by', 'Lactate');\nfiles.header('x-timestamp', function(req, res) {\n  return new Date().toUTCString();\n});\n\nvar headers = {};\nfiles.headers(headers);\n```\n\n###Status listeners\n\nLactate extends EventEmitter for emitting status code events. Codes Lactate is aware of are:\n\n* `200` *OK*\n* `304` *Not Modified*\n* `400` *Bad Request*\n* `403` *Forbidden*\n* `404` *Not Found*\n* `405` *Method Not Allowed*\n* `500` *Internal Error*\n\nCallbacks are given an object which has the following properties:\n\n* `url` The requested URL\n* `method` The request method (GET, HEAD)\n* `headers` Request headers\n* `address` Request IP address\n* `port` Request port\n* `path` Absolute file path to the requested file, if it exists\n* `msg` HTTP satus message\n\n```js\nvar files = lactate.dir('files', {});\nfiles.on('404', function(req) {\n  console.log('404', req.url);\n});\n```\n\n##Options\n\n### Setting options\n\nBoolean options may be set using `enable` and `disable` methods. Other options may be set using `set` method with either key/value or an options object.\n\n**Passing to initialization function**\n\n```js\nvar lactate = require('lactate').Lactate({\n  max_age:'two days'\n})\n```\n\n**Using `set` method**\n\n```js\nlactate.set('hidden', true)\n```\n\n**Using enable/disable:**\n\n```js\nlactate.disable('gzip');\nlactate.enable('minify');\n```\n\n**Special options methods**\n\nLactate has some special methods to reduce visual clutter:\n\n```js\nlactate.maxAge('two days');\n```\n\nis equivalent to:\n\n```js\nlactate.set('max_age', 'two days');\n```\n\nSimilarly, the `headers` method is for setting custom response headers. \n\n**Underscores or spaces**\n\nUse spaces instead of underscores if you prefer:\n\n```js\nlactate.disable('max age');\nlactate.enable('watch files');\n```\n\n### Options available\n\n+ `root` **string**\n\nLocal directory from which to serve files. By default, the current working directory.\n\n+ `from` **string**\n\nPublic directory exposed to clients. If set, only requests from /*directory* will complete. Contrast this with the `root` option which is the location of files on the serving machine, not necessarily the requested path.\n\n+ `subdirs` **boolean**\n\nBy default subdirectories are served. To disable this, set `subdirs` to false.\n\n+ `hidden` **boolean**\n\nWhether or not to serve hidden files. Default is false.\n\n+ `error pages` **boolean**\n\nEnabled by default. When disabled, Lactate will not serve error pages for 404 resposes, etc..\n\n+ `autoindex` **boolean**\n\nAutomatically display directory indexes. Disabled by default.\n\n+ `cache` **boolean** or **object**\n\nKeep files in-memory. Enabled by default. For caching options and more information about caching strategy, see [Caching Options](https://github.com/Weltschmerz/Lactate#caching-options).\n\n+ `gzip` **boolean**\n\nIf false, disables automatic gzipping for text files (HTML, JS, CSS). Enabled by default.\n\n+ `minify` **boolean**\n\nIf true, will automatically minify JavaScript and CSS using [Abridge](https://github.com/Weltschmerz/Abridge). Disabled by default.\n\n+ `watch files` **boolean**\n\nDetermines whether Lactate will watch files to update its cache. If this is disabled, then your file cache will not update automatically as files are modified on the server.\n\n+ `headers` **object** or **function**\n\nSets custom response headers. If the option value is a function, it is a callback which is give (req, res) arguments. This function should return the header value; it is a mapping function.\n\n+ `max age` **number** or **string**\n\nPass this function a number (of seconds) or a string and appropriate headers will be set for client-side caching. Lactate comes with expiration defaults, such as 'two days' or '5 years and sixteen days' See [Expire](https://github.com/Weltschmerz/Expire) for details.\n\n```js\nlactate.set('max_age', 87500)\n//87500 seconds\nlactate.set('max_age', 'two days')\n//172800 seconds\nlactate.set'max_age', 'five weeks and one minute and ten seconds')\n//3024070 seconds\nlactate.set('max_age', 'one year and 2 months and seven weeks and 16 seconds')\n//41050028 seconds\n```\n\n+ `not found` **string** or **function**\n\nFor custom 404 handling. Functions are supplied the response for 100% custom response handling. Otherwise, if set to a string, this option will be treated as an ordinary file path and abide rules for gzipping / in-memory cache.\n\n+ `debug` **boolean**\n\nColored status / msg / path logging, for debugging purposes.\n\n###Caching options\n\nPass an object to the `cache` option setting. The following fields are accepted and optional:\n\n* `expire` Seconds expiration for cache keys. Keys expire after they are untouched for x-seconds. Default is `15min`.\n* `max keys` Maximum number of keys to keep in memory. Default is `1000`.\n* `max size` Maximum size in MB to keep in cache. Default is `100mb`.\n* `seg threshold` Determines the threshold after which to segment a file for streaming instead of traditional writing. Default is `200kb`.\n\n\n## License\n\nMIT License\n\nCopyright 2012 Brandon Wilson\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","_id":"lactate@0.11.13","dist":{"shasum":"43e29f6b0168c979904612cdaa45615554a834a3","tarball":"https://registry.npmjs.org/lactate/-/lactate-0.11.13.tgz","integrity":"sha512-K8tI10sLEFKsdppB9EBqtCO6FJFaCKtFhJN9Hi9JFmItD519cKzTBlqifb6QAtYP+rHEFW37n0EraokxF5Z+8Q==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBUnm36Fbg2nLVF6ayZofuL60ekOOEiq++0xnfAxqpYPAiEAxMrWveW6enJRGwqb8Hu6AXs/9m+l/+iAbz0b4LmyTQA="}]},"_npmVersion":"1.1.62","_npmUser":{"name":"Weltschmerz","email":"chlavois@gmail.com"},"maintainers":[{"name":"Weltschmerz","email":"chlavois@gmail.com"}],"directories":{}},"0.12.0":{"name":"lactate","version":"0.12.0","description":"Simple and featureful assets server","keywords":["static","file","server","assets","cache"],"repository":{"type":"git","url":"git://github.com/Weltschmerz/Lactate.git"},"author":{"name":"Weltschmerz","email":"chlavois@gmail.com"},"dependencies":{"mime":"1.2.7","suckle":"latest","expire":"latest","abridge":"latest","fraction":"latest","optimist":"0.3.5","redis":"0.8.1"},"devDependencies":{"mocha":"1.6.0","should":"1.2.0"},"main":"index.js","bin":{"lactate":"bin/lactate"},"scripts":{"test":"make test"},"engines":{"node":">= 0.6.0"},"readme":"# Lactate\n\n`npm install -g lactate`\n\nAn exceedingly fast static file handler, with a few electives.\n\n### Features\n\n* In-memory caching\n* Redis caching\n* Robust cache-control setting\n* Automatic gzipping\n* Automatic minification\n* Custom 404 pages\n* Custom response headers\n* Asset bundling and minification\n* Middleware export\n* Default error pages\n* on(status) listeners\n* Colored log output\n* Global executable\n* Directory indexing\n* Express.static API compatibility\n* node-static API compatibility\n\n## Using Lactate\n\n### Global executable\n\nIf installed globally with `npm install -g lactate`, you will have the `lactate` command at your disposal. This will run lactate static file server in the current working directory, utilizing the `cluster` module for multiple CPU cores. All [options](https://github.com/Weltschmerz/Lactate#options) are available.\n\n```code\n$ lactate --help\nUsage: lactate [options]\n\nOptions:\n--root, -r                    Local path                          [default: \"\"]\n--from, -f                    Public path                         [default: \"\"]\n--subdirs, -s                 Serve subdirectories                [default: true]\n--hidden, -h                  Serve hidden files                  [default: false]\n--error_pages, --error-pages  Serve error pages                   [default: true]\n--autoindex, -a               Automatically index directories     [default: true]\n--cache, -c                   Store assets in-memory              [default: true]\n--redis_cache, --rc           Store assets in-memory using Redis  [default: true]\n--watch_files, --watch-files  Watch files for cache update        [default: true]\n--max_age, --max-age, -M      Client-side caching max-age         [default: 172800]\n--gzip, -g                    Gzip text assets                    [default: true]\n--minify, -m                  Minify text assets                  [default: false]\n--bundle, -b                  Bundle text assets                  [default: false]\n--rebundle, --rb              Rebundle assets if modified         [default: true]\n--headers, -H                 Custom response headers             [default: \"\"]\n--debug, -d                   Log HTTP info                       [default: true]\n--quiet, -q                   Prevent all log output              [default: false]\n\n```\n\n### Programmatic lactating\n\nLactate can be used with either plain node, or with Express. With Express, Lactate is a drop-in replacement for `static` middleware, but with far more ability. The examples below use Express 2.x API for simplicity. See the [examples](https://github.com/Weltschmerz/Lactate/tree/master/example) for various examples.\n\n```js\nvar lactate = require('lactate');\nvar express = require('express');\n\nvar app = express.createServer();\napp.use(lactate.static(__dirname + '/files'));\n```\n\n## Testing Lactate\n\nIf installed locally (without -g flag to npm install):\n\n1. `cd` into `~/node_modules/lactate`\n2. `npm install ./` to install devDependencies\n3. `make test` to run mocha test\n\n##The varieties of Lactate experience\n\n###Creating a Lactate server\n\n```js\nvar lactate = require('lactate'); \nvar options = {root:'files'}; \nvar server = lactate.createServer(options); \n\nserver.listen(8080);\n```\n\n###Creating a directory handler\n\n```js\nvar lactate = require('lactate');\nvar options = {from:'public/path/to/files'};\nvar files = lactate.dir('files', options);\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', function(req, res) {\n  files.serve(req, res);\n});\n\nserver.listen(8080);\n```\n\n###Using directory middleware\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files', options);\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', files.toMiddleware());\nserver.listen(8080);\n```\n\n###Integrating with Express\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files', options);\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8080);\n```\n\n###Using Express.static API\n\n```js\nvar lactate = require('lactate');\nvar express = require('express');\nvar app = express();\n\napp.use(lactate.static(__dirname + '/files'));\napp.listen(8000);\n```\n\n###Using node-static API\n\n```js\nvar lactate = require('lactate');\nvar files = new(lactate.Server)('./files');\n\nvar http = require('http');\nvar server = new http.Server;\n\n// You could also pass a .toMiddleware()'d function\n\nserver.addListener('request', function(req, res) {\n  files.serve(req, res);\n});\n\nserver.listen(8000);\n```\n\n###Serving individual files\n\n```js\nvar lactate = require('lactate');\n\nvar fileOptions = {from:'public/directory'};\nvar files = lactate.dir('files', fileOptions);\n\nvar pageOptions = {};\nvar pages = lactate.dir('pages');\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', function(req, res) {\n  if (req.url === '/') {\n    pages.serve('index.html', req, res);\n  } else {\n    files.serve(req, res);\n  };\n});\n```\n\n###Setting options\n\n```js\nvar lactate = require('lactate');\n\nvar fileOptions = {\n  from:'public'\n};\n\nvar files = lactate.dir('files', fileOptions);\n\nfiles.set('cache', false);\nfiles.disable('gzip');\nfiles.maxAge('ten days');\n\nvar express = require('express');\nvar app = express():\n  \napp.get('/public/*', files.toMiddleware());\napp.listen(8080);\n```\n\n###Bundling assets\n\n```js\nvar lactate = require('lactate');\nvar options = {\n  from:'files'\n};\n\nvar files = lactate.dir('files', options);\n\n// Combine and minify all scripts to 'common.js'\nfiles.bundle('js', 'common.js', function(err, data) {\n// Handle errors\n});\n\n// Combine and minify all CSS to 'common.css'\nfiles.bundleCSS('common.css');\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8000);\n```\n\n###Using custom 404 pages\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files');\n\nfiles.notFound('path/to/404/page.html');\n\nfiles.notFound(function(req, res) {\n  res.writeHead(404);\n  res.end('Woops, 404');\n});\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8000);\n```\n\n###Using custom response headers\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files');\n\nfiles.setHeader('x-powered-by', 'Lactate');\nfiles.header('x-timestamp', function(req, res) {\n  return new Date().toUTCString();\n});\n\nvar headers = {};\nfiles.headers(headers);\n```\n\n###Status listeners\n\nLactate extends EventEmitter for emitting status code events. Codes Lactate is aware of are:\n\n* `200` *OK*\n* `304` *Not Modified*\n* `400` *Bad Request*\n* `403` *Forbidden*\n* `404` *Not Found*\n* `405` *Method Not Allowed*\n* `500` *Internal Error*\n\nCallbacks are given an object which has the following properties:\n\n* `url` The requested URL\n* `method` The request method (GET, HEAD)\n* `headers` Request headers\n* `address` Request IP address\n* `port` Request port\n* `path` Absolute file path to the requested file, if it exists\n* `msg` HTTP satus message\n\n```js\nvar files = lactate.dir('files', {});\nfiles.on('404', function(req) {\n  console.log('404', req.url);\n});\n```\n\n##Options\n\n### Setting options\n\nBoolean options may be set using `enable` and `disable` methods. Other options may be set using `set` method with either key/value or an options object.\n\n**Passing to initialization function**\n\n```js\nvar lactate = require('lactate').Lactate({\n  max_age:'two days'\n})\n```\n\n**Using `set` method**\n\n```js\nlactate.set('hidden', true)\n```\n\n**Using enable/disable:**\n\n```js\nlactate.disable('gzip');\nlactate.enable('minify');\n```\n\n**Special options methods**\n\nLactate has some special methods to reduce visual clutter:\n\n```js\nlactate.maxAge('two days');\n```\n\nis equivalent to:\n\n```js\nlactate.set('max_age', 'two days');\n```\n\nSimilarly, the `headers` method is for setting custom response headers. \n\n**Underscores or spaces**\n\nUse spaces instead of underscores if you prefer:\n\n```js\nlactate.disable('max age');\nlactate.enable('watch files');\n```\n\n### Options available\n\n+ `root` **string**\n\nLocal directory from which to serve files. By default, the current working directory.\n\n+ `from` **string**\n\nPublic directory exposed to clients. If set, only requests from /*directory* will complete. Contrast this with the `root` option which is the location of files on the serving machine, not necessarily the requested path.\n\n+ `subdirs` **boolean**\n\nBy default subdirectories are served. To disable this, set `subdirs` to false.\n\n+ `hidden` **boolean**\n\nWhether or not to serve hidden files. Default is false.\n\n+ `error pages` **boolean**\n\nEnabled by default. When disabled, Lactate will not serve error pages for 404 resposes, etc..\n\n+ `autoindex` **boolean**\n\nAutomatically display directory indexes. Disabled by default.\n\n+ `cache` **boolean** or **object**\n\nKeep files in-memory. Enabled by default. For caching options and more information about caching strategy, see [Caching Options](https://github.com/Weltschmerz/Lactate#caching-options).\n\n+ `gzip` **boolean**\n\nIf false, disables automatic gzipping for text files (HTML, JS, CSS). Enabled by default.\n\n+ `minify` **boolean**\n\nIf true, will automatically minify JavaScript and CSS using [Abridge](https://github.com/Weltschmerz/Abridge). Disabled by default.\n\n+ `watch files` **boolean**\n\nDetermines whether Lactate will watch files to update its cache. If this is disabled, then your file cache will not update automatically as files are modified on the server.\n\n+ `headers` **object** or **function**\n\nSets custom response headers. If the option value is a function, it is a callback which is give (req, res) arguments. This function should return the header value; it is a mapping function.\n\n+ `max age` **number** or **string**\n\nPass this function a number (of seconds) or a string and appropriate headers will be set for client-side caching. Lactate comes with expiration defaults, such as 'two days' or '5 years and sixteen days' See [Expire](https://github.com/Weltschmerz/Expire) for details.\n\n```js\nlactate.set('max_age', 87500)\n//87500 seconds\nlactate.set('max_age', 'two days')\n//172800 seconds\nlactate.set'max_age', 'five weeks and one minute and ten seconds')\n//3024070 seconds\nlactate.set('max_age', 'one year and 2 months and seven weeks and 16 seconds')\n//41050028 seconds\n```\n\n+ `not found` **string** or **function**\n\nFor custom 404 handling. Functions are supplied the response for 100% custom response handling. Otherwise, if set to a string, this option will be treated as an ordinary file path and abide rules for gzipping / in-memory cache.\n\n+ `debug` **boolean**\n\nColored status / msg / path logging, for debugging purposes.\n\n###Caching options\n\nPass an object to the `cache` option setting. The following fields are accepted and optional:\n\n* `expire` Seconds expiration for cache keys. Keys expire after they are untouched for x-seconds. Default is `15min`.\n* `max keys` Maximum number of keys to keep in memory. Default is `1000`.\n* `max size` Maximum size in MB to keep in cache. Default is `100mb`.\n* `seg threshold` Determines the threshold after which to segment a file for streaming instead of traditional writing. Default is `200kb`.\n\n\n## License\n\nMIT License\n\nCopyright 2012 Brandon Wilson\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","_id":"lactate@0.12.0","dist":{"shasum":"83ad704193aabc0b6686924360032c1fc2be9e8a","tarball":"https://registry.npmjs.org/lactate/-/lactate-0.12.0.tgz","integrity":"sha512-E4dMWpXg8nWgbqVPkEBEIrpPO0CN6mu16VvV3ykws69I3mlKowwJRHXGUBe2jPJ6cePqWss02ZjtHVavRL62cw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFXaHi/roZoJk2/P85I4wktZuSZYsKwcHnuboFxy3yPdAiEA2H8DWNdsP+1wEj4WQ6VRDMudRHD3pzxw6mw+B6UlnXk="}]},"_npmVersion":"1.1.62","_npmUser":{"name":"Weltschmerz","email":"chlavois@gmail.com"},"maintainers":[{"name":"Weltschmerz","email":"chlavois@gmail.com"}],"directories":{}},"0.12.1":{"name":"lactate","version":"0.12.1","description":"Simple and featureful assets server","keywords":["static","file","server","assets","cache"],"repository":{"type":"git","url":"git://github.com/Weltschmerz/Lactate.git"},"author":{"name":"Weltschmerz","email":"chlavois@gmail.com"},"dependencies":{"mime":"1.2.7","suckle":"latest","expire":"latest","abridge":"latest","fraction":"latest","optimist":"0.3.5","redis":"0.8.1"},"devDependencies":{"mocha":"1.6.0","should":"1.2.0"},"main":"index.js","bin":{"lactate":"bin/lactate"},"scripts":{"test":"make test"},"engines":{"node":">= 0.6.0"},"readme":"# Lactate\n\n`npm install -g lactate`\n\nAn exceedingly fast static file handler, with a few electives.\n\n### Features\n\n* In-memory caching\n* Redis caching\n* Robust cache-control setting\n* Automatic gzipping\n* Automatic minification\n* Custom 404 pages\n* Custom response headers\n* Asset bundling and minification\n* Middleware export\n* Default error pages\n* on(status) listeners\n* Colored log output\n* Global executable\n* Directory indexing\n* Express.static API compatibility\n* node-static API compatibility\n\n## Using Lactate\n\n### Global executable\n\nIf installed globally with `npm install -g lactate`, you will have the `lactate` command at your disposal. This will run lactate static file server in the current working directory, utilizing the `cluster` module for multiple CPU cores. All [options](https://github.com/Weltschmerz/Lactate#options) are available.\n\n```code\n$ lactate --help\nUsage: lactate [options]\n\nOptions:\n--root, -r                    Local path                          [default: \"\"]\n--from, -f                    Public path                         [default: \"\"]\n--subdirs, -s                 Serve subdirectories                [default: true]\n--hidden, -h                  Serve hidden files                  [default: false]\n--error_pages, --error-pages  Serve error pages                   [default: true]\n--autoindex, -a               Automatically index directories     [default: true]\n--cache, -c                   Store assets in-memory              [default: true]\n--redis_cache, --rc           Store assets in-memory using Redis  [default: true]\n--watch_files, --watch-files  Watch files for cache update        [default: true]\n--max_age, --max-age, -M      Client-side caching max-age         [default: 172800]\n--gzip, -g                    Gzip text assets                    [default: true]\n--minify, -m                  Minify text assets                  [default: false]\n--bundle, -b                  Bundle text assets                  [default: false]\n--rebundle, --rb              Rebundle assets if modified         [default: true]\n--headers, -H                 Custom response headers             [default: \"\"]\n--debug, -d                   Log HTTP info                       [default: true]\n--quiet, -q                   Prevent all log output              [default: false]\n\n```\n\n### Programmatic lactating\n\nLactate can be used with either plain node, or with Express. With Express, Lactate is a drop-in replacement for `static` middleware, but with far more ability. The examples below use Express 2.x API for simplicity. See the [examples](https://github.com/Weltschmerz/Lactate/tree/master/example) for various examples.\n\n```js\nvar lactate = require('lactate');\nvar express = require('express');\n\nvar app = express.createServer();\napp.use(lactate.static(__dirname + '/files'));\n```\n\n## Testing Lactate\n\nIf installed locally (without -g flag to npm install):\n\n1. `cd` into `~/node_modules/lactate`\n2. `npm install ./` to install devDependencies\n3. `make test` to run mocha test\n\n##The varieties of Lactate experience\n\n###Creating a Lactate server\n\n```js\nvar lactate = require('lactate'); \nvar options = {root:'files'}; \nvar server = lactate.createServer(options); \n\nserver.listen(8080);\n```\n\n###Creating a directory handler\n\n```js\nvar lactate = require('lactate');\nvar options = {from:'public/path/to/files'};\nvar files = lactate.dir('files', options);\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', function(req, res) {\n  files.serve(req, res);\n});\n\nserver.listen(8080);\n```\n\n###Using directory middleware\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files', options);\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', files.toMiddleware());\nserver.listen(8080);\n```\n\n###Integrating with Express\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files', options);\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8080);\n```\n\n###Using Express.static API\n\n```js\nvar lactate = require('lactate');\nvar express = require('express');\nvar app = express();\n\napp.use(lactate.static(__dirname + '/files'));\napp.listen(8000);\n```\n\n###Using node-static API\n\n```js\nvar lactate = require('lactate');\nvar files = new(lactate.Server)('./files');\n\nvar http = require('http');\nvar server = new http.Server;\n\n// You could also pass a .toMiddleware()'d function\n\nserver.addListener('request', function(req, res) {\n  files.serve(req, res);\n});\n\nserver.listen(8000);\n```\n\n###Serving individual files\n\n```js\nvar lactate = require('lactate');\n\nvar fileOptions = {from:'public/directory'};\nvar files = lactate.dir('files', fileOptions);\n\nvar pageOptions = {};\nvar pages = lactate.dir('pages');\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', function(req, res) {\n  if (req.url === '/') {\n    pages.serve('index.html', req, res);\n  } else {\n    files.serve(req, res);\n  };\n});\n```\n\n###Setting options\n\n```js\nvar lactate = require('lactate');\n\nvar fileOptions = {\n  from:'public'\n};\n\nvar files = lactate.dir('files', fileOptions);\n\nfiles.set('cache', false);\nfiles.disable('gzip');\nfiles.maxAge('ten days');\n\nvar express = require('express');\nvar app = express():\n  \napp.get('/public/*', files.toMiddleware());\napp.listen(8080);\n```\n\n###Bundling assets\n\n```js\nvar lactate = require('lactate');\nvar options = {\n  from:'files'\n};\n\nvar files = lactate.dir('files', options);\n\n// Combine and minify all scripts to 'common.js'\nfiles.bundle('js', 'common.js', function(err, data) {\n// Handle errors\n});\n\n// Combine and minify all CSS to 'common.css'\nfiles.bundleCSS('common.css');\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8000);\n```\n\n###Using custom 404 pages\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files');\n\nfiles.notFound('path/to/404/page.html');\n\nfiles.notFound(function(req, res) {\n  res.writeHead(404);\n  res.end('Woops, 404');\n});\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8000);\n```\n\n###Using custom response headers\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files');\n\nfiles.setHeader('x-powered-by', 'Lactate');\nfiles.header('x-timestamp', function(req, res) {\n  return new Date().toUTCString();\n});\n\nvar headers = {};\nfiles.headers(headers);\n```\n\n###Status listeners\n\nLactate extends EventEmitter for emitting status code events. Codes Lactate is aware of are:\n\n* `200` *OK*\n* `304` *Not Modified*\n* `400` *Bad Request*\n* `403` *Forbidden*\n* `404` *Not Found*\n* `405` *Method Not Allowed*\n* `500` *Internal Error*\n\nCallbacks are given an object which has the following properties:\n\n* `url` The requested URL\n* `method` The request method (GET, HEAD)\n* `headers` Request headers\n* `address` Request IP address\n* `port` Request port\n* `path` Absolute file path to the requested file, if it exists\n* `msg` HTTP satus message\n\n```js\nvar files = lactate.dir('files', {});\nfiles.on('404', function(req) {\n  console.log('404', req.url);\n});\n```\n\n##Options\n\n### Setting options\n\nBoolean options may be set using `enable` and `disable` methods. Other options may be set using `set` method with either key/value or an options object.\n\n**Passing to initialization function**\n\n```js\nvar lactate = require('lactate').Lactate({\n  max_age:'two days'\n})\n```\n\n**Using `set` method**\n\n```js\nlactate.set('hidden', true)\n```\n\n**Using enable/disable:**\n\n```js\nlactate.disable('gzip');\nlactate.enable('minify');\n```\n\n**Special options methods**\n\nLactate has some special methods to reduce visual clutter:\n\n```js\nlactate.maxAge('two days');\n```\n\nis equivalent to:\n\n```js\nlactate.set('max_age', 'two days');\n```\n\nSimilarly, the `headers` method is for setting custom response headers. \n\n**Underscores or spaces**\n\nUse spaces instead of underscores if you prefer:\n\n```js\nlactate.disable('max age');\nlactate.enable('watch files');\n```\n\n### Options available\n\n+ `root` **string**\n\nLocal directory from which to serve files. By default, the current working directory.\n\n+ `from` **string**\n\nPublic directory exposed to clients. If set, only requests from /*directory* will complete. Contrast this with the `root` option which is the location of files on the serving machine, not necessarily the requested path.\n\n+ `subdirs` **boolean**\n\nBy default subdirectories are served. To disable this, set `subdirs` to false.\n\n+ `hidden` **boolean**\n\nWhether or not to serve hidden files. Default is false.\n\n+ `error pages` **boolean**\n\nEnabled by default. When disabled, Lactate will not serve error pages for 404 resposes, etc..\n\n+ `autoindex` **boolean**\n\nAutomatically display directory indexes. Disabled by default.\n\n+ `cache` **boolean** or **object**\n\nKeep files in-memory. Enabled by default. For caching options and more information about caching strategy, see [Caching Options](https://github.com/Weltschmerz/Lactate#caching-options).\n\n+ `gzip` **boolean**\n\nIf false, disables automatic gzipping for text files (HTML, JS, CSS). Enabled by default.\n\n+ `minify` **boolean**\n\nIf true, will automatically minify JavaScript and CSS using [Abridge](https://github.com/Weltschmerz/Abridge). Disabled by default.\n\n+ `watch files` **boolean**\n\nDetermines whether Lactate will watch files to update its cache. If this is disabled, then your file cache will not update automatically as files are modified on the server.\n\n+ `headers` **object** or **function**\n\nSets custom response headers. If the option value is a function, it is a callback which is give (req, res) arguments. This function should return the header value; it is a mapping function.\n\n+ `max age` **number** or **string**\n\nPass this function a number (of seconds) or a string and appropriate headers will be set for client-side caching. Lactate comes with expiration defaults, such as 'two days' or '5 years and sixteen days' See [Expire](https://github.com/Weltschmerz/Expire) for details.\n\n```js\nlactate.set('max_age', 87500)\n//87500 seconds\nlactate.set('max_age', 'two days')\n//172800 seconds\nlactate.set'max_age', 'five weeks and one minute and ten seconds')\n//3024070 seconds\nlactate.set('max_age', 'one year and 2 months and seven weeks and 16 seconds')\n//41050028 seconds\n```\n\n+ `not found` **string** or **function**\n\nFor custom 404 handling. Functions are supplied the response for 100% custom response handling. Otherwise, if set to a string, this option will be treated as an ordinary file path and abide rules for gzipping / in-memory cache.\n\n+ `debug` **boolean**\n\nColored status / msg / path logging, for debugging purposes.\n\n###Caching options\n\nPass an object to the `cache` option setting. The following fields are accepted and optional:\n\n* `expire` Seconds expiration for cache keys. Keys expire after they are untouched for x-seconds. Default is `15min`.\n* `max keys` Maximum number of keys to keep in memory. Default is `Infinity`.\n* `max size` Maximum size in MB to keep in cache. Default is `100mb`.\n* `segment` Determines the threshold after which to segment a file for streaming instead of traditional writing. Default is `200kb`.\n\n```js\n  var options = {};\n  \n  options.cache = {\n    expire:5,\n    max_keys:200,\n    max_size:2,\n    segment:100\n  };\n\n  var files = lactate.static('files', options);\n\n  // Or use a string representation. Same as setting for max-age.\n  options.cache.expire = 'fifteen minutes';\n  files.set('cache', options.cache);\n```\n\n\n## License\n\nMIT\n\n","_id":"lactate@0.12.1","dist":{"shasum":"372de15bbad26c3f54ab061ccc683c5967274564","tarball":"https://registry.npmjs.org/lactate/-/lactate-0.12.1.tgz","integrity":"sha512-nqh9cF56PLJiCinhmVhG0XyZqxXuxlTUN13lO2lBUZgC45C+MmHv3Aeqv1B5q7M2tUK1V6JaKOmof/qDcil0Kw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIG+A2hzZm5j9ha7re+GAas+ryrNGjypnMYHBnGY+hGWVAiB6aM81N4lRyJzE9ekvPgczItd9G8In4uLTvB81ULdVKA=="}]},"_npmVersion":"1.1.62","_npmUser":{"name":"Weltschmerz","email":"chlavois@gmail.com"},"maintainers":[{"name":"Weltschmerz","email":"chlavois@gmail.com"}],"directories":{}},"0.12.2":{"name":"lactate","version":"0.12.2","description":"Simple and featureful assets server","keywords":["static","file","server","assets","cache"],"repository":{"type":"git","url":"git://github.com/Weltschmerz/Lactate.git"},"author":{"name":"Weltschmerz","email":"chlavois@gmail.com"},"dependencies":{"mime":"1.2.7","suckle":"latest","expire":"latest","abridge":"latest","fraction":"latest","optimist":"0.3.5","redis":"0.8.1"},"devDependencies":{"mocha":"1.6.0","should":"1.2.0"},"main":"index.js","bin":{"lactate":"bin/lactate"},"scripts":{"test":"make test"},"engines":{"node":">= 0.6.0"},"readme":"# Lactate\n\n`npm install -g lactate`\n\nAn exceedingly fast static file handler, with a few electives.\n\n### Features\n\n* In-memory caching\n* Redis caching\n* Robust cache-control setting\n* Automatic gzipping\n* Automatic minification\n* Custom 404 pages\n* Custom response headers\n* Asset bundling and minification\n* Middleware export\n* Default error pages\n* on(status) listeners\n* Colored log output\n* Global executable\n* Directory indexing\n* Express.static API compatibility\n* node-static API compatibility\n\n## Using Lactate\n\n### Global executable\n\nIf installed globally with `npm install -g lactate`, you will have the `lactate` command at your disposal. This will run lactate static file server in the current working directory, utilizing the `cluster` module for multiple CPU cores. All [options](https://github.com/Weltschmerz/Lactate#options) are available.\n\n```code\n$ lactate --help\nUsage: lactate [options]\n\nOptions:\n--root, -r                    Local path                          [default: \"\"]\n--from, -f                    Public path                         [default: \"\"]\n--subdirs, -s                 Serve subdirectories                [default: true]\n--hidden, -h                  Serve hidden files                  [default: false]\n--error_pages, --error-pages  Serve error pages                   [default: true]\n--autoindex, -a               Automatically index directories     [default: true]\n--cache, -c                   Store assets in-memory              [default: true]\n--redis_cache, --rc           Store assets in-memory using Redis  [default: true]\n--watch_files, --watch-files  Watch files for cache update        [default: true]\n--max_age, --max-age, -M      Client-side caching max-age         [default: 172800]\n--gzip, -g                    Gzip text assets                    [default: true]\n--minify, -m                  Minify text assets                  [default: false]\n--bundle, -b                  Bundle text assets                  [default: false]\n--rebundle, --rb              Rebundle assets if modified         [default: true]\n--headers, -H                 Custom response headers             [default: \"\"]\n--debug, -d                   Log HTTP info                       [default: true]\n--quiet, -q                   Prevent all log output              [default: false]\n\n```\n\n### Programmatic lactating\n\nLactate can be used with either plain node, or with Express. With Express, Lactate is a drop-in replacement for `static` middleware, but with far more ability. The examples below use Express 2.x API for simplicity. See the [examples](https://github.com/Weltschmerz/Lactate/tree/master/example) for various examples.\n\n```js\nvar lactate = require('lactate');\nvar express = require('express');\n\nvar app = express.createServer();\napp.use(lactate.static(__dirname + '/files'));\n```\n\n## Testing Lactate\n\nIf installed locally (without -g flag to npm install):\n\n1. `cd` into `~/node_modules/lactate`\n2. `npm install ./` to install devDependencies\n3. `make test` to run mocha test\n\n##The varieties of Lactate experience\n\n###Creating a Lactate server\n\n```js\nvar lactate = require('lactate'); \nvar options = {root:'files'}; \nvar server = lactate.createServer(options); \n\nserver.listen(8080);\n```\n\n###Creating a directory handler\n\n```js\nvar lactate = require('lactate');\nvar options = {from:'public/path/to/files'};\nvar files = lactate.dir('files', options);\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', function(req, res) {\n  files.serve(req, res);\n});\n\nserver.listen(8080);\n```\n\n###Using directory middleware\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files', options);\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', files.toMiddleware());\nserver.listen(8080);\n```\n\n###Integrating with Express\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files', options);\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8080);\n```\n\n###Using Express.static API\n\n```js\nvar lactate = require('lactate');\nvar express = require('express');\nvar app = express();\n\napp.use(lactate.static(__dirname + '/files'));\napp.listen(8000);\n```\n\n###Using node-static API\n\n```js\nvar lactate = require('lactate');\nvar files = new(lactate.Server)('./files');\n\nvar http = require('http');\nvar server = new http.Server;\n\n// You could also pass a .toMiddleware()'d function\n\nserver.addListener('request', function(req, res) {\n  files.serve(req, res);\n});\n\nserver.listen(8000);\n```\n\n###Serving individual files\n\n```js\nvar lactate = require('lactate');\n\nvar fileOptions = {from:'public/directory'};\nvar files = lactate.dir('files', fileOptions);\n\nvar pageOptions = {};\nvar pages = lactate.dir('pages');\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', function(req, res) {\n  if (req.url === '/') {\n    pages.serve('index.html', req, res);\n  } else {\n    files.serve(req, res);\n  };\n});\n```\n\n###Setting options\n\n```js\nvar lactate = require('lactate');\n\nvar fileOptions = {\n  from:'public'\n};\n\nvar files = lactate.dir('files', fileOptions);\n\nfiles.set('cache', false);\nfiles.disable('gzip');\nfiles.maxAge('ten days');\n\nvar express = require('express');\nvar app = express():\n  \napp.get('/public/*', files.toMiddleware());\napp.listen(8080);\n```\n\n###Bundling assets\n\n```js\nvar lactate = require('lactate');\nvar options = {\n  from:'files'\n};\n\nvar files = lactate.dir('files', options);\n\n// Combine and minify all scripts to 'common.js'\nfiles.bundle('js', 'common.js', function(err, data) {\n// Handle errors\n});\n\n// Combine and minify all CSS to 'common.css'\nfiles.bundleCSS('common.css');\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8000);\n```\n\n###Using custom 404 pages\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files');\n\nfiles.notFound('path/to/404/page.html');\n\nfiles.notFound(function(req, res) {\n  res.writeHead(404);\n  res.end('Woops, 404');\n});\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8000);\n```\n\n###Using custom response headers\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files');\n\nfiles.setHeader('x-powered-by', 'Lactate');\nfiles.header('x-timestamp', function(req, res) {\n  return new Date().toUTCString();\n});\n\nvar headers = {};\nfiles.headers(headers);\n```\n\n###Status listeners\n\nLactate extends EventEmitter for emitting status code events. Codes Lactate is aware of are:\n\n* `200` *OK*\n* `304` *Not Modified*\n* `400` *Bad Request*\n* `403` *Forbidden*\n* `404` *Not Found*\n* `405` *Method Not Allowed*\n* `500` *Internal Error*\n\nCallbacks are given an object which has the following properties:\n\n* `url` The requested URL\n* `method` The request method (GET, HEAD)\n* `headers` Request headers\n* `address` Request IP address\n* `port` Request port\n* `path` Absolute file path to the requested file, if it exists\n* `msg` HTTP satus message\n\n```js\nvar files = lactate.dir('files', {});\nfiles.on('404', function(req) {\n  console.log('404', req.url);\n});\n```\n\n##Options\n\n### Setting options\n\nBoolean options may be set using `enable` and `disable` methods. Other options may be set using `set` method with either key/value or an options object.\n\n**Passing to initialization function**\n\n```js\nvar lactate = require('lactate').Lactate({\n  max_age:'two days'\n})\n```\n\n**Using `set` method**\n\n```js\nlactate.set('hidden', true)\n```\n\n**Using enable/disable:**\n\n```js\nlactate.disable('gzip');\nlactate.enable('minify');\n```\n\n**Special options methods**\n\nLactate has some special methods to reduce visual clutter:\n\n```js\nlactate.maxAge('two days');\n```\n\nis equivalent to:\n\n```js\nlactate.set('max_age', 'two days');\n```\n\nSimilarly, the `headers` method is for setting custom response headers. \n\n**Underscores or spaces**\n\nUse spaces instead of underscores if you prefer:\n\n```js\nlactate.disable('max age');\nlactate.enable('watch files');\n```\n\n### Options available\n\n+ `root` **string**\n\nLocal directory from which to serve files. By default, the current working directory.\n\n+ `from` **string**\n\nPublic directory exposed to clients. If set, only requests from /*directory* will complete. Contrast this with the `root` option which is the location of files on the serving machine, not necessarily the requested path.\n\n+ `subdirs` **boolean**\n\nBy default subdirectories are served. To disable this, set `subdirs` to false.\n\n+ `hidden` **boolean**\n\nWhether or not to serve hidden files. Default is false.\n\n+ `error pages` **boolean**\n\nEnabled by default. When disabled, Lactate will not serve error pages for 404 resposes, etc..\n\n+ `autoindex` **boolean**\n\nAutomatically display directory indexes. Disabled by default.\n\n+ `cache` **boolean** or **object**\n\nKeep files in-memory. Enabled by default. For caching options and more information about caching strategy, see [Caching Options](https://github.com/Weltschmerz/Lactate#caching-options).\n\n+ `gzip` **boolean**\n\nIf false, disables automatic gzipping for text files (HTML, JS, CSS). Enabled by default.\n\n+ `minify` **boolean**\n\nIf true, will automatically minify JavaScript and CSS using [Abridge](https://github.com/Weltschmerz/Abridge). Disabled by default.\n\n+ `watch files` **boolean**\n\nDetermines whether Lactate will watch files to update its cache. If this is disabled, then your file cache will not update automatically as files are modified on the server.\n\n+ `headers` **object** or **function**\n\nSets custom response headers. If the option value is a function, it is a callback which is give (req, res) arguments. This function should return the header value; it is a mapping function.\n\n+ `max age` **number** or **string**\n\nPass this function a number (of seconds) or a string and appropriate headers will be set for client-side caching. Lactate comes with expiration defaults, such as 'two days' or '5 years and sixteen days' See [Expire](https://github.com/Weltschmerz/Expire) for details.\n\n```js\nlactate.set('max_age', 87500)\n//87500 seconds\nlactate.set('max_age', 'two days')\n//172800 seconds\nlactate.set'max_age', 'five weeks and one minute and ten seconds')\n//3024070 seconds\nlactate.set('max_age', 'one year and 2 months and seven weeks and 16 seconds')\n//41050028 seconds\n```\n\n+ `not found` **string** or **function**\n\nFor custom 404 handling. Functions are supplied the response for 100% custom response handling. Otherwise, if set to a string, this option will be treated as an ordinary file path and abide rules for gzipping / in-memory cache.\n\n+ `debug` **boolean**\n\nColored status / msg / path logging, for debugging purposes.\n\n###Caching options\n\nPass an object to the `cache` option setting. The following fields are accepted and optional:\n\n* `expire` Seconds expiration for cache keys. Keys expire after they are untouched for x-seconds. Default is `15min`.\n* `max keys` Maximum number of keys to keep in memory. Default is `Infinity`.\n* `max size` Maximum size in MB to keep in cache. Default is `100mb`.\n* `segment` Determines the threshold after which to segment a file for streaming instead of traditional writing. Default is `200kb`.\n\n```js\n  var options = {};\n  \n  options.cache = {\n    expire:5,\n    max_keys:200,\n    max_size:2,\n    segment:100\n  };\n\n  var files = lactate.static('files', options);\n\n  // Or use a string representation. Same as setting for max-age.\n  options.cache.expire = 'fifteen minutes';\n  files.set('cache', options.cache);\n```\n\n\n## License\n\nMIT\n\n","_id":"lactate@0.12.2","dist":{"shasum":"0812dba69eb9ab5b6fcc1f0b6d40018fcaa0f1e7","tarball":"https://registry.npmjs.org/lactate/-/lactate-0.12.2.tgz","integrity":"sha512-RUpu8zU8oaupkbvD1wLF2e4+3Pvh1WKfiEcl/T7heSZc2SHf7TwphR/xssxe2MdT9qynNcylIpei1lzyh7esjw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFR/XvZ1/910GacNdRrn0+jcOMbi0eMmjXmYMkl3e7nbAiAybGjDfmwa4kOE0udXUw+2f8ojYBvxoQE/PFKSfJPjMA=="}]},"_npmVersion":"1.1.62","_npmUser":{"name":"Weltschmerz","email":"chlavois@gmail.com"},"maintainers":[{"name":"Weltschmerz","email":"chlavois@gmail.com"}],"directories":{}},"0.12.3":{"name":"lactate","version":"0.12.3","description":"Simple and featureful assets server","keywords":["static","file","server","assets","cache"],"repository":{"type":"git","url":"git://github.com/Weltschmerz/Lactate.git"},"author":{"name":"Weltschmerz","email":"chlavois@gmail.com"},"dependencies":{"mime":"1.2.7","suckle":"latest","expire":"latest","abridge":"latest","fraction":"latest","optimist":"0.3.5","redis":"0.8.1"},"devDependencies":{"mocha":"1.7.0","should":"1.2.1"},"main":"index.js","bin":{"lactate":"bin/lactate"},"scripts":{"test":"make test"},"engines":{"node":">= 0.6.0"},"readme":"# Lactate\n\n`npm install -g lactate`\n\nAn exceedingly fast static file handler, with a few electives.\n\n### Features\n\n* In-memory caching\n* Redis caching\n* Robust cache-control setting\n* Automatic gzipping\n* Automatic minification\n* Custom 404 pages\n* Custom response headers\n* Asset bundling and minification\n* Middleware export\n* Default error pages\n* on(status) listeners\n* Colored log output\n* Global executable\n* Directory indexing\n* Express.static API compatibility\n* node-static API compatibility\n\n## Using Lactate\n\n### Global executable\n\nIf installed globally with `npm install -g lactate`, you will have the `lactate` command at your disposal. This will run lactate static file server in the current working directory, utilizing the `cluster` module for multiple CPU cores. All [options](https://github.com/Weltschmerz/Lactate#options) are available.\n\n```code\n$ lactate --help\nUsage: lactate [options]\n\nOptions:\n--root, -r                    Local path                          [default: \"\"]\n--from, -f                    Public path                         [default: \"\"]\n--subdirs, -s                 Serve subdirectories                [default: true]\n--hidden, -h                  Serve hidden files                  [default: false]\n--error_pages, --error-pages  Serve error pages                   [default: true]\n--autoindex, -a               Automatically index directories     [default: true]\n--cache, -c                   Store assets in-memory              [default: true]\n--redis_cache, --rc           Store assets in-memory using Redis  [default: true]\n--watch_files, --watch-files  Watch files for cache update        [default: true]\n--max_age, --max-age, -M      Client-side caching max-age         [default: 172800]\n--gzip, -g                    Gzip text assets                    [default: true]\n--minify, -m                  Minify text assets                  [default: false]\n--bundle, -b                  Bundle text assets                  [default: false]\n--rebundle, --rb              Rebundle assets if modified         [default: true]\n--headers, -H                 Custom response headers             [default: \"\"]\n--debug, -d                   Log HTTP info                       [default: true]\n--quiet, -q                   Prevent all log output              [default: false]\n\n```\n\n### Programmatic lactating\n\nLactate can be used with either plain node, or with Express. With Express, Lactate is a drop-in replacement for `static` middleware, but with far more ability. The examples below use Express 2.x API for simplicity. See the [examples](https://github.com/Weltschmerz/Lactate/tree/master/example) for various examples.\n\n```js\nvar lactate = require('lactate');\nvar express = require('express');\n\nvar app = express.createServer();\napp.use(lactate.static(__dirname + '/files'));\n```\n\n## Testing Lactate\n\nIf installed locally (without -g flag to npm install):\n\n1. `cd` into `~/node_modules/lactate`\n2. `npm install ./` to install devDependencies\n3. `make test` to run mocha test\n\n##The varieties of Lactate experience\n\n###Creating a Lactate server\n\n```js\nvar lactate = require('lactate'); \nvar options = {root:'files'}; \nvar server = lactate.createServer(options); \n\nserver.listen(8080);\n```\n\n###Creating a directory handler\n\n```js\nvar lactate = require('lactate');\nvar options = {from:'public/path/to/files'};\nvar files = lactate.dir('files', options);\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', function(req, res) {\n  files.serve(req, res);\n});\n\nserver.listen(8080);\n```\n\n###Using directory middleware\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files', options);\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', files.toMiddleware());\nserver.listen(8080);\n```\n\n###Integrating with Express\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files', options);\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8080);\n```\n\n###Using Express.static API\n\n```js\nvar lactate = require('lactate');\nvar express = require('express');\nvar app = express();\n\napp.use(lactate.static(__dirname + '/files'));\napp.listen(8000);\n```\n\n###Using node-static API\n\n```js\nvar lactate = require('lactate');\nvar files = new(lactate.Server)('./files');\n\nvar http = require('http');\nvar server = new http.Server;\n\n// You could also pass a .toMiddleware()'d function\n\nserver.addListener('request', function(req, res) {\n  files.serve(req, res);\n});\n\nserver.listen(8000);\n```\n\n###Serving individual files\n\n```js\nvar lactate = require('lactate');\n\nvar fileOptions = {from:'public/directory'};\nvar files = lactate.dir('files', fileOptions);\n\nvar pageOptions = {};\nvar pages = lactate.dir('pages');\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', function(req, res) {\n  if (req.url === '/') {\n    pages.serve('index.html', req, res);\n  } else {\n    files.serve(req, res);\n  };\n});\n```\n\n###Setting options\n\n```js\nvar lactate = require('lactate');\n\nvar fileOptions = {\n  from:'public'\n};\n\nvar files = lactate.dir('files', fileOptions);\n\nfiles.set('cache', false);\nfiles.disable('gzip');\nfiles.maxAge('ten days');\n\nvar express = require('express');\nvar app = express():\n  \napp.get('/public/*', files.toMiddleware());\napp.listen(8080);\n```\n\n###Bundling assets\n\n```js\nvar lactate = require('lactate');\nvar options = {\n  from:'files'\n};\n\nvar files = lactate.dir('files', options);\n\n// Combine and minify all scripts to 'common.js'\nfiles.bundle('js', 'common.js', function(err, data) {\n// Handle errors\n});\n\n// Combine and minify all CSS to 'common.css'\nfiles.bundleCSS('common.css');\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8000);\n```\n\n###Using custom 404 pages\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files');\n\nfiles.notFound('path/to/404/page.html');\n\nfiles.notFound(function(req, res) {\n  res.writeHead(404);\n  res.end('Woops, 404');\n});\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8000);\n```\n\n###Using custom response headers\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files');\n\nfiles.setHeader('x-powered-by', 'Lactate');\nfiles.header('x-timestamp', function(req, res) {\n  return new Date().toUTCString();\n});\n\nvar headers = {};\nfiles.headers(headers);\n```\n\n###Status listeners\n\nLactate extends EventEmitter for emitting status code events. Codes Lactate is aware of are:\n\n* `200` *OK*\n* `304` *Not Modified*\n* `400` *Bad Request*\n* `403` *Forbidden*\n* `404` *Not Found*\n* `405` *Method Not Allowed*\n* `500` *Internal Error*\n\nCallbacks are given an object which has the following properties:\n\n* `url` The requested URL\n* `method` The request method (GET, HEAD)\n* `headers` Request headers\n* `address` Request IP address\n* `port` Request port\n* `path` Absolute file path to the requested file, if it exists\n* `msg` HTTP satus message\n\n```js\nvar files = lactate.dir('files', {});\nfiles.on('404', function(req) {\n  console.log('404', req.url);\n});\n```\n\n##Options\n\n### Setting options\n\nBoolean options may be set using `enable` and `disable` methods. Other options may be set using `set` method with either key/value or an options object.\n\n**Passing to initialization function**\n\n```js\nvar lactate = require('lactate').Lactate({\n  max_age:'two days'\n})\n```\n\n**Using `set` method**\n\n```js\nlactate.set('hidden', true)\n```\n\n**Using enable/disable:**\n\n```js\nlactate.disable('gzip');\nlactate.enable('minify');\n```\n\n**Special options methods**\n\nLactate has some special methods to reduce visual clutter:\n\n```js\nlactate.maxAge('two days');\n```\n\nis equivalent to:\n\n```js\nlactate.set('max_age', 'two days');\n```\n\nSimilarly, the `headers` method is for setting custom response headers. \n\n**Underscores or spaces**\n\nUse spaces instead of underscores if you prefer:\n\n```js\nlactate.disable('max age');\nlactate.enable('watch files');\n```\n\n### Options available\n\n+ `root` **string**\n\nLocal directory from which to serve files. By default, the current working directory.\n\n+ `from` **string**\n\nPublic directory exposed to clients. If set, only requests from /*directory* will complete. Contrast this with the `root` option which is the location of files on the serving machine, not necessarily the requested path.\n\n+ `subdirs` **boolean**\n\nBy default subdirectories are served. To disable this, set `subdirs` to false.\n\n+ `hidden` **boolean**\n\nWhether or not to serve hidden files. Default is false.\n\n+ `error pages` **boolean**\n\nEnabled by default. When disabled, Lactate will not serve error pages for 404 resposes, etc..\n\n+ `autoindex` **boolean**\n\nAutomatically display directory indexes. Disabled by default.\n\n+ `cache` **boolean** or **object**\n\nKeep files in-memory. Enabled by default. For caching options and more information about caching strategy, see [Caching Options](https://github.com/Weltschmerz/Lactate#caching-options).\n\n+ `gzip` **boolean**\n\nIf false, disables automatic gzipping for text files (HTML, JS, CSS). Enabled by default.\n\n+ `minify` **boolean**\n\nIf true, will automatically minify JavaScript and CSS using [Abridge](https://github.com/Weltschmerz/Abridge). Disabled by default.\n\n+ `watch files` **boolean**\n\nDetermines whether Lactate will watch files to update its cache. If this is disabled, then your file cache will not update automatically as files are modified on the server.\n\n+ `headers` **object** or **function**\n\nSets custom response headers. If the option value is a function, it is a callback which is give (req, res) arguments. This function should return the header value; it is a mapping function.\n\n+ `max age` **number** or **string**\n\nPass this function a number (of seconds) or a string and appropriate headers will be set for client-side caching. Lactate comes with expiration defaults, such as 'two days' or '5 years and sixteen days' See [Expire](https://github.com/Weltschmerz/Expire) for details.\n\n```js\nlactate.set('max_age', 87500)\n//87500 seconds\nlactate.set('max_age', 'two days')\n//172800 seconds\nlactate.set'max_age', 'five weeks and one minute and ten seconds')\n//3024070 seconds\nlactate.set('max_age', 'one year and 2 months and seven weeks and 16 seconds')\n//41050028 seconds\n```\n\n+ `not found` **string** or **function**\n\nFor custom 404 handling. Functions are supplied the response for 100% custom response handling. Otherwise, if set to a string, this option will be treated as an ordinary file path and abide rules for gzipping / in-memory cache.\n\n+ `debug` **boolean**\n\nColored status / msg / path logging, for debugging purposes.\n\n###Caching options\n\nPass an object to the `cache` option setting. The following fields are accepted and optional:\n\n* `expire` Seconds expiration for cache keys. Keys expire after they are untouched for x-seconds. Default is `15min`.\n* `max keys` Maximum number of keys to keep in memory. Default is `Infinity`.\n* `max size` Maximum size in MB to keep in cache. Default is `100mb`.\n* `segment` Determines the threshold after which to segment a file for streaming instead of traditional writing. Default is `200kb`.\n\n```js\n  var options = {};\n  \n  options.cache = {\n    expire:5,\n    max_keys:200,\n    max_size:2,\n    segment:100\n  };\n\n  var files = lactate.static('files', options);\n\n  // Or use a string representation. Same as setting for max-age.\n  options.cache.expire = 'fifteen minutes';\n  files.set('cache', options.cache);\n```\n\n\n## License\n\nMIT\n\n","_id":"lactate@0.12.3","dist":{"shasum":"5d61fecd08f55e8396bed50cb1677eb14939b12c","tarball":"https://registry.npmjs.org/lactate/-/lactate-0.12.3.tgz","integrity":"sha512-nJDGejRb3cX3FeOfeREd6Nvt+lAPzK7i7DTRUOzyUoj3T9e8Q77UGqBloOXsLfj2ojgfZT+00Sq4Q0Ob5D1xBA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGYm/6Yu6y8H0F3NGXqteH8Orm7w3GHabEz7n25S4zUPAiACs86qVTPQGKoVBOprBjWuwnJafL9h+ld6OcRsqnp/jA=="}]},"_npmVersion":"1.1.62","_npmUser":{"name":"Weltschmerz","email":"chlavois@gmail.com"},"maintainers":[{"name":"Weltschmerz","email":"chlavois@gmail.com"}],"directories":{}},"0.12.4":{"name":"lactate","version":"0.12.4","description":"Simple and featureful assets server","keywords":["static","file","server","assets","cache"],"repository":{"type":"git","url":"git://github.com/Weltschmerz/Lactate.git"},"author":{"name":"Weltschmerz","email":"chlavois@gmail.com"},"dependencies":{"mime":"1.2.7","suckle":"latest","expire":"latest","abridge":"latest","fraction":"latest","optimist":"0.3.5","redis":"0.8.1"},"devDependencies":{"mocha":"1.7.0","should":"1.2.1"},"main":"index.js","bin":{"lactate":"bin/lactate"},"scripts":{"test":"make test"},"engines":{"node":">= 0.6.0"},"readme":"# Lactate\n\n`npm install -g lactate`\n\nAn exceedingly fast static file handler, with a few electives.\n\n### Features\n\n* In-memory caching\n* Redis caching\n* Robust cache-control setting\n* Automatic gzipping\n* Automatic minification\n* Custom 404 pages\n* Custom response headers\n* Asset bundling and minification\n* Middleware export\n* Default error pages\n* on(status) listeners\n* Colored log output\n* Global executable\n* Directory indexing\n* Express.static API compatibility\n* node-static API compatibility\n\n## Using Lactate\n\n### Global executable\n\nIf installed globally with `npm install -g lactate`, you will have the `lactate` command at your disposal. This will run lactate static file server in the current working directory, utilizing the `cluster` module for multiple CPU cores. All [options](https://github.com/Weltschmerz/Lactate#options) are available.\n\n```code\n$ lactate --help\nUsage: lactate [options]\n\nOptions:\n--root, -r                    Local path                          [default: \"\"]\n--from, -f                    Public path                         [default: \"\"]\n--subdirs, -s                 Serve subdirectories                [default: true]\n--hidden, -h                  Serve hidden files                  [default: false]\n--error_pages, --error-pages  Serve error pages                   [default: true]\n--autoindex, -a               Automatically index directories     [default: true]\n--cache, -c                   Store assets in-memory              [default: true]\n--redis_cache, --rc           Store assets in-memory using Redis  [default: true]\n--watch_files, --watch-files  Watch files for cache update        [default: true]\n--max_age, --max-age, -M      Client-side caching max-age         [default: 172800]\n--gzip, -g                    Gzip text assets                    [default: true]\n--minify, -m                  Minify text assets                  [default: false]\n--bundle, -b                  Bundle text assets                  [default: false]\n--rebundle, --rb              Rebundle assets if modified         [default: true]\n--headers, -H                 Custom response headers             [default: \"\"]\n--debug, -d                   Log HTTP info                       [default: true]\n--quiet, -q                   Prevent all log output              [default: false]\n\n```\n\n### Programmatic lactating\n\nLactate can be used with either plain node, or with Express. With Express, Lactate is a drop-in replacement for `static` middleware, but with far more ability. The examples below use Express 2.x API for simplicity. See the [examples](https://github.com/Weltschmerz/Lactate/tree/master/example) for various examples.\n\n```js\nvar lactate = require('lactate');\nvar express = require('express');\n\nvar app = express.createServer();\napp.use(lactate.static(__dirname + '/files'));\n```\n\n## Testing Lactate\n\nIf installed locally (without -g flag to npm install):\n\n1. `cd` into `~/node_modules/lactate`\n2. `npm install ./` to install devDependencies\n3. `make test` to run mocha test\n\n##The varieties of Lactate experience\n\n###Creating a Lactate server\n\n```js\nvar lactate = require('lactate'); \nvar options = {root:'files'}; \nvar server = lactate.createServer(options); \n\nserver.listen(8080);\n```\n\n###Creating a directory handler\n\n```js\nvar lactate = require('lactate');\nvar options = {from:'public/path/to/files'};\nvar files = lactate.dir('files', options);\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', function(req, res) {\n  files.serve(req, res);\n});\n\nserver.listen(8080);\n```\n\n###Using directory middleware\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files', options);\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', files.toMiddleware());\nserver.listen(8080);\n```\n\n###Integrating with Express\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files', options);\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8080);\n```\n\n###Using Express.static API\n\n```js\nvar lactate = require('lactate');\nvar express = require('express');\nvar app = express();\n\napp.use(lactate.static(__dirname + '/files'));\napp.listen(8000);\n```\n\n###Using node-static API\n\n```js\nvar lactate = require('lactate');\nvar files = new(lactate.Server)('./files');\n\nvar http = require('http');\nvar server = new http.Server;\n\n// You could also pass a .toMiddleware()'d function\n\nserver.addListener('request', function(req, res) {\n  files.serve(req, res);\n});\n\nserver.listen(8000);\n```\n\n###Serving individual files\n\n```js\nvar lactate = require('lactate');\n\nvar fileOptions = {from:'public/directory'};\nvar files = lactate.dir('files', fileOptions);\n\nvar pageOptions = {};\nvar pages = lactate.dir('pages');\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', function(req, res) {\n  if (req.url === '/') {\n    pages.serve('index.html', req, res);\n  } else {\n    files.serve(req, res);\n  };\n});\n```\n\n###Setting options\n\n```js\nvar lactate = require('lactate');\n\nvar fileOptions = {\n  from:'public'\n};\n\nvar files = lactate.dir('files', fileOptions);\n\nfiles.set('cache', false);\nfiles.disable('gzip');\nfiles.maxAge('ten days');\n\nvar express = require('express');\nvar app = express():\n  \napp.get('/public/*', files.toMiddleware());\napp.listen(8080);\n```\n\n###Bundling assets\n\n```js\nvar lactate = require('lactate');\nvar options = {\n  from:'files'\n};\n\nvar files = lactate.dir('files', options);\n\n// Combine and minify all scripts to 'common.js'\nfiles.bundle('js', 'common.js', function(err, data) {\n// Handle errors\n});\n\n// Combine and minify all CSS to 'common.css'\nfiles.bundleCSS('common.css');\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8000);\n```\n\n###Using custom 404 pages\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files');\n\nfiles.notFound('path/to/404/page.html');\n\nfiles.notFound(function(req, res) {\n  res.writeHead(404);\n  res.end('Woops, 404');\n});\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8000);\n```\n\n###Using custom response headers\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files');\n\nfiles.setHeader('x-powered-by', 'Lactate');\nfiles.header('x-timestamp', function(req, res) {\n  return new Date().toUTCString();\n});\n\nvar headers = {};\nfiles.headers(headers);\n```\n\n###Status listeners\n\nLactate extends EventEmitter for emitting status code events. Codes Lactate is aware of are:\n\n* `200` *OK*\n* `304` *Not Modified*\n* `400` *Bad Request*\n* `403` *Forbidden*\n* `404` *Not Found*\n* `405` *Method Not Allowed*\n* `500` *Internal Error*\n\nCallbacks are given an object which has the following properties:\n\n* `url` The requested URL\n* `method` The request method (GET, HEAD)\n* `headers` Request headers\n* `address` Request IP address\n* `port` Request port\n* `path` Absolute file path to the requested file, if it exists\n* `msg` HTTP satus message\n\n```js\nvar files = lactate.dir('files', {});\nfiles.on('404', function(req) {\n  console.log('404', req.url);\n});\n```\n\n##Options\n\n### Setting options\n\nBoolean options may be set using `enable` and `disable` methods. Other options may be set using `set` method with either key/value or an options object.\n\n**Passing to initialization function**\n\n```js\nvar lactate = require('lactate').Lactate({\n  max_age:'two days'\n})\n```\n\n**Using `set` method**\n\n```js\nlactate.set('hidden', true)\n```\n\n**Using enable/disable:**\n\n```js\nlactate.disable('gzip');\nlactate.enable('minify');\n```\n\n**Special options methods**\n\nLactate has some special methods to reduce visual clutter:\n\n```js\nlactate.maxAge('two days');\n```\n\nis equivalent to:\n\n```js\nlactate.set('max_age', 'two days');\n```\n\nSimilarly, the `headers` method is for setting custom response headers. \n\n**Underscores or spaces**\n\nUse spaces instead of underscores if you prefer:\n\n```js\nlactate.disable('max age');\nlactate.enable('watch files');\n```\n\n### Options available\n\n+ `root` **string**\n\nLocal directory from which to serve files. By default, the current working directory.\n\n+ `from` **string**\n\nPublic directory exposed to clients. If set, only requests from /*directory* will complete. Contrast this with the `root` option which is the location of files on the serving machine, not necessarily the requested path.\n\n+ `subdirs` **boolean**\n\nBy default subdirectories are served. To disable this, set `subdirs` to false.\n\n+ `hidden` **boolean**\n\nWhether or not to serve hidden files. Default is false.\n\n+ `error pages` **boolean**\n\nEnabled by default. When disabled, Lactate will not serve error pages for 404 resposes, etc..\n\n+ `autoindex` **boolean**\n\nAutomatically display directory indexes. Disabled by default.\n\n+ `cache` **boolean** or **object**\n\nKeep files in-memory. Enabled by default. For caching options and more information about caching strategy, see [Caching Options](https://github.com/Weltschmerz/Lactate#caching-options).\n\n+ `gzip` **boolean**\n\nIf false, disables automatic gzipping for text files (HTML, JS, CSS). Enabled by default.\n\n+ `minify` **boolean**\n\nIf true, will automatically minify JavaScript and CSS using [Abridge](https://github.com/Weltschmerz/Abridge). Disabled by default.\n\n+ `watch files` **boolean**\n\nDetermines whether Lactate will watch files to update its cache. If this is disabled, then your file cache will not update automatically as files are modified on the server.\n\n+ `headers` **object** or **function**\n\nSets custom response headers. If the option value is a function, it is a callback which is give (req, res) arguments. This function should return the header value; it is a mapping function.\n\n+ `max age` **number** or **string**\n\nPass this function a number (of seconds) or a string and appropriate headers will be set for client-side caching. Lactate comes with expiration defaults, such as 'two days' or '5 years and sixteen days' See [Expire](https://github.com/Weltschmerz/Expire) for details.\n\n```js\nlactate.set('max_age', 87500)\n//87500 seconds\nlactate.set('max_age', 'two days')\n//172800 seconds\nlactate.set'max_age', 'five weeks and one minute and ten seconds')\n//3024070 seconds\nlactate.set('max_age', 'one year and 2 months and seven weeks and 16 seconds')\n//41050028 seconds\n```\n\n+ `not found` **string** or **function**\n\nFor custom 404 handling. Functions are supplied the response for 100% custom response handling. Otherwise, if set to a string, this option will be treated as an ordinary file path and abide rules for gzipping / in-memory cache.\n\n+ `debug` **boolean**\n\nColored status / msg / path logging, for debugging purposes.\n\n###Caching options\n\nPass an object to the `cache` option setting. The following fields are accepted and optional:\n\n* `expire` Seconds expiration for cache keys. Keys expire after they are untouched for x-seconds. Default is `15min`.\n* `max keys` Maximum number of keys to keep in memory. Default is `Infinity`.\n* `max size` Maximum size in MB to keep in cache. Default is `100mb`.\n* `segment` Determines the threshold after which to segment a file for streaming instead of traditional writing. Default is `200kb`.\n\n```js\n  var options = {};\n  \n  options.cache = {\n    expire:5,\n    max_keys:200,\n    max_size:2,\n    segment:100\n  };\n\n  var files = lactate.static('files', options);\n\n  // Or use a string representation. Same as setting for max-age.\n  options.cache.expire = 'fifteen minutes';\n  files.set('cache', options.cache);\n```\n\n\n## License\n\nMIT\n\n","_id":"lactate@0.12.4","dist":{"shasum":"1465bf3e57df6bb0f3316fb0bae567e1f782ee04","tarball":"https://registry.npmjs.org/lactate/-/lactate-0.12.4.tgz","integrity":"sha512-f0AiogRmDp5VFLg/r+Y11Id6nT8G7Clfg9JzD21Ul4hJlpqZKpW7pK2iIZruYT3xsYQ893Z5r/q9dUokMzVWWw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEoIfzSE+qV015k/ANpPBHljM+jlTQ3UUkvr0YFI8YQDAiBAFuKBOeHR/Bs4ACy6zO3/4CqogfJx7kdnm6zS5jbLBw=="}]},"_npmVersion":"1.1.62","_npmUser":{"name":"Weltschmerz","email":"chlavois@gmail.com"},"maintainers":[{"name":"Weltschmerz","email":"chlavois@gmail.com"}],"directories":{}},"0.12.5":{"name":"lactate","version":"0.12.5","description":"Simple and featureful assets server","keywords":["static","file","server","assets","cache"],"repository":{"type":"git","url":"git://github.com/Weltschmerz/Lactate.git"},"author":{"name":"Weltschmerz","email":"chlavois@gmail.com"},"dependencies":{"mime":"1.2.7","suckle":"latest","expire":"latest","abridge":"latest","fraction":"latest","optimist":"0.3.5","redis":"0.8.1"},"devDependencies":{"mocha":"1.7.0","should":"1.2.1"},"main":"index.js","bin":{"lactate":"bin/lactate"},"scripts":{"test":"make test"},"engines":{"node":">= 0.6.0"},"readme":"# Lactate\n\n`npm install -g lactate`\n\nAn exceedingly fast static file handler, with a few electives.\n\n### Features\n\n* In-memory caching\n* Redis caching\n* Robust cache-control setting\n* Automatic gzipping\n* Automatic minification\n* Custom 404 pages\n* Custom response headers\n* Asset bundling and minification\n* Middleware export\n* Default error pages\n* on(status) listeners\n* Colored log output\n* Global executable\n* Directory indexing\n* Express.static API compatibility\n* node-static API compatibility\n\n## Using Lactate\n\n### Global executable\n\nIf installed globally with `npm install -g lactate`, you will have the `lactate` command at your disposal. This will run lactate static file server in the current working directory, utilizing the `cluster` module for multiple CPU cores. All [options](https://github.com/Weltschmerz/Lactate#options) are available.\n\n```code\n$ lactate --help\nUsage: lactate [options]\n\nOptions:\n--root, -r                    Local path                          [default: \"\"]\n--from, -f                    Public path                         [default: \"\"]\n--subdirs, -s                 Serve subdirectories                [default: true]\n--hidden, -h                  Serve hidden files                  [default: false]\n--error_pages, --error-pages  Serve error pages                   [default: true]\n--autoindex, -a               Automatically index directories     [default: true]\n--cache, -c                   Store assets in-memory              [default: true]\n--redis_cache, --rc           Store assets in-memory using Redis  [default: true]\n--watch_files, --watch-files  Watch files for cache update        [default: true]\n--max_age, --max-age, -M      Client-side caching max-age         [default: 172800]\n--gzip, -g                    Gzip text assets                    [default: true]\n--minify, -m                  Minify text assets                  [default: false]\n--bundle, -b                  Bundle text assets                  [default: false]\n--rebundle, --rb              Rebundle assets if modified         [default: true]\n--headers, -H                 Custom response headers             [default: \"\"]\n--debug, -d                   Log HTTP info                       [default: true]\n--quiet, -q                   Prevent all log output              [default: false]\n\n```\n\n### Programmatic lactating\n\nLactate can be used with either plain node, or with Express. With Express, Lactate is a drop-in replacement for `static` middleware, but with far more ability. The examples below use Express 2.x API for simplicity. See the [examples](https://github.com/Weltschmerz/Lactate/tree/master/example) for various examples.\n\n```js\nvar lactate = require('lactate');\nvar express = require('express');\n\nvar app = express.createServer();\napp.use(lactate.static(__dirname + '/files'));\n```\n\n## Testing Lactate\n\nIf installed locally (without -g flag to npm install):\n\n1. `cd` into `~/node_modules/lactate`\n2. `npm install ./` to install devDependencies\n3. `make test` to run mocha test\n\n##The varieties of Lactate experience\n\n###Creating a Lactate server\n\n```js\nvar lactate = require('lactate'); \nvar options = {root:'files'}; \nvar server = lactate.createServer(options); \n\nserver.listen(8080);\n```\n\n###Creating a directory handler\n\n```js\nvar lactate = require('lactate');\nvar options = {from:'public/path/to/files'};\nvar files = lactate.dir('files', options);\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', function(req, res) {\n  files.serve(req, res);\n});\n\nserver.listen(8080);\n```\n\n###Using directory middleware\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files', options);\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', files.toMiddleware());\nserver.listen(8080);\n```\n\n###Integrating with Express\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files', options);\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8080);\n```\n\n###Using Express.static API\n\n```js\nvar lactate = require('lactate');\nvar express = require('express');\nvar app = express();\n\napp.use(lactate.static(__dirname + '/files'));\napp.listen(8000);\n```\n\n###Using node-static API\n\n```js\nvar lactate = require('lactate');\nvar files = new(lactate.Server)('./files');\n\nvar http = require('http');\nvar server = new http.Server;\n\n// You could also pass a .toMiddleware()'d function\n\nserver.addListener('request', function(req, res) {\n  files.serve(req, res);\n});\n\nserver.listen(8000);\n```\n\n###Serving individual files\n\n```js\nvar lactate = require('lactate');\n\nvar fileOptions = {from:'public/directory'};\nvar files = lactate.dir('files', fileOptions);\n\nvar pageOptions = {};\nvar pages = lactate.dir('pages');\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', function(req, res) {\n  if (req.url === '/') {\n    pages.serve('index.html', req, res);\n  } else {\n    files.serve(req, res);\n  };\n});\n```\n\n###Setting options\n\n```js\nvar lactate = require('lactate');\n\nvar fileOptions = {\n  from:'public'\n};\n\nvar files = lactate.dir('files', fileOptions);\n\nfiles.set('cache', false);\nfiles.disable('gzip');\nfiles.maxAge('ten days');\n\nvar express = require('express');\nvar app = express():\n  \napp.get('/public/*', files.toMiddleware());\napp.listen(8080);\n```\n\n###Bundling assets\n\n```js\nvar lactate = require('lactate');\nvar options = {\n  from:'files'\n};\n\nvar files = lactate.dir('files', options);\n\n// Combine and minify all scripts to 'common.js'\nfiles.bundle('js', 'common.js', function(err, data) {\n// Handle errors\n});\n\n// Combine and minify all CSS to 'common.css'\nfiles.bundleCSS('common.css');\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8000);\n```\n\n###Using custom 404 pages\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files');\n\nfiles.notFound('path/to/404/page.html');\n\nfiles.notFound(function(req, res) {\n  res.writeHead(404);\n  res.end('Woops, 404');\n});\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8000);\n```\n\n###Using custom response headers\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files');\n\nfiles.setHeader('x-powered-by', 'Lactate');\nfiles.header('x-timestamp', function(req, res) {\n  return new Date().toUTCString();\n});\n\nvar headers = {};\nfiles.headers(headers);\n```\n\n###Status listeners\n\nLactate extends EventEmitter for emitting status code events. Codes Lactate is aware of are:\n\n* `200` *OK*\n* `304` *Not Modified*\n* `400` *Bad Request*\n* `403` *Forbidden*\n* `404` *Not Found*\n* `405` *Method Not Allowed*\n* `500` *Internal Error*\n\nCallbacks are given an object which has the following properties:\n\n* `url` The requested URL\n* `method` The request method (GET, HEAD)\n* `headers` Request headers\n* `address` Request IP address\n* `port` Request port\n* `path` Absolute file path to the requested file, if it exists\n* `msg` HTTP satus message\n\n```js\nvar files = lactate.dir('files', {});\nfiles.on('404', function(req) {\n  console.log('404', req.url);\n});\n```\n\n##Options\n\n### Setting options\n\nBoolean options may be set using `enable` and `disable` methods. Other options may be set using `set` method with either key/value or an options object.\n\n**Passing to initialization function**\n\n```js\nvar lactate = require('lactate').Lactate({\n  max_age:'two days'\n})\n```\n\n**Using `set` method**\n\n```js\nlactate.set('hidden', true)\n```\n\n**Using enable/disable:**\n\n```js\nlactate.disable('gzip');\nlactate.enable('minify');\n```\n\n**Special options methods**\n\nLactate has some special methods to reduce visual clutter:\n\n```js\nlactate.maxAge('two days');\n```\n\nis equivalent to:\n\n```js\nlactate.set('max_age', 'two days');\n```\n\nSimilarly, the `headers` method is for setting custom response headers. \n\n**Underscores or spaces**\n\nUse spaces instead of underscores if you prefer:\n\n```js\nlactate.disable('max age');\nlactate.enable('watch files');\n```\n\n### Options available\n\n+ `root` **string**\n\nLocal directory from which to serve files. By default, the current working directory.\n\n+ `from` **string**\n\nPublic directory exposed to clients. If set, only requests from /*directory* will complete. Contrast this with the `root` option which is the location of files on the serving machine, not necessarily the requested path.\n\n+ `subdirs` **boolean**\n\nBy default subdirectories are served. To disable this, set `subdirs` to false.\n\n+ `hidden` **boolean**\n\nWhether or not to serve hidden files. Default is false.\n\n+ `error pages` **boolean**\n\nEnabled by default. When disabled, Lactate will not serve error pages for 404 resposes, etc..\n\n+ `autoindex` **boolean**\n\nAutomatically display directory indexes. Disabled by default.\n\n+ `cache` **boolean** or **object**\n\nKeep files in-memory. Enabled by default. For caching options and more information about caching strategy, see [Caching Options](https://github.com/Weltschmerz/Lactate#caching-options).\n\n+ `gzip` **boolean**\n\nIf false, disables automatic gzipping for text files (HTML, JS, CSS). Enabled by default.\n\n+ `minify` **boolean**\n\nIf true, will automatically minify JavaScript and CSS using [Abridge](https://github.com/Weltschmerz/Abridge). Disabled by default.\n\n+ `watch files` **boolean**\n\nDetermines whether Lactate will watch files to update its cache. If this is disabled, then your file cache will not update automatically as files are modified on the server.\n\n+ `headers` **object** or **function**\n\nSets custom response headers. If the option value is a function, it is a callback which is give (req, res) arguments. This function should return the header value; it is a mapping function.\n\n+ `max age` **number** or **string**\n\nPass this function a number (of seconds) or a string and appropriate headers will be set for client-side caching. Lactate comes with expiration defaults, such as 'two days' or '5 years and sixteen days' See [Expire](https://github.com/Weltschmerz/Expire) for details.\n\n```js\nlactate.set('max_age', 87500)\n//87500 seconds\nlactate.set('max_age', 'two days')\n//172800 seconds\nlactate.set'max_age', 'five weeks and one minute and ten seconds')\n//3024070 seconds\nlactate.set('max_age', 'one year and 2 months and seven weeks and 16 seconds')\n//41050028 seconds\n```\n\n+ `not found` **string** or **function**\n\nFor custom 404 handling. Functions are supplied the response for 100% custom response handling. Otherwise, if set to a string, this option will be treated as an ordinary file path and abide rules for gzipping / in-memory cache.\n\n+ `debug` **boolean**\n\nColored status / msg / path logging, for debugging purposes.\n\n###Caching options\n\nPass an object to the `cache` option setting. The following fields are accepted and optional:\n\n* `expire` Seconds expiration for cache keys. Keys expire after they are untouched for x-seconds. Default is `15min`.\n* `max keys` Maximum number of keys to keep in memory. Default is `Infinity`.\n* `max size` Maximum size in MB to keep in cache. Default is `100mb`.\n* `segment` Determines the threshold after which to segment a file for streaming instead of traditional writing. Default is `200kb`.\n\n```js\n  var options = {};\n  \n  options.cache = {\n    expire:5,\n    max_keys:200,\n    max_size:2,\n    segment:100\n  };\n\n  var files = lactate.static('files', options);\n\n  // Or use a string representation. Same as setting for max-age.\n  options.cache.expire = 'fifteen minutes';\n  files.set('cache', options.cache);\n```\n\n\n## License\n\nMIT\n\n","_id":"lactate@0.12.5","dist":{"shasum":"7b3ff0c7489733aac2c5cb828e738fa218dc92c0","tarball":"https://registry.npmjs.org/lactate/-/lactate-0.12.5.tgz","integrity":"sha512-yijYLpr78WhReAlbYRMjf5nNtFajx4iQOAlLSX85WpXFgcgVIMHWnfdtEC4q+X9ZnMV1NBsThbtvOOel5GRw2Q==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCFt+5Ob0D1eUqhqzIsDSLbsCJACYTgAuTEmPAv50W0WQIhAMNXV2rfXAUlYuUccTSGWyPUBrf5RYz9i2WuTZRuveqw"}]},"_npmVersion":"1.1.62","_npmUser":{"name":"Weltschmerz","email":"chlavois@gmail.com"},"maintainers":[{"name":"Weltschmerz","email":"chlavois@gmail.com"}],"directories":{}},"0.12.6":{"name":"lactate","version":"0.12.6","description":"Simple and featureful assets server","keywords":["static","file","server","assets","cache"],"repository":{"type":"git","url":"git://github.com/Weltschmerz/Lactate.git"},"author":{"name":"Weltschmerz","email":"chlavois@gmail.com"},"dependencies":{"mime":"1.2.7","suckle":"latest","expire":"latest","abridge":"latest","fraction":"latest","optimist":"0.3.5","redis":"0.8.1"},"devDependencies":{"mocha":"1.7.0","should":"1.2.1"},"main":"index.js","bin":{"lactate":"bin/lactate"},"scripts":{"test":"make test"},"engines":{"node":">= 0.6.0"},"readme":"# Lactate\n\n`npm install -g lactate`\n\nAn exceedingly fast static file handler, with a few electives.\n\n### Features\n\n* In-memory caching\n* Redis caching\n* Robust cache-control setting\n* Automatic gzipping\n* Automatic minification\n* Custom 404 pages\n* Custom response headers\n* Asset bundling and minification\n* Middleware export\n* Default error pages\n* on(status) listeners\n* Colored log output\n* Global executable\n* Directory indexing\n* Express.static API compatibility\n* node-static API compatibility\n\n## Using Lactate\n\n### Global executable\n\nIf installed globally with `npm install -g lactate`, you will have the `lactate` command at your disposal. This will run lactate static file server in the current working directory, utilizing the `cluster` module for multiple CPU cores. All [options](https://github.com/Weltschmerz/Lactate#options) are available.\n\n```code\n$ lactate --help\nUsage: lactate [options]\n\nOptions:\n--root, -r                    Local path                          [default: \"\"]\n--from, -f                    Public path                         [default: \"\"]\n--subdirs, -s                 Serve subdirectories                [default: true]\n--hidden, -h                  Serve hidden files                  [default: false]\n--error_pages, --error-pages  Serve error pages                   [default: true]\n--autoindex, -a               Automatically index directories     [default: true]\n--cache, -c                   Store assets in-memory              [default: true]\n--redis_cache, --rc           Store assets in-memory using Redis  [default: true]\n--watch_files, --watch-files  Watch files for cache update        [default: true]\n--max_age, --max-age, -M      Client-side caching max-age         [default: 172800]\n--gzip, -g                    Gzip text assets                    [default: true]\n--minify, -m                  Minify text assets                  [default: false]\n--bundle, -b                  Bundle text assets                  [default: false]\n--rebundle, --rb              Rebundle assets if modified         [default: true]\n--headers, -H                 Custom response headers             [default: \"\"]\n--debug, -d                   Log HTTP info                       [default: true]\n--quiet, -q                   Prevent all log output              [default: false]\n\n```\n\n### Programmatic lactating\n\nLactate can be used with either plain node, or with Express. With Express, Lactate is a drop-in replacement for `static` middleware, but with far more ability. The examples below use Express 2.x API for simplicity. See the [examples](https://github.com/Weltschmerz/Lactate/tree/master/example) for various examples.\n\n```js\nvar lactate = require('lactate');\nvar express = require('express');\n\nvar app = express.createServer();\napp.use(lactate.static(__dirname + '/files'));\n```\n\n## Testing Lactate\n\nIf installed locally (without -g flag to npm install):\n\n1. `cd` into `~/node_modules/lactate`\n2. `npm install ./` to install devDependencies\n3. `make test` to run mocha test\n\n##The varieties of Lactate experience\n\n###Creating a Lactate server\n\n```js\nvar lactate = require('lactate'); \nvar options = {root:'files'}; \nvar server = lactate.createServer(options); \n\nserver.listen(8080);\n```\n\n###Creating a directory handler\n\n```js\nvar lactate = require('lactate');\nvar options = {from:'public/path/to/files'};\nvar files = lactate.dir('files', options);\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', function(req, res) {\n  files.serve(req, res);\n});\n\nserver.listen(8080);\n```\n\n###Using directory middleware\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files', options);\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', files.toMiddleware());\nserver.listen(8080);\n```\n\n###Integrating with Express\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files', options);\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8080);\n```\n\n###Using Express.static API\n\n```js\nvar lactate = require('lactate');\nvar express = require('express');\nvar app = express();\n\napp.use(lactate.static(__dirname + '/files'));\napp.listen(8000);\n```\n\n###Using node-static API\n\n```js\nvar lactate = require('lactate');\nvar files = new(lactate.Server)('./files');\n\nvar http = require('http');\nvar server = new http.Server;\n\n// You could also pass a .toMiddleware()'d function\n\nserver.addListener('request', function(req, res) {\n  files.serve(req, res);\n});\n\nserver.listen(8000);\n```\n\n###Serving individual files\n\n```js\nvar lactate = require('lactate');\n\nvar fileOptions = {from:'public/directory'};\nvar files = lactate.dir('files', fileOptions);\n\nvar pageOptions = {};\nvar pages = lactate.dir('pages');\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', function(req, res) {\n  if (req.url === '/') {\n    pages.serve('index.html', req, res);\n  } else {\n    files.serve(req, res);\n  };\n});\n```\n\n###Setting options\n\n```js\nvar lactate = require('lactate');\n\nvar fileOptions = {\n  from:'public'\n};\n\nvar files = lactate.dir('files', fileOptions);\n\nfiles.set('cache', false);\nfiles.disable('gzip');\nfiles.maxAge('ten days');\n\nvar express = require('express');\nvar app = express():\n  \napp.get('/public/*', files.toMiddleware());\napp.listen(8080);\n```\n\n###Bundling assets\n\n```js\nvar lactate = require('lactate');\nvar options = {\n  from:'files'\n};\n\nvar files = lactate.dir('files', options);\n\n// Combine and minify all scripts to 'common.js'\nfiles.bundle('js', 'common.js', function(err, data) {\n// Handle errors\n});\n\n// Combine and minify all CSS to 'common.css'\nfiles.bundleCSS('common.css');\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8000);\n```\n\n###Using custom 404 pages\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files');\n\nfiles.notFound('path/to/404/page.html');\n\nfiles.notFound(function(req, res) {\n  res.writeHead(404);\n  res.end('Woops, 404');\n});\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8000);\n```\n\n###Using custom response headers\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files');\n\nfiles.setHeader('x-powered-by', 'Lactate');\nfiles.header('x-timestamp', function(req, res) {\n  return new Date().toUTCString();\n});\n\nvar headers = {};\nfiles.headers(headers);\n```\n\n###Status listeners\n\nLactate extends EventEmitter for emitting status code events. Codes Lactate is aware of are:\n\n* `200` *OK*\n* `304` *Not Modified*\n* `400` *Bad Request*\n* `403` *Forbidden*\n* `404` *Not Found*\n* `405` *Method Not Allowed*\n* `500` *Internal Error*\n\nCallbacks are given an object which has the following properties:\n\n* `url` The requested URL\n* `method` The request method (GET, HEAD)\n* `headers` Request headers\n* `address` Request IP address\n* `port` Request port\n* `path` Absolute file path to the requested file, if it exists\n* `msg` HTTP satus message\n\n```js\nvar files = lactate.dir('files', {});\nfiles.on('404', function(req) {\n  console.log('404', req.url);\n});\n```\n\n##Options\n\n### Setting options\n\nBoolean options may be set using `enable` and `disable` methods. Other options may be set using `set` method with either key/value or an options object.\n\n**Passing to initialization function**\n\n```js\nvar lactate = require('lactate').Lactate({\n  max_age:'two days'\n})\n```\n\n**Using `set` method**\n\n```js\nlactate.set('hidden', true)\n```\n\n**Using enable/disable:**\n\n```js\nlactate.disable('gzip');\nlactate.enable('minify');\n```\n\n**Special options methods**\n\nLactate has some special methods to reduce visual clutter:\n\n```js\nlactate.maxAge('two days');\n```\n\nis equivalent to:\n\n```js\nlactate.set('max_age', 'two days');\n```\n\nSimilarly, the `headers` method is for setting custom response headers. \n\n**Underscores or spaces**\n\nUse spaces instead of underscores if you prefer:\n\n```js\nlactate.disable('max age');\nlactate.enable('watch files');\n```\n\n### Options available\n\n+ `root` **string**\n\nLocal directory from which to serve files. By default, the current working directory.\n\n+ `from` **string**\n\nPublic directory exposed to clients. If set, only requests from /*directory* will complete. Contrast this with the `root` option which is the location of files on the serving machine, not necessarily the requested path.\n\n+ `subdirs` **boolean**\n\nBy default subdirectories are served. To disable this, set `subdirs` to false.\n\n+ `hidden` **boolean**\n\nWhether or not to serve hidden files. Default is false.\n\n+ `error pages` **boolean**\n\nEnabled by default. When disabled, Lactate will not serve error pages for 404 resposes, etc..\n\n+ `autoindex` **boolean**\n\nAutomatically display directory indexes. Disabled by default.\n\n+ `cache` **boolean** or **object**\n\nKeep files in-memory. Enabled by default. For caching options and more information about caching strategy, see [Caching Options](https://github.com/Weltschmerz/Lactate#caching-options).\n\n+ `gzip` **boolean**\n\nIf false, disables automatic gzipping for text files (HTML, JS, CSS). Enabled by default.\n\n+ `minify` **boolean**\n\nIf true, will automatically minify JavaScript and CSS using [Abridge](https://github.com/Weltschmerz/Abridge). Disabled by default.\n\n+ `watch files` **boolean**\n\nDetermines whether Lactate will watch files to update its cache. If this is disabled, then your file cache will not update automatically as files are modified on the server.\n\n+ `headers` **object** or **function**\n\nSets custom response headers. If the option value is a function, it is a callback which is give (req, res) arguments. This function should return the header value; it is a mapping function.\n\n+ `max age` **number** or **string**\n\nPass this function a number (of seconds) or a string and appropriate headers will be set for client-side caching. Lactate comes with expiration defaults, such as 'two days' or '5 years and sixteen days' See [Expire](https://github.com/Weltschmerz/Expire) for details.\n\n```js\nlactate.set('max_age', 87500)\n//87500 seconds\nlactate.set('max_age', 'two days')\n//172800 seconds\nlactate.set'max_age', 'five weeks and one minute and ten seconds')\n//3024070 seconds\nlactate.set('max_age', 'one year and 2 months and seven weeks and 16 seconds')\n//41050028 seconds\n```\n\n+ `not found` **string** or **function**\n\nFor custom 404 handling. Functions are supplied the response for 100% custom response handling. Otherwise, if set to a string, this option will be treated as an ordinary file path and abide rules for gzipping / in-memory cache.\n\n+ `debug` **boolean**\n\nColored status / msg / path logging, for debugging purposes.\n\n###Caching options\n\nPass an object to the `cache` option setting. The following fields are accepted and optional:\n\n* `expire` Seconds expiration for cache keys. Keys expire after they are untouched for x-seconds. Default is `15min`.\n* `max keys` Maximum number of keys to keep in memory. Default is `Infinity`.\n* `max size` Maximum size in MB to keep in cache. Default is `100mb`.\n* `segment` Determines the threshold after which to segment a file for streaming instead of traditional writing. Default is `200kb`.\n\n```js\n  var options = {};\n  \n  options.cache = {\n    expire:5,\n    max_keys:200,\n    max_size:2,\n    segment:100\n  };\n\n  var files = lactate.static('files', options);\n\n  // Or use a string representation. Same as setting for max-age.\n  options.cache.expire = 'fifteen minutes';\n  files.set('cache', options.cache);\n```\n\n\n## License\n\nMIT\n\n","_id":"lactate@0.12.6","dist":{"shasum":"4ce72d6c064d172aac7a5f940541915d0b13af0c","tarball":"https://registry.npmjs.org/lactate/-/lactate-0.12.6.tgz","integrity":"sha512-nP9n74szIT2HZFoscHj06fusp6cUHX2yyo3pqmOnPYMHSYWnEsamQp08G09dPV8WewI8SqotA5jHbkhJ/wLObg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICJbsLnvEFHmr3XvF5oRAZN8N7Td1eZHMOa3lS/koOO5AiBIw0Oog6aUhS7NSgSU2VrKYWcMb0pDudGZBh2RxdXalg=="}]},"_npmVersion":"1.1.62","_npmUser":{"name":"Weltschmerz","email":"chlavois@gmail.com"},"maintainers":[{"name":"Weltschmerz","email":"chlavois@gmail.com"}],"directories":{}},"0.12.7":{"name":"lactate","version":"0.12.7","description":"Simple and featureful assets server","keywords":["static","file","server","assets","cache"],"repository":{"type":"git","url":"git://github.com/Weltschmerz/Lactate.git"},"author":{"name":"Weltschmerz","email":"chlavois@gmail.com"},"dependencies":{"mime":"1.2.7","suckle":"latest","expire":"latest","abridge":"latest","fraction":"latest","optimist":"0.3.5","redis":"0.8.1"},"devDependencies":{"mocha":"1.7.0","should":"1.2.1"},"main":"index.js","bin":{"lactate":"bin/lactate"},"scripts":{"test":"make test"},"engines":{"node":">= 0.6.0"},"readme":"# Lactate\n\n`npm install -g lactate`\n\nAn exceedingly fast static file handler, with a few electives.\n\n### Features\n\n* In-memory caching\n* Redis caching\n* Robust cache-control setting\n* Automatic gzipping\n* Automatic minification\n* Custom 404 pages\n* Custom response headers\n* Asset bundling and minification\n* Middleware export\n* Default error pages\n* on(status) listeners\n* Colored log output\n* Global executable\n* Directory indexing\n* Express.static API compatibility\n* node-static API compatibility\n\n## Using Lactate\n\n### Global executable\n\nIf installed globally with `npm install -g lactate`, you will have the `lactate` command at your disposal. This will run lactate static file server in the current working directory, utilizing the `cluster` module for multiple CPU cores. All [options](https://github.com/Weltschmerz/Lactate#options) are available.\n\n```code\n$ lactate --help\nUsage: lactate [options]\n\nOptions:\n--root, -r                    Local path                          [default: \"\"]\n--from, -f                    Public path                         [default: \"\"]\n--subdirs, -s                 Serve subdirectories                [default: true]\n--hidden, -h                  Serve hidden files                  [default: false]\n--error_pages, --error-pages  Serve error pages                   [default: true]\n--autoindex, -a               Automatically index directories     [default: true]\n--cache, -c                   Store assets in-memory              [default: true]\n--redis_cache, --rc           Store assets in-memory using Redis  [default: true]\n--watch_files, --watch-files  Watch files for cache update        [default: true]\n--max_age, --max-age, -M      Client-side caching max-age         [default: 172800]\n--gzip, -g                    Gzip text assets                    [default: true]\n--minify, -m                  Minify text assets                  [default: false]\n--bundle, -b                  Bundle text assets                  [default: false]\n--rebundle, --rb              Rebundle assets if modified         [default: true]\n--headers, -H                 Custom response headers             [default: \"\"]\n--debug, -d                   Log HTTP info                       [default: true]\n--quiet, -q                   Prevent all log output              [default: false]\n\n```\n\n### Programmatic lactating\n\nLactate can be used with either plain node, or with Express. With Express, Lactate is a drop-in replacement for `static` middleware, but with far more ability. The examples below use Express 2.x API for simplicity. See the [examples](https://github.com/Weltschmerz/Lactate/tree/master/example) for various examples.\n\n```js\nvar lactate = require('lactate');\nvar express = require('express');\n\nvar app = express.createServer();\napp.use(lactate.static(__dirname + '/files'));\n```\n\n## Testing Lactate\n\nIf installed locally (without -g flag to npm install):\n\n1. `cd` into `~/node_modules/lactate`\n2. `npm install ./` to install devDependencies\n3. `make test` to run mocha test\n\n##The varieties of Lactate experience\n\n###Creating a Lactate server\n\n```js\nvar lactate = require('lactate'); \nvar options = {root:'files'}; \nvar server = lactate.createServer(options); \n\nserver.listen(8080);\n```\n\n###Creating a directory handler\n\n```js\nvar lactate = require('lactate');\nvar options = {from:'public/path/to/files'};\nvar files = lactate.dir('files', options);\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', function(req, res) {\n  files.serve(req, res);\n});\n\nserver.listen(8080);\n```\n\n###Using directory middleware\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files', options);\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', files.toMiddleware());\nserver.listen(8080);\n```\n\n###Integrating with Express\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files', options);\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8080);\n```\n\n###Using Express.static API\n\n```js\nvar lactate = require('lactate');\nvar express = require('express');\nvar app = express();\n\napp.use(lactate.static(__dirname + '/files'));\napp.listen(8000);\n```\n\n###Using node-static API\n\n```js\nvar lactate = require('lactate');\nvar files = new(lactate.Server)('./files');\n\nvar http = require('http');\nvar server = new http.Server;\n\n// You could also pass a .toMiddleware()'d function\n\nserver.addListener('request', function(req, res) {\n  files.serve(req, res);\n});\n\nserver.listen(8000);\n```\n\n###Serving individual files\n\n```js\nvar lactate = require('lactate');\n\nvar fileOptions = {from:'public/directory'};\nvar files = lactate.dir('files', fileOptions);\n\nvar pageOptions = {};\nvar pages = lactate.dir('pages');\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', function(req, res) {\n  if (req.url === '/') {\n    pages.serve('index.html', req, res);\n  } else {\n    files.serve(req, res);\n  };\n});\n```\n\n###Setting options\n\n```js\nvar lactate = require('lactate');\n\nvar fileOptions = {\n  from:'public'\n};\n\nvar files = lactate.dir('files', fileOptions);\n\nfiles.set('cache', false);\nfiles.disable('gzip');\nfiles.maxAge('ten days');\n\nvar express = require('express');\nvar app = express():\n  \napp.get('/public/*', files.toMiddleware());\napp.listen(8080);\n```\n\n###Bundling assets\n\n```js\nvar lactate = require('lactate');\nvar options = {\n  from:'files'\n};\n\nvar files = lactate.dir('files', options);\n\n// Combine and minify all scripts to 'common.js'\nfiles.bundle('js', 'common.js', function(err, data) {\n// Handle errors\n});\n\n// Combine and minify all CSS to 'common.css'\nfiles.bundleCSS('common.css');\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8000);\n```\n\n###Using custom 404 pages\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files');\n\nfiles.notFound('path/to/404/page.html');\n\nfiles.notFound(function(req, res) {\n  res.writeHead(404);\n  res.end('Woops, 404');\n});\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8000);\n```\n\n###Using custom response headers\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files');\n\nfiles.setHeader('x-powered-by', 'Lactate');\nfiles.header('x-timestamp', function(req, res) {\n  return new Date().toUTCString();\n});\n\nvar headers = {};\nfiles.headers(headers);\n```\n\n###Status listeners\n\nLactate extends EventEmitter for emitting status code events. Codes Lactate is aware of are:\n\n* `200` *OK*\n* `304` *Not Modified*\n* `400` *Bad Request*\n* `403` *Forbidden*\n* `404` *Not Found*\n* `405` *Method Not Allowed*\n* `500` *Internal Error*\n\nCallbacks are given an object which has the following properties:\n\n* `url` The requested URL\n* `method` The request method (GET, HEAD)\n* `headers` Request headers\n* `address` Request IP address\n* `port` Request port\n* `path` Absolute file path to the requested file, if it exists\n* `msg` HTTP satus message\n\n```js\nvar files = lactate.dir('files', {});\nfiles.on('404', function(req) {\n  console.log('404', req.url);\n});\n```\n\n##Options\n\n### Setting options\n\nBoolean options may be set using `enable` and `disable` methods. Other options may be set using `set` method with either key/value or an options object.\n\n**Passing to initialization function**\n\n```js\nvar lactate = require('lactate').Lactate({\n  max_age:'two days'\n})\n```\n\n**Using `set` method**\n\n```js\nlactate.set('hidden', true)\n```\n\n**Using enable/disable:**\n\n```js\nlactate.disable('gzip');\nlactate.enable('minify');\n```\n\n**Special options methods**\n\nLactate has some special methods to reduce visual clutter:\n\n```js\nlactate.maxAge('two days');\n```\n\nis equivalent to:\n\n```js\nlactate.set('max_age', 'two days');\n```\n\nSimilarly, the `headers` method is for setting custom response headers. \n\n**Underscores or spaces**\n\nUse spaces instead of underscores if you prefer:\n\n```js\nlactate.disable('max age');\nlactate.enable('watch files');\n```\n\n### Options available\n\n+ `root` **string**\n\nLocal directory from which to serve files. By default, the current working directory.\n\n+ `from` **string**\n\nPublic directory exposed to clients. If set, only requests from /*directory* will complete. Contrast this with the `root` option which is the location of files on the serving machine, not necessarily the requested path.\n\n+ `subdirs` **boolean**\n\nBy default subdirectories are served. To disable this, set `subdirs` to false.\n\n+ `hidden` **boolean**\n\nWhether or not to serve hidden files. Default is false.\n\n+ `error pages` **boolean**\n\nEnabled by default. When disabled, Lactate will not serve error pages for 404 resposes, etc..\n\n+ `autoindex` **boolean**\n\nAutomatically display directory indexes. Disabled by default.\n\n+ `cache` **boolean** or **object**\n\nKeep files in-memory. Enabled by default. For caching options and more information about caching strategy, see [Caching Options](https://github.com/Weltschmerz/Lactate#caching-options).\n\n+ `gzip` **boolean**\n\nIf false, disables automatic gzipping for text files (HTML, JS, CSS). Enabled by default.\n\n+ `minify` **boolean**\n\nIf true, will automatically minify JavaScript and CSS using [Abridge](https://github.com/Weltschmerz/Abridge). Disabled by default.\n\n+ `watch files` **boolean**\n\nDetermines whether Lactate will watch files to update its cache. If this is disabled, then your file cache will not update automatically as files are modified on the server.\n\n+ `headers` **object** or **function**\n\nSets custom response headers. If the option value is a function, it is a callback which is give (req, res) arguments. This function should return the header value; it is a mapping function.\n\n+ `max age` **number** or **string**\n\nPass this function a number (of seconds) or a string and appropriate headers will be set for client-side caching. Lactate comes with expiration defaults, such as 'two days' or '5 years and sixteen days' See [Expire](https://github.com/Weltschmerz/Expire) for details.\n\n```js\nlactate.set('max_age', 87500)\n//87500 seconds\nlactate.set('max_age', 'two days')\n//172800 seconds\nlactate.set'max_age', 'five weeks and one minute and ten seconds')\n//3024070 seconds\nlactate.set('max_age', 'one year and 2 months and seven weeks and 16 seconds')\n//41050028 seconds\n```\n\n+ `not found` **string** or **function**\n\nFor custom 404 handling. Functions are supplied the response for 100% custom response handling. Otherwise, if set to a string, this option will be treated as an ordinary file path and abide rules for gzipping / in-memory cache.\n\n+ `debug` **boolean**\n\nColored status / msg / path logging, for debugging purposes.\n\n###Caching options\n\nPass an object to the `cache` option setting. The following fields are accepted and optional:\n\n* `expire` Seconds expiration for cache keys. Keys expire after they are untouched for x-seconds. Default is `15min`.\n* `max keys` Maximum number of keys to keep in memory. Default is `Infinity`.\n* `max size` Maximum size in MB to keep in cache. Default is `100mb`.\n* `segment` Determines the threshold after which to segment a file for streaming instead of traditional writing. Default is `200kb`.\n\n```js\n  var options = {};\n  \n  options.cache = {\n    expire:5,\n    max_keys:200,\n    max_size:2,\n    segment:100\n  };\n\n  var files = lactate.static('files', options);\n\n  // Or use a string representation. Same as setting for max-age.\n  options.cache.expire = 'fifteen minutes';\n  files.set('cache', options.cache);\n```\n\n\n## License\n\nMIT\n\n","_id":"lactate@0.12.7","dist":{"shasum":"4b360db63433ba35ca90a09eabd4a5bb70cde8c3","tarball":"https://registry.npmjs.org/lactate/-/lactate-0.12.7.tgz","integrity":"sha512-NIsaPCor2vo78BBxCgCRP6jPZpjJNVlPWRq+C3guglvK7I5/vOB9iW7i+vlGK9RUUy910AaaQCq2gUK2ygTV2Q==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCyTUmoyaVthxGxiLlUuIsBBVBGg1bdGogGQmXENgs6iwIhAL77UCeV+NJeA+dhEhkR24koHvWW7UfiDgIaiqPxlVRc"}]},"_npmVersion":"1.1.62","_npmUser":{"name":"Weltschmerz","email":"chlavois@gmail.com"},"maintainers":[{"name":"Weltschmerz","email":"chlavois@gmail.com"}],"directories":{}},"0.12.8":{"name":"lactate","version":"0.12.8","description":"Simple and featureful assets server","keywords":["static","file","server","assets","cache"],"repository":{"type":"git","url":"git://github.com/Weltschmerz/Lactate.git"},"author":{"name":"Weltschmerz","email":"chlavois@gmail.com"},"dependencies":{"mime":"1.2.7","suckle":"latest","expire":"latest","abridge":"latest","fraction":"latest","optimist":"0.3.5","redis":"0.8.1"},"devDependencies":{"mocha":"1.7.0","should":"1.2.1"},"main":"index.js","bin":{"lactate":"bin/lactate"},"scripts":{"test":"make test"},"engines":{"node":">= 0.6.0"},"readme":"# Lactate\n\n`npm install -g lactate`\n\nAn exceedingly fast static file handler, with a few electives.\n\n### Features\n\n* In-memory caching\n* Redis caching\n* Robust cache-control setting\n* Automatic gzipping\n* Automatic minification\n* Custom 404 pages\n* Custom response headers\n* Asset bundling and minification\n* Middleware export\n* Default error pages\n* on(status) listeners\n* Colored log output\n* Global executable\n* Directory indexing\n* Express.static API compatibility\n* node-static API compatibility\n\n## Using Lactate\n\n### Global executable\n\nIf installed globally with `npm install -g lactate`, you will have the `lactate` command at your disposal. This will run lactate static file server in the current working directory, utilizing the `cluster` module for multiple CPU cores. All [options](https://github.com/Weltschmerz/Lactate#options) are available.\n\n```code\n$ lactate --help\nUsage: lactate [options]\n\nOptions:\n--root, -r                    Local path                          [default: \"\"]\n--from, -f                    Public path                         [default: \"\"]\n--subdirs, -s                 Serve subdirectories                [default: true]\n--hidden, -h                  Serve hidden files                  [default: false]\n--error_pages, --error-pages  Serve error pages                   [default: true]\n--autoindex, -a               Automatically index directories     [default: true]\n--cache, -c                   Store assets in-memory              [default: true]\n--redis_cache, --rc           Store assets in-memory using Redis  [default: true]\n--watch_files, --watch-files  Watch files for cache update        [default: true]\n--max_age, --max-age, -M      Client-side caching max-age         [default: 172800]\n--gzip, -g                    Gzip text assets                    [default: true]\n--minify, -m                  Minify text assets                  [default: false]\n--bundle, -b                  Bundle text assets                  [default: false]\n--rebundle, --rb              Rebundle assets if modified         [default: true]\n--headers, -H                 Custom response headers             [default: \"\"]\n--debug, -d                   Log HTTP info                       [default: true]\n--quiet, -q                   Prevent all log output              [default: false]\n\n```\n\n### Programmatic lactating\n\nLactate can be used with either plain node, or with Express. With Express, Lactate is a drop-in replacement for `static` middleware, but with far more ability. The examples below use Express 2.x API for simplicity. See the [examples](https://github.com/Weltschmerz/Lactate/tree/master/example) for various examples.\n\n```js\nvar lactate = require('lactate');\nvar express = require('express');\n\nvar app = express.createServer();\napp.use(lactate.static(__dirname + '/files'));\n```\n\n## Testing Lactate\n\nIf installed locally (without -g flag to npm install):\n\n1. `cd` into `~/node_modules/lactate`\n2. `npm install ./` to install devDependencies\n3. `make test` to run mocha test\n\n##The varieties of Lactate experience\n\n###Creating a Lactate server\n\n```js\nvar lactate = require('lactate'); \nvar options = {root:'files'}; \nvar server = lactate.createServer(options); \n\nserver.listen(8080);\n```\n\n###Creating a directory handler\n\n```js\nvar lactate = require('lactate');\nvar options = {from:'public/path/to/files'};\nvar files = lactate.dir('files', options);\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', function(req, res) {\n  files.serve(req, res);\n});\n\nserver.listen(8080);\n```\n\n###Using directory middleware\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files', options);\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', files.toMiddleware());\nserver.listen(8080);\n```\n\n###Integrating with Express\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files', options);\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8080);\n```\n\n###Using Express.static API\n\n```js\nvar lactate = require('lactate');\nvar express = require('express');\nvar app = express();\n\napp.use(lactate.static(__dirname + '/files'));\napp.listen(8000);\n```\n\n###Using node-static API\n\n```js\nvar lactate = require('lactate');\nvar files = new(lactate.Server)('./files');\n\nvar http = require('http');\nvar server = new http.Server;\n\n// You could also pass a .toMiddleware()'d function\n\nserver.addListener('request', function(req, res) {\n  files.serve(req, res);\n});\n\nserver.listen(8000);\n```\n\n###Serving individual files\n\n```js\nvar lactate = require('lactate');\n\nvar fileOptions = {from:'public/directory'};\nvar files = lactate.dir('files', fileOptions);\n\nvar pageOptions = {};\nvar pages = lactate.dir('pages');\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', function(req, res) {\n  if (req.url === '/') {\n    pages.serve('index.html', req, res);\n  } else {\n    files.serve(req, res);\n  };\n});\n```\n\n###Setting options\n\n```js\nvar lactate = require('lactate');\n\nvar fileOptions = {\n  from:'public'\n};\n\nvar files = lactate.dir('files', fileOptions);\n\nfiles.set('cache', false);\nfiles.disable('gzip');\nfiles.maxAge('ten days');\n\nvar express = require('express');\nvar app = express():\n  \napp.get('/public/*', files.toMiddleware());\napp.listen(8080);\n```\n\n###Bundling assets\n\n```js\nvar lactate = require('lactate');\nvar options = {\n  from:'files'\n};\n\nvar files = lactate.dir('files', options);\n\n// Combine and minify all scripts to 'common.js'\nfiles.bundle('js', 'common.js', function(err, data) {\n// Handle errors\n});\n\n// Combine and minify all CSS to 'common.css'\nfiles.bundleCSS('common.css');\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8000);\n```\n\n###Using custom 404 pages\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files');\n\nfiles.notFound('path/to/404/page.html');\n\nfiles.notFound(function(req, res) {\n  res.writeHead(404);\n  res.end('Woops, 404');\n});\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8000);\n```\n\n###Using custom response headers\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files');\n\nfiles.setHeader('x-powered-by', 'Lactate');\nfiles.header('x-timestamp', function(req, res) {\n  return new Date().toUTCString();\n});\n\nvar headers = {};\nfiles.headers(headers);\n```\n\n###Status listeners\n\nLactate extends EventEmitter for emitting status code events. Codes Lactate is aware of are:\n\n* `200` *OK*\n* `304` *Not Modified*\n* `400` *Bad Request*\n* `403` *Forbidden*\n* `404` *Not Found*\n* `405` *Method Not Allowed*\n* `500` *Internal Error*\n\nCallbacks are given an object which has the following properties:\n\n* `url` The requested URL\n* `method` The request method (GET, HEAD)\n* `headers` Request headers\n* `address` Request IP address\n* `port` Request port\n* `path` Absolute file path to the requested file, if it exists\n* `msg` HTTP satus message\n\n```js\nvar files = lactate.dir('files', {});\nfiles.on('404', function(req) {\n  console.log('404', req.url);\n});\n```\n\n##Options\n\n### Setting options\n\nBoolean options may be set using `enable` and `disable` methods. Other options may be set using `set` method with either key/value or an options object.\n\n**Passing to initialization function**\n\n```js\nvar lactate = require('lactate').Lactate({\n  max_age:'two days'\n})\n```\n\n**Using `set` method**\n\n```js\nlactate.set('hidden', true)\n```\n\n**Using enable/disable:**\n\n```js\nlactate.disable('gzip');\nlactate.enable('minify');\n```\n\n**Special options methods**\n\nLactate has some special methods to reduce visual clutter:\n\n```js\nlactate.maxAge('two days');\n```\n\nis equivalent to:\n\n```js\nlactate.set('max_age', 'two days');\n```\n\nSimilarly, the `headers` method is for setting custom response headers. \n\n**Underscores or spaces**\n\nUse spaces instead of underscores if you prefer:\n\n```js\nlactate.disable('max age');\nlactate.enable('watch files');\n```\n\n### Options available\n\n+ `root` **string**\n\nLocal directory from which to serve files. By default, the current working directory.\n\n+ `from` **string**\n\nPublic directory exposed to clients. If set, only requests from /*directory* will complete. Contrast this with the `root` option which is the location of files on the serving machine, not necessarily the requested path.\n\n+ `subdirs` **boolean**\n\nBy default subdirectories are served. To disable this, set `subdirs` to false.\n\n+ `hidden` **boolean**\n\nWhether or not to serve hidden files. Default is false.\n\n+ `error pages` **boolean**\n\nEnabled by default. When disabled, Lactate will not serve error pages for 404 resposes, etc..\n\n+ `autoindex` **boolean**\n\nAutomatically display directory indexes. Disabled by default.\n\n+ `cache` **boolean** or **object**\n\nKeep files in-memory. Enabled by default. For caching options and more information about caching strategy, see [Caching Options](https://github.com/Weltschmerz/Lactate#caching-options).\n\n+ `gzip` **boolean**\n\nIf false, disables automatic gzipping for text files (HTML, JS, CSS). Enabled by default.\n\n+ `minify` **boolean**\n\nIf true, will automatically minify JavaScript and CSS using [Abridge](https://github.com/Weltschmerz/Abridge). Disabled by default.\n\n+ `watch files` **boolean**\n\nDetermines whether Lactate will watch files to update its cache. If this is disabled, then your file cache will not update automatically as files are modified on the server.\n\n+ `headers` **object** or **function**\n\nSets custom response headers. If the option value is a function, it is a callback which is give (req, res) arguments. This function should return the header value; it is a mapping function.\n\n+ `max age` **number** or **string**\n\nPass this function a number (of seconds) or a string and appropriate headers will be set for client-side caching. Lactate comes with expiration defaults, such as 'two days' or '5 years and sixteen days' See [Expire](https://github.com/Weltschmerz/Expire) for details.\n\n```js\nlactate.set('max_age', 87500)\n//87500 seconds\nlactate.set('max_age', 'two days')\n//172800 seconds\nlactate.set'max_age', 'five weeks and one minute and ten seconds')\n//3024070 seconds\nlactate.set('max_age', 'one year and 2 months and seven weeks and 16 seconds')\n//41050028 seconds\n```\n\n+ `not found` **string** or **function**\n\nFor custom 404 handling. Functions are supplied the response for 100% custom response handling. Otherwise, if set to a string, this option will be treated as an ordinary file path and abide rules for gzipping / in-memory cache.\n\n+ `debug` **boolean**\n\nColored status / msg / path logging, for debugging purposes.\n\n###Caching options\n\nPass an object to the `cache` option setting. The following fields are accepted and optional:\n\n* `expire` Seconds expiration for cache keys. Keys expire after they are untouched for x-seconds. Default is `15min`.\n* `max keys` Maximum number of keys to keep in memory. Default is `Infinity`.\n* `max size` Maximum size in MB to keep in cache. Default is `100mb`.\n* `segment` Determines the threshold after which to segment a file for streaming instead of traditional writing. Default is `200kb`.\n\n```js\n  var options = {};\n  \n  options.cache = {\n    expire:5,\n    max_keys:200,\n    max_size:2,\n    segment:100\n  };\n\n  var files = lactate.static('files', options);\n\n  // Or use a string representation. Same as setting for max-age.\n  options.cache.expire = 'fifteen minutes';\n  files.set('cache', options.cache);\n```\n\n\n## License\n\nMIT\n\n","_id":"lactate@0.12.8","dist":{"shasum":"e11989be8815e3c84637ebe4c48745c5de8fbb5a","tarball":"https://registry.npmjs.org/lactate/-/lactate-0.12.8.tgz","integrity":"sha512-oHI5sT4RvVIp42FKcb/uoaky2v+rdjkM8t+It0x04eOlt8RouSWc0Jwd1Fpn2NcNXA1Tg75+H6YmIqknswTXCg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC0Ixu5Ic/HQvUPRa83PEdX0vAA9ebcsf7cFNyfhf30FgIgPFCTAm9AbiBzepU7KzTqKv0a2zfI+9xwTcspIUEfHHQ="}]},"_npmVersion":"1.1.62","_npmUser":{"name":"Weltschmerz","email":"chlavois@gmail.com"},"maintainers":[{"name":"Weltschmerz","email":"chlavois@gmail.com"}],"directories":{}},"0.12.9":{"name":"lactate","version":"0.12.9","description":"Simple and featureful assets server","keywords":["static","file","server","assets","cache"],"repository":{"type":"git","url":"git://github.com/Weltschmerz/Lactate.git"},"author":{"name":"Weltschmerz","email":"chlavois@gmail.com"},"dependencies":{"mime":"1.2.7","suckle":"latest","expire":"latest","abridge":"latest","fraction":"latest","optimist":"0.3.5","redis":"0.8.2"},"devDependencies":{"mocha":"1.7.0","should":"1.2.1"},"main":"index.js","bin":{"lactate":"bin/lactate"},"scripts":{"test":"make test"},"engines":{"node":">= 0.6.0"},"readme":"# Lactate\n\n`npm install -g lactate`\n\nAn exceedingly fast static file handler, with a few electives.\n\n### Features\n\n* In-memory caching\n* Redis caching\n* Robust cache-control setting\n* Automatic gzipping\n* Automatic minification\n* Custom 404 pages\n* Custom response headers\n* Asset bundling and minification\n* Middleware export\n* Default error pages\n* on(status) listeners\n* Colored log output\n* Global executable\n* Directory indexing\n* Express.static API compatibility\n* node-static API compatibility\n\n## Using Lactate\n\n### Global executable\n\nIf installed globally with `npm install -g lactate`, you will have the `lactate` command at your disposal. This will run lactate static file server in the current working directory, utilizing the `cluster` module for multiple CPU cores. All [options](https://github.com/Weltschmerz/Lactate#options) are available.\n\n```code\n$ lactate --help\nUsage: lactate [options]\n\nOptions:\n--root, -r                    Local path                          [default: \"\"]\n--from, -f                    Public path                         [default: \"\"]\n--subdirs, -s                 Serve subdirectories                [default: true]\n--hidden, -h                  Serve hidden files                  [default: false]\n--error_pages, --error-pages  Serve error pages                   [default: true]\n--autoindex, -a               Automatically index directories     [default: true]\n--cache, -c                   Store assets in-memory              [default: true]\n--redis_cache, --rc           Store assets in-memory using Redis  [default: true]\n--watch_files, --watch-files  Watch files for cache update        [default: true]\n--max_age, --max-age, -M      Client-side caching max-age         [default: 172800]\n--gzip, -g                    Gzip text assets                    [default: true]\n--minify, -m                  Minify text assets                  [default: false]\n--bundle, -b                  Bundle text assets                  [default: false]\n--rebundle, --rb              Rebundle assets if modified         [default: true]\n--headers, -H                 Custom response headers             [default: \"\"]\n--debug, -d                   Log HTTP info                       [default: true]\n--quiet, -q                   Prevent all log output              [default: false]\n\n```\n\n### Programmatic lactating\n\nLactate can be used with either plain node, or with Express. With Express, Lactate is a drop-in replacement for `static` middleware, but with far more ability. The examples below use Express 2.x API for simplicity. See the [examples](https://github.com/Weltschmerz/Lactate/tree/master/example) for various examples.\n\n```js\nvar lactate = require('lactate');\nvar express = require('express');\n\nvar app = express.createServer();\napp.use(lactate.static(__dirname + '/files'));\n```\n\n## Testing Lactate\n\nIf installed locally (without -g flag to npm install):\n\n1. `cd` into `~/node_modules/lactate`\n2. `npm install ./` to install devDependencies\n3. `make test` to run mocha test\n\n##The varieties of Lactate experience\n\n###Creating a Lactate server\n\n```js\nvar lactate = require('lactate'); \nvar options = {root:'files'}; \nvar server = lactate.createServer(options); \n\nserver.listen(8080);\n```\n\n###Creating a directory handler\n\n```js\nvar lactate = require('lactate');\nvar options = {from:'public/path/to/files'};\nvar files = lactate.dir('files', options);\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', function(req, res) {\n  files.serve(req, res);\n});\n\nserver.listen(8080);\n```\n\n###Using directory middleware\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files', options);\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', files.toMiddleware());\nserver.listen(8080);\n```\n\n###Integrating with Express\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files', options);\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8080);\n```\n\n###Using Express.static API\n\n```js\nvar lactate = require('lactate');\nvar express = require('express');\nvar app = express();\n\napp.use(lactate.static(__dirname + '/files'));\napp.listen(8000);\n```\n\n###Using node-static API\n\n```js\nvar lactate = require('lactate');\nvar files = new(lactate.Server)('./files');\n\nvar http = require('http');\nvar server = new http.Server;\n\n// You could also pass a .toMiddleware()'d function\n\nserver.addListener('request', function(req, res) {\n  files.serve(req, res);\n});\n\nserver.listen(8000);\n```\n\n###Serving individual files\n\n```js\nvar lactate = require('lactate');\n\nvar fileOptions = {from:'public/directory'};\nvar files = lactate.dir('files', fileOptions);\n\nvar pageOptions = {};\nvar pages = lactate.dir('pages');\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', function(req, res) {\n  if (req.url === '/') {\n    pages.serve('index.html', req, res);\n  } else {\n    files.serve(req, res);\n  };\n});\n```\n\n###Setting options\n\n```js\nvar lactate = require('lactate');\n\nvar fileOptions = {\n  from:'public'\n};\n\nvar files = lactate.dir('files', fileOptions);\n\nfiles.set('cache', false);\nfiles.disable('gzip');\nfiles.maxAge('ten days');\n\nvar express = require('express');\nvar app = express():\n  \napp.get('/public/*', files.toMiddleware());\napp.listen(8080);\n```\n\n###Bundling assets\n\n```js\nvar lactate = require('lactate');\nvar options = {\n  from:'files'\n};\n\nvar files = lactate.dir('files', options);\n\n// Combine and minify all scripts to 'common.js'\nfiles.bundle('js', 'common.js', function(err, data) {\n// Handle errors\n});\n\n// Combine and minify all CSS to 'common.css'\nfiles.bundleCSS('common.css');\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8000);\n```\n\n###Using custom 404 pages\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files');\n\nfiles.notFound('path/to/404/page.html');\n\nfiles.notFound(function(req, res) {\n  res.writeHead(404);\n  res.end('Woops, 404');\n});\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8000);\n```\n\n###Using custom response headers\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files');\n\nfiles.setHeader('x-powered-by', 'Lactate');\nfiles.header('x-timestamp', function(req, res) {\n  return new Date().toUTCString();\n});\n\nvar headers = {};\nfiles.headers(headers);\n```\n\n###Status listeners\n\nLactate extends EventEmitter for emitting status code events. Codes Lactate is aware of are:\n\n* `200` *OK*\n* `304` *Not Modified*\n* `400` *Bad Request*\n* `403` *Forbidden*\n* `404` *Not Found*\n* `405` *Method Not Allowed*\n* `500` *Internal Error*\n\nCallbacks are given an object which has the following properties:\n\n* `url` The requested URL\n* `method` The request method (GET, HEAD)\n* `headers` Request headers\n* `address` Request IP address\n* `port` Request port\n* `path` Absolute file path to the requested file, if it exists\n* `msg` HTTP satus message\n\n```js\nvar files = lactate.dir('files', {});\nfiles.on('404', function(req) {\n  console.log('404', req.url);\n});\n```\n\n##Options\n\n### Setting options\n\nBoolean options may be set using `enable` and `disable` methods. Other options may be set using `set` method with either key/value or an options object.\n\n**Passing to initialization function**\n\n```js\nvar lactate = require('lactate').Lactate({\n  max_age:'two days'\n})\n```\n\n**Using `set` method**\n\n```js\nlactate.set('hidden', true)\n```\n\n**Using enable/disable:**\n\n```js\nlactate.disable('gzip');\nlactate.enable('minify');\n```\n\n**Special options methods**\n\nLactate has some special methods to reduce visual clutter:\n\n```js\nlactate.maxAge('two days');\n```\n\nis equivalent to:\n\n```js\nlactate.set('max_age', 'two days');\n```\n\nSimilarly, the `headers` method is for setting custom response headers. \n\n**Underscores or spaces**\n\nUse spaces instead of underscores if you prefer:\n\n```js\nlactate.disable('max age');\nlactate.enable('watch files');\n```\n\n### Options available\n\n+ `root` **string**\n\nLocal directory from which to serve files. By default, the current working directory.\n\n+ `from` **string**\n\nPublic directory exposed to clients. If set, only requests from /*directory* will complete. Contrast this with the `root` option which is the location of files on the serving machine, not necessarily the requested path.\n\n+ `subdirs` **boolean**\n\nBy default subdirectories are served. To disable this, set `subdirs` to false.\n\n+ `hidden` **boolean**\n\nWhether or not to serve hidden files. Default is false.\n\n+ `error pages` **boolean**\n\nEnabled by default. When disabled, Lactate will not serve error pages for 404 resposes, etc..\n\n+ `autoindex` **boolean**\n\nAutomatically display directory indexes. Disabled by default.\n\n+ `cache` **boolean** or **object**\n\nKeep files in-memory. Enabled by default. For caching options and more information about caching strategy, see [Caching Options](https://github.com/Weltschmerz/Lactate#caching-options).\n\n+ `gzip` **boolean**\n\nIf false, disables automatic gzipping for text files (HTML, JS, CSS). Enabled by default.\n\n+ `minify` **boolean**\n\nIf true, will automatically minify JavaScript and CSS using [Abridge](https://github.com/Weltschmerz/Abridge). Disabled by default.\n\n+ `watch files` **boolean**\n\nDetermines whether Lactate will watch files to update its cache. If this is disabled, then your file cache will not update automatically as files are modified on the server.\n\n+ `headers` **object** or **function**\n\nSets custom response headers. If the option value is a function, it is a callback which is give (req, res) arguments. This function should return the header value; it is a mapping function.\n\n+ `max age` **number** or **string**\n\nPass this function a number (of seconds) or a string and appropriate headers will be set for client-side caching. Lactate comes with expiration defaults, such as 'two days' or '5 years and sixteen days' See [Expire](https://github.com/Weltschmerz/Expire) for details.\n\n```js\nlactate.set('max_age', 87500)\n//87500 seconds\nlactate.set('max_age', 'two days')\n//172800 seconds\nlactate.set'max_age', 'five weeks and one minute and ten seconds')\n//3024070 seconds\nlactate.set('max_age', 'one year and 2 months and seven weeks and 16 seconds')\n//41050028 seconds\n```\n\n+ `not found` **string** or **function**\n\nFor custom 404 handling. Functions are supplied the response for 100% custom response handling. Otherwise, if set to a string, this option will be treated as an ordinary file path and abide rules for gzipping / in-memory cache.\n\n+ `debug` **boolean**\n\nColored status / msg / path logging, for debugging purposes.\n\n###Caching options\n\nPass an object to the `cache` option setting. The following fields are accepted and optional:\n\n* `expire` Seconds expiration for cache keys. Keys expire after they are untouched for x-seconds. Default is `15min`.\n* `max keys` Maximum number of keys to keep in memory. Default is `Infinity`.\n* `max size` Maximum size in MB to keep in cache. Default is `100mb`.\n* `segment` Determines the threshold after which to segment a file for streaming instead of traditional writing. Default is `200kb`.\n\n```js\n  var options = {};\n  \n  options.cache = {\n    expire:5,\n    max_keys:200,\n    max_size:2,\n    segment:100\n  };\n\n  var files = lactate.static('files', options);\n\n  // Or use a string representation. Same as setting for max-age.\n  options.cache.expire = 'fifteen minutes';\n  files.set('cache', options.cache);\n```\n\n\n## License\n\nMIT\n\n","_id":"lactate@0.12.9","dist":{"shasum":"fa7cff1d81fe0782b9cb1036c5408f4144230c7c","tarball":"https://registry.npmjs.org/lactate/-/lactate-0.12.9.tgz","integrity":"sha512-n+QZpG0uorTRPNRCXTLzYtGlplk3dws53eyOMjCK24xUyVpSwY+H0ONM2m7tHlzcPYCpoI+ivuiRFLmr1q+6QQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDYe7Y03nkAdSSKQa7ZwBmxXMgZxKnwR/diuKq2OinjjwIgWS66hXaNbyVE0g0qpqmmwrJMM6K8ctlEQGmwUpwLhk8="}]},"_npmVersion":"1.1.62","_npmUser":{"name":"Weltschmerz","email":"chlavois@gmail.com"},"maintainers":[{"name":"Weltschmerz","email":"chlavois@gmail.com"}],"directories":{}},"0.12.10":{"name":"lactate","version":"0.12.10","description":"Simple and featureful assets server","keywords":["static","file","server","assets","cache"],"repository":{"type":"git","url":"git://github.com/Weltschmerz/Lactate.git"},"author":{"name":"Weltschmerz","email":"chlavois@gmail.com"},"dependencies":{"mime":"1.2.7","suckle":"latest","expire":"latest","abridge":"latest","fraction":"latest","optimist":"0.3.5","redis":"0.8.2"},"devDependencies":{"mocha":"1.7.1","should":"1.2.1"},"main":"index.js","bin":{"lactate":"bin/lactate"},"scripts":{"test":"make test"},"engines":{"node":">= 0.6.0"},"readme":"# Lactate\n\n`npm install -g lactate`\n\nAn exceedingly fast static file handler, with a few electives.\n\n### Features\n\n* In-memory caching\n* Redis caching\n* Robust cache-control setting\n* Automatic gzipping\n* Automatic minification\n* Custom 404 pages\n* Custom response headers\n* Asset bundling and minification\n* Middleware export\n* Default error pages\n* on(status) listeners\n* Colored log output\n* Global executable\n* Directory indexing\n* Express.static API compatibility\n* node-static API compatibility\n\n## Using Lactate\n\n### Global executable\n\nIf installed globally with `npm install -g lactate`, you will have the `lactate` command at your disposal. This will run lactate static file server in the current working directory, utilizing the `cluster` module for multiple CPU cores. All [options](https://github.com/Weltschmerz/Lactate#options) are available.\n\n```code\n$ lactate --help\nUsage: lactate [options]\n\nOptions:\n--root, -r                    Local path                          [default: \"\"]\n--from, -f                    Public path                         [default: \"\"]\n--subdirs, -s                 Serve subdirectories                [default: true]\n--hidden, -h                  Serve hidden files                  [default: false]\n--error_pages, --error-pages  Serve error pages                   [default: true]\n--autoindex, -a               Automatically index directories     [default: true]\n--cache, -c                   Store assets in-memory              [default: true]\n--redis_cache, --rc           Store assets in-memory using Redis  [default: true]\n--watch_files, --watch-files  Watch files for cache update        [default: true]\n--max_age, --max-age, -M      Client-side caching max-age         [default: 172800]\n--gzip, -g                    Gzip text assets                    [default: true]\n--minify, -m                  Minify text assets                  [default: false]\n--bundle, -b                  Bundle text assets                  [default: false]\n--rebundle, --rb              Rebundle assets if modified         [default: true]\n--headers, -H                 Custom response headers             [default: \"\"]\n--debug, -d                   Log HTTP info                       [default: true]\n--quiet, -q                   Prevent all log output              [default: false]\n\n```\n\n### Programmatic lactating\n\nLactate can be used with either plain node, or with Express. With Express, Lactate is a drop-in replacement for `static` middleware, but with far more ability. The examples below use Express 2.x API for simplicity. See the [examples](https://github.com/Weltschmerz/Lactate/tree/master/example) for various examples.\n\n```js\nvar lactate = require('lactate');\nvar express = require('express');\n\nvar app = express.createServer();\napp.use(lactate.static(__dirname + '/files'));\n```\n\n## Testing Lactate\n\nIf installed locally (without -g flag to npm install):\n\n1. `cd` into `~/node_modules/lactate`\n2. `npm install ./` to install devDependencies\n3. `make test` to run mocha test\n\n##The varieties of Lactate experience\n\n###Creating a Lactate server\n\n```js\nvar lactate = require('lactate'); \nvar options = {root:'files'}; \nvar server = lactate.createServer(options); \n\nserver.listen(8080);\n```\n\n###Creating a directory handler\n\n```js\nvar lactate = require('lactate');\nvar options = {from:'public/path/to/files'};\nvar files = lactate.dir('files', options);\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', function(req, res) {\n  files.serve(req, res);\n});\n\nserver.listen(8080);\n```\n\n###Using directory middleware\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files', options);\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', files.toMiddleware());\nserver.listen(8080);\n```\n\n###Integrating with Express\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files', options);\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8080);\n```\n\n###Using Express.static API\n\n```js\nvar lactate = require('lactate');\nvar express = require('express');\nvar app = express();\n\napp.use(lactate.static(__dirname + '/files'));\napp.listen(8000);\n```\n\n###Using node-static API\n\n```js\nvar lactate = require('lactate');\nvar files = new(lactate.Server)('./files');\n\nvar http = require('http');\nvar server = new http.Server;\n\n// You could also pass a .toMiddleware()'d function\n\nserver.addListener('request', function(req, res) {\n  files.serve(req, res);\n});\n\nserver.listen(8000);\n```\n\n###Serving individual files\n\n```js\nvar lactate = require('lactate');\n\nvar fileOptions = {from:'public/directory'};\nvar files = lactate.dir('files', fileOptions);\n\nvar pageOptions = {};\nvar pages = lactate.dir('pages');\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', function(req, res) {\n  if (req.url === '/') {\n    pages.serve('index.html', req, res);\n  } else {\n    files.serve(req, res);\n  };\n});\n```\n\n###Setting options\n\n```js\nvar lactate = require('lactate');\n\nvar fileOptions = {\n  from:'public'\n};\n\nvar files = lactate.dir('files', fileOptions);\n\nfiles.set('cache', false);\nfiles.disable('gzip');\nfiles.maxAge('ten days');\n\nvar express = require('express');\nvar app = express():\n  \napp.get('/public/*', files.toMiddleware());\napp.listen(8080);\n```\n\n###Bundling assets\n\n```js\nvar lactate = require('lactate');\nvar options = {\n  from:'files'\n};\n\nvar files = lactate.dir('files', options);\n\n// Combine and minify all scripts to 'common.js'\nfiles.bundle('js', 'common.js', function(err, data) {\n// Handle errors\n});\n\n// Combine and minify all CSS to 'common.css'\nfiles.bundleCSS('common.css');\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8000);\n```\n\n###Using custom 404 pages\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files');\n\nfiles.notFound('path/to/404/page.html');\n\nfiles.notFound(function(req, res) {\n  res.writeHead(404);\n  res.end('Woops, 404');\n});\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8000);\n```\n\n###Using custom response headers\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files');\n\nfiles.setHeader('x-powered-by', 'Lactate');\nfiles.header('x-timestamp', function(req, res) {\n  return new Date().toUTCString();\n});\n\nvar headers = {};\nfiles.headers(headers);\n```\n\n###Status listeners\n\nLactate extends EventEmitter for emitting status code events. Codes Lactate is aware of are:\n\n* `200` *OK*\n* `304` *Not Modified*\n* `400` *Bad Request*\n* `403` *Forbidden*\n* `404` *Not Found*\n* `405` *Method Not Allowed*\n* `500` *Internal Error*\n\nCallbacks are given an object which has the following properties:\n\n* `url` The requested URL\n* `method` The request method (GET, HEAD)\n* `headers` Request headers\n* `address` Request IP address\n* `port` Request port\n* `path` Absolute file path to the requested file, if it exists\n* `msg` HTTP satus message\n\n```js\nvar files = lactate.dir('files', {});\nfiles.on('404', function(req) {\n  console.log('404', req.url);\n});\n```\n\n##Options\n\n### Setting options\n\nBoolean options may be set using `enable` and `disable` methods. Other options may be set using `set` method with either key/value or an options object.\n\n**Passing to initialization function**\n\n```js\nvar lactate = require('lactate').Lactate({\n  max_age:'two days'\n})\n```\n\n**Using `set` method**\n\n```js\nlactate.set('hidden', true)\n```\n\n**Using enable/disable:**\n\n```js\nlactate.disable('gzip');\nlactate.enable('minify');\n```\n\n**Special options methods**\n\nLactate has some special methods to reduce visual clutter:\n\n```js\nlactate.maxAge('two days');\n```\n\nis equivalent to:\n\n```js\nlactate.set('max_age', 'two days');\n```\n\nSimilarly, the `headers` method is for setting custom response headers. \n\n**Underscores or spaces**\n\nUse spaces instead of underscores if you prefer:\n\n```js\nlactate.disable('max age');\nlactate.enable('watch files');\n```\n\n### Options available\n\n+ `root` **string**\n\nLocal directory from which to serve files. By default, the current working directory.\n\n+ `from` **string**\n\nPublic directory exposed to clients. If set, only requests from /*directory* will complete. Contrast this with the `root` option which is the location of files on the serving machine, not necessarily the requested path.\n\n+ `subdirs` **boolean**\n\nBy default subdirectories are served. To disable this, set `subdirs` to false.\n\n+ `hidden` **boolean**\n\nWhether or not to serve hidden files. Default is false.\n\n+ `error pages` **boolean**\n\nEnabled by default. When disabled, Lactate will not serve error pages for 404 resposes, etc..\n\n+ `autoindex` **boolean**\n\nAutomatically display directory indexes. Disabled by default.\n\n+ `cache` **boolean** or **object**\n\nKeep files in-memory. Enabled by default. For caching options and more information about caching strategy, see [Caching Options](https://github.com/Weltschmerz/Lactate#caching-options).\n\n+ `gzip` **boolean**\n\nIf false, disables automatic gzipping for text files (HTML, JS, CSS). Enabled by default.\n\n+ `minify` **boolean**\n\nIf true, will automatically minify JavaScript and CSS using [Abridge](https://github.com/Weltschmerz/Abridge). Disabled by default.\n\n+ `watch files` **boolean**\n\nDetermines whether Lactate will watch files to update its cache. If this is disabled, then your file cache will not update automatically as files are modified on the server.\n\n+ `headers` **object** or **function**\n\nSets custom response headers. If the option value is a function, it is a callback which is give (req, res) arguments. This function should return the header value; it is a mapping function.\n\n+ `max age` **number** or **string**\n\nPass this function a number (of seconds) or a string and appropriate headers will be set for client-side caching. Lactate comes with expiration defaults, such as 'two days' or '5 years and sixteen days' See [Expire](https://github.com/Weltschmerz/Expire) for details.\n\n```js\nlactate.set('max_age', 87500)\n//87500 seconds\nlactate.set('max_age', 'two days')\n//172800 seconds\nlactate.set'max_age', 'five weeks and one minute and ten seconds')\n//3024070 seconds\nlactate.set('max_age', 'one year and 2 months and seven weeks and 16 seconds')\n//41050028 seconds\n```\n\n+ `not found` **string** or **function**\n\nFor custom 404 handling. Functions are supplied the response for 100% custom response handling. Otherwise, if set to a string, this option will be treated as an ordinary file path and abide rules for gzipping / in-memory cache.\n\n+ `debug` **boolean**\n\nColored status / msg / path logging, for debugging purposes.\n\n###Caching options\n\nPass an object to the `cache` option setting. The following fields are accepted and optional:\n\n* `expire` Seconds expiration for cache keys. Keys expire after they are untouched for x-seconds. Default is `15min`.\n* `max keys` Maximum number of keys to keep in memory. Default is `Infinity`.\n* `max size` Maximum size in MB to keep in cache. Default is `100mb`.\n* `segment` Determines the threshold after which to segment a file for streaming instead of traditional writing. Default is `200kb`.\n\n```js\n  var options = {};\n  \n  options.cache = {\n    expire:5,\n    max_keys:200,\n    max_size:2,\n    segment:100\n  };\n\n  var files = lactate.static('files', options);\n\n  // Or use a string representation. Same as setting for max-age.\n  options.cache.expire = 'fifteen minutes';\n  files.set('cache', options.cache);\n```\n\n\n## License\n\nMIT\n\n","_id":"lactate@0.12.10","dist":{"shasum":"3c5c284c166328a6f2c379d3b5f6de9422db70ec","tarball":"https://registry.npmjs.org/lactate/-/lactate-0.12.10.tgz","integrity":"sha512-Zu4CAn08L41DhAdK5pwlAbFsgTuFI89SZXYzPi64N/yofmD04Y5194c5alyT197dIKHScQBKFzohUtAhf7lyFQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDkiPbPZtMyWiHsQ66hXR57g1F/pyzkG28WRt9athvNyQIgSSvZnpI8cw01mLbswA2U6MCgiwwUaRkYcc4rfKBcB7k="}]},"_npmVersion":"1.1.62","_npmUser":{"name":"Weltschmerz","email":"chlavois@gmail.com"},"maintainers":[{"name":"Weltschmerz","email":"chlavois@gmail.com"}],"directories":{}},"0.12.11":{"name":"lactate","version":"0.12.11","description":"Simple and featureful assets server","keywords":["static","file","server","assets","cache"],"repository":{"type":"git","url":"git://github.com/Weltschmerz/Lactate.git"},"author":{"name":"Weltschmerz","email":"wltsmrz@gmail.com"},"dependencies":{"mime":"1.2.7","suckle":"latest","expire":"latest","abridge":"latest","fraction":"latest","optimist":"0.3.5","redis":"0.8.2"},"devDependencies":{"mocha":"1.7.4","should":"1.2.1"},"main":"index.js","bin":{"lactate":"bin/lactate"},"scripts":{"test":"make test"},"engines":{"node":">= 0.6.0"},"readme":"# Lactate\n\n`npm install -g lactate`\n\nAn exceedingly fast static file handler, with a few electives.\n\n### Features\n\n* In-memory caching\n* Redis caching\n* Robust cache-control setting\n* Automatic gzipping\n* Automatic minification\n* Custom 404 pages\n* Custom response headers\n* Asset bundling and minification\n* Middleware export\n* Default error pages\n* on(status) listeners\n* Colored log output\n* Global executable\n* Directory indexing\n* Express.static API compatibility\n* node-static API compatibility\n\n## Using Lactate\n\n### Global executable\n\nIf installed globally with `npm install -g lactate`, you will have the `lactate` command at your disposal. This will run lactate static file server in the current working directory, utilizing the `cluster` module for multiple CPU cores. All [options](https://github.com/Weltschmerz/Lactate#options) are available.\n\n```code\n$ lactate --help\nUsage: lactate [options]\n\nOptions:\n--root, -r                    Local path                          [default: \"\"]\n--from, -f                    Public path                         [default: \"\"]\n--subdirs, -s                 Serve subdirectories                [default: true]\n--hidden, -h                  Serve hidden files                  [default: false]\n--error_pages, --error-pages  Serve error pages                   [default: true]\n--autoindex, -a               Automatically index directories     [default: true]\n--cache, -c                   Store assets in-memory              [default: true]\n--redis_cache, --rc           Store assets in-memory using Redis  [default: true]\n--watch_files, --watch-files  Watch files for cache update        [default: true]\n--max_age, --max-age, -M      Client-side caching max-age         [default: 172800]\n--gzip, -g                    Gzip text assets                    [default: true]\n--minify, -m                  Minify text assets                  [default: false]\n--bundle, -b                  Bundle text assets                  [default: false]\n--rebundle, --rb              Rebundle assets if modified         [default: true]\n--headers, -H                 Custom response headers             [default: \"\"]\n--debug, -d                   Log HTTP info                       [default: true]\n--quiet, -q                   Prevent all log output              [default: false]\n\n```\n\n### Programmatic lactating\n\nLactate can be used with either plain node, or with Express. With Express, Lactate is a drop-in replacement for `static` middleware, but with far more ability. The examples below use Express 2.x API for simplicity. See the [examples](https://github.com/Weltschmerz/Lactate/tree/master/example) for various examples.\n\n```js\nvar lactate = require('lactate');\nvar express = require('express');\n\nvar app = express.createServer();\napp.use(lactate.static(__dirname + '/files'));\n```\n\n## Testing Lactate\n\nIf installed locally (without -g flag to npm install):\n\n1. `cd` into `~/node_modules/lactate`\n2. `npm install ./` to install devDependencies\n3. `make test` to run mocha test\n\n##The varieties of Lactate experience\n\n###Creating a Lactate server\n\n```js\nvar lactate = require('lactate'); \nvar options = {root:'files'}; \nvar server = lactate.createServer(options); \n\nserver.listen(8080);\n```\n\n###Creating a directory handler\n\n```js\nvar lactate = require('lactate');\nvar options = {from:'public/path/to/files'};\nvar files = lactate.dir('files', options);\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', function(req, res) {\n  files.serve(req, res);\n});\n\nserver.listen(8080);\n```\n\n###Using directory middleware\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files', options);\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', files.toMiddleware());\nserver.listen(8080);\n```\n\n###Integrating with Express\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files', options);\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8080);\n```\n\n###Using Express.static API\n\n```js\nvar lactate = require('lactate');\nvar express = require('express');\nvar app = express();\n\napp.use(lactate.static(__dirname + '/files'));\napp.listen(8000);\n```\n\n###Using node-static API\n\n```js\nvar lactate = require('lactate');\nvar files = new(lactate.Server)('./files');\n\nvar http = require('http');\nvar server = new http.Server;\n\n// You could also pass a .toMiddleware()'d function\n\nserver.addListener('request', function(req, res) {\n  files.serve(req, res);\n});\n\nserver.listen(8000);\n```\n\n###Serving individual files\n\n```js\nvar lactate = require('lactate');\n\nvar fileOptions = {from:'public/directory'};\nvar files = lactate.dir('files', fileOptions);\n\nvar pageOptions = {};\nvar pages = lactate.dir('pages');\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', function(req, res) {\n  if (req.url === '/') {\n    pages.serve('index.html', req, res);\n  } else {\n    files.serve(req, res);\n  };\n});\nserver.listen(8000);\n```\n\n###Setting options\n\n```js\nvar lactate = require('lactate');\n\nvar fileOptions = {\n  from:'public'\n};\n\nvar files = lactate.dir('files', fileOptions);\n\nfiles.set('cache', false);\nfiles.disable('gzip');\nfiles.maxAge('ten days');\n\nvar express = require('express');\nvar app = express():\n  \napp.get('/public/*', files.toMiddleware());\napp.listen(8080);\n```\n\n###Bundling assets\n\n```js\nvar lactate = require('lactate');\nvar options = {\n  from:'files'\n};\n\nvar files = lactate.dir('files', options);\n\n// Combine and minify all scripts to 'common.js'\nfiles.bundle('js', 'common.js', function(err, data) {\n// Handle errors\n});\n\n// Combine and minify all CSS to 'common.css'\nfiles.bundleCSS('common.css');\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8000);\n```\n\n###Using custom 404 pages\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files');\n\nfiles.notFound('path/to/404/page.html');\n\nfiles.notFound(function(req, res) {\n  res.writeHead(404);\n  res.end('Woops, 404');\n});\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8000);\n```\n\n###Using custom response headers\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files');\n\nfiles.setHeader('x-powered-by', 'Lactate');\nfiles.header('x-timestamp', function(req, res) {\n  return new Date().toUTCString();\n});\n\nvar headers = {};\nfiles.headers(headers);\n```\n\n###Status listeners\n\nLactate extends EventEmitter for emitting status code events. Codes Lactate is aware of are:\n\n* `200` *OK*\n* `304` *Not Modified*\n* `400` *Bad Request*\n* `403` *Forbidden*\n* `404` *Not Found*\n* `405` *Method Not Allowed*\n* `500` *Internal Error*\n\nCallbacks are given an object which has the following properties:\n\n* `url` The requested URL\n* `method` The request method (GET, HEAD)\n* `headers` Request headers\n* `address` Request IP address\n* `port` Request port\n* `path` Absolute file path to the requested file, if it exists\n* `msg` HTTP satus message\n\n```js\nvar files = lactate.dir('files', {});\nfiles.on('404', function(req) {\n  console.log('404', req.url);\n});\n```\n\n##Options\n\n### Setting options\n\nBoolean options may be set using `enable` and `disable` methods. Other options may be set using `set` method with either key/value or an options object.\n\n**Passing to initialization function**\n\n```js\nvar lactate = require('lactate').Lactate({\n  max_age:'two days'\n})\n```\n\n**Using `set` method**\n\n```js\nlactate.set('hidden', true)\n```\n\n**Using enable/disable:**\n\n```js\nlactate.disable('gzip');\nlactate.enable('minify');\n```\n\n**Special options methods**\n\nLactate has some special methods to reduce visual clutter:\n\n```js\nlactate.maxAge('two days');\n```\n\nis equivalent to:\n\n```js\nlactate.set('max_age', 'two days');\n```\n\nSimilarly, the `headers` method is for setting custom response headers. \n\n**Underscores or spaces**\n\nUse spaces instead of underscores if you prefer:\n\n```js\nlactate.disable('max age');\nlactate.enable('watch files');\n```\n\n### Options available\n\n+ `root` **string**\n\nLocal directory from which to serve files. By default, the current working directory.\n\n+ `from` **string**\n\nPublic directory exposed to clients. If set, only requests from /*directory* will complete. Contrast this with the `root` option which is the location of files on the serving machine, not necessarily the requested path.\n\n+ `subdirs` **boolean**\n\nBy default subdirectories are served. To disable this, set `subdirs` to false.\n\n+ `hidden` **boolean**\n\nWhether or not to serve hidden files. Default is false.\n\n+ `error pages` **boolean**\n\nEnabled by default. When disabled, Lactate will not serve error pages for 404 resposes, etc..\n\n+ `autoindex` **boolean**\n\nAutomatically display directory indexes. Disabled by default.\n\n+ `cache` **boolean** or **object**\n\nKeep files in-memory. Enabled by default. For caching options and more information about caching strategy, see [Caching Options](https://github.com/Weltschmerz/Lactate#caching-options).\n\n+ `gzip` **boolean**\n\nIf false, disables automatic gzipping for text files (HTML, JS, CSS). Enabled by default.\n\n+ `minify` **boolean**\n\nIf true, will automatically minify JavaScript and CSS using [Abridge](https://github.com/Weltschmerz/Abridge). Disabled by default.\n\n+ `watch files` **boolean**\n\nDetermines whether Lactate will watch files to update its cache. If this is disabled, then your file cache will not update automatically as files are modified on the server.\n\n+ `headers` **object** or **function**\n\nSets custom response headers. If the option value is a function, it is a callback which is give (req, res) arguments. This function should return the header value; it is a mapping function.\n\n+ `max age` **number** or **string**\n\nPass this function a number (of seconds) or a string and appropriate headers will be set for client-side caching. Lactate comes with expiration defaults, such as 'two days' or '5 years and sixteen days' See [Expire](https://github.com/Weltschmerz/Expire) for details.\n\n```js\nlactate.set('max_age', 87500)\n//87500 seconds\nlactate.set('max_age', 'two days')\n//172800 seconds\nlactate.set'max_age', 'five weeks and one minute and ten seconds')\n//3024070 seconds\nlactate.set('max_age', 'one year and 2 months and seven weeks and 16 seconds')\n//41050028 seconds\n```\n\n+ `not found` **string** or **function**\n\nFor custom 404 handling. Functions are supplied the response for 100% custom response handling. Otherwise, if set to a string, this option will be treated as an ordinary file path and abide rules for gzipping / in-memory cache.\n\n+ `debug` **boolean**\n\nColored status / msg / path logging, for debugging purposes.\n\n###Caching options\n\nPass an object to the `cache` option setting. The following fields are accepted and optional:\n\n* `expire` Seconds expiration for cache keys. Keys expire after they are untouched for x-seconds. Default is `15min`.\n* `max keys` Maximum number of keys to keep in memory. Default is `Infinity`.\n* `max size` Maximum size in MB to keep in cache. Default is `100mb`.\n* `segment` Determines the threshold after which to segment a file for streaming instead of traditional writing. Default is `200kb`.\n\n```js\n  var options = {};\n  \n  options.cache = {\n    expire:5,\n    max_keys:200,\n    max_size:2,\n    segment:100\n  };\n\n  var files = lactate.static('files', options);\n\n  // Or use a string representation. Same as setting for max-age.\n  options.cache.expire = 'fifteen minutes';\n  files.set('cache', options.cache);\n```\n\n\n## License\n\nMIT\n\n","_id":"lactate@0.12.11","dist":{"shasum":"86d1f16fd452840b5403baee7fa5bc775fa6e8d9","tarball":"https://registry.npmjs.org/lactate/-/lactate-0.12.11.tgz","integrity":"sha512-MLaZfrkYjG/kwlOHeHebS9KlRrtpH3TWrN0xLcQXly6+D/cLpk8lDKmPm35eQOrXfjDt/JAdpTLBqVrlweq5UA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIE/UK9qy4Jeywm7hmxu12F9ywJgmHryP/wwBCz9i56/xAiAfzcyH0OccWXBaWGaiptSwJKjesX4/LORMwChS0ZR5TQ=="}]},"_npmVersion":"1.1.62","_npmUser":{"name":"Weltschmerz","email":"chlavois@gmail.com"},"maintainers":[{"name":"Weltschmerz","email":"chlavois@gmail.com"}],"directories":{}},"0.12.12":{"name":"lactate","version":"0.12.12","description":"Simple and featureful assets server","keywords":["static","file","server","assets","cache"],"repository":{"type":"git","url":"git://github.com/Weltschmerz/Lactate.git"},"author":{"name":"Weltschmerz","email":"wltsmrz@gmail.com"},"dependencies":{"mime":"1.2.7","suckle":"latest","expire":"latest","abridge":"latest","fraction":"latest","optimist":"0.3.5","redis":"0.8.2"},"devDependencies":{"mocha":"1.7.4","should":"1.2.1"},"main":"index.js","bin":{"lactate":"bin/lactate"},"scripts":{"test":"make test"},"engines":{"node":">= 0.6.0"},"readme":"# Lactate\n\n`npm install -g lactate`\n\nAn exceedingly fast static file handler, with a few electives.\n\n### Features\n\n* In-memory caching\n* Redis caching\n* Robust cache-control setting\n* Automatic gzipping\n* Automatic minification\n* Custom 404 pages\n* Custom response headers\n* Asset bundling and minification\n* Middleware export\n* Default error pages\n* on(status) listeners\n* Colored log output\n* Global executable\n* Directory indexing\n* Express.static API compatibility\n* node-static API compatibility\n\n## Using Lactate\n\n### Global executable\n\nIf installed globally with `npm install -g lactate`, you will have the `lactate` command at your disposal. This will run lactate static file server in the current working directory, utilizing the `cluster` module for multiple CPU cores. All [options](https://github.com/Weltschmerz/Lactate#options) are available.\n\n```code\n$ lactate --help\nUsage: lactate [options]\n\nOptions:\n--root, -r                    Local path                          [default: \"\"]\n--from, -f                    Public path                         [default: \"\"]\n--subdirs, -s                 Serve subdirectories                [default: true]\n--hidden, -h                  Serve hidden files                  [default: false]\n--error_pages, --error-pages  Serve error pages                   [default: true]\n--autoindex, -a               Automatically index directories     [default: true]\n--cache, -c                   Store assets in-memory              [default: true]\n--redis_cache, --rc           Store assets in-memory using Redis  [default: true]\n--watch_files, --watch-files  Watch files for cache update        [default: true]\n--max_age, --max-age, -M      Client-side caching max-age         [default: 172800]\n--gzip, -g                    Gzip text assets                    [default: true]\n--minify, -m                  Minify text assets                  [default: false]\n--bundle, -b                  Bundle text assets                  [default: false]\n--rebundle, --rb              Rebundle assets if modified         [default: true]\n--headers, -H                 Custom response headers             [default: \"\"]\n--debug, -d                   Log HTTP info                       [default: true]\n--quiet, -q                   Prevent all log output              [default: false]\n\n```\n\n### Programmatic lactating\n\nLactate can be used with either plain node, or with Express. With Express, Lactate is a drop-in replacement for `static` middleware, but with far more ability. The examples below use Express 2.x API for simplicity. See the [examples](https://github.com/Weltschmerz/Lactate/tree/master/example) for various examples.\n\n```js\nvar lactate = require('lactate');\nvar express = require('express');\n\nvar app = express.createServer();\napp.use(lactate.static(__dirname + '/files'));\n```\n\n## Testing Lactate\n\nIf installed locally (without -g flag to npm install):\n\n1. `cd` into `~/node_modules/lactate`\n2. `npm install ./` to install devDependencies\n3. `make test` to run mocha test\n\n##The varieties of Lactate experience\n\n###Creating a Lactate server\n\n```js\nvar lactate = require('lactate'); \nvar options = {root:'files'}; \nvar server = lactate.createServer(options); \n\nserver.listen(8080);\n```\n\n###Creating a directory handler\n\n```js\nvar lactate = require('lactate');\nvar options = {from:'public/path/to/files'};\nvar files = lactate.dir('files', options);\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', function(req, res) {\n  files.serve(req, res);\n});\n\nserver.listen(8080);\n```\n\n###Using directory middleware\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files', options);\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', files.toMiddleware());\nserver.listen(8080);\n```\n\n###Integrating with Express\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files', options);\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8080);\n```\n\n###Using Express.static API\n\n```js\nvar lactate = require('lactate');\nvar express = require('express');\nvar app = express();\n\napp.use(lactate.static(__dirname + '/files'));\napp.listen(8000);\n```\n\n###Using node-static API\n\n```js\nvar lactate = require('lactate');\nvar files = new(lactate.Server)('./files');\n\nvar http = require('http');\nvar server = new http.Server;\n\n// You could also pass a .toMiddleware()'d function\n\nserver.addListener('request', function(req, res) {\n  files.serve(req, res);\n});\n\nserver.listen(8000);\n```\n\n###Serving individual files\n\n```js\nvar lactate = require('lactate');\n\nvar fileOptions = {from:'public/directory'};\nvar files = lactate.dir('files', fileOptions);\n\nvar pageOptions = {};\nvar pages = lactate.dir('pages');\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', function(req, res) {\n  if (req.url === '/') {\n    pages.serve('index.html', req, res);\n  } else {\n    files.serve(req, res);\n  };\n});\nserver.listen(8000);\n```\n\n###Setting options\n\n```js\nvar lactate = require('lactate');\n\nvar fileOptions = {\n  from:'public'\n};\n\nvar files = lactate.dir('files', fileOptions);\n\nfiles.set('cache', false);\nfiles.disable('gzip');\nfiles.maxAge('ten days');\n\nvar express = require('express');\nvar app = express():\n  \napp.get('/public/*', files.toMiddleware());\napp.listen(8080);\n```\n\n###Bundling assets\n\n```js\nvar lactate = require('lactate');\nvar options = {\n  from:'files'\n};\n\nvar files = lactate.dir('files', options);\n\n// Combine and minify all scripts to 'common.js'\nfiles.bundle('js', 'common.js', function(err, data) {\n// Handle errors\n});\n\n// Combine and minify all CSS to 'common.css'\nfiles.bundleCSS('common.css');\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8000);\n```\n\n###Using custom 404 pages\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files');\n\nfiles.notFound('path/to/404/page.html');\n\nfiles.notFound(function(req, res) {\n  res.writeHead(404);\n  res.end('Woops, 404');\n});\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8000);\n```\n\n###Using custom response headers\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files');\n\nfiles.setHeader('x-powered-by', 'Lactate');\nfiles.header('x-timestamp', function(req, res) {\n  return new Date().toUTCString();\n});\n\nvar headers = {};\nfiles.headers(headers);\n```\n\n###Status listeners\n\nLactate extends EventEmitter for emitting status code events. Codes Lactate is aware of are:\n\n* `200` *OK*\n* `304` *Not Modified*\n* `400` *Bad Request*\n* `403` *Forbidden*\n* `404` *Not Found*\n* `405` *Method Not Allowed*\n* `500` *Internal Error*\n\nCallbacks are given an object which has the following properties:\n\n* `url` The requested URL\n* `method` The request method (GET, HEAD)\n* `headers` Request headers\n* `address` Request IP address\n* `port` Request port\n* `path` Absolute file path to the requested file, if it exists\n* `msg` HTTP satus message\n\n```js\nvar files = lactate.dir('files', {});\nfiles.on('404', function(req) {\n  console.log('404', req.url);\n});\n```\n\n##Options\n\n### Setting options\n\nBoolean options may be set using `enable` and `disable` methods. Other options may be set using `set` method with either key/value or an options object.\n\n**Passing to initialization function**\n\n```js\nvar lactate = require('lactate').Lactate({\n  max_age:'two days'\n})\n```\n\n**Using `set` method**\n\n```js\nlactate.set('hidden', true)\n```\n\n**Using enable/disable:**\n\n```js\nlactate.disable('gzip');\nlactate.enable('minify');\n```\n\n**Special options methods**\n\nLactate has some special methods to reduce visual clutter:\n\n```js\nlactate.maxAge('two days');\n```\n\nis equivalent to:\n\n```js\nlactate.set('max_age', 'two days');\n```\n\nSimilarly, the `headers` method is for setting custom response headers. \n\n**Underscores or spaces**\n\nUse spaces instead of underscores if you prefer:\n\n```js\nlactate.disable('max age');\nlactate.enable('watch files');\n```\n\n### Options available\n\n+ `root` **string**\n\nLocal directory from which to serve files. By default, the current working directory.\n\n+ `from` **string**\n\nPublic directory exposed to clients. If set, only requests from /*directory* will complete. Contrast this with the `root` option which is the location of files on the serving machine, not necessarily the requested path.\n\n+ `subdirs` **boolean**\n\nBy default subdirectories are served. To disable this, set `subdirs` to false.\n\n+ `hidden` **boolean**\n\nWhether or not to serve hidden files. Default is false.\n\n+ `error pages` **boolean**\n\nEnabled by default. When disabled, Lactate will not serve error pages for 404 resposes, etc..\n\n+ `autoindex` **boolean**\n\nAutomatically display directory indexes. Disabled by default.\n\n+ `cache` **boolean** or **object**\n\nKeep files in-memory. Enabled by default. For caching options and more information about caching strategy, see [Caching Options](https://github.com/Weltschmerz/Lactate#caching-options).\n\n+ `gzip` **boolean**\n\nIf false, disables automatic gzipping for text files (HTML, JS, CSS). Enabled by default.\n\n+ `minify` **boolean**\n\nIf true, will automatically minify JavaScript and CSS using [Abridge](https://github.com/Weltschmerz/Abridge). Disabled by default.\n\n+ `watch files` **boolean**\n\nDetermines whether Lactate will watch files to update its cache. If this is disabled, then your file cache will not update automatically as files are modified on the server.\n\n+ `headers` **object** or **function**\n\nSets custom response headers. If the option value is a function, it is a callback which is give (req, res) arguments. This function should return the header value; it is a mapping function.\n\n+ `max age` **number** or **string**\n\nPass this function a number (of seconds) or a string and appropriate headers will be set for client-side caching. Lactate comes with expiration defaults, such as 'two days' or '5 years and sixteen days' See [Expire](https://github.com/Weltschmerz/Expire) for details.\n\n```js\nlactate.set('max_age', 87500)\n//87500 seconds\nlactate.set('max_age', 'two days')\n//172800 seconds\nlactate.set'max_age', 'five weeks and one minute and ten seconds')\n//3024070 seconds\nlactate.set('max_age', 'one year and 2 months and seven weeks and 16 seconds')\n//41050028 seconds\n```\n\n+ `not found` **string** or **function**\n\nFor custom 404 handling. Functions are supplied the response for 100% custom response handling. Otherwise, if set to a string, this option will be treated as an ordinary file path and abide rules for gzipping / in-memory cache.\n\n+ `debug` **boolean**\n\nColored status / msg / path logging, for debugging purposes.\n\n###Caching options\n\nPass an object to the `cache` option setting. The following fields are accepted and optional:\n\n* `expire` Seconds expiration for cache keys. Keys expire after they are untouched for x-seconds. Default is `15min`.\n* `max keys` Maximum number of keys to keep in memory. Default is `Infinity`.\n* `max size` Maximum size in MB to keep in cache. Default is `100mb`.\n* `segment` Determines the threshold after which to segment a file for streaming instead of traditional writing. Default is `200kb`.\n\n```js\n  var options = {};\n  \n  options.cache = {\n    expire:5,\n    max_keys:200,\n    max_size:2,\n    segment:100\n  };\n\n  var files = lactate.static('files', options);\n\n  // Or use a string representation. Same as setting for max-age.\n  options.cache.expire = 'fifteen minutes';\n  files.set('cache', options.cache);\n```\n\n\n## License\n\nMIT\n\n","_id":"lactate@0.12.12","dist":{"shasum":"8e036a9cf547f425d5cab42f369e258762ca013d","tarball":"https://registry.npmjs.org/lactate/-/lactate-0.12.12.tgz","integrity":"sha512-+AfEheWBd15X9MwD1kZxnJfgVp3BdKqytbUtTGF3Wak4cRqVj8+fiOGSZLSJWyK4IYEtAOilv2NlTifxJSk6rA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDamnBfE3Xew3QkPQCdZhDAQP4lpyXb4sasKtoTMGf3qAIgLZ9+JG4Wm1VgrVZt8W7mF9E3QZI0cXxq8d90VkpGzf4="}]},"_npmVersion":"1.1.62","_npmUser":{"name":"Weltschmerz","email":"chlavois@gmail.com"},"maintainers":[{"name":"Weltschmerz","email":"chlavois@gmail.com"}],"directories":{}},"0.13.0":{"name":"lactate","version":"0.13.0","description":"Simple and featureful assets server","keywords":["static","file","server","assets","cache"],"repository":{"type":"git","url":"git://github.com/Weltschmerz/Lactate.git"},"author":{"name":"Weltschmerz","email":"wltsmrz@gmail.com"},"dependencies":{"mime":"1.2.7","suckle":"latest","expire":"latest","abridge":"latest","fraction":"latest","optimist":"0.3.5"},"devDependencies":{"mocha":"1.7.4","should":"1.2.1"},"main":"index.js","bin":{"lactate":"bin/lactate"},"scripts":{"test":"make test"},"engines":{"node":">= 0.6.0"},"readme":"# Lactate\n\n`npm install -g lactate`\n\nAn exceedingly fast static file handler, with a few electives.\n\n### Features\n\n* In-memory caching\n* Redis caching\n* Robust cache-control setting\n* Automatic gzipping\n* Automatic minification\n* Custom 404 pages\n* Custom response headers\n* Custom gzip patterns\n* Asset bundling and minification\n* Middleware export\n* Default error pages\n* on(status) listeners\n* Colored log output\n* Global executable\n* Directory indexing\n* Express.static API compatibility\n* node-static API compatibility\n\n## Using Lactate\n\n### Global executable\n\nIf installed globally with `npm install -g lactate`, you will have the `lactate` command at your disposal. This will run lactate static file server in the current working directory, utilizing the `cluster` module for multiple CPU cores. All [options](https://github.com/Weltschmerz/Lactate#options) are available.\n\n```code\n$ lactate --help\nUsage: lactate [options]\n\nOptions:\n--root, -r                    Local path                          [default: \"\"]\n--from, -f                    Public path                         [default: \"\"]\n--subdirs, -s                 Serve subdirectories                [default: true]\n--hidden, -h                  Serve hidden files                  [default: false]\n--error_pages, --error-pages  Serve error pages                   [default: true]\n--autoindex, -a               Automatically index directories     [default: true]\n--cache, -c                   Store assets in-memory              [default: true]\n--redis_cache, --rc           Store assets in-memory using Redis  [default: true]\n--watch_files, --watch-files  Watch files for cache update        [default: true]\n--max_age, --max-age, -M      Client-side caching max-age         [default: 172800]\n--gzip, -g                    Gzip text assets                    [default: true]\n--minify, -m                  Minify text assets                  [default: false]\n--bundle, -b                  Bundle text assets                  [default: false]\n--rebundle, --rb              Rebundle assets if modified         [default: true]\n--headers, -H                 Custom response headers             [default: \"\"]\n--debug, -d                   Log HTTP info                       [default: true]\n--quiet, -q                   Prevent all log output              [default: false]\n\n```\n\n### Programmatic lactating\n\nLactate can be used with either plain node, or with Express. With Express, Lactate is a drop-in replacement for `static` middleware, but with far more ability. The examples below use Express 2.x API for simplicity. See the [examples](https://github.com/Weltschmerz/Lactate/tree/master/example) for various examples.\n\n```js\nvar lactate = require('lactate');\nvar express = require('express');\n\nvar app = express.createServer();\napp.use(lactate.static(__dirname + '/files'));\n```\n\n## Testing Lactate\n\nIf installed locally (without -g flag to npm install):\n\n1. `cd` into `~/node_modules/lactate`\n2. `npm install ./` to install devDependencies\n3. `make test` to run mocha test\n\n##The varieties of Lactate experience\n\n###Creating a Lactate server\n\n```js\nvar lactate = require('lactate'); \nvar options = {root:'files'}; \nvar server = lactate.createServer(options); \n\nserver.listen(8080);\n```\n\n###Creating a directory handler\n\n```js\nvar lactate = require('lactate');\nvar options = {from:'public/path/to/files'};\nvar files = lactate.dir('files', options);\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', function(req, res) {\n  files.serve(req, res);\n});\n\nserver.listen(8080);\n```\n\n###Using directory middleware\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files', options);\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', files.toMiddleware());\nserver.listen(8080);\n```\n\n###Integrating with Express\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files', options);\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8080);\n```\n\n###Using Express.static API\n\n```js\nvar lactate = require('lactate');\nvar express = require('express');\nvar app = express();\n\napp.use(lactate.static(__dirname + '/files'));\napp.listen(8000);\n```\n\n###Using node-static API\n\n```js\nvar lactate = require('lactate');\nvar files = new(lactate.Server)('./files');\n\nvar http = require('http');\nvar server = new http.Server;\n\n// You could also pass a .toMiddleware()'d function\n\nserver.addListener('request', function(req, res) {\n  files.serve(req, res);\n});\n\nserver.listen(8000);\n```\n\n###Serving individual files\n\n```js\nvar lactate = require('lactate');\n\nvar fileOptions = {from:'public/directory'};\nvar files = lactate.dir('files', fileOptions);\n\nvar pageOptions = {};\nvar pages = lactate.dir('pages');\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', function(req, res) {\n  if (req.url === '/') {\n    pages.serve('index.html', req, res);\n  } else {\n    files.serve(req, res);\n  };\n});\nserver.listen(8000);\n```\n\n###Setting options\n\n```js\nvar lactate = require('lactate');\n\nvar fileOptions = {\n  from:'public'\n};\n\nvar files = lactate.dir('files', fileOptions);\n\nfiles.set('cache', false);\nfiles.disable('gzip');\nfiles.maxAge('ten days');\n\nvar express = require('express');\nvar app = express():\n  \napp.get('/public/*', files.toMiddleware());\napp.listen(8080);\n```\n\n###Bundling assets\n\n```js\nvar lactate = require('lactate');\nvar options = {\n  from:'files'\n};\n\nvar files = lactate.dir('files', options);\n\n// Combine and minify all scripts to 'common.js'\nfiles.bundle('js', 'common.js', function(err, data) {\n// Handle errors\n});\n\n// Combine and minify all CSS to 'common.css'\nfiles.bundleCSS('common.css');\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8000);\n```\n\n###Using custom 404 pages\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files');\n\nfiles.notFound('path/to/404/page.html');\n\nfiles.notFound(function(req, res) {\n  res.writeHead(404);\n  res.end('Woops, 404');\n});\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8000);\n```\n\n###Using custom response headers\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files');\n\nfiles.setHeader('x-powered-by', 'Lactate');\nfiles.header('x-timestamp', function(req, res) {\n  return new Date().toUTCString();\n});\n\nvar headers = {};\nfiles.headers(headers);\n```\n\n###Status listeners\n\nLactate extends EventEmitter for emitting status code events. Codes Lactate is aware of are:\n\n* `200` *OK*\n* `304` *Not Modified*\n* `400` *Bad Request*\n* `403` *Forbidden*\n* `404` *Not Found*\n* `405` *Method Not Allowed*\n* `500` *Internal Error*\n\nCallbacks are given an object which has the following properties:\n\n* `url` The requested URL\n* `method` The request method (GET, HEAD)\n* `headers` Request headers\n* `address` Request IP address\n* `port` Request port\n* `path` Absolute file path to the requested file, if it exists\n* `msg` HTTP satus message\n\n```js\nvar files = lactate.dir('files', {});\nfiles.on('404', function(req) {\n  console.log('404', req.url);\n});\n```\n\n##Options\n\n### Setting options\n\nBoolean options may be set using `enable` and `disable` methods. Other options may be set using `set` method with either key/value or an options object.\n\n**Passing to initialization function**\n\n```js\nvar lactate = require('lactate').Lactate({\n  max_age:'two days'\n})\n```\n\n**Using `set` method**\n\n```js\nlactate.set('hidden', true)\n```\n\n**Using enable/disable:**\n\n```js\nlactate.disable('gzip');\nlactate.enable('minify');\n```\n\n**Special options methods**\n\nLactate has some special methods to reduce visual clutter:\n\n```js\nlactate.maxAge('two days');\n```\n\nis equivalent to:\n\n```js\nlactate.set('max_age', 'two days');\n```\n\nSimilarly, the `headers` method is for setting custom response headers. \n\n**Underscores or spaces**\n\nUse spaces instead of underscores if you prefer:\n\n```js\nlactate.disable('max age');\nlactate.enable('watch files');\n```\n\n### Options available\n\n+ `root` **string**\n\nLocal directory from which to serve files. By default, the current working directory.\n\n+ `from` **string**\n\nPublic directory exposed to clients. If set, only requests from /*directory* will complete. Contrast this with the `root` option which is the location of files on the serving machine, not necessarily the requested path.\n\n+ `subdirs` **boolean**\n\nBy default subdirectories are served. To disable this, set `subdirs` to false.\n\n+ `hidden` **boolean**\n\nWhether or not to serve hidden files. Default is false.\n\n+ `error pages` **boolean**\n\nEnabled by default. When disabled, Lactate will not serve error pages for 404 resposes, etc..\n\n+ `autoindex` **boolean**\n\nAutomatically display directory indexes. Disabled by default.\n\n+ `cache` **boolean** or **object**\n\nKeep files in-memory. Enabled by default. For caching options and more information about caching strategy, see [Caching Options](https://github.com/Weltschmerz/Lactate#caching-options).\n\n+ `gzip` **boolean**\n\nIf false, disables automatic gzipping for text files (HTML, JS, CSS). Enabled by default.\n\n+ `minify` **boolean**\n\nIf true, will automatically minify JavaScript and CSS using [Abridge](https://github.com/Weltschmerz/Abridge). Disabled by default.\n\n+ `watch files` **boolean**\n\nDetermines whether Lactate will watch files to update its cache. If this is disabled, then your file cache will not update automatically as files are modified on the server.\n\n+ `headers` **object** or **function**\n\nSets custom response headers. If the option value is a function, it is a callback which is give (req, res) arguments. This function should return the header value; it is a mapping function.\n\n+ `max age` **number** or **string**\n\nPass this function a number (of seconds) or a string and appropriate headers will be set for client-side caching. Lactate comes with expiration defaults, such as 'two days' or '5 years and sixteen days' See [Expire](https://github.com/Weltschmerz/Expire) for details.\n\n```js\nlactate.set('max_age', 87500)\n//87500 seconds\nlactate.set('max_age', 'two days')\n//172800 seconds\nlactate.set'max_age', 'five weeks and one minute and ten seconds')\n//3024070 seconds\nlactate.set('max_age', 'one year and 2 months and seven weeks and 16 seconds')\n//41050028 seconds\n```\n\n+ `not found` **string** or **function**\n\nFor custom 404 handling. Functions are supplied the response for 100% custom response handling. Otherwise, if set to a string, this option will be treated as an ordinary file path and abide rules for gzipping / in-memory cache.\n\n+ `gzip patterns` **array**\n\nSet custom gzip RegExp patterns. The patterns are matched with mime types. E.g. `/(\\+|\\/)xml$/` may be used for matching XML documents for gzipping. You may either use:\n\n```js\nlactate.set('gzip patterns', []);\n```\n\nOr perhaps more conveniently:\n\n```js\n//Accepts RegExp or String\nlactate.gzip(/pattern/, ...);\n```\n\n+ `debug` **boolean**\n\nColored status / msg / path logging, for debugging purposes.\n\n###Caching options\n\nPass an object to the `cache` option setting. The following fields are accepted and optional:\n\n* `expire` Seconds expiration for cache keys. Keys expire after they are untouched for x-seconds. Default is `15min`.\n* `max keys` Maximum number of keys to keep in memory. Default is `Infinity`.\n* `max size` Maximum size in MB to keep in cache. Default is `100mb`.\n* `segment` Determines the threshold after which to segment a file for streaming instead of traditional writing. Default is `200kb`.\n\n```js\n  var options = {};\n  \n  options.cache = {\n    expire:5,\n    max_keys:200,\n    max_size:2,\n    segment:100\n  };\n\n  var files = lactate.static('files', options);\n\n  // Or use a string representation. Same as setting for max-age.\n  options.cache.expire = 'fifteen minutes';\n  files.set('cache', options.cache);\n```\n\n\n## License\n\nMIT\n\n","_id":"lactate@0.13.0","dist":{"shasum":"301f41ea0de9b4a29724e1a03c6eba0dd2b4e63c","tarball":"https://registry.npmjs.org/lactate/-/lactate-0.13.0.tgz","integrity":"sha512-W6TNnZoo2sZcTo6XYg17be7n1+ODrMPqkWeeHXQXND48h4gEq8aSfy+qEIm3YWfsn9oCFWTumfetB+Ogw9ThEA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDnQfY/ecQ6UntrXaPpm3jI9Cj2WXRKodNpdZkutx4j4AIgTyus4DEhvaSp6zbrfqboOEV21Xg4G26IaYQ7JIOmu1s="}]},"_npmVersion":"1.1.62","_npmUser":{"name":"Weltschmerz","email":"chlavois@gmail.com"},"maintainers":[{"name":"Weltschmerz","email":"chlavois@gmail.com"}],"directories":{}},"0.13.1":{"name":"lactate","version":"0.13.1","description":"Simple and featureful assets server","keywords":["static","file","server","assets","cache"],"repository":{"type":"git","url":"git://github.com/Weltschmerz/Lactate.git"},"author":{"name":"Weltschmerz","email":"wltsmrz@gmail.com"},"dependencies":{"mime":"1.2.7","suckle":"latest","expire":"latest","abridge":"latest","fraction":"latest","optimist":"0.3.5"},"devDependencies":{"mocha":"1.7.4","should":"1.2.1"},"main":"index.js","bin":{"lactate":"bin/lactate"},"scripts":{"test":"make test"},"engines":{"node":">= 0.6.0"},"readme":"# Lactate\n\n`npm install -g lactate`\n\nAn exceedingly fast static file handler, with a few electives.\n\n### Features\n\n* In-memory caching\n* Redis caching\n* Robust cache-control setting\n* Automatic gzipping\n* Automatic minification\n* Custom 404 pages\n* Custom response headers\n* Custom gzip patterns\n* Asset bundling and minification\n* Middleware export\n* Default error pages\n* on(status) listeners\n* Colored log output\n* Global executable\n* Directory indexing\n* Express.static API compatibility\n* node-static API compatibility\n\n## Using Lactate\n\n### Global executable\n\nIf installed globally with `npm install -g lactate`, you will have the `lactate` command at your disposal. This will run lactate static file server in the current working directory, utilizing the `cluster` module for multiple CPU cores. All [options](https://github.com/Weltschmerz/Lactate#options) are available.\n\n```code\n$ lactate --help\nUsage: lactate [options]\n\nOptions:\n--root, -r                    Local path                          [default: \"\"]\n--from, -f                    Public path                         [default: \"\"]\n--subdirs, -s                 Serve subdirectories                [default: true]\n--hidden, -h                  Serve hidden files                  [default: false]\n--error_pages, --error-pages  Serve error pages                   [default: true]\n--autoindex, -a               Automatically index directories     [default: true]\n--cache, -c                   Store assets in-memory              [default: true]\n--redis_cache, --rc           Store assets in-memory using Redis  [default: true]\n--watch_files, --watch-files  Watch files for cache update        [default: true]\n--max_age, --max-age, -M      Client-side caching max-age         [default: 172800]\n--gzip, -g                    Gzip text assets                    [default: true]\n--minify, -m                  Minify text assets                  [default: false]\n--bundle, -b                  Bundle text assets                  [default: false]\n--rebundle, --rb              Rebundle assets if modified         [default: true]\n--headers, -H                 Custom response headers             [default: \"\"]\n--debug, -d                   Log HTTP info                       [default: true]\n--quiet, -q                   Prevent all log output              [default: false]\n\n```\n\n### Programmatic lactating\n\nLactate can be used with either plain node, or with Express. With Express, Lactate is a drop-in replacement for `static` middleware, but with far more ability. The examples below use Express 2.x API for simplicity. See the [examples](https://github.com/Weltschmerz/Lactate/tree/master/example) for various examples.\n\n```js\nvar lactate = require('lactate');\nvar express = require('express');\n\nvar app = express.createServer();\napp.use(lactate.static(__dirname + '/files'));\n```\n\n## Testing Lactate\n\nIf installed locally (without -g flag to npm install):\n\n1. `cd` into `~/node_modules/lactate`\n2. `npm install ./` to install devDependencies\n3. `make test` to run mocha test\n\n##The varieties of Lactate experience\n\n###Creating a Lactate server\n\n```js\nvar lactate = require('lactate'); \nvar options = {root:'files'}; \nvar server = lactate.createServer(options); \n\nserver.listen(8080);\n```\n\n###Creating a directory handler\n\n```js\nvar lactate = require('lactate');\nvar options = {from:'public/path/to/files'};\nvar files = lactate.dir('files', options);\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', function(req, res) {\n  files.serve(req, res);\n});\n\nserver.listen(8080);\n```\n\n###Using directory middleware\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files', options);\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', files.toMiddleware());\nserver.listen(8080);\n```\n\n###Integrating with Express\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files', options);\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8080);\n```\n\n###Using Express.static API\n\n```js\nvar lactate = require('lactate');\nvar express = require('express');\nvar app = express();\n\napp.use(lactate.static(__dirname + '/files'));\napp.listen(8000);\n```\n\n###Using node-static API\n\n```js\nvar lactate = require('lactate');\nvar files = new(lactate.Server)('./files');\n\nvar http = require('http');\nvar server = new http.Server;\n\n// You could also pass a .toMiddleware()'d function\n\nserver.addListener('request', function(req, res) {\n  files.serve(req, res);\n});\n\nserver.listen(8000);\n```\n\n###Serving individual files\n\n```js\nvar lactate = require('lactate');\n\nvar fileOptions = {from:'public/directory'};\nvar files = lactate.dir('files', fileOptions);\n\nvar pageOptions = {};\nvar pages = lactate.dir('pages');\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', function(req, res) {\n  if (req.url === '/') {\n    pages.serve('index.html', req, res);\n  } else {\n    files.serve(req, res);\n  };\n});\nserver.listen(8000);\n```\n\n###Setting options\n\n```js\nvar lactate = require('lactate');\n\nvar fileOptions = {\n  from:'public'\n};\n\nvar files = lactate.dir('files', fileOptions);\n\nfiles.set('cache', false);\nfiles.disable('gzip');\nfiles.maxAge('ten days');\n\nvar express = require('express');\nvar app = express():\n  \napp.get('/public/*', files.toMiddleware());\napp.listen(8080);\n```\n\n###Bundling assets\n\n```js\nvar lactate = require('lactate');\nvar options = {\n  from:'files'\n};\n\nvar files = lactate.dir('files', options);\n\n// Combine and minify all scripts to 'common.js'\nfiles.bundle('js', 'common.js', function(err, data) {\n// Handle errors\n});\n\n// Combine and minify all CSS to 'common.css'\nfiles.bundleCSS('common.css');\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8000);\n```\n\n###Using custom 404 pages\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files');\n\nfiles.notFound('path/to/404/page.html');\n\nfiles.notFound(function(req, res) {\n  res.writeHead(404);\n  res.end('Woops, 404');\n});\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8000);\n```\n\n###Using custom response headers\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files');\n\nfiles.setHeader('x-powered-by', 'Lactate');\nfiles.header('x-timestamp', function(req, res) {\n  return new Date().toUTCString();\n});\n\nvar headers = {};\nfiles.headers(headers);\n```\n\n###Status listeners\n\nLactate extends EventEmitter for emitting status code events. Codes Lactate is aware of are:\n\n* `200` *OK*\n* `304` *Not Modified*\n* `400` *Bad Request*\n* `403` *Forbidden*\n* `404` *Not Found*\n* `405` *Method Not Allowed*\n* `500` *Internal Error*\n\nCallbacks are given an object which has the following properties:\n\n* `url` The requested URL\n* `method` The request method (GET, HEAD)\n* `headers` Request headers\n* `address` Request IP address\n* `port` Request port\n* `path` Absolute file path to the requested file, if it exists\n* `msg` HTTP satus message\n\n```js\nvar files = lactate.dir('files', {});\nfiles.on('404', function(req) {\n  console.log('404', req.url);\n});\n```\n\n##Options\n\n### Setting options\n\nBoolean options may be set using `enable` and `disable` methods. Other options may be set using `set` method with either key/value or an options object.\n\n**Passing to initialization function**\n\n```js\nvar lactate = require('lactate').Lactate({\n  max_age:'two days'\n})\n```\n\n**Using `set` method**\n\n```js\nlactate.set('hidden', true)\n```\n\n**Using enable/disable:**\n\n```js\nlactate.disable('gzip');\nlactate.enable('minify');\n```\n\n**Special options methods**\n\nLactate has some special methods to reduce visual clutter:\n\n```js\nlactate.maxAge('two days');\n```\n\nis equivalent to:\n\n```js\nlactate.set('max_age', 'two days');\n```\n\nSimilarly, the `headers` method is for setting custom response headers. \n\n**Underscores or spaces**\n\nUse spaces instead of underscores if you prefer:\n\n```js\nlactate.disable('max age');\nlactate.enable('watch files');\n```\n\n### Options available\n\n+ `root` **string**\n\nLocal directory from which to serve files. By default, the current working directory.\n\n+ `from` **string**\n\nPublic directory exposed to clients. If set, only requests from /*directory* will complete. Contrast this with the `root` option which is the location of files on the serving machine, not necessarily the requested path.\n\n+ `subdirs` **boolean**\n\nBy default subdirectories are served. To disable this, set `subdirs` to false.\n\n+ `hidden` **boolean**\n\nWhether or not to serve hidden files. Default is false.\n\n+ `error pages` **boolean**\n\nEnabled by default. When disabled, Lactate will not serve error pages for 404 resposes, etc..\n\n+ `autoindex` **boolean**\n\nAutomatically display directory indexes. Disabled by default.\n\n+ `cache` **boolean** or **object**\n\nKeep files in-memory. Enabled by default. For caching options and more information about caching strategy, see [Caching Options](https://github.com/Weltschmerz/Lactate#caching-options).\n\n+ `gzip` **boolean**\n\nIf false, disables automatic gzipping for text files (HTML, JS, CSS). Enabled by default.\n\n+ `minify` **boolean**\n\nIf true, will automatically minify JavaScript and CSS using [Abridge](https://github.com/Weltschmerz/Abridge). Disabled by default.\n\n+ `watch files` **boolean**\n\nDetermines whether Lactate will watch files to update its cache. If this is disabled, then your file cache will not update automatically as files are modified on the server.\n\n+ `headers` **object** or **function**\n\nSets custom response headers. If the option value is a function, it is a callback which is give (req, res) arguments. This function should return the header value; it is a mapping function.\n\n+ `max age` **number** or **string**\n\nPass this function a number (of seconds) or a string and appropriate headers will be set for client-side caching. Lactate comes with expiration defaults, such as 'two days' or '5 years and sixteen days' See [Expire](https://github.com/Weltschmerz/Expire) for details.\n\n```js\nlactate.set('max_age', 87500)\n//87500 seconds\nlactate.set('max_age', 'two days')\n//172800 seconds\nlactate.set'max_age', 'five weeks and one minute and ten seconds')\n//3024070 seconds\nlactate.set('max_age', 'one year and 2 months and seven weeks and 16 seconds')\n//41050028 seconds\n```\n\n+ `not found` **string** or **function**\n\nFor custom 404 handling. Functions are supplied the response for 100% custom response handling. Otherwise, if set to a string, this option will be treated as an ordinary file path and abide rules for gzipping / in-memory cache.\n\n+ `gzip patterns` **array**\n\nSet custom gzip RegExp patterns. The patterns are matched with mime types. E.g. `/(\\+|\\/)xml$/` may be used for matching XML documents for gzipping. You may either use:\n\n```js\nlactate.set('gzip patterns', []);\n```\n\nOr perhaps more conveniently:\n\n```js\n//Accepts RegExp or String\nlactate.gzip(/pattern/, ...);\n```\n\n+ `debug` **boolean**\n\nColored status / msg / path logging, for debugging purposes.\n\n###Caching options\n\nPass an object to the `cache` option setting. The following fields are accepted and optional:\n\n* `expire` Seconds expiration for cache keys. Keys expire after they are untouched for x-seconds. Default is `15min`.\n* `max keys` Maximum number of keys to keep in memory. Default is `Infinity`.\n* `max size` Maximum size in MB to keep in cache. Default is `100mb`.\n* `segment` Determines the threshold after which to segment a file for streaming instead of traditional writing. Default is `200kb`.\n\n```js\n  var options = {};\n  \n  options.cache = {\n    expire:5,\n    max_keys:200,\n    max_size:2,\n    segment:100\n  };\n\n  var files = lactate.static('files', options);\n\n  // Or use a string representation. Same as setting for max-age.\n  options.cache.expire = 'fifteen minutes';\n  files.set('cache', options.cache);\n```\n\n\n## License\n\nMIT\n\n","_id":"lactate@0.13.1","dist":{"shasum":"5f5524eb58f2f76f0b1cd360d93858b9cca676c3","tarball":"https://registry.npmjs.org/lactate/-/lactate-0.13.1.tgz","integrity":"sha512-kd+14QwGhPck2qiwyddfAB0Nr1vFiEyr+V1qfSQCai3dxcjSkuvz2Kckx1sJDiGtAKdS8jhfQMHoyapdJ0uu1g==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDZef/g8bNjEGNAJb8cd9Nxb5uQaIrV259KPn77On6anAiEA9yS2f4amMQifinsfCcvLlBJl52ZBWbUcIIBLEWqtlLI="}]},"_npmVersion":"1.1.62","_npmUser":{"name":"Weltschmerz","email":"chlavois@gmail.com"},"maintainers":[{"name":"Weltschmerz","email":"chlavois@gmail.com"}],"directories":{}},"0.13.2":{"name":"lactate","version":"0.13.2","description":"Simple and featureful assets server","keywords":["static","file","server","assets","cache"],"repository":{"type":"git","url":"git://github.com/Weltschmerz/Lactate.git"},"author":{"name":"Weltschmerz","email":"wltsmrz@gmail.com"},"dependencies":{"mime":"1.2.7","suckle":"latest","expire":"latest","abridge":"latest","fraction":"latest","optimist":"0.3.5"},"devDependencies":{"mocha":"1.7.4","should":"1.2.1"},"main":"index.js","bin":{"lactate":"bin/lactate"},"scripts":{"test":"make test"},"engines":{"node":">= 0.6.0"},"readme":"# Lactate\n\n`npm install -g lactate`\n\nAn exceedingly fast static file handler, with a few electives.\n\n### Features\n\n* In-memory caching\n* Redis caching\n* Robust cache-control setting\n* Automatic gzipping\n* Automatic minification\n* Custom 404 pages\n* Custom response headers\n* Custom gzip patterns\n* Asset bundling and minification\n* Middleware export\n* Default error pages\n* on(status) listeners\n* Colored log output\n* Global executable\n* Directory indexing\n* Express.static API compatibility\n* node-static API compatibility\n\n## Using Lactate\n\n### Global executable\n\nIf installed globally with `npm install -g lactate`, you will have the `lactate` command at your disposal. This will run lactate static file server in the current working directory, utilizing the `cluster` module for multiple CPU cores. All [options](https://github.com/Weltschmerz/Lactate#options) are available.\n\n```code\n$ lactate --help\nUsage: lactate [options]\n\nOptions:\n--root, -r                    Local path                          [default: \"\"]\n--from, -f                    Public path                         [default: \"\"]\n--subdirs, -s                 Serve subdirectories                [default: true]\n--hidden, -h                  Serve hidden files                  [default: false]\n--error_pages, --error-pages  Serve error pages                   [default: true]\n--autoindex, -a               Automatically index directories     [default: true]\n--cache, -c                   Store assets in-memory              [default: true]\n--redis_cache, --rc           Store assets in-memory using Redis  [default: true]\n--watch_files, --watch-files  Watch files for cache update        [default: true]\n--max_age, --max-age, -M      Client-side caching max-age         [default: 172800]\n--gzip, -g                    Gzip text assets                    [default: true]\n--minify, -m                  Minify text assets                  [default: false]\n--bundle, -b                  Bundle text assets                  [default: false]\n--rebundle, --rb              Rebundle assets if modified         [default: true]\n--headers, -H                 Custom response headers             [default: \"\"]\n--debug, -d                   Log HTTP info                       [default: true]\n--quiet, -q                   Prevent all log output              [default: false]\n\n```\n\n### Programmatic lactating\n\nLactate can be used with either plain node, or with Express. With Express, Lactate is a drop-in replacement for `static` middleware, but with far more ability. The examples below use Express 2.x API for simplicity. See the [examples](https://github.com/Weltschmerz/Lactate/tree/master/example) for various examples.\n\n```js\nvar lactate = require('lactate');\nvar express = require('express');\n\nvar app = express.createServer();\napp.use(lactate.static(__dirname + '/files'));\n```\n\n## Testing Lactate\n\nIf installed locally (without -g flag to npm install):\n\n1. `cd` into `~/node_modules/lactate`\n2. `npm install ./` to install devDependencies\n3. `make test` to run mocha test\n\n##The varieties of Lactate experience\n\n###Creating a Lactate server\n\n```js\nvar lactate = require('lactate'); \nvar options = {root:'files'}; \nvar server = lactate.createServer(options); \n\nserver.listen(8080);\n```\n\n###Creating a directory handler\n\n```js\nvar lactate = require('lactate');\nvar options = {from:'public/path/to/files'};\nvar files = lactate.dir('files', options);\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', function(req, res) {\n  files.serve(req, res);\n});\n\nserver.listen(8080);\n```\n\n###Using directory middleware\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files', options);\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', files.toMiddleware());\nserver.listen(8080);\n```\n\n###Integrating with Express\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files', options);\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8080);\n```\n\n###Using Express.static API\n\n```js\nvar lactate = require('lactate');\nvar express = require('express');\nvar app = express();\n\napp.use(lactate.static(__dirname + '/files'));\napp.listen(8000);\n```\n\n###Using node-static API\n\n```js\nvar lactate = require('lactate');\nvar files = new(lactate.Server)('./files');\n\nvar http = require('http');\nvar server = new http.Server;\n\n// You could also pass a .toMiddleware()'d function\n\nserver.addListener('request', function(req, res) {\n  files.serve(req, res);\n});\n\nserver.listen(8000);\n```\n\n###Serving individual files\n\n```js\nvar lactate = require('lactate');\n\nvar fileOptions = {from:'public/directory'};\nvar files = lactate.dir('files', fileOptions);\n\nvar pageOptions = {};\nvar pages = lactate.dir('pages');\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', function(req, res) {\n  if (req.url === '/') {\n    pages.serve('index.html', req, res);\n  } else {\n    files.serve(req, res);\n  };\n});\nserver.listen(8000);\n```\n\n###Setting options\n\n```js\nvar lactate = require('lactate');\n\nvar fileOptions = {\n  from:'public'\n};\n\nvar files = lactate.dir('files', fileOptions);\n\nfiles.set('cache', false);\nfiles.disable('gzip');\nfiles.maxAge('ten days');\n\nvar express = require('express');\nvar app = express():\n  \napp.get('/public/*', files.toMiddleware());\napp.listen(8080);\n```\n\n###Bundling assets\n\n```js\nvar lactate = require('lactate');\nvar options = {\n  from:'files'\n};\n\nvar files = lactate.dir('files', options);\n\n// Combine and minify all scripts to 'common.js'\nfiles.bundle('js', 'common.js', function(err, data) {\n// Handle errors\n});\n\n// Combine and minify all CSS to 'common.css'\nfiles.bundleCSS('common.css');\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8000);\n```\n\n###Using custom 404 pages\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files');\n\nfiles.notFound('path/to/404/page.html');\n\nfiles.notFound(function(req, res) {\n  res.writeHead(404);\n  res.end('Woops, 404');\n});\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8000);\n```\n\n###Using custom response headers\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files');\n\nfiles.setHeader('x-powered-by', 'Lactate');\nfiles.header('x-timestamp', function(req, res) {\n  return new Date().toUTCString();\n});\n\nvar headers = {};\nfiles.headers(headers);\n```\n\n###Status listeners\n\nLactate extends EventEmitter for emitting status code events.\n\n```js\nvar files = lactate.dir('files');\nfiles.on('404', function(req) {\n  console.log('404', req.url);\n});\n```\n\n##Options\n\n### Setting options\n\nBoolean options may be set using `enable` and `disable` methods. Other options may be set using `set` method with either key/value or an options object.\n\n**Passing to initialization function**\n\n```js\nvar lactate = require('lactate').Lactate({\n  max_age:'two days'\n})\n```\n\n**Using `set` method**\n\n```js\nlactate.set('hidden', true)\n```\n\n**Using enable/disable:**\n\n```js\nlactate.disable('gzip');\nlactate.enable('minify');\n```\n\n**Special options methods**\n\nLactate has some special methods to reduce visual clutter:\n\n```js\nlactate.maxAge('two days');\n```\n\nis equivalent to:\n\n```js\nlactate.set('max_age', 'two days');\n```\n\nSimilarly, the `headers` method is for setting custom response headers. \n\n**Underscores or spaces**\n\nUse spaces instead of underscores if you prefer:\n\n```js\nlactate.disable('max age');\nlactate.enable('watch files');\n```\n\n### Options available\n\n+ `root` **string**\n\nLocal directory from which to serve files. By default, the current working directory.\n\n+ `from` **string**\n\nPublic directory exposed to clients. If set, only requests from /*directory* will complete. Contrast this with the `root` option which is the location of files on the serving machine, not necessarily the requested path.\n\n+ `subdirs` **boolean**\n\nBy default subdirectories are served. To disable this, set `subdirs` to false.\n\n+ `hidden` **boolean**\n\nWhether or not to serve hidden files. Default is false.\n\n+ `error pages` **boolean**\n\nEnabled by default. When disabled, Lactate will not serve error pages for 404 resposes, etc..\n\n+ `autoindex` **boolean**\n\nAutomatically display directory indexes. Disabled by default.\n\n+ `cache` **boolean** or **object**\n\nKeep files in-memory. Enabled by default. For caching options and more information about caching strategy, see [Caching Options](https://github.com/Weltschmerz/Lactate#caching-options).\n\n+ `gzip` **boolean**\n\nIf false, disables automatic gzipping for text files (HTML, JS, CSS). Enabled by default.\n\n+ `minify` **boolean**\n\nIf true, will automatically minify JavaScript and CSS using [Abridge](https://github.com/Weltschmerz/Abridge). Disabled by default.\n\n+ `watch files` **boolean**\n\nDetermines whether Lactate will watch files to update its cache. If this is disabled, then your file cache will not update automatically as files are modified on the server.\n\n+ `headers` **object** or **function**\n\nSets custom response headers. If the option value is a function, it is a callback which is give (req, res) arguments. This function should return the header value; it is a mapping function.\n\n+ `max age` **number** or **string**\n\nPass this function a number (of seconds) or a string and appropriate headers will be set for client-side caching. Lactate comes with expiration defaults, such as 'two days' or '5 years and sixteen days' See [Expire](https://github.com/Weltschmerz/Expire) for details.\n\n```js\nlactate.set('max_age', 87500)\n//87500 seconds\nlactate.set('max_age', 'two days')\n//172800 seconds\nlactate.set'max_age', 'five weeks and one minute and ten seconds')\n//3024070 seconds\nlactate.set('max_age', 'one year and 2 months and seven weeks and 16 seconds')\n//41050028 seconds\n```\n\n+ `not found` **string** or **function**\n\nFor custom 404 handling. Functions are supplied the response for 100% custom response handling. Otherwise, if set to a string, this option will be treated as an ordinary file path and abide rules for gzipping / in-memory cache.\n\n+ `gzip patterns` **array**\n\nSet custom gzip RegExp patterns. The patterns are matched with mime types. E.g. `/(\\+|\\/)xml$/` may be used for matching XML documents for gzipping. You may either use:\n\n```js\nlactate.set('gzip patterns', []);\n```\n\nOr perhaps more conveniently:\n\n```js\n//Accepts RegExp or String\nlactate.gzip(/pattern/, ...);\n```\n\n+ `debug` **boolean**\n\nColored status / msg / path logging, for debugging purposes.\n\n###Caching options\n\nPass an object to the `cache` option setting. The following fields are accepted and optional:\n\n* `expire` Seconds expiration for cache keys. Keys expire after they are untouched for x-seconds. Default is `15min`.\n* `max keys` Maximum number of keys to keep in memory. Default is `Infinity`.\n* `max size` Maximum size in MB to keep in cache. Default is `100mb`.\n* `segment` Determines the threshold after which to segment a file for streaming instead of traditional writing. Default is `200kb`.\n\n```js\n  var options = {};\n  \n  options.cache = {\n    expire:5,\n    max_keys:200,\n    max_size:2,\n    segment:100\n  };\n\n  var files = lactate.static('files', options);\n\n  // Or use a string representation. Same as setting for max-age.\n  options.cache.expire = 'fifteen minutes';\n  files.set('cache', options.cache);\n```\n\n\n## License\n\nMIT\n\n","_id":"lactate@0.13.2","dist":{"shasum":"b2b0550aace071a0cbfa36a6c7bfae10785a40f8","tarball":"https://registry.npmjs.org/lactate/-/lactate-0.13.2.tgz","integrity":"sha512-wXqH3z4CurIKmYQRwEtJuZSMMUOkiYU9HFzf9OGSo6zbK+UkW7k/sg1BpBntQkMY5HEZSj8zH0FA1knGcc5VhA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBRcuqWQlm6uAdx3cvjdO8s7dLLTPwjl1Z8OT9y1JG+CAiBz/bpsXn5MhSfeUtk8oIQR2zFqvSmDrccAZdUIqPQCNg=="}]},"_npmVersion":"1.1.62","_npmUser":{"name":"Weltschmerz","email":"wltsmrz@gmail.com"},"maintainers":[{"name":"Weltschmerz","email":"chlavois@gmail.com"}]},"0.13.3":{"name":"lactate","version":"0.13.3","description":"Simple and featureful assets server","keywords":["static","file","server","assets","cache"],"repository":{"type":"git","url":"git://github.com/Weltschmerz/Lactate.git"},"author":{"name":"Weltschmerz","email":"wltsmrz@gmail.com"},"dependencies":{"mime":"1.2.7","suckle":"latest","expire":"latest","abridge":"latest","fraction":"latest","optimist":"0.3.5"},"devDependencies":{"mocha":"1.7.4","should":"1.2.1"},"main":"index.js","bin":{"lactate":"bin/lactate"},"scripts":{"test":"make test"},"engines":{"node":">= 0.6.0"},"readme":"# Lactate\n\n`npm install -g lactate`\n\nAn exceedingly fast static file handler, with a few electives.\n\n### Features\n\n* In-memory caching\n* Redis caching\n* Robust cache-control setting\n* Automatic gzipping\n* Automatic minification\n* Custom 404 pages\n* Custom response headers\n* Custom / automatic charset headers\n* Custom gzip patterns\n* Asset bundling and minification\n* Middleware export\n* Default error pages\n* on(status) listeners\n* Colored log output\n* Global executable\n* Directory indexing\n* Express.static API compatibility\n* node-static API compatibility\n\n## Using Lactate\n\n### Global executable\n\nIf installed globally with `npm install -g lactate`, you will have the `lactate` command at your disposal. This will run lactate static file server in the current working directory, utilizing the `cluster` module for multiple CPU cores. All [options](https://github.com/Weltschmerz/Lactate#options) are available.\n\n```code\n$ lactate --help\nUsage: lactate [options]\n\nOptions:\n--root, -r                    Local path                          [default: \"\"]\n--from, -f                    Public path                         [default: \"\"]\n--subdirs, -s                 Serve subdirectories                [default: true]\n--hidden, -h                  Serve hidden files                  [default: false]\n--error_pages, --error-pages  Serve error pages                   [default: true]\n--autoindex, -a               Automatically index directories     [default: true]\n--cache, -c                   Store assets in-memory              [default: true]\n--redis_cache, --rc           Store assets in-memory using Redis  [default: true]\n--watch_files, --watch-files  Watch files for cache update        [default: true]\n--max_age, --max-age, -M      Client-side caching max-age         [default: 172800]\n--gzip, -g                    Gzip text assets                    [default: true]\n--minify, -m                  Minify text assets                  [default: false]\n--bundle, -b                  Bundle text assets                  [default: false]\n--rebundle, --rb              Rebundle assets if modified         [default: true]\n--headers, -H                 Custom response headers             [default: \"\"]\n--debug, -d                   Log HTTP info                       [default: true]\n--quiet, -q                   Prevent all log output              [default: false]\n\n```\n\n### Programmatic lactating\n\nLactate can be used with either plain node, or with Express. With Express, Lactate is a drop-in replacement for `static` middleware, but with far more ability. The examples below use Express 2.x API for simplicity. See the [examples](https://github.com/Weltschmerz/Lactate/tree/master/example) for various examples.\n\n```js\nvar lactate = require('lactate');\nvar express = require('express');\n\nvar app = express.createServer();\napp.use(lactate.static(__dirname + '/files'));\n```\n\n## Testing Lactate\n\nIf installed locally (without -g flag to npm install):\n\n1. `cd` into `~/node_modules/lactate`\n2. `npm install ./` to install devDependencies\n3. `make test` to run mocha test\n\n##The varieties of Lactate experience\n\n###Creating a Lactate server\n\n```js\nvar lactate = require('lactate'); \nvar options = {root:'files'}; \nvar server = lactate.createServer(options); \n\nserver.listen(8080);\n```\n\n###Creating a directory handler\n\n```js\nvar lactate = require('lactate');\nvar options = {from:'public/path/to/files'};\nvar files = lactate.dir('files', options);\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', function(req, res) {\n  files.serve(req, res);\n});\n\nserver.listen(8080);\n```\n\n###Using directory middleware\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files', options);\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', files.toMiddleware());\nserver.listen(8080);\n```\n\n###Integrating with Express\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files', options);\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8080);\n```\n\n###Using Express.static API\n\n```js\nvar lactate = require('lactate');\nvar express = require('express');\nvar app = express();\n\napp.use(lactate.static(__dirname + '/files'));\napp.listen(8000);\n```\n\n###Using node-static API\n\n```js\nvar lactate = require('lactate');\nvar files = new(lactate.Server)('./files');\n\nvar http = require('http');\nvar server = new http.Server;\n\n// You could also pass a .toMiddleware()'d function\n\nserver.addListener('request', function(req, res) {\n  files.serve(req, res);\n});\n\nserver.listen(8000);\n```\n\n###Serving individual files\n\n```js\nvar lactate = require('lactate');\n\nvar fileOptions = {from:'public/directory'};\nvar files = lactate.dir('files', fileOptions);\n\nvar pageOptions = {};\nvar pages = lactate.dir('pages');\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', function(req, res) {\n  if (req.url === '/') {\n    pages.serve('index.html', req, res);\n  } else {\n    files.serve(req, res);\n  };\n});\nserver.listen(8000);\n```\n\n###Setting options\n\n```js\nvar lactate = require('lactate');\n\nvar fileOptions = {\n  from:'public'\n};\n\nvar files = lactate.dir('files', fileOptions);\n\nfiles.set('cache', false);\nfiles.disable('gzip');\nfiles.maxAge('ten days');\n\nvar express = require('express');\nvar app = express():\n  \napp.get('/public/*', files.toMiddleware());\napp.listen(8080);\n```\n\n###Bundling assets\n\n```js\nvar lactate = require('lactate');\nvar options = {\n  from:'files'\n};\n\nvar files = lactate.dir('files', options);\n\n// Combine and minify all scripts to 'common.js'\nfiles.bundle('js', 'common.js', function(err, data) {\n// Handle errors\n});\n\n// Combine and minify all CSS to 'common.css'\nfiles.bundleCSS('common.css');\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8000);\n```\n\n###Using custom 404 pages\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files');\n\nfiles.notFound('path/to/404/page.html');\n\nfiles.notFound(function(req, res) {\n  res.writeHead(404);\n  res.end('Woops, 404');\n});\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8000);\n```\n\n###Using custom response headers\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files');\n\nfiles.setHeader('x-powered-by', 'Lactate');\nfiles.header('x-timestamp', function(req, res) {\n  return new Date().toUTCString();\n});\n\nvar headers = {};\nfiles.headers(headers);\n```\n\n###Status listeners\n\nLactate extends EventEmitter for emitting status code events.\n\n```js\nvar files = lactate.dir('files');\nfiles.on('404', function(req) {\n  console.log('404', req.url);\n});\n```\n\n##Options\n\n### Setting options\n\nBoolean options may be set using `enable` and `disable` methods. Other options may be set using `set` method with either key/value or an options object.\n\n**Passing to initialization function**\n\n```js\nvar lactate = require('lactate').Lactate({\n  max_age:'two days'\n})\n```\n\n**Using `set` method**\n\n```js\nlactate.set('hidden', true)\n```\n\n**Using enable/disable:**\n\n```js\nlactate.disable('gzip');\nlactate.enable('minify');\n```\n\n**Special options methods**\n\nLactate has some special methods to reduce visual clutter. For setting client-side expiration use `maxAge`\n\n```js\nlactate.maxAge('two days');\n```\n\nis equivalent to:\n\n```js\nlactate.set('max age', 'two days');\n```\n\nFor setting `custom headers` you may use `setHeader`\n\n```js\nlactate.setHeader('x-powered-by', 'Rodent exercise');\n```\n\nYou can also use a function with `setHeader` for added variance:\n\n```js\nlactate.setHeader('x-id', function(req, res) {\n  return Math.random().toString(36).substring(2);\n}):\n```\n\nFor defining `charsets`, you may use `Lactate.define`\n\n```js\nlactate.define('js', 'application/javascript');\n```\n\nor with an object\n\n```js\nlactate.define({\n  'html': 'text/html; charset=utf-8',\n  'js': 'application/javascript'\n});\n```\n\n**Underscores or spaces**\n\nUse spaces instead of underscores if you prefer:\n\n```js\nlactate.disable('max age');\nlactate.enable('watch files');\n```\n\n### Options available\n\n+ `root` **string**\n\nLocal directory from which to serve files. By default, the current working directory.\n\n+ `from` **string**\n\nPublic directory exposed to clients. If set, only requests from /*directory* will complete. Contrast this with the `root` option which is the location of files on the serving machine, not necessarily the requested path.\n\n+ `subdirs` **boolean**\n\nBy default subdirectories are served. To disable this, set `subdirs` to false.\n\n+ `hidden` **boolean**\n\nWhether or not to serve hidden files. Default is false.\n\n+ `error pages` **boolean**\n\nEnabled by default. When disabled, Lactate will not serve error pages for 404 resposes, etc..\n\n+ `autoindex` **boolean**\n\nAutomatically display directory indexes. Disabled by default.\n\n+ `cache` **boolean** or **object**\n\nKeep files in-memory. Enabled by default. For caching options and more information about caching strategy, see [Caching Options](https://github.com/Weltschmerz/Lactate#caching-options).\n\n+ `gzip` **boolean**\n\nIf false, disables automatic gzipping for text files (HTML, JS, CSS). Enabled by default.\n\n+ `minify` **boolean**\n\nIf true, will automatically minify JavaScript and CSS using [Abridge](https://github.com/Weltschmerz/Abridge). Disabled by default.\n\n+ `watch files` **boolean**\n\nDetermines whether Lactate will watch files to update its cache. If this is disabled, then your file cache will not update automatically as files are modified on the server.\n\n+ `headers` **object** or **function**\n\nSets custom response headers. If the option value is a function, it is a callback which is give (req, res) arguments. This function should return the header value; it is a mapping function.\n\n+ `max age` **number** or **string**\n\nPass this function a number (of seconds) or a string and appropriate headers will be set for client-side caching. Lactate comes with expiration defaults, such as 'two days' or '5 years and sixteen days' See [Expire](https://github.com/Weltschmerz/Expire) for details.\n\n```js\nlactate.set('max_age', 87500)\n//87500 seconds\nlactate.set('max_age', 'two days')\n//172800 seconds\nlactate.set'max_age', 'five weeks and one minute and ten seconds')\n//3024070 seconds\nlactate.set('max_age', 'one year and 2 months and seven weeks and 16 seconds')\n//41050028 seconds\n```\n\n+ `not found` **string** or **function**\n\nFor custom 404 handling. Functions are supplied the response for 100% custom response handling. Otherwise, if set to a string, this option will be treated as an ordinary file path and abide rules for gzipping / in-memory cache.\n\n+ `gzip patterns` **array**\n\nSet custom gzip RegExp patterns. The patterns are matched with mime types. E.g. `/(\\+|\\/)xml$/` may be used for matching XML documents for gzipping. You may either use:\n\n```js\nlactate.set('gzip patterns', []);\n```\n\nOr perhaps more conveniently:\n\n```js\n//Accepts RegExp or String\nlactate.gzip(/pattern/, ...);\n```\n\n+ `charset` **boolean** or **string**\n\nSet custom response charset, or automatically detect charset using `node-mime`.\n\n```js\nlactate.enable('charset');\n// Content-Type: text/html; charset=UTF-8\n```\n\n```js\nlactate.set('charset', 'utf-8');\n// Content-Type: text/html; charset=UTF-8\n```\n\n+ `debug` **boolean**\n\nColored status / msg / path logging, for debugging purposes.\n\n###Caching options\n\nPass an object to the `cache` option setting. The following fields are accepted and optional:\n\n* `expire` Seconds expiration for cache keys. Keys expire after they are untouched for x-seconds. Default is `15min`.\n* `max keys` Maximum number of keys to keep in memory. Default is `Infinity`.\n* `max size` Maximum size in MB to keep in cache. Default is `100mb`.\n* `segment` Determines the threshold after which to segment a file for streaming instead of traditional writing. Default is `200kb`.\n\n```js\n  var options = {};\n  \n  options.cache = {\n    expire:5,\n    max_keys:200,\n    max_size:2,\n    segment:100\n  };\n\n  var files = lactate.static('files', options);\n\n  // Or use a string representation. Same as setting for max-age.\n  options.cache.expire = 'fifteen minutes';\n  files.set('cache', options.cache);\n```\n\n\n## License\n\nMIT\n\n","_id":"lactate@0.13.3","dist":{"shasum":"6162fcbbe3737d59da34cecec5779e441754f092","tarball":"https://registry.npmjs.org/lactate/-/lactate-0.13.3.tgz","integrity":"sha512-3k7wtNQHUsZS4tqkW4xN0koxiNOVj8ARBJx6GdBzFn8lhQCPkfmFiB6ZkB8a2EDju7ZeOQrm1dT9Zjj1w/i+1Q==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIH3F0OZyfNqTZ72YOEvpux6FHK/MNb2TTBWAXqRpAGRNAiAt90RNh1Hot1OHKJAvwphrdoGop/dPiJFklLAxFcEnPQ=="}]},"_npmVersion":"1.1.62","_npmUser":{"name":"Weltschmerz","email":"wltsmrz@gmail.com"},"maintainers":[{"name":"Weltschmerz","email":"chlavois@gmail.com"}]},"0.13.4":{"name":"lactate","version":"0.13.4","description":"Simple and featureful assets server","keywords":["static","file","server","assets","cache"],"repository":{"type":"git","url":"git://github.com/Weltschmerz/Lactate.git"},"author":{"name":"Weltschmerz","email":"wltsmrz@gmail.com"},"dependencies":{"mime":"1.2.7","suckle":"latest","expire":"latest","abridge":"latest","fraction":"latest","optimist":"0.3.5"},"devDependencies":{"mocha":"1.7.4","should":"1.2.1"},"main":"index.js","bin":{"lactate":"bin/lactate"},"scripts":{"test":"make test"},"engines":{"node":">= 0.6.0"},"readme":"# Lactate\n\n`npm install -g lactate`\n\nAn exceedingly fast static file handler, with a few electives.\n\n### Features\n\n* In-memory caching\n* Redis caching\n* Robust cache-control setting\n* Automatic gzipping\n* Automatic minification\n* Custom 404 pages\n* Custom response headers\n* Custom / automatic charset headers\n* Custom gzip patterns\n* Asset bundling and minification\n* Middleware export\n* Default error pages\n* on(status) listeners\n* Colored log output\n* Global executable\n* Directory indexing\n* Express.static API compatibility\n* node-static API compatibility\n\n## Using Lactate\n\n### Global executable\n\nIf installed globally with `npm install -g lactate`, you will have the `lactate` command at your disposal. This will run lactate static file server in the current working directory, utilizing the `cluster` module for multiple CPU cores. All [options](https://github.com/Weltschmerz/Lactate#options) are available.\n\n```code\n$ lactate --help\nUsage: lactate [options]\n\nOptions:\n--root, -r                    Local path                          [default: \"\"]\n--from, -f                    Public path                         [default: \"\"]\n--subdirs, -s                 Serve subdirectories                [default: true]\n--hidden, -h                  Serve hidden files                  [default: false]\n--error_pages, --error-pages  Serve error pages                   [default: true]\n--autoindex, -a               Automatically index directories     [default: true]\n--cache, -c                   Store assets in-memory              [default: true]\n--redis_cache, --rc           Store assets in-memory using Redis  [default: true]\n--watch_files, --watch-files  Watch files for cache update        [default: true]\n--max_age, --max-age, -M      Client-side caching max-age         [default: 172800]\n--gzip, -g                    Gzip text assets                    [default: true]\n--minify, -m                  Minify text assets                  [default: false]\n--bundle, -b                  Bundle text assets                  [default: false]\n--rebundle, --rb              Rebundle assets if modified         [default: true]\n--headers, -H                 Custom response headers             [default: \"\"]\n--debug, -d                   Log HTTP info                       [default: true]\n--quiet, -q                   Prevent all log output              [default: false]\n\n```\n\n### Programmatic lactating\n\nLactate can be used with either plain node, or with Express. With Express, Lactate is a drop-in replacement for `static` middleware, but with far more ability. The examples below use Express 2.x API for simplicity. See the [examples](https://github.com/Weltschmerz/Lactate/tree/master/example) for various examples.\n\n```js\nvar lactate = require('lactate');\nvar express = require('express');\n\nvar app = express.createServer();\napp.use(lactate.static(__dirname + '/files'));\n```\n\n## Testing Lactate\n\nIf installed locally (without -g flag to npm install):\n\n1. `cd` into `~/node_modules/lactate`\n2. `npm install ./` to install devDependencies\n3. `make test` to run mocha test\n\n##The varieties of Lactate experience\n\n###Creating a Lactate server\n\n```js\nvar lactate = require('lactate'); \nvar options = {root:'files'}; \nvar server = lactate.createServer(options); \n\nserver.listen(8080);\n```\n\n###Creating a directory handler\n\n```js\nvar lactate = require('lactate');\nvar options = {from:'public/path/to/files'};\nvar files = lactate.dir('files', options);\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', function(req, res) {\n  files.serve(req, res);\n});\n\nserver.listen(8080);\n```\n\n###Using directory middleware\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files', options);\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', files.toMiddleware());\nserver.listen(8080);\n```\n\n###Integrating with Express\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files', options);\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8080);\n```\n\n###Using Express.static API\n\n```js\nvar lactate = require('lactate');\nvar express = require('express');\nvar app = express();\n\napp.use(lactate.static(__dirname + '/files'));\napp.listen(8000);\n```\n\n###Using node-static API\n\n```js\nvar lactate = require('lactate');\nvar files = new(lactate.Server)('./files');\n\nvar http = require('http');\nvar server = new http.Server;\n\n// You could also pass a .toMiddleware()'d function\n\nserver.addListener('request', function(req, res) {\n  files.serve(req, res);\n});\n\nserver.listen(8000);\n```\n\n###Serving individual files\n\n```js\nvar lactate = require('lactate');\n\nvar fileOptions = {from:'public/directory'};\nvar files = lactate.dir('files', fileOptions);\n\nvar pageOptions = {};\nvar pages = lactate.dir('pages');\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', function(req, res) {\n  if (req.url === '/') {\n    pages.serve('index.html', req, res);\n  } else {\n    files.serve(req, res);\n  };\n});\nserver.listen(8000);\n```\n\n###Setting options\n\n```js\nvar lactate = require('lactate');\n\nvar fileOptions = {\n  from:'public'\n};\n\nvar files = lactate.dir('files', fileOptions);\n\nfiles.set('cache', false);\nfiles.disable('gzip');\nfiles.maxAge('ten days');\n\nvar express = require('express');\nvar app = express():\n  \napp.get('/public/*', files.toMiddleware());\napp.listen(8080);\n```\n\n###Bundling assets\n\n```js\nvar lactate = require('lactate');\nvar options = {\n  from:'files'\n};\n\nvar files = lactate.dir('files', options);\n\n// Combine and minify all scripts to 'common.js'\nfiles.bundle('js', 'common.js', function(err, data) {\n// Handle errors\n});\n\n// Combine and minify all CSS to 'common.css'\nfiles.bundleCSS('common.css');\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8000);\n```\n\n###Using custom 404 pages\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files');\n\nfiles.notFound('path/to/404/page.html');\n\nfiles.notFound(function(req, res) {\n  res.writeHead(404);\n  res.end('Woops, 404');\n});\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8000);\n```\n\n###Using custom response headers\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files');\n\nfiles.setHeader('x-powered-by', 'Lactate');\nfiles.header('x-timestamp', function(req, res) {\n  return new Date().toUTCString();\n});\n\nvar headers = {};\nfiles.headers(headers);\n```\n\n###Status listeners\n\nLactate extends EventEmitter for emitting status code events.\n\n```js\nvar files = lactate.dir('files');\nfiles.on('404', function(req) {\n  console.log('404', req.url);\n});\n```\n\n##Options\n\n### Setting options\n\nBoolean options may be set using `enable` and `disable` methods. Other options may be set using `set` method with either key/value or an options object.\n\n**Passing to initialization function**\n\n```js\nvar lactate = require('lactate').Lactate({\n  max_age:'two days'\n})\n```\n\n**Using `set` method**\n\n```js\nlactate.set('hidden', true)\n```\n\n**Using enable/disable:**\n\n```js\nlactate.disable('gzip');\nlactate.enable('minify');\n```\n\n**Special options methods**\n\nLactate has some special methods to reduce visual clutter. For setting client-side expiration use `maxAge`\n\n```js\nlactate.maxAge('two days');\n```\n\nis equivalent to:\n\n```js\nlactate.set('max age', 'two days');\n```\n\nFor setting `custom headers` you may use `setHeader`\n\n```js\nlactate.setHeader('x-powered-by', 'Rodent exercise');\n```\n\nYou can also use a function with `setHeader` for added variance:\n\n```js\nlactate.setHeader('x-id', function(req, res) {\n  return Math.random().toString(36).substring(2);\n}):\n```\n\nFor defining `charsets`, you may use `Lactate.define`\n\n```js\nlactate.define('js', 'application/javascript');\n```\n\nor with an object\n\n```js\nlactate.define({\n  'html': 'text/html; charset=utf-8',\n  'js': 'application/javascript'\n});\n```\n\n**Underscores or spaces**\n\nUse spaces instead of underscores if you prefer:\n\n```js\nlactate.disable('max age');\nlactate.enable('watch files');\n```\n\n### Options available\n\n+ `root` **string**\n\nLocal directory from which to serve files. By default, the current working directory.\n\n+ `from` **string**\n\nPublic directory exposed to clients. If set, only requests from /*directory* will complete. Contrast this with the `root` option which is the location of files on the serving machine, not necessarily the requested path.\n\n+ `subdirs` **boolean**\n\nBy default subdirectories are served. To disable this, set `subdirs` to false.\n\n+ `hidden` **boolean**\n\nWhether or not to serve hidden files. Default is false.\n\n+ `error pages` **boolean**\n\nEnabled by default. When disabled, Lactate will not serve error pages for 404 resposes, etc..\n\n+ `autoindex` **boolean**\n\nAutomatically display directory indexes. Disabled by default.\n\n+ `cache` **boolean** or **object**\n\nKeep files in-memory. Enabled by default. For caching options and more information about caching strategy, see [Caching Options](https://github.com/Weltschmerz/Lactate#caching-options).\n\n+ `gzip` **boolean**\n\nIf false, disables automatic gzipping for text files (HTML, JS, CSS). Enabled by default.\n\n+ `minify` **boolean**\n\nIf true, will automatically minify JavaScript and CSS using [Abridge](https://github.com/Weltschmerz/Abridge). Disabled by default.\n\n+ `watch files` **boolean**\n\nDetermines whether Lactate will watch files to update its cache. If this is disabled, then your file cache will not update automatically as files are modified on the server.\n\n+ `headers` **object** or **function**\n\nSets custom response headers. If the option value is a function, it is a callback which is give (req, res) arguments. This function should return the header value; it is a mapping function.\n\n+ `max age` **number** or **string**\n\nPass this function a number (of seconds) or a string and appropriate headers will be set for client-side caching. Lactate comes with expiration defaults, such as 'two days' or '5 years and sixteen days' See [Expire](https://github.com/Weltschmerz/Expire) for details.\n\n```js\nlactate.set('max_age', 87500)\n//87500 seconds\nlactate.set('max_age', 'two days')\n//172800 seconds\nlactate.set'max_age', 'five weeks and one minute and ten seconds')\n//3024070 seconds\nlactate.set('max_age', 'one year and 2 months and seven weeks and 16 seconds')\n//41050028 seconds\n```\n\n+ `not found` **string** or **function**\n\nFor custom 404 handling. Functions are supplied the response for 100% custom response handling. Otherwise, if set to a string, this option will be treated as an ordinary file path and abide rules for gzipping / in-memory cache.\n\n+ `gzip patterns` **array**\n\nSet custom gzip RegExp patterns. The patterns are matched with mime types. E.g. `/(\\+|\\/)xml$/` may be used for matching XML documents for gzipping. You may either use:\n\n```js\nlactate.set('gzip patterns', []);\n```\n\nOr perhaps more conveniently:\n\n```js\n//Accepts RegExp or String\nlactate.gzip(/pattern/, ...);\n```\n\n+ `charset` **boolean** or **string**\n\nSet custom response charset, or automatically detect charset using `node-mime`.\n\n```js\nlactate.enable('charset');\n// Content-Type: text/html; charset=UTF-8\n```\n\n```js\nlactate.set('charset', 'utf-8');\n// Content-Type: text/html; charset=UTF-8\n```\n\n+ `debug` **boolean**\n\nColored status / msg / path logging, for debugging purposes.\n\n###Caching options\n\nPass an object to the `cache` option setting. The following fields are accepted and optional:\n\n* `expire` Seconds expiration for cache keys. Keys expire after they are untouched for x-seconds. Default is `15min`.\n* `max keys` Maximum number of keys to keep in memory. Default is `Infinity`.\n* `max size` Maximum size in MB to keep in cache. Default is `100mb`.\n* `segment` Determines the threshold after which to segment a file for streaming instead of traditional writing. Default is `200kb`.\n\n```js\n  var options = {};\n  \n  options.cache = {\n    expire:5,\n    max_keys:200,\n    max_size:2,\n    segment:100\n  };\n\n  var files = lactate.static('files', options);\n\n  // Or use a string representation. Same as setting for max-age.\n  options.cache.expire = 'fifteen minutes';\n  files.set('cache', options.cache);\n```\n\n\n## License\n\nMIT\n\n","_id":"lactate@0.13.4","dist":{"shasum":"faa8cbbcb16277d22ef3c06eced28a246531c356","tarball":"https://registry.npmjs.org/lactate/-/lactate-0.13.4.tgz","integrity":"sha512-RHzjcJuPz4SUyFAhm9S31/WViYPq29aN8Ac07lDkBDkbaRwepzTZ3IwNLPJ1ojCfDkWcFbp/5owLnU8TL22jUw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC5+DYBvmaMEEgcv4eKk1VtGd0VW1m1f/uicYEOOIK/EgIgKwJUsbxyQI4SFySN6WxbGYc4mQptlVJ0yAfAHN1SdRw="}]},"_npmVersion":"1.1.62","_npmUser":{"name":"Weltschmerz","email":"wltsmrz@gmail.com"},"maintainers":[{"name":"Weltschmerz","email":"chlavois@gmail.com"}]},"0.13.5":{"name":"lactate","version":"0.13.5","description":"Simple and featureful assets server","keywords":["static","file","server","assets","cache"],"repository":{"type":"git","url":"git://github.com/Weltschmerz/Lactate.git"},"author":{"name":"Weltschmerz","email":"wltsmrz@gmail.com"},"dependencies":{"mime":"1.2.7","suckle":"latest","expire":"latest","abridge":"latest","fraction":"latest","optimist":"0.3.5"},"devDependencies":{"mocha":"1.7.4","should":"1.2.1"},"main":"index.js","bin":{"lactate":"bin/lactate"},"scripts":{"test":"make test"},"engines":{"node":">= 0.6.0"},"readme":"# Lactate\n\n`npm install -g lactate`\n\nAn exceedingly fast static file handler, with a few electives.\n\n### Features\n\n* In-memory caching\n* Redis caching\n* Robust cache-control setting\n* Automatic gzipping\n* Automatic minification\n* Custom 404 pages\n* Custom response headers\n* Custom / automatic charset headers\n* Custom gzip patterns\n* Asset bundling and minification\n* Middleware export\n* Default error pages\n* on(status) listeners\n* Colored log output\n* Global executable\n* Directory indexing\n* Express.static API compatibility\n* node-static API compatibility\n\n## Using Lactate\n\n### Global executable\n\nIf installed globally with `npm install -g lactate`, you will have the `lactate` command at your disposal. This will run lactate static file server in the current working directory, utilizing the `cluster` module for multiple CPU cores. All [options](https://github.com/Weltschmerz/Lactate#options) are available.\n\n```code\n$ lactate --help\nUsage: lactate [options]\n\nOptions:\n--root, -r                    Local path                          [default: \"\"]\n--from, -f                    Public path                         [default: \"\"]\n--subdirs, -s                 Serve subdirectories                [default: true]\n--hidden, -h                  Serve hidden files                  [default: false]\n--error_pages, --error-pages  Serve error pages                   [default: true]\n--autoindex, -a               Automatically index directories     [default: true]\n--cache, -c                   Store assets in-memory              [default: true]\n--redis_cache, --rc           Store assets in-memory using Redis  [default: true]\n--watch_files, --watch-files  Watch files for cache update        [default: true]\n--max_age, --max-age, -M      Client-side caching max-age         [default: 172800]\n--gzip, -g                    Gzip text assets                    [default: true]\n--minify, -m                  Minify text assets                  [default: false]\n--bundle, -b                  Bundle text assets                  [default: false]\n--rebundle, --rb              Rebundle assets if modified         [default: true]\n--headers, -H                 Custom response headers             [default: \"\"]\n--debug, -d                   Log HTTP info                       [default: true]\n--quiet, -q                   Prevent all log output              [default: false]\n\n```\n\n### Programmatic lactating\n\nLactate can be used with either plain node, or with Express. With Express, Lactate is a drop-in replacement for `static` middleware, but with far more ability. The examples below use Express 2.x API for simplicity. See the [examples](https://github.com/Weltschmerz/Lactate/tree/master/example) for various examples.\n\n```js\nvar lactate = require('lactate');\nvar express = require('express');\n\nvar app = express.createServer();\napp.use(lactate.static(__dirname + '/files'));\n```\n\n## Testing Lactate\n\nIf installed locally (without -g flag to npm install):\n\n1. `cd` into `~/node_modules/lactate`\n2. `npm install ./` to install devDependencies\n3. `make test` to run mocha test\n\n##The varieties of Lactate experience\n\n###Creating a Lactate server\n\n```js\nvar lactate = require('lactate'); \nvar options = {root:'files'}; \nvar server = lactate.createServer(options); \n\nserver.listen(8080);\n```\n\n###Creating a directory handler\n\n```js\nvar lactate = require('lactate');\nvar options = {from:'public/path/to/files'};\nvar files = lactate.dir('files', options);\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', function(req, res) {\n  files.serve(req, res);\n});\n\nserver.listen(8080);\n```\n\n###Using directory middleware\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files', options);\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', files.toMiddleware());\nserver.listen(8080);\n```\n\n###Integrating with Express\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files', options);\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8080);\n```\n\n###Using Express.static API\n\n```js\nvar lactate = require('lactate');\nvar express = require('express');\nvar app = express();\n\napp.use(lactate.static(__dirname + '/files'));\napp.listen(8000);\n```\n\n###Using node-static API\n\n```js\nvar lactate = require('lactate');\nvar files = new(lactate.Server)('./files');\n\nvar http = require('http');\nvar server = new http.Server;\n\n// You could also pass a .toMiddleware()'d function\n\nserver.addListener('request', function(req, res) {\n  files.serve(req, res);\n});\n\nserver.listen(8000);\n```\n\n###Serving individual files\n\n```js\nvar lactate = require('lactate');\n\nvar fileOptions = {from:'public/directory'};\nvar files = lactate.dir('files', fileOptions);\n\nvar pageOptions = {};\nvar pages = lactate.dir('pages');\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', function(req, res) {\n  if (req.url === '/') {\n    pages.serve('index.html', req, res);\n  } else {\n    files.serve(req, res);\n  };\n});\nserver.listen(8000);\n```\n\n###Setting options\n\n```js\nvar lactate = require('lactate');\n\nvar fileOptions = {\n  from:'public'\n};\n\nvar files = lactate.dir('files', fileOptions);\n\nfiles.set('cache', false);\nfiles.disable('gzip');\nfiles.maxAge('ten days');\n\nvar express = require('express');\nvar app = express():\n  \napp.get('/public/*', files.toMiddleware());\napp.listen(8080);\n```\n\n###Bundling assets\n\n```js\nvar lactate = require('lactate');\nvar options = {\n  from:'files'\n};\n\nvar files = lactate.dir('files', options);\n\n// Combine and minify all scripts to 'common.js'\nfiles.bundle('js', 'common.js', function(err, data) {\n// Handle errors\n});\n\n// Combine and minify all CSS to 'common.css'\nfiles.bundleCSS('common.css');\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8000);\n```\n\n###Using custom 404 pages\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files');\n\nfiles.notFound('path/to/404/page.html');\n\nfiles.notFound(function(req, res) {\n  res.writeHead(404);\n  res.end('Woops, 404');\n});\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8000);\n```\n\n###Using custom response headers\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files');\n\nfiles.setHeader('x-powered-by', 'Lactate');\nfiles.header('x-timestamp', function(req, res) {\n  return new Date().toUTCString();\n});\n\nvar headers = {};\nfiles.headers(headers);\n```\n\n###Status listeners\n\nLactate extends EventEmitter for emitting status code events.\n\n```js\nvar files = lactate.dir('files');\nfiles.on('404', function(req) {\n  console.log('404', req.url);\n});\n```\n\n##Options\n\n### Setting options\n\nBoolean options may be set using `enable` and `disable` methods. Other options may be set using `set` method with either key/value or an options object.\n\n**Passing to initialization function**\n\n```js\nvar lactate = require('lactate').Lactate({\n  max_age:'two days'\n})\n```\n\n**Using `set` method**\n\n```js\nlactate.set('hidden', true)\n```\n\n**Using enable/disable:**\n\n```js\nlactate.disable('gzip');\nlactate.enable('minify');\n```\n\n**Special options methods**\n\nLactate has some special methods to reduce visual clutter. For setting client-side expiration use `maxAge`\n\n```js\nlactate.maxAge('two days');\n```\n\nis equivalent to:\n\n```js\nlactate.set('max age', 'two days');\n```\n\nFor setting `custom headers` you may use `setHeader`\n\n```js\nlactate.setHeader('x-powered-by', 'Rodent exercise');\n```\n\nYou can also use a function with `setHeader` for added variance:\n\n```js\nlactate.setHeader('x-id', function(req, res) {\n  return Math.random().toString(36).substring(2);\n}):\n```\n\nFor defining `charsets`, you may use `Lactate.define`\n\n```js\nlactate.define('js', 'application/javascript');\n```\n\nor with an object\n\n```js\nlactate.define({\n  'html': 'text/html; charset=utf-8',\n  'js': 'application/javascript'\n});\n```\n\n**Underscores or spaces**\n\nUse spaces instead of underscores if you prefer:\n\n```js\nlactate.disable('max age');\nlactate.enable('watch files');\n```\n\n### Options available\n\n+ `root` **string**\n\nLocal directory from which to serve files. By default, the current working directory.\n\n+ `from` **string**\n\nPublic directory exposed to clients. If set, only requests from /*directory* will complete. Contrast this with the `root` option which is the location of files on the serving machine, not necessarily the requested path.\n\n+ `subdirs` **boolean**\n\nBy default subdirectories are served. To disable this, set `subdirs` to false.\n\n+ `hidden` **boolean**\n\nWhether or not to serve hidden files. Default is false.\n\n+ `error pages` **boolean**\n\nEnabled by default. When disabled, Lactate will not serve error pages for 404 resposes, etc..\n\n+ `autoindex` **boolean**\n\nAutomatically display directory indexes. Disabled by default.\n\n+ `cache` **boolean** or **object**\n\nKeep files in-memory. Enabled by default. For caching options and more information about caching strategy, see [Caching Options](https://github.com/Weltschmerz/Lactate#caching-options).\n\n+ `gzip` **boolean**\n\nIf false, disables automatic gzipping for text files (HTML, JS, CSS). Enabled by default.\n\n+ `minify` **boolean**\n\nIf true, will automatically minify JavaScript and CSS using [Abridge](https://github.com/Weltschmerz/Abridge). Disabled by default.\n\n+ `watch files` **boolean**\n\nDetermines whether Lactate will watch files to update its cache. If this is disabled, then your file cache will not update automatically as files are modified on the server.\n\n+ `headers` **object** or **function**\n\nSets custom response headers. If the option value is a function, it is a callback which is give (req, res) arguments. This function should return the header value; it is a mapping function.\n\n+ `max age` **number** or **string**\n\nPass this function a number (of seconds) or a string and appropriate headers will be set for client-side caching. Lactate comes with expiration defaults, such as 'two days' or '5 years and sixteen days' See [Expire](https://github.com/Weltschmerz/Expire) for details.\n\n```js\nlactate.set('max_age', 87500)\n//87500 seconds\nlactate.set('max_age', 'two days')\n//172800 seconds\nlactate.set'max_age', 'five weeks and one minute and ten seconds')\n//3024070 seconds\nlactate.set('max_age', 'one year and 2 months and seven weeks and 16 seconds')\n//41050028 seconds\n```\n\n+ `not found` **string** or **function**\n\nFor custom 404 handling. Functions are supplied the response for 100% custom response handling. Otherwise, if set to a string, this option will be treated as an ordinary file path and abide rules for gzipping / in-memory cache.\n\n+ `gzip patterns` **array**\n\nSet custom gzip RegExp patterns. The patterns are matched with mime types. E.g. `/(\\+|\\/)xml$/` may be used for matching XML documents for gzipping. You may either use:\n\n```js\nlactate.set('gzip patterns', []);\n```\n\nOr perhaps more conveniently:\n\n```js\n//Accepts RegExp or String\nlactate.gzip(/pattern/, ...);\n```\n\n+ `charset` **boolean** or **string**\n\nSet custom response charset, or automatically detect charset using `node-mime`.\n\n```js\nlactate.enable('charset');\n// Content-Type: text/html; charset=UTF-8\n```\n\n```js\nlactate.set('charset', 'utf-8');\n// Content-Type: text/html; charset=UTF-8\n```\n\n+ `debug` **boolean**\n\nColored status / msg / path logging, for debugging purposes.\n\n###Caching options\n\nPass an object to the `cache` option setting. The following fields are accepted and optional:\n\n* `expire` Seconds expiration for cache keys. Keys expire after they are untouched for x-seconds. Default is `15min`.\n* `max keys` Maximum number of keys to keep in memory. Default is `Infinity`.\n* `max size` Maximum size in MB to keep in cache. Default is `100mb`.\n* `segment` Determines the threshold after which to segment a file for streaming instead of traditional writing. Default is `200kb`.\n\n```js\n  var options = {};\n  \n  options.cache = {\n    expire:5,\n    max_keys:200,\n    max_size:2,\n    segment:100\n  };\n\n  var files = lactate.static('files', options);\n\n  // Or use a string representation. Same as setting for max-age.\n  options.cache.expire = 'fifteen minutes';\n  files.set('cache', options.cache);\n```\n\n\n## License\n\nMIT\n\n","_id":"lactate@0.13.5","dist":{"shasum":"97c116d57d6c053b1e984fc4916e96379aa355dd","tarball":"https://registry.npmjs.org/lactate/-/lactate-0.13.5.tgz","integrity":"sha512-unfn9Au7OCQhDbCOH2DQQ7fVTZgE0FJAySzvjvqI8ZQmueZ13qxWKPtRF834JbTjW0uh5YRZY+1yl14TlpZOUw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFop+nCHeYZ2scCV0pRe0vJgR1b5wcbA/3BR/KomeAn4AiEA5pHOoVJj4HDoEQaPZQIhmz0kta/fhDlEVxNupG4Vaxs="}]},"_npmVersion":"1.1.62","_npmUser":{"name":"Weltschmerz","email":"wltsmrz@gmail.com"},"maintainers":[{"name":"Weltschmerz","email":"chlavois@gmail.com"}]},"0.13.6":{"name":"lactate","version":"0.13.6","description":"Simple and featureful assets server","keywords":["static","file","server","assets","cache"],"repository":{"type":"git","url":"git://github.com/Weltschmerz/Lactate.git"},"author":{"name":"Weltschmerz","email":"wltsmrz@gmail.com"},"dependencies":{"mime":"1.2.7","suckle":"latest","expire":"latest","abridge":"latest","fraction":"latest","optimist":"0.3.5"},"devDependencies":{"mocha":"1.7.4","should":"1.2.1"},"main":"index.js","bin":{"lactate":"bin/lactate"},"scripts":{"test":"make test"},"engines":{"node":">= 0.6.0"},"readme":"# Lactate\n\n`npm install -g lactate`\n\nAn exceedingly fast static file handler, with a few electives.\n\n### Features\n\n* In-memory caching\n* Redis caching\n* Robust cache-control setting\n* Automatic gzipping\n* Automatic minification\n* Custom 404 pages\n* Custom response headers\n* Custom / automatic charset headers\n* Custom gzip patterns\n* Asset bundling and minification\n* Middleware export\n* Default error pages\n* on(status) listeners\n* Colored log output\n* Global executable\n* Directory indexing\n* Express.static API compatibility\n* node-static API compatibility\n\n## Using Lactate\n\n### Global executable\n\nIf installed globally with `npm install -g lactate`, you will have the `lactate` command at your disposal. This will run lactate static file server in the current working directory, utilizing the `cluster` module for multiple CPU cores. All [options](https://github.com/Weltschmerz/Lactate#options) are available.\n\n```code\n$ lactate --help\nUsage: lactate [options]\n\nOptions:\n--root, -r                    Local path                          [default: \"\"]\n--from, -f                    Public path                         [default: \"\"]\n--subdirs, -s                 Serve subdirectories                [default: true]\n--hidden, -h                  Serve hidden files                  [default: false]\n--error_pages, --error-pages  Serve error pages                   [default: true]\n--autoindex, -a               Automatically index directories     [default: true]\n--cache, -c                   Store assets in-memory              [default: true]\n--redis_cache, --rc           Store assets in-memory using Redis  [default: true]\n--watch_files, --watch-files  Watch files for cache update        [default: true]\n--max_age, --max-age, -M      Client-side caching max-age         [default: 172800]\n--gzip, -g                    Gzip text assets                    [default: true]\n--minify, -m                  Minify text assets                  [default: false]\n--bundle, -b                  Bundle text assets                  [default: false]\n--rebundle, --rb              Rebundle assets if modified         [default: true]\n--headers, -H                 Custom response headers             [default: \"\"]\n--debug, -d                   Log HTTP info                       [default: true]\n--quiet, -q                   Prevent all log output              [default: false]\n\n```\n\n### Programmatic lactating\n\nLactate can be used with either plain node, or with Express. With Express, Lactate is a drop-in replacement for `static` middleware, but with far more ability. The examples below use Express 2.x API for simplicity. See the [examples](https://github.com/Weltschmerz/Lactate/tree/master/example) for various examples.\n\n```js\nvar lactate = require('lactate');\nvar express = require('express');\n\nvar app = express.createServer();\napp.use(lactate.static(__dirname + '/files'));\n```\n\n## Testing Lactate\n\nIf installed locally (without -g flag to npm install):\n\n1. `cd` into `~/node_modules/lactate`\n2. `npm install ./` to install devDependencies\n3. `make test` to run mocha test\n\n##The varieties of Lactate experience\n\n###Creating a Lactate server\n\n```js\nvar lactate = require('lactate'); \nvar options = {root:'files'}; \nvar server = lactate.createServer(options); \n\nserver.listen(8080);\n```\n\n###Creating a directory handler\n\n```js\nvar lactate = require('lactate');\nvar options = {from:'public/path/to/files'};\nvar files = lactate.dir('files', options);\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', function(req, res) {\n  files.serve(req, res);\n});\n\nserver.listen(8080);\n```\n\n###Using directory middleware\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files', options);\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', files.toMiddleware());\nserver.listen(8080);\n```\n\n###Integrating with Express\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files', options);\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8080);\n```\n\n###Using Express.static API\n\n```js\nvar lactate = require('lactate');\nvar express = require('express');\nvar app = express();\n\napp.use(lactate.static(__dirname + '/files'));\napp.listen(8000);\n```\n\n###Using node-static API\n\n```js\nvar lactate = require('lactate');\nvar files = new(lactate.Server)('./files');\n\nvar http = require('http');\nvar server = new http.Server;\n\n// You could also pass a .toMiddleware()'d function\n\nserver.addListener('request', function(req, res) {\n  files.serve(req, res);\n});\n\nserver.listen(8000);\n```\n\n###Serving individual files\n\n```js\nvar lactate = require('lactate');\n\nvar fileOptions = {from:'public/directory'};\nvar files = lactate.dir('files', fileOptions);\n\nvar pageOptions = {};\nvar pages = lactate.dir('pages');\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', function(req, res) {\n  if (req.url === '/') {\n    pages.serve('index.html', req, res);\n  } else {\n    files.serve(req, res);\n  };\n});\nserver.listen(8000);\n```\n\n###Setting options\n\n```js\nvar lactate = require('lactate');\n\nvar fileOptions = {\n  from:'public'\n};\n\nvar files = lactate.dir('files', fileOptions);\n\nfiles.set('cache', false);\nfiles.disable('gzip');\nfiles.maxAge('ten days');\n\nvar express = require('express');\nvar app = express():\n  \napp.get('/public/*', files.toMiddleware());\napp.listen(8080);\n```\n\n###Bundling assets\n\n```js\nvar lactate = require('lactate');\nvar options = {\n  from:'files'\n};\n\nvar files = lactate.dir('files', options);\n\n// Combine and minify all scripts to 'common.js'\nfiles.bundle('js', 'common.js', function(err, data) {\n// Handle errors\n});\n\n// Combine and minify all CSS to 'common.css'\nfiles.bundleCSS('common.css');\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8000);\n```\n\n###Using custom 404 pages\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files');\n\nfiles.notFound('path/to/404/page.html');\n\nfiles.notFound(function(req, res) {\n  res.writeHead(404);\n  res.end('Woops, 404');\n});\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8000);\n```\n\n###Using custom response headers\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files');\n\nfiles.setHeader('x-powered-by', 'Lactate');\nfiles.header('x-timestamp', function(req, res) {\n  return new Date().toUTCString();\n});\n\nvar headers = {};\nfiles.headers(headers);\n```\n\n###Status listeners\n\nLactate extends EventEmitter for emitting status code events.\n\n```js\nvar files = lactate.dir('files');\nfiles.on('404', function(req) {\n  console.log('404', req.url);\n});\n```\n\n##Options\n\n### Setting options\n\nBoolean options may be set using `enable` and `disable` methods. Other options may be set using `set` method with either key/value or an options object.\n\n**Passing to initialization function**\n\n```js\nvar lactate = require('lactate').Lactate({\n  max_age:'two days'\n})\n```\n\n**Using `set` method**\n\n```js\nlactate.set('hidden', true)\n```\n\n**Using enable/disable:**\n\n```js\nlactate.disable('gzip');\nlactate.enable('minify');\n```\n\n**Special options methods**\n\nLactate has some special methods to reduce visual clutter. For setting client-side expiration use `maxAge`\n\n```js\nlactate.maxAge('two days');\n```\n\nis equivalent to:\n\n```js\nlactate.set('max age', 'two days');\n```\n\nFor setting `custom headers` you may use `setHeader`\n\n```js\nlactate.setHeader('x-powered-by', 'Rodent exercise');\n```\n\nYou can also use a function with `setHeader` for added variance:\n\n```js\nlactate.setHeader('x-id', function(req, res) {\n  return Math.random().toString(36).substring(2);\n}):\n```\n\nFor defining `charsets`, you may use `Lactate.define`\n\n```js\nlactate.define('js', 'application/javascript');\n```\n\nor with an object\n\n```js\nlactate.define({\n  'html': 'text/html; charset=utf-8',\n  'js': 'application/javascript'\n});\n```\n\n**Underscores or spaces**\n\nUse spaces instead of underscores if you prefer:\n\n```js\nlactate.disable('max age');\nlactate.enable('watch files');\n```\n\n### Options available\n\n+ `root` **string**\n\nLocal directory from which to serve files. By default, the current working directory.\n\n+ `from` **string**\n\nPublic directory exposed to clients. If set, only requests from /*directory* will complete. Contrast this with the `root` option which is the location of files on the serving machine, not necessarily the requested path.\n\n+ `subdirs` **boolean**\n\nBy default subdirectories are served. To disable this, set `subdirs` to false.\n\n+ `hidden` **boolean**\n\nWhether or not to serve hidden files. Default is false.\n\n+ `error pages` **boolean**\n\nEnabled by default. When disabled, Lactate will not serve error pages for 404 resposes, etc..\n\n+ `autoindex` **boolean**\n\nAutomatically display directory indexes. Disabled by default.\n\n+ `cache` **boolean** or **object**\n\nKeep files in-memory. Enabled by default. For caching options and more information about caching strategy, see [Caching Options](https://github.com/Weltschmerz/Lactate#caching-options).\n\n+ `gzip` **boolean**\n\nIf false, disables automatic gzipping for text files (HTML, JS, CSS). Enabled by default.\n\n+ `minify` **boolean**\n\nIf true, will automatically minify JavaScript and CSS using [Abridge](https://github.com/Weltschmerz/Abridge). Disabled by default.\n\n+ `watch files` **boolean**\n\nDetermines whether Lactate will watch files to update its cache. If this is disabled, then your file cache will not update automatically as files are modified on the server.\n\n+ `headers` **object** or **function**\n\nSets custom response headers. If the option value is a function, it is a callback which is give (req, res) arguments. This function should return the header value; it is a mapping function.\n\n+ `max age` **number** or **string**\n\nPass this function a number (of seconds) or a string and appropriate headers will be set for client-side caching. Lactate comes with expiration defaults, such as 'two days' or '5 years and sixteen days' See [Expire](https://github.com/Weltschmerz/Expire) for details.\n\n```js\nlactate.set('max_age', 87500)\n//87500 seconds\nlactate.set('max_age', 'two days')\n//172800 seconds\nlactate.set'max_age', 'five weeks and one minute and ten seconds')\n//3024070 seconds\nlactate.set('max_age', 'one year and 2 months and seven weeks and 16 seconds')\n//41050028 seconds\n```\n\n+ `not found` **string** or **function**\n\nFor custom 404 handling. Functions are supplied the response for 100% custom response handling. Otherwise, if set to a string, this option will be treated as an ordinary file path and abide rules for gzipping / in-memory cache.\n\n+ `gzip patterns` **array**\n\nSet custom gzip RegExp patterns. The patterns are matched with mime types. E.g. `/(\\+|\\/)xml$/` may be used for matching XML documents for gzipping. You may either use:\n\n```js\nlactate.set('gzip patterns', []);\n```\n\nOr perhaps more conveniently:\n\n```js\n//Accepts RegExp or String\nlactate.gzip(/pattern/, ...);\n```\n\n+ `charset` **boolean** or **string**\n\nSet custom response charset, or automatically detect charset using `node-mime`.\n\n```js\nlactate.enable('charset');\n// Content-Type: text/html; charset=UTF-8\n```\n\n```js\nlactate.set('charset', 'utf-8');\n// Content-Type: text/html; charset=UTF-8\n```\n\n+ `debug` **boolean**\n\nColored status / msg / path logging, for debugging purposes.\n\n###Caching options\n\nPass an object to the `cache` option setting. The following fields are accepted and optional:\n\n* `expire` Seconds expiration for cache keys. Keys expire after they are untouched for x-seconds. Default is `15min`.\n* `max keys` Maximum number of keys to keep in memory. Default is `Infinity`.\n* `max size` Maximum size in MB to keep in cache. Default is `100mb`.\n* `segment` Determines the threshold after which to segment a file for streaming instead of traditional writing. Default is `200kb`.\n\n```js\n  var options = {};\n  \n  options.cache = {\n    expire:5,\n    max_keys:200,\n    max_size:2,\n    segment:100\n  };\n\n  var files = lactate.static('files', options);\n\n  // Or use a string representation. Same as setting for max-age.\n  options.cache.expire = 'fifteen minutes';\n  files.set('cache', options.cache);\n```\n\n\n## License\n\nMIT\n\n","_id":"lactate@0.13.6","dist":{"shasum":"4f24d262916cf38a5d43079470815d63e3f14556","tarball":"https://registry.npmjs.org/lactate/-/lactate-0.13.6.tgz","integrity":"sha512-+ZtCaJwkuYPd9hDpBKKYaDATi96AAfU66pQlSRMy7A+UCboi7FIH8P+rwGHaU6l5ZDCULFIhXnuUSsUmxNk38w==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDM9DOXkSWDkUVTssF3+tO1v1VzAKy/JBxnCB7Ez+PBdAIgZTnjED22wlogVLtWLMN2+k2xCfszmmOOXmaDdri036Y="}]},"_npmVersion":"1.1.62","_npmUser":{"name":"Weltschmerz","email":"wltsmrz@gmail.com"},"maintainers":[{"name":"Weltschmerz","email":"chlavois@gmail.com"}]},"0.13.7":{"name":"lactate","version":"0.13.7","description":"Simple and featureful assets server","keywords":["static","file","server","assets","cache"],"repository":{"type":"git","url":"git://github.com/Weltschmerz/Lactate.git"},"author":{"name":"Weltschmerz","email":"wltsmrz@gmail.com"},"dependencies":{"mime":"1.2.7","suckle":"latest","expire":"latest","abridge":"latest","fraction":"latest","optimist":"0.3.5"},"devDependencies":{"mocha":"1.7.4","should":"1.2.1"},"main":"index.js","bin":{"lactate":"bin/lactate"},"scripts":{"test":"make test"},"engines":{"node":">= 0.6.0"},"readme":"# Lactate\n\n`npm install -g lactate`\n\nAn exceedingly fast static file handler, with a few electives.\n\n### Features\n\n* In-memory caching\n* Redis caching\n* Robust cache-control setting\n* Automatic gzipping\n* Automatic minification\n* Custom 404 pages\n* Custom response headers\n* Custom / automatic charset headers\n* Custom gzip patterns\n* Asset bundling and minification\n* Middleware export\n* Default error pages\n* on(status) listeners\n* Colored log output\n* Global executable\n* Directory indexing\n* Express.static API compatibility\n* node-static API compatibility\n\n## Using Lactate\n\n### Global executable\n\nIf installed globally with `npm install -g lactate`, you will have the `lactate` command at your disposal. This will run lactate static file server in the current working directory, utilizing the `cluster` module for multiple CPU cores. All [options](https://github.com/Weltschmerz/Lactate#options) are available.\n\n```code\n$ lactate --help\nUsage: lactate [options]\n\nOptions:\n--root, -r                    Local path                          [default: \"\"]\n--from, -f                    Public path                         [default: \"\"]\n--subdirs, -s                 Serve subdirectories                [default: true]\n--hidden, -h                  Serve hidden files                  [default: false]\n--error_pages, --error-pages  Serve error pages                   [default: true]\n--autoindex, -a               Automatically index directories     [default: true]\n--cache, -c                   Store assets in-memory              [default: true]\n--redis_cache, --rc           Store assets in-memory using Redis  [default: true]\n--watch_files, --watch-files  Watch files for cache update        [default: true]\n--max_age, --max-age, -M      Client-side caching max-age         [default: 172800]\n--gzip, -g                    Gzip text assets                    [default: true]\n--minify, -m                  Minify text assets                  [default: false]\n--bundle, -b                  Bundle text assets                  [default: false]\n--rebundle, --rb              Rebundle assets if modified         [default: true]\n--headers, -H                 Custom response headers             [default: \"\"]\n--debug, -d                   Log HTTP info                       [default: true]\n--quiet, -q                   Prevent all log output              [default: false]\n\n```\n\n### Programmatic lactating\n\nLactate can be used with either plain node, or with Express. With Express, Lactate is a drop-in replacement for `static` middleware, but with far more ability. The examples below use Express 2.x API for simplicity. See the [examples](https://github.com/Weltschmerz/Lactate/tree/master/example) for various examples.\n\n```js\nvar lactate = require('lactate');\nvar express = require('express');\n\nvar app = express.createServer();\napp.use(lactate.static(__dirname + '/files'));\n```\n\n## Testing Lactate\n\nIf installed locally (without -g flag to npm install):\n\n1. `cd` into `~/node_modules/lactate`\n2. `npm install ./` to install devDependencies\n3. `make test` to run mocha test\n\n##The varieties of Lactate experience\n\n###Creating a Lactate server\n\n```js\nvar lactate = require('lactate'); \nvar options = {root:'files'}; \nvar server = lactate.createServer(options); \n\nserver.listen(8080);\n```\n\n###Creating a directory handler\n\n```js\nvar lactate = require('lactate');\nvar options = {from:'public/path/to/files'};\nvar files = lactate.dir('files', options);\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', function(req, res) {\n  files.serve(req, res);\n});\n\nserver.listen(8080);\n```\n\n###Using directory middleware\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files', options);\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', files.toMiddleware());\nserver.listen(8080);\n```\n\n###Integrating with Express\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files', options);\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8080);\n```\n\n###Using Express.static API\n\n```js\nvar lactate = require('lactate');\nvar express = require('express');\nvar app = express();\n\napp.use(lactate.static(__dirname + '/files'));\napp.listen(8000);\n```\n\n###Using node-static API\n\n```js\nvar lactate = require('lactate');\nvar files = new(lactate.Server)('./files');\n\nvar http = require('http');\nvar server = new http.Server;\n\n// You could also pass a .toMiddleware()'d function\n\nserver.addListener('request', function(req, res) {\n  files.serve(req, res);\n});\n\nserver.listen(8000);\n```\n\n###Serving individual files\n\n```js\nvar lactate = require('lactate');\n\nvar fileOptions = {from:'public/directory'};\nvar files = lactate.dir('files', fileOptions);\n\nvar pageOptions = {};\nvar pages = lactate.dir('pages');\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', function(req, res) {\n  if (req.url === '/') {\n    pages.serve('index.html', req, res);\n  } else {\n    files.serve(req, res);\n  };\n});\nserver.listen(8000);\n```\n\n###Setting options\n\n```js\nvar lactate = require('lactate');\n\nvar fileOptions = {\n  from:'public'\n};\n\nvar files = lactate.dir('files', fileOptions);\n\nfiles.set('cache', false);\nfiles.disable('gzip');\nfiles.maxAge('ten days');\n\nvar express = require('express');\nvar app = express():\n  \napp.get('/public/*', files.toMiddleware());\napp.listen(8080);\n```\n\n###Bundling assets\n\n```js\nvar lactate = require('lactate');\nvar options = {\n  from:'files'\n};\n\nvar files = lactate.dir('files', options);\n\n// Combine and minify all scripts to 'common.js'\nfiles.bundle('js', 'common.js', function(err, data) {\n// Handle errors\n});\n\n// Combine and minify all CSS to 'common.css'\nfiles.bundleCSS('common.css');\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8000);\n```\n\n###Using custom 404 pages\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files');\n\nfiles.notFound('path/to/404/page.html');\n\nfiles.notFound(function(req, res) {\n  res.writeHead(404);\n  res.end('Woops, 404');\n});\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8000);\n```\n\n###Using custom response headers\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files');\n\nfiles.setHeader('x-powered-by', 'Lactate');\nfiles.header('x-timestamp', function(req, res) {\n  return new Date().toUTCString();\n});\n\nvar headers = {};\nfiles.headers(headers);\n```\n\n###Status listeners\n\nLactate extends EventEmitter for emitting status code events.\n\n```js\nvar files = lactate.dir('files');\nfiles.on('404', function(req) {\n  console.log('404', req.url);\n});\n```\n\n##Options\n\n### Setting options\n\nBoolean options may be set using `enable` and `disable` methods. Other options may be set using `set` method with either key/value or an options object.\n\n**Passing to initialization function**\n\n```js\nvar lactate = require('lactate').Lactate({\n  max_age:'two days'\n})\n```\n\n**Using `set` method**\n\n```js\nlactate.set('hidden', true)\n```\n\n**Using enable/disable:**\n\n```js\nlactate.disable('gzip');\nlactate.enable('minify');\n```\n\n**Special options methods**\n\nLactate has some special methods to reduce visual clutter. For setting client-side expiration use `maxAge`\n\n```js\nlactate.maxAge('two days');\n```\n\nis equivalent to:\n\n```js\nlactate.set('max age', 'two days');\n```\n\nFor setting `custom headers` you may use `setHeader`\n\n```js\nlactate.setHeader('x-powered-by', 'Rodent exercise');\n```\n\nYou can also use a function with `setHeader` for added variance:\n\n```js\nlactate.setHeader('x-id', function(req, res) {\n  return Math.random().toString(36).substring(2);\n}):\n```\n\nFor defining `charsets`, you may use `Lactate.define`\n\n```js\nlactate.define('js', 'application/javascript');\n```\n\nor with an object\n\n```js\nlactate.define({\n  'html': 'text/html; charset=utf-8',\n  'js': 'application/javascript'\n});\n```\n\n**Underscores or spaces**\n\nUse spaces instead of underscores if you prefer:\n\n```js\nlactate.disable('max age');\nlactate.enable('watch files');\n```\n\n### Options available\n\n+ `root` **string**\n\nLocal directory from which to serve files. By default, the current working directory.\n\n+ `from` **string**\n\nPublic directory exposed to clients. If set, only requests from /*directory* will complete. Contrast this with the `root` option which is the location of files on the serving machine, not necessarily the requested path.\n\n+ `subdirs` **boolean**\n\nBy default subdirectories are served. To disable this, set `subdirs` to false.\n\n+ `hidden` **boolean**\n\nWhether or not to serve hidden files. Default is false.\n\n+ `error pages` **boolean**\n\nEnabled by default. When disabled, Lactate will not serve error pages for 404 resposes, etc..\n\n+ `autoindex` **boolean**\n\nAutomatically display directory indexes. Disabled by default.\n\n+ `cache` **boolean** or **object**\n\nKeep files in-memory. Enabled by default. For caching options and more information about caching strategy, see [Caching Options](https://github.com/Weltschmerz/Lactate#caching-options).\n\n+ `gzip` **boolean**\n\nIf false, disables automatic gzipping for text files (HTML, JS, CSS). Enabled by default.\n\n+ `minify` **boolean**\n\nIf true, will automatically minify JavaScript and CSS using [Abridge](https://github.com/Weltschmerz/Abridge). Disabled by default.\n\n+ `watch files` **boolean**\n\nDetermines whether Lactate will watch files to update its cache. If this is disabled, then your file cache will not update automatically as files are modified on the server.\n\n+ `headers` **object** or **function**\n\nSets custom response headers. If the option value is a function, it is a callback which is give (req, res) arguments. This function should return the header value; it is a mapping function.\n\n+ `max age` **number** or **string**\n\nPass this function a number (of seconds) or a string and appropriate headers will be set for client-side caching. Lactate comes with expiration defaults, such as 'two days' or '5 years and sixteen days' See [Expire](https://github.com/Weltschmerz/Expire) for details.\n\n```js\nlactate.set('max_age', 87500)\n//87500 seconds\nlactate.set('max_age', 'two days')\n//172800 seconds\nlactate.set'max_age', 'five weeks and one minute and ten seconds')\n//3024070 seconds\nlactate.set('max_age', 'one year and 2 months and seven weeks and 16 seconds')\n//41050028 seconds\n```\n\n+ `not found` **string** or **function**\n\nFor custom 404 handling. Functions are supplied the response for 100% custom response handling. Otherwise, if set to a string, this option will be treated as an ordinary file path and abide rules for gzipping / in-memory cache.\n\n+ `gzip patterns` **array**\n\nSet custom gzip RegExp patterns. The patterns are matched with mime types. E.g. `/(\\+|\\/)xml$/` may be used for matching XML documents for gzipping. You may either use:\n\n```js\nlactate.set('gzip patterns', []);\n```\n\nOr perhaps more conveniently:\n\n```js\n//Accepts RegExp or String\nlactate.gzip(/pattern/, ...);\n```\n\n+ `charset` **boolean** or **string**\n\nSet custom response charset, or automatically detect charset using `node-mime`.\n\n```js\nlactate.enable('charset');\n// Content-Type: text/html; charset=UTF-8\n```\n\n```js\nlactate.set('charset', 'utf-8');\n// Content-Type: text/html; charset=UTF-8\n```\n\n+ `debug` **boolean**\n\nColored status / msg / path logging, for debugging purposes.\n\n###Caching options\n\nPass an object to the `cache` option setting. The following fields are accepted and optional:\n\n* `expire` Seconds expiration for cache keys. Keys expire after they are untouched for x-seconds. Default is `15min`.\n* `max keys` Maximum number of keys to keep in memory. Default is `Infinity`.\n* `max size` Maximum size in MB to keep in cache. Default is `100mb`.\n* `segment` Determines the threshold after which to segment a file for streaming instead of traditional writing. Default is `200kb`.\n\n```js\n  var options = {};\n  \n  options.cache = {\n    expire:5,\n    max_keys:200,\n    max_size:2,\n    segment:100\n  };\n\n  var files = lactate.static('files', options);\n\n  // Or use a string representation. Same as setting for max-age.\n  options.cache.expire = 'fifteen minutes';\n  files.set('cache', options.cache);\n```\n\n\n## License\n\nMIT\n\n","_id":"lactate@0.13.7","dist":{"shasum":"cd4deb2a48da65ae1c410c1633e3cc1e3dff8272","tarball":"https://registry.npmjs.org/lactate/-/lactate-0.13.7.tgz","integrity":"sha512-Sc2FPjoFPu0ylNzCsrJJXd/6xVoVmXP9mzvLX/AQ+0A2dq+UP4yzqdx05YPDCpBhOWugC5IGK9YGFrI2Z1YCOQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHdOwHL3aRBdDUYYFxWnL6zdT8Gh9GGMVPdohas+q5GwAiEAqw0PLh0nP5xwDAExqkpKopKe6lEi2ObrRxUJAUA0i6Q="}]},"_npmVersion":"1.1.62","_npmUser":{"name":"Weltschmerz","email":"wltsmrz@gmail.com"},"maintainers":[{"name":"Weltschmerz","email":"chlavois@gmail.com"}]},"0.13.8":{"name":"lactate","version":"0.13.8","description":"Simple and featureful assets server","keywords":["static","file","server","assets","cache"],"repository":{"type":"git","url":"git://github.com/Weltschmerz/Lactate.git"},"author":{"name":"Weltschmerz","email":"wltsmrz@gmail.com"},"dependencies":{"mime":"1.2.9","suckle":"latest","expire":"latest","abridge":"latest","fraction":"latest","optimist":"0.3.5"},"devDependencies":{"mocha":"1.8.1","should":"1.2.1"},"main":"index.js","bin":{"lactate":"bin/lactate"},"scripts":{"test":"make test"},"engines":{"node":">= 0.6.0"},"readme":"# Lactate\n\n`npm install -g lactate`\n\nAn exceedingly fast static file handler, with a few electives.\n\n### Features\n\n* In-memory caching\n* Redis caching\n* Robust cache-control setting\n* Automatic gzipping\n* Automatic minification\n* Custom 404 pages\n* Custom response headers\n* Custom / automatic charset headers\n* Custom gzip patterns\n* Asset bundling and minification\n* Middleware export\n* Default error pages\n* on(status) listeners\n* Colored log output\n* Global executable\n* Directory indexing\n* Express.static API compatibility\n* node-static API compatibility\n\n## Using Lactate\n\n### Global executable\n\nIf installed globally with `npm install -g lactate`, you will have the `lactate` command at your disposal. This will run lactate static file server in the current working directory, utilizing the `cluster` module for multiple CPU cores. All [options](https://github.com/Weltschmerz/Lactate#options) are available.\n\n```code\n$ lactate --help\nUsage: lactate [options]\n\nOptions:\n--root, -r                    Local path                          [default: \"\"]\n--from, -f                    Public path                         [default: \"\"]\n--subdirs, -s                 Serve subdirectories                [default: true]\n--hidden, -h                  Serve hidden files                  [default: false]\n--error_pages, --error-pages  Serve error pages                   [default: true]\n--autoindex, -a               Automatically index directories     [default: true]\n--cache, -c                   Store assets in-memory              [default: true]\n--redis_cache, --rc           Store assets in-memory using Redis  [default: true]\n--watch_files, --watch-files  Watch files for cache update        [default: true]\n--max_age, --max-age, -M      Client-side caching max-age         [default: 172800]\n--gzip, -g                    Gzip text assets                    [default: true]\n--minify, -m                  Minify text assets                  [default: false]\n--bundle, -b                  Bundle text assets                  [default: false]\n--rebundle, --rb              Rebundle assets if modified         [default: true]\n--headers, -H                 Custom response headers             [default: \"\"]\n--debug, -d                   Log HTTP info                       [default: true]\n--quiet, -q                   Prevent all log output              [default: false]\n\n```\n\n### Programmatic lactating\n\nLactate can be used with either plain node, or with Express. With Express, Lactate is a drop-in replacement for `static` middleware, but with far more ability. The examples below use Express 2.x API for simplicity. See the [examples](https://github.com/Weltschmerz/Lactate/tree/master/example) for various examples.\n\n```js\nvar lactate = require('lactate');\nvar express = require('express');\n\nvar app = express.createServer();\napp.use(lactate.static(__dirname + '/files'));\n```\n\n## Testing Lactate\n\nIf installed locally (without -g flag to npm install):\n\n1. `cd` into `~/node_modules/lactate`\n2. `npm install ./` to install devDependencies\n3. `make test` to run mocha test\n\n##The varieties of Lactate experience\n\n###Creating a Lactate server\n\n```js\nvar lactate = require('lactate'); \nvar options = {root:'files'}; \nvar server = lactate.createServer(options); \n\nserver.listen(8080);\n```\n\n###Creating a directory handler\n\n```js\nvar lactate = require('lactate');\nvar options = {from:'public/path/to/files'};\nvar files = lactate.dir('files', options);\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', function(req, res) {\n  files.serve(req, res);\n});\n\nserver.listen(8080);\n```\n\n###Using directory middleware\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files', options);\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', files.toMiddleware());\nserver.listen(8080);\n```\n\n###Integrating with Express\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files', options);\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8080);\n```\n\n###Using Express.static API\n\n```js\nvar lactate = require('lactate');\nvar express = require('express');\nvar app = express();\n\napp.use(lactate.static(__dirname + '/files'));\napp.listen(8000);\n```\n\n###Using node-static API\n\n```js\nvar lactate = require('lactate');\nvar files = new(lactate.Server)('./files');\n\nvar http = require('http');\nvar server = new http.Server;\n\n// You could also pass a .toMiddleware()'d function\n\nserver.addListener('request', function(req, res) {\n  files.serve(req, res);\n});\n\nserver.listen(8000);\n```\n\n###Serving individual files\n\n```js\nvar lactate = require('lactate');\n\nvar fileOptions = {from:'public/directory'};\nvar files = lactate.dir('files', fileOptions);\n\nvar pageOptions = {};\nvar pages = lactate.dir('pages');\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', function(req, res) {\n  if (req.url === '/') {\n    pages.serve('index.html', req, res);\n  } else {\n    files.serve(req, res);\n  };\n});\nserver.listen(8000);\n```\n\n###Setting options\n\n```js\nvar lactate = require('lactate');\n\nvar fileOptions = {\n  from:'public'\n};\n\nvar files = lactate.dir('files', fileOptions);\n\nfiles.set('cache', false);\nfiles.disable('gzip');\nfiles.maxAge('ten days');\n\nvar express = require('express');\nvar app = express():\n  \napp.get('/public/*', files.toMiddleware());\napp.listen(8080);\n```\n\n###Bundling assets\n\n```js\nvar lactate = require('lactate');\nvar options = {\n  from:'files'\n};\n\nvar files = lactate.dir('files', options);\n\n// Combine and minify all scripts to 'common.js'\nfiles.bundle('js', 'common.js', function(err, data) {\n// Handle errors\n});\n\n// Combine and minify all CSS to 'common.css'\nfiles.bundleCSS('common.css');\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8000);\n```\n\n###Using custom 404 pages\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files');\n\nfiles.notFound('path/to/404/page.html');\n\nfiles.notFound(function(req, res) {\n  res.writeHead(404);\n  res.end('Woops, 404');\n});\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8000);\n```\n\n###Using custom response headers\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files');\n\nfiles.setHeader('x-powered-by', 'Lactate');\nfiles.header('x-timestamp', function(req, res) {\n  return new Date().toUTCString();\n});\n\nvar headers = {};\nfiles.headers(headers);\n```\n\n###Status listeners\n\nLactate extends EventEmitter for emitting status code events.\n\n```js\nvar files = lactate.dir('files');\nfiles.on('404', function(req) {\n  console.log('404', req.url);\n});\n```\n\n##Options\n\n### Setting options\n\nBoolean options may be set using `enable` and `disable` methods. Other options may be set using `set` method with either key/value or an options object.\n\n**Passing to initialization function**\n\n```js\nvar lactate = require('lactate').Lactate({\n  max_age:'two days'\n})\n```\n\n**Using `set` method**\n\n```js\nlactate.set('hidden', true)\n```\n\n**Using enable/disable:**\n\n```js\nlactate.disable('gzip');\nlactate.enable('minify');\n```\n\n**Special options methods**\n\nLactate has some special methods to reduce visual clutter. For setting client-side expiration use `maxAge`\n\n```js\nlactate.maxAge('two days');\n```\n\nis equivalent to:\n\n```js\nlactate.set('max age', 'two days');\n```\n\nFor setting `custom headers` you may use `setHeader`\n\n```js\nlactate.setHeader('x-powered-by', 'Rodent exercise');\n```\n\nYou can also use a function with `setHeader` for added variance:\n\n```js\nlactate.setHeader('x-id', function(req, res) {\n  return Math.random().toString(36).substring(2);\n}):\n```\n\nFor defining `charsets`, you may use `Lactate.define`\n\n```js\nlactate.define('js', 'application/javascript');\n```\n\nor with an object\n\n```js\nlactate.define({\n  'html': 'text/html; charset=utf-8',\n  'js': 'application/javascript'\n});\n```\n\n**Underscores or spaces**\n\nUse spaces instead of underscores if you prefer:\n\n```js\nlactate.disable('max age');\nlactate.enable('watch files');\n```\n\n### Options available\n\n+ `root` **string**\n\nLocal directory from which to serve files. By default, the current working directory.\n\n+ `from` **string**\n\nPublic directory exposed to clients. If set, only requests from /*directory* will complete. Contrast this with the `root` option which is the location of files on the serving machine, not necessarily the requested path.\n\n+ `subdirs` **boolean**\n\nBy default subdirectories are served. To disable this, set `subdirs` to false.\n\n+ `hidden` **boolean**\n\nWhether or not to serve hidden files. Default is false.\n\n+ `error pages` **boolean**\n\nEnabled by default. When disabled, Lactate will not serve error pages for 404 resposes, etc..\n\n+ `autoindex` **boolean**\n\nAutomatically display directory indexes. Disabled by default.\n\n+ `cache` **boolean** or **object**\n\nKeep files in-memory. Enabled by default. For caching options and more information about caching strategy, see [Caching Options](https://github.com/Weltschmerz/Lactate#caching-options).\n\n+ `gzip` **boolean**\n\nIf false, disables automatic gzipping for text files (HTML, JS, CSS). Enabled by default.\n\n+ `minify` **boolean**\n\nIf true, will automatically minify JavaScript and CSS using [Abridge](https://github.com/Weltschmerz/Abridge). Disabled by default.\n\n+ `watch files` **boolean**\n\nDetermines whether Lactate will watch files to update its cache. If this is disabled, then your file cache will not update automatically as files are modified on the server.\n\n+ `headers` **object** or **function**\n\nSets custom response headers. If the option value is a function, it is a callback which is give (req, res) arguments. This function should return the header value; it is a mapping function.\n\n+ `max age` **number** or **string**\n\nPass this function a number (of seconds) or a string and appropriate headers will be set for client-side caching. Lactate comes with expiration defaults, such as 'two days' or '5 years and sixteen days' See [Expire](https://github.com/Weltschmerz/Expire) for details.\n\n```js\nlactate.set('max_age', 87500)\n//87500 seconds\nlactate.set('max_age', 'two days')\n//172800 seconds\nlactate.set'max_age', 'five weeks and one minute and ten seconds')\n//3024070 seconds\nlactate.set('max_age', 'one year and 2 months and seven weeks and 16 seconds')\n//41050028 seconds\n```\n\n+ `not found` **string** or **function**\n\nFor custom 404 handling. Functions are supplied the response for 100% custom response handling. Otherwise, if set to a string, this option will be treated as an ordinary file path and abide rules for gzipping / in-memory cache.\n\n+ `gzip patterns` **array**\n\nSet custom gzip RegExp patterns. The patterns are matched with mime types. E.g. `/(\\+|\\/)xml$/` may be used for matching XML documents for gzipping. You may either use:\n\n```js\nlactate.set('gzip patterns', []);\n```\n\nOr perhaps more conveniently:\n\n```js\n//Accepts RegExp or String\nlactate.gzip(/pattern/, ...);\n```\n\n+ `charset` **boolean** or **string**\n\nSet custom response charset, or automatically detect charset using `node-mime`.\n\n```js\nlactate.enable('charset');\n// Content-Type: text/html; charset=UTF-8\n```\n\n```js\nlactate.set('charset', 'utf-8');\n// Content-Type: text/html; charset=UTF-8\n```\n\n+ `debug` **boolean**\n\nColored status / msg / path logging, for debugging purposes.\n\n###Caching options\n\nPass an object to the `cache` option setting. The following fields are accepted and optional:\n\n* `expire` Seconds expiration for cache keys. Keys expire after they are untouched for x-seconds. Default is `15min`.\n* `max keys` Maximum number of keys to keep in memory. Default is `Infinity`.\n* `max size` Maximum size in MB to keep in cache. Default is `100mb`.\n* `segment` Determines the threshold after which to segment a file for streaming instead of traditional writing. Default is `200kb`.\n\n```js\n  var options = {};\n  \n  options.cache = {\n    expire:5,\n    max_keys:200,\n    max_size:2,\n    segment:100\n  };\n\n  var files = lactate.static('files', options);\n\n  // Or use a string representation. Same as setting for max-age.\n  options.cache.expire = 'fifteen minutes';\n  files.set('cache', options.cache);\n```\n\n\n## License\n\nMIT\n\n","readmeFilename":"README.md","_id":"lactate@0.13.8","dist":{"shasum":"52e0f0c1cf0edfd1cef426a3915c558a1b14b209","tarball":"https://registry.npmjs.org/lactate/-/lactate-0.13.8.tgz","integrity":"sha512-+A6lbnCIw5NPUmJz29H5980UYWnZ0rcIIzohAGBz3N+It3HdeSifu6JG71HfQ4PM4oHC8jiy5eU91PPoMnH/+A==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCYqGknUkATe/bfoegLiwAnbgqHBgGGhfDNpJFibBrTHwIhAJkpJTxV8CRFDxiJdNwSFMCnl9mjriwAqjC/QiietCVY"}]},"_npmVersion":"1.1.69","_npmUser":{"name":"Weltschmerz","email":"wltsmrz@gmail.com"},"maintainers":[{"name":"Weltschmerz","email":"chlavois@gmail.com"}]},"0.13.9":{"name":"lactate","version":"0.13.9","description":"Simple and featureful assets server","keywords":["static","file","server","assets","cache"],"repository":{"type":"git","url":"git://github.com/Weltschmerz/Lactate.git"},"author":{"name":"Weltschmerz","email":"wltsmrz@gmail.com"},"dependencies":{"mime":"1.2.9","suckle":"latest","expire":"latest","abridge":"latest","fraction":"latest","optimist":"0.3.5"},"devDependencies":{"mocha":"1.8.1","should":"1.2.1"},"main":"index.js","bin":{"lactate":"bin/lactate"},"scripts":{"test":"make test"},"engines":{"node":">= 0.6.0"},"readme":"# Lactate\n\n`npm install -g lactate`\n\nAn exceedingly fast static file handler, with a few electives.\n\n### Features\n\n* In-memory caching\n* Redis caching\n* Robust cache-control setting\n* Automatic gzipping\n* Automatic minification\n* Custom 404 pages\n* Custom response headers\n* Custom / automatic charset headers\n* Custom gzip patterns\n* Asset bundling and minification\n* Middleware export\n* Default error pages\n* on(status) listeners\n* Colored log output\n* Global executable\n* Directory indexing\n* Express.static API compatibility\n* node-static API compatibility\n\n## Using Lactate\n\n### Global executable\n\nIf installed globally with `npm install -g lactate`, you will have the `lactate` command at your disposal. This will run lactate static file server in the current working directory, utilizing the `cluster` module for multiple CPU cores. All [options](https://github.com/Weltschmerz/Lactate#options) are available.\n\n```code\n$ lactate --help\nUsage: lactate [options]\n\nOptions:\n--root, -r                    Local path                          [default: \"\"]\n--from, -f                    Public path                         [default: \"\"]\n--subdirs, -s                 Serve subdirectories                [default: true]\n--hidden, -h                  Serve hidden files                  [default: false]\n--error_pages, --error-pages  Serve error pages                   [default: true]\n--autoindex, -a               Automatically index directories     [default: true]\n--cache, -c                   Store assets in-memory              [default: true]\n--redis_cache, --rc           Store assets in-memory using Redis  [default: true]\n--watch_files, --watch-files  Watch files for cache update        [default: true]\n--max_age, --max-age, -M      Client-side caching max-age         [default: 172800]\n--gzip, -g                    Gzip text assets                    [default: true]\n--minify, -m                  Minify text assets                  [default: false]\n--bundle, -b                  Bundle text assets                  [default: false]\n--rebundle, --rb              Rebundle assets if modified         [default: true]\n--headers, -H                 Custom response headers             [default: \"\"]\n--debug, -d                   Log HTTP info                       [default: true]\n--quiet, -q                   Prevent all log output              [default: false]\n\n```\n\n### Programmatic lactating\n\nLactate can be used with either plain node, or with Express. With Express, Lactate is a drop-in replacement for `static` middleware, but with far more ability. The examples below use Express 2.x API for simplicity. See the [examples](https://github.com/Weltschmerz/Lactate/tree/master/example) for various examples.\n\n```js\nvar lactate = require('lactate');\nvar express = require('express');\n\nvar app = express.createServer();\napp.use(lactate.static(__dirname + '/files'));\n```\n\n## Testing Lactate\n\nIf installed locally (without -g flag to npm install):\n\n1. `cd` into `~/node_modules/lactate`\n2. `npm install ./` to install devDependencies\n3. `make test` to run mocha test\n\n##The varieties of Lactate experience\n\n###Creating a Lactate server\n\n```js\nvar lactate = require('lactate'); \nvar options = {root:'files'}; \nvar server = lactate.createServer(options); \n\nserver.listen(8080);\n```\n\n###Creating a directory handler\n\n```js\nvar lactate = require('lactate');\nvar options = {from:'public/path/to/files'};\nvar files = lactate.dir('files', options);\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', function(req, res) {\n  files.serve(req, res);\n});\n\nserver.listen(8080);\n```\n\n###Using directory middleware\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files', options);\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', files.toMiddleware());\nserver.listen(8080);\n```\n\n###Integrating with Express\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files', options);\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8080);\n```\n\n###Using Express.static API\n\n```js\nvar lactate = require('lactate');\nvar express = require('express');\nvar app = express();\n\napp.use(lactate.static(__dirname + '/files'));\napp.listen(8000);\n```\n\n###Using node-static API\n\n```js\nvar lactate = require('lactate');\nvar files = new(lactate.Server)('./files');\n\nvar http = require('http');\nvar server = new http.Server;\n\n// You could also pass a .toMiddleware()'d function\n\nserver.addListener('request', function(req, res) {\n  files.serve(req, res);\n});\n\nserver.listen(8000);\n```\n\n###Serving individual files\n\n```js\nvar lactate = require('lactate');\n\nvar fileOptions = {from:'public/directory'};\nvar files = lactate.dir('files', fileOptions);\n\nvar pageOptions = {};\nvar pages = lactate.dir('pages');\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', function(req, res) {\n  if (req.url === '/') {\n    pages.serve('index.html', req, res);\n  } else {\n    files.serve(req, res);\n  };\n});\nserver.listen(8000);\n```\n\n###Setting options\n\n```js\nvar lactate = require('lactate');\n\nvar fileOptions = {\n  from:'public'\n};\n\nvar files = lactate.dir('files', fileOptions);\n\nfiles.set('cache', false);\nfiles.disable('gzip');\nfiles.maxAge('ten days');\n\nvar express = require('express');\nvar app = express():\n  \napp.get('/public/*', files.toMiddleware());\napp.listen(8080);\n```\n\n###Bundling assets\n\n```js\nvar lactate = require('lactate');\nvar options = {\n  from:'files'\n};\n\nvar files = lactate.dir('files', options);\n\n// Combine and minify all scripts to 'common.js'\nfiles.bundle('js', 'common.js', function(err, data) {\n// Handle errors\n});\n\n// Combine and minify all CSS to 'common.css'\nfiles.bundleCSS('common.css');\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8000);\n```\n\n###Using custom 404 pages\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files');\n\nfiles.notFound('path/to/404/page.html');\n\nfiles.notFound(function(req, res) {\n  res.writeHead(404);\n  res.end('Woops, 404');\n});\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8000);\n```\n\n###Using custom response headers\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files');\n\nfiles.setHeader('x-powered-by', 'Lactate');\nfiles.header('x-timestamp', function(req, res) {\n  return new Date().toUTCString();\n});\n\nvar headers = {};\nfiles.headers(headers);\n```\n\n###Status listeners\n\nLactate extends EventEmitter for emitting status code events.\n\n```js\nvar files = lactate.dir('files');\nfiles.on('404', function(req) {\n  console.log('404', req.url);\n});\n```\n\n##Options\n\n### Setting options\n\nBoolean options may be set using `enable` and `disable` methods. Other options may be set using `set` method with either key/value or an options object.\n\n**Passing to initialization function**\n\n```js\nvar lactate = require('lactate').Lactate({\n  max_age:'two days'\n})\n```\n\n**Using `set` method**\n\n```js\nlactate.set('hidden', true)\n```\n\n**Using enable/disable:**\n\n```js\nlactate.disable('gzip');\nlactate.enable('minify');\n```\n\n**Special options methods**\n\nLactate has some special methods to reduce visual clutter. For setting client-side expiration use `maxAge`\n\n```js\nlactate.maxAge('two days');\n```\n\nis equivalent to:\n\n```js\nlactate.set('max age', 'two days');\n```\n\nFor setting `custom headers` you may use `setHeader`\n\n```js\nlactate.setHeader('x-powered-by', 'Rodent exercise');\n```\n\nYou can also use a function with `setHeader` for added variance:\n\n```js\nlactate.setHeader('x-id', function(req, res) {\n  return Math.random().toString(36).substring(2);\n}):\n```\n\nFor defining `charsets`, you may use `Lactate.define`\n\n```js\nlactate.define('js', 'application/javascript');\n```\n\nor with an object\n\n```js\nlactate.define({\n  'html': 'text/html; charset=utf-8',\n  'js': 'application/javascript'\n});\n```\n\n**Underscores or spaces**\n\nUse spaces instead of underscores if you prefer:\n\n```js\nlactate.disable('max age');\nlactate.enable('watch files');\n```\n\n### Options available\n\n+ `root` **string**\n\nLocal directory from which to serve files. By default, the current working directory.\n\n+ `from` **string**\n\nPublic directory exposed to clients. If set, only requests from /*directory* will complete. Contrast this with the `root` option which is the location of files on the serving machine, not necessarily the requested path.\n\n+ `subdirs` **boolean**\n\nBy default subdirectories are served. To disable this, set `subdirs` to false.\n\n+ `hidden` **boolean**\n\nWhether or not to serve hidden files. Default is false.\n\n+ `error pages` **boolean**\n\nEnabled by default. When disabled, Lactate will not serve error pages for 404 resposes, etc..\n\n+ `autoindex` **boolean**\n\nAutomatically display directory indexes. Disabled by default.\n\n+ `cache` **boolean** or **object**\n\nKeep files in-memory. Enabled by default. For caching options and more information about caching strategy, see [Caching Options](https://github.com/Weltschmerz/Lactate#caching-options).\n\n+ `gzip` **boolean**\n\nIf false, disables automatic gzipping for text files (HTML, JS, CSS). Enabled by default.\n\n+ `minify` **boolean**\n\nIf true, will automatically minify JavaScript and CSS using [Abridge](https://github.com/Weltschmerz/Abridge). Disabled by default.\n\n+ `watch files` **boolean**\n\nDetermines whether Lactate will watch files to update its cache. If this is disabled, then your file cache will not update automatically as files are modified on the server.\n\n+ `headers` **object** or **function**\n\nSets custom response headers. If the option value is a function, it is a callback which is give (req, res) arguments. This function should return the header value; it is a mapping function.\n\n+ `max age` **number** or **string**\n\nPass this function a number (of seconds) or a string and appropriate headers will be set for client-side caching. Lactate comes with expiration defaults, such as 'two days' or '5 years and sixteen days' See [Expire](https://github.com/Weltschmerz/Expire) for details.\n\n```js\nlactate.set('max_age', 87500)\n//87500 seconds\nlactate.set('max_age', 'two days')\n//172800 seconds\nlactate.set'max_age', 'five weeks and one minute and ten seconds')\n//3024070 seconds\nlactate.set('max_age', 'one year and 2 months and seven weeks and 16 seconds')\n//41050028 seconds\n```\n\n+ `not found` **string** or **function**\n\nFor custom 404 handling. Functions are supplied the response for 100% custom response handling. Otherwise, if set to a string, this option will be treated as an ordinary file path and abide rules for gzipping / in-memory cache.\n\n+ `gzip patterns` **array**\n\nSet custom gzip RegExp patterns. The patterns are matched with mime types. E.g. `/(\\+|\\/)xml$/` may be used for matching XML documents for gzipping. You may either use:\n\n```js\nlactate.set('gzip patterns', []);\n```\n\nOr perhaps more conveniently:\n\n```js\n//Accepts RegExp or String\nlactate.gzip(/pattern/, ...);\n```\n\n+ `charset` **boolean** or **string**\n\nSet custom response charset, or automatically detect charset using `node-mime`.\n\n```js\nlactate.enable('charset');\n// Content-Type: text/html; charset=UTF-8\n```\n\n```js\nlactate.set('charset', 'utf-8');\n// Content-Type: text/html; charset=UTF-8\n```\n\n+ `debug` **boolean**\n\nColored status / msg / path logging, for debugging purposes.\n\n###Caching options\n\nPass an object to the `cache` option setting. The following fields are accepted and optional:\n\n* `expire` Seconds expiration for cache keys. Keys expire after they are untouched for x-seconds. Default is `15min`.\n* `max keys` Maximum number of keys to keep in memory. Default is `Infinity`.\n* `max size` Maximum size in MB to keep in cache. Default is `100mb`.\n* `segment` Determines the threshold after which to segment a file for streaming instead of traditional writing. Default is `200kb`.\n\n```js\n  var options = {};\n  \n  options.cache = {\n    expire:5,\n    max_keys:200,\n    max_size:2,\n    segment:100\n  };\n\n  var files = lactate.static('files', options);\n\n  // Or use a string representation. Same as setting for max-age.\n  options.cache.expire = 'fifteen minutes';\n  files.set('cache', options.cache);\n```\n\n\n## License\n\nMIT\n\n","readmeFilename":"README.md","_id":"lactate@0.13.9","dist":{"shasum":"b89ad258e6df0eb47948ab873d21d54cf64ddb6e","tarball":"https://registry.npmjs.org/lactate/-/lactate-0.13.9.tgz","integrity":"sha512-fNer4n4DRSA7y7b8spU616ttE958Tjy7FBtSxrM/7wPxIb5Y8KrxGqqUuI17ZChqKMEbVi7v1t568yw7E8uJTA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDLt2JwiH8JZM2nOvfyQJPkyDMO8iuIFtO8QFEpUQhb7QIhAJSb8Q9DQOMNYqdDDHbWRFuKe9jIfISbU1prOeey2HzX"}]},"_npmVersion":"1.1.69","_npmUser":{"name":"Weltschmerz","email":"wltsmrz@gmail.com"},"maintainers":[{"name":"Weltschmerz","email":"chlavois@gmail.com"}]},"0.13.10":{"name":"lactate","version":"0.13.10","description":"Simple and featureful assets server","keywords":["static","file","server","assets","cache"],"repository":{"type":"git","url":"git://github.com/Weltschmerz/Lactate.git"},"author":{"name":"Weltschmerz","email":"wltsmrz@gmail.com"},"dependencies":{"mime":"1.2.9","suckle":"latest","expire":"latest","abridge":"latest","fraction":"latest","optimist":"0.3.5"},"devDependencies":{"mocha":"1.8.1","should":"1.2.1"},"main":"index.js","bin":{"lactate":"bin/lactate"},"scripts":{"test":"make test"},"engines":{"node":">= 0.6.0"},"readme":"# Lactate\n\n`npm install -g lactate`\n\nAn exceedingly fast static file handler, with a few electives.\n\n### Features\n\n* In-memory caching\n* Redis caching\n* Robust cache-control setting\n* Automatic gzipping\n* Automatic minification\n* Custom 404 pages\n* Custom response headers\n* Custom / automatic charset headers\n* Custom gzip patterns\n* Asset bundling and minification\n* Middleware export\n* Default error pages\n* on(status) listeners\n* Colored log output\n* Global executable\n* Directory indexing\n* Express.static API compatibility\n* node-static API compatibility\n\n## Using Lactate\n\n### Global executable\n\nIf installed globally with `npm install -g lactate`, you will have the `lactate` command at your disposal. This will run lactate static file server in the current working directory, utilizing the `cluster` module for multiple CPU cores. All [options](https://github.com/Weltschmerz/Lactate#options) are available.\n\n```code\n$ lactate --help\nUsage: lactate [options]\n\nOptions:\n--root, -r                    Local path                          [default: \"\"]\n--from, -f                    Public path                         [default: \"\"]\n--subdirs, -s                 Serve subdirectories                [default: true]\n--hidden, -h                  Serve hidden files                  [default: false]\n--error_pages, --error-pages  Serve error pages                   [default: true]\n--autoindex, -a               Automatically index directories     [default: true]\n--cache, -c                   Store assets in-memory              [default: true]\n--redis_cache, --rc           Store assets in-memory using Redis  [default: true]\n--watch_files, --watch-files  Watch files for cache update        [default: true]\n--max_age, --max-age, -M      Client-side caching max-age         [default: 172800]\n--gzip, -g                    Gzip text assets                    [default: true]\n--minify, -m                  Minify text assets                  [default: false]\n--bundle, -b                  Bundle text assets                  [default: false]\n--rebundle, --rb              Rebundle assets if modified         [default: true]\n--headers, -H                 Custom response headers             [default: \"\"]\n--debug, -d                   Log HTTP info                       [default: true]\n--quiet, -q                   Prevent all log output              [default: false]\n\n```\n\n### Programmatic lactating\n\nLactate can be used with either plain node, or with Express. With Express, Lactate is a drop-in replacement for `static` middleware, but with far more ability. The examples below use Express 2.x API for simplicity. See the [examples](https://github.com/Weltschmerz/Lactate/tree/master/example) for various examples.\n\n```js\nvar lactate = require('lactate');\nvar express = require('express');\n\nvar app = express.createServer();\napp.use(lactate.static(__dirname + '/files'));\n```\n\n## Testing Lactate\n\nIf installed locally (without -g flag to npm install):\n\n1. `cd` into `~/node_modules/lactate`\n2. `npm install ./` to install devDependencies\n3. `make test` to run mocha test\n\n##The varieties of Lactate experience\n\n###Creating a Lactate server\n\n```js\nvar lactate = require('lactate'); \nvar options = {root:'files'}; \nvar server = lactate.createServer(options); \n\nserver.listen(8080);\n```\n\n###Creating a directory handler\n\n```js\nvar lactate = require('lactate');\nvar options = {from:'public/path/to/files'};\nvar files = lactate.dir('files', options);\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', function(req, res) {\n  files.serve(req, res);\n});\n\nserver.listen(8080);\n```\n\n###Using directory middleware\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files', options);\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', files.toMiddleware());\nserver.listen(8080);\n```\n\n###Integrating with Express\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files', options);\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8080);\n```\n\n###Using Express.static API\n\n```js\nvar lactate = require('lactate');\nvar express = require('express');\nvar app = express();\n\napp.use(lactate.static(__dirname + '/files'));\napp.listen(8000);\n```\n\n###Using node-static API\n\n```js\nvar lactate = require('lactate');\nvar files = new(lactate.Server)('./files');\n\nvar http = require('http');\nvar server = new http.Server;\n\n// You could also pass a .toMiddleware()'d function\n\nserver.addListener('request', function(req, res) {\n  files.serve(req, res);\n});\n\nserver.listen(8000);\n```\n\n###Serving individual files\n\n```js\nvar lactate = require('lactate');\n\nvar fileOptions = {from:'public/directory'};\nvar files = lactate.dir('files', fileOptions);\n\nvar pageOptions = {};\nvar pages = lactate.dir('pages');\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', function(req, res) {\n  if (req.url === '/') {\n    pages.serve('index.html', req, res);\n  } else {\n    files.serve(req, res);\n  };\n});\nserver.listen(8000);\n```\n\n###Setting options\n\n```js\nvar lactate = require('lactate');\n\nvar fileOptions = {\n  from:'public'\n};\n\nvar files = lactate.dir('files', fileOptions);\n\nfiles.set('cache', false);\nfiles.disable('gzip');\nfiles.maxAge('ten days');\n\nvar express = require('express');\nvar app = express():\n  \napp.get('/public/*', files.toMiddleware());\napp.listen(8080);\n```\n\n###Bundling assets\n\n```js\nvar lactate = require('lactate');\nvar options = {\n  from:'files'\n};\n\nvar files = lactate.dir('files', options);\n\n// Combine and minify all scripts to 'common.js'\nfiles.bundle('js', 'common.js', function(err, data) {\n// Handle errors\n});\n\n// Combine and minify all CSS to 'common.css'\nfiles.bundleCSS('common.css');\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8000);\n```\n\n###Using custom 404 pages\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files');\n\nfiles.notFound('path/to/404/page.html');\n\nfiles.notFound(function(req, res) {\n  res.writeHead(404);\n  res.end('Woops, 404');\n});\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8000);\n```\n\n###Using custom response headers\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files');\n\nfiles.setHeader('x-powered-by', 'Lactate');\nfiles.header('x-timestamp', function(req, res) {\n  return new Date().toUTCString();\n});\n\nvar headers = {};\nfiles.headers(headers);\n```\n\n###Status listeners\n\nLactate extends EventEmitter for emitting status code events.\n\n```js\nvar files = lactate.dir('files');\nfiles.on('404', function(req) {\n  console.log('404', req.url);\n});\n```\n\n##Options\n\n### Setting options\n\nBoolean options may be set using `enable` and `disable` methods. Other options may be set using `set` method with either key/value or an options object.\n\n**Passing to initialization function**\n\n```js\nvar lactate = require('lactate').Lactate({\n  max_age:'two days'\n})\n```\n\n**Using `set` method**\n\n```js\nlactate.set('hidden', true)\n```\n\n**Using enable/disable:**\n\n```js\nlactate.disable('gzip');\nlactate.enable('minify');\n```\n\n**Special options methods**\n\nLactate has some special methods to reduce visual clutter. For setting client-side expiration use `maxAge`\n\n```js\nlactate.maxAge('two days');\n```\n\nis equivalent to:\n\n```js\nlactate.set('max age', 'two days');\n```\n\nFor setting `custom headers` you may use `setHeader`\n\n```js\nlactate.setHeader('x-powered-by', 'Rodent exercise');\n```\n\nYou can also use a function with `setHeader` for added variance:\n\n```js\nlactate.setHeader('x-id', function(req, res) {\n  return Math.random().toString(36).substring(2);\n}):\n```\n\nFor defining `charsets`, you may use `Lactate.define`\n\n```js\nlactate.define('js', 'application/javascript');\n```\n\nor with an object\n\n```js\nlactate.define({\n  'html': 'text/html; charset=utf-8',\n  'js': 'application/javascript'\n});\n```\n\n**Underscores or spaces**\n\nUse spaces instead of underscores if you prefer:\n\n```js\nlactate.disable('max age');\nlactate.enable('watch files');\n```\n\n### Options available\n\n+ `root` **string**\n\nLocal directory from which to serve files. By default, the current working directory.\n\n+ `from` **string**\n\nPublic directory exposed to clients. If set, only requests from /*directory* will complete. Contrast this with the `root` option which is the location of files on the serving machine, not necessarily the requested path.\n\n+ `subdirs` **boolean**\n\nBy default subdirectories are served. To disable this, set `subdirs` to false.\n\n+ `hidden` **boolean**\n\nWhether or not to serve hidden files. Default is false.\n\n+ `error pages` **boolean**\n\nEnabled by default. When disabled, Lactate will not serve error pages for 404 resposes, etc..\n\n+ `autoindex` **boolean**\n\nAutomatically display directory indexes. Disabled by default.\n\n+ `cache` **boolean** or **object**\n\nKeep files in-memory. Enabled by default. For caching options and more information about caching strategy, see [Caching Options](https://github.com/Weltschmerz/Lactate#caching-options).\n\n+ `gzip` **boolean**\n\nIf false, disables automatic gzipping for text files (HTML, JS, CSS). Enabled by default.\n\n+ `minify` **boolean**\n\nIf true, will automatically minify JavaScript and CSS using [Abridge](https://github.com/Weltschmerz/Abridge). Disabled by default.\n\n+ `watch files` **boolean**\n\nDetermines whether Lactate will watch files to update its cache. If this is disabled, then your file cache will not update automatically as files are modified on the server.\n\n+ `headers` **object** or **function**\n\nSets custom response headers. If the option value is a function, it is a callback which is give (req, res) arguments. This function should return the header value; it is a mapping function.\n\n+ `max age` **number** or **string**\n\nPass this function a number (of seconds) or a string and appropriate headers will be set for client-side caching. Lactate comes with expiration defaults, such as 'two days' or '5 years and sixteen days' See [Expire](https://github.com/Weltschmerz/Expire) for details.\n\n```js\nlactate.set('max_age', 87500)\n//87500 seconds\nlactate.set('max_age', 'two days')\n//172800 seconds\nlactate.set'max_age', 'five weeks and one minute and ten seconds')\n//3024070 seconds\nlactate.set('max_age', 'one year and 2 months and seven weeks and 16 seconds')\n//41050028 seconds\n```\n\n+ `not found` **string** or **function**\n\nFor custom 404 handling. Functions are supplied the response for 100% custom response handling. Otherwise, if set to a string, this option will be treated as an ordinary file path and abide rules for gzipping / in-memory cache.\n\n+ `gzip patterns` **array**\n\nSet custom gzip RegExp patterns. The patterns are matched with mime types. E.g. `/(\\+|\\/)xml$/` may be used for matching XML documents for gzipping. You may either use:\n\n```js\nlactate.set('gzip patterns', []);\n```\n\nOr perhaps more conveniently:\n\n```js\n//Accepts RegExp or String\nlactate.gzip(/pattern/, ...);\n```\n\n+ `charset` **boolean** or **string**\n\nSet custom response charset, or automatically detect charset using `node-mime`.\n\n```js\nlactate.enable('charset');\n// Content-Type: text/html; charset=UTF-8\n```\n\n```js\nlactate.set('charset', 'utf-8');\n// Content-Type: text/html; charset=UTF-8\n```\n\n+ `debug` **boolean**\n\nColored status / msg / path logging, for debugging purposes.\n\n###Caching options\n\nPass an object to the `cache` option setting. The following fields are accepted and optional:\n\n* `expire` Seconds expiration for cache keys. Keys expire after they are untouched for x-seconds. Default is `15min`.\n* `max keys` Maximum number of keys to keep in memory. Default is `Infinity`.\n* `max size` Maximum size in MB to keep in cache. Default is `100mb`.\n* `segment` Determines the threshold after which to segment a file for streaming instead of traditional writing. Default is `200kb`.\n\n```js\n  var options = {};\n  \n  options.cache = {\n    expire:5,\n    max_keys:200,\n    max_size:2,\n    segment:100\n  };\n\n  var files = lactate.static('files', options);\n\n  // Or use a string representation. Same as setting for max-age.\n  options.cache.expire = 'fifteen minutes';\n  files.set('cache', options.cache);\n```\n\n\n## License\n\nMIT\n\n","readmeFilename":"README.md","_id":"lactate@0.13.10","dist":{"shasum":"75f39b26b9a13d390a06819aaa5a42a21ba2d20e","tarball":"https://registry.npmjs.org/lactate/-/lactate-0.13.10.tgz","integrity":"sha512-YvjANMRvOZDLEUMSGazq0ZAJktEgiAWomwxwY4vgdeY6UmBKz9M4ZYy4sZtg6ijMYzwF03JfKRV8RNK3Nt2EoA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFNy74TJ7j54fWM2cWs6UZWb5rv84Z/f7tKRJfC6qrwxAiBYOhvEykPicgbYqLL7HsPdYxMw3MLBLxfHK6EF5EO9/Q=="}]},"_npmVersion":"1.1.69","_npmUser":{"name":"Weltschmerz","email":"wltsmrz@gmail.com"},"maintainers":[{"name":"Weltschmerz","email":"chlavois@gmail.com"}]},"0.13.11":{"name":"lactate","version":"0.13.11","description":"Simple and featureful assets server","keywords":["static","file","server","assets","cache"],"repository":{"type":"git","url":"git://github.com/Weltschmerz/Lactate.git"},"author":{"name":"Weltschmerz","email":"wltsmrz@gmail.com"},"dependencies":{"mime":"1.2.9","suckle":"latest","expire":"latest","abridge":"latest","fraction":"latest","optimist":"0.3.5"},"devDependencies":{"mocha":"1.8.2","should":"1.2.2"},"main":"index.js","bin":{"lactate":"bin/lactate"},"scripts":{"test":"make test"},"engines":{"node":">= 0.6.0"},"readme":"# Lactate\n\n`npm install -g lactate`\n\nAn exceedingly fast static file handler, with a few electives.\n\n### Features\n\n* In-memory caching\n* Redis caching\n* Robust cache-control setting\n* Automatic gzipping\n* Automatic minification\n* Custom 404 pages\n* Custom response headers\n* Custom / automatic charset headers\n* Custom gzip patterns\n* Asset bundling and minification\n* Middleware export\n* Default error pages\n* on(status) listeners\n* Colored log output\n* Global executable\n* Directory indexing\n* Express.static API compatibility\n* node-static API compatibility\n\n## Using Lactate\n\n### Global executable\n\nIf installed globally with `npm install -g lactate`, you will have the `lactate` command at your disposal. This will run lactate static file server in the current working directory, utilizing the `cluster` module for multiple CPU cores. All [options](https://github.com/Weltschmerz/Lactate#options) are available.\n\n```code\n$ lactate --help\nUsage: lactate [options]\n\nOptions:\n--root, -r          Local path                          [default: \"\"]\n--from, -f          Public path                         [default: \"\"]\n--subdirs, -s       Serve subdirectories                [default: true]\n--hidden, -h        Serve hidden files                  [default: false]\n--error-pages       Serve error pages                   [default: true]\n--autoindex, -a     Automatically index directories     [default: true]\n--cache, -c         Store assets in-memory              [default: true]\n--watch-files       Watch files for cache update        [default: true]\n--client-cache      Client-side caching max-age         [default: 172800]\n--gzip, -g          Gzip text assets                    [default: true]\n--minify, -m        Minify text assets                  [default: false]\n--bundle, -b        Bundle text assets                  [default: false]\n--rebundle, --rb    Rebundle assets if modified         [default: true]\n--headers, -H       Custom response headers             [default: \"\"]\n--debug, -d         Log HTTP info                       [default: true]\n--quiet, -q         Prevent all log output              [default: false]\n\n```\n\n### Programmatic lactating\n\nLactate can be used with either plain node, or with Express. With Express, Lactate is a drop-in replacement for `static` middleware, but with far more ability. The examples below use Express 2.x API for simplicity. See the [examples](https://github.com/Weltschmerz/Lactate/tree/master/example) for various examples.\n\n```js\nvar lactate = require('lactate');\nvar express = require('express');\n\nvar app = express();\napp.use(lactate.static(__dirname + '/files'));\n```\n\n## Testing Lactate\n\nIf installed locally (without -g flag to npm install):\n\n1. `cd` into `~/node_modules/lactate`\n2. `npm install ./` to install devDependencies\n3. `make test` to run mocha test\n\n##The varieties of Lactate experience\n\n###Creating a Lactate server\n\n```js\nvar lactate = require('lactate'); \nvar options = {root:'files'}; \nvar server = lactate.createServer(options); \n\nserver.listen(8080);\n```\n\n###Creating a directory handler\n\n```js\nvar lactate = require('lactate');\nvar options = {from:'public/path/to/files'};\nvar files = lactate.dir('files', options);\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', function(req, res) {\n  files.serve(req, res);\n});\n\nserver.listen(8080);\n```\n\n###Using directory middleware\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files', options);\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', files.toMiddleware());\nserver.listen(8080);\n```\n\n###Integrating with Express\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files', options);\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8080);\n```\n\n###Using Express.static API\n\n```js\nvar lactate = require('lactate');\nvar express = require('express');\nvar app = express();\n\napp.use(lactate.static(__dirname + '/files'));\napp.listen(8000);\n```\n\n###Using node-static API\n\n```js\nvar lactate = require('lactate');\nvar files = new(lactate.Server)('./files');\n\nvar http = require('http');\nvar server = new http.Server;\n\n// You could also pass a .toMiddleware()'d function\n\nserver.addListener('request', function(req, res) {\n  files.serve(req, res);\n});\n\nserver.listen(8000);\n```\n\n###Serving individual files\n\n```js\nvar lactate = require('lactate');\n\nvar fileOptions = {from:'public/directory'};\nvar files = lactate.dir('files', fileOptions);\n\nvar pageOptions = {};\nvar pages = lactate.dir('pages');\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', function(req, res) {\n  if (req.url === '/') {\n    pages.serve('index.html', req, res);\n  } else {\n    files.serve(req, res);\n  };\n});\nserver.listen(8000);\n```\n\n###Setting options\n\n```js\nvar lactate = require('lactate');\n\nvar fileOptions = {\n  from:'public'\n};\n\nvar files = lactate.dir('files', fileOptions);\n\nfiles.set('cache', false);\nfiles.disable('gzip');\nfiles.maxAge('ten days');\n\nvar express = require('express');\nvar app = express():\n  \napp.get('/public/*', files.toMiddleware());\napp.listen(8080);\n```\n\n###Bundling assets\n\n```js\nvar lactate = require('lactate');\nvar options = {\n  from:'files'\n};\n\nvar files = lactate.dir('files', options);\n\n// Combine and minify all scripts to 'common.js'\nfiles.bundle('js', 'common.js', function(err, data) {\n// Handle errors\n});\n\n// Combine and minify all CSS to 'common.css'\nfiles.bundleCSS('common.css');\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8000);\n```\n\n###Using custom 404 pages\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files');\n\nfiles.notFound('path/to/404/page.html');\n\nfiles.notFound(function(req, res) {\n  res.writeHead(404);\n  res.end('Woops, 404');\n});\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8000);\n```\n\n###Using custom response headers\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files');\n\nfiles.setHeader('x-powered-by', 'Lactate');\nfiles.header('x-timestamp', function(req, res) {\n  return new Date().toUTCString();\n});\n\nvar headers = {};\nfiles.headers(headers);\n```\n\n###Status listeners\n\nLactate extends EventEmitter for emitting status code events.\n\n```js\nvar files = lactate.dir('files');\nfiles.on('404', function(req) {\n  console.log('404', req.url);\n});\n```\n\n##Options\n\n### Setting options\n\nBoolean options may be set using `enable` and `disable` methods. Other options may be set using `set` method with either key/value or an options object.\n\n**Passing to initialization function**\n\n```js\nvar lactate = require('lactate').Lactate({\n  max_age:'two days'\n})\n```\n\n**Using `set` method**\n\n```js\nlactate.set('hidden', true)\n```\n\n**Using enable/disable:**\n\n```js\nlactate.disable('gzip');\nlactate.enable('minify');\n```\n\n**Special options methods**\n\nLactate has some special methods to reduce visual clutter. For setting client-side expiration use `maxAge`\n\n```js\nlactate.maxAge('two days');\n```\n\nis equivalent to:\n\n```js\nlactate.set('max age', 'two days');\n```\n\nFor setting `custom headers` you may use `setHeader`\n\n```js\nlactate.setHeader('x-powered-by', 'Rodent exercise');\n```\n\nYou can also use a function with `setHeader` for added variance:\n\n```js\nlactate.setHeader('x-id', function(req, res) {\n  return Math.random().toString(36).substring(2);\n}):\n```\n\nFor defining `charsets`, you may use `Lactate.define`\n\n```js\nlactate.define('js', 'application/javascript');\n```\n\nor with an object\n\n```js\nlactate.define({\n  'html': 'text/html; charset=utf-8',\n  'js': 'application/javascript'\n});\n```\n\n**Underscores or spaces**\n\nUse spaces instead of underscores if you prefer:\n\n```js\nlactate.disable('max age');\nlactate.enable('watch files');\n```\n\n### Options available\n\n+ `root` **string**\n\nLocal directory from which to serve files. By default, the current working directory.\n\n+ `from` **string**\n\nPublic directory exposed to clients. If set, only requests from /*directory* will complete. Contrast this with the `root` option which is the location of files on the serving machine, not necessarily the requested path.\n\n+ `subdirs` **boolean**\n\nBy default subdirectories are served. To disable this, set `subdirs` to false.\n\n+ `hidden` **boolean**\n\nWhether or not to serve hidden files. Default is false.\n\n+ `error pages` **boolean**\n\nEnabled by default. When disabled, Lactate will not serve error pages for 404 resposes, etc..\n\n+ `autoindex` **boolean**\n\nAutomatically display directory indexes. Disabled by default.\n\n+ `cache` **boolean** or **object**\n\nKeep files in-memory. Enabled by default. For caching options and more information about caching strategy, see [Caching Options](https://github.com/Weltschmerz/Lactate#caching-options).\n\n+ `gzip` **boolean**\n\nIf false, disables automatic gzipping for text files (HTML, JS, CSS). Enabled by default.\n\n+ `minify` **boolean**\n\nIf true, will automatically minify JavaScript and CSS using [Abridge](https://github.com/Weltschmerz/Abridge). Disabled by default.\n\n+ `watch files` **boolean**\n\nDetermines whether Lactate will watch files to update its cache. If this is disabled, then your file cache will not update automatically as files are modified on the server.\n\n+ `headers` **object** or **function**\n\nSets custom response headers. If the option value is a function, it is a callback which is give (req, res) arguments. This function should return the header value; it is a mapping function.\n\n+ `max age` **number** or **string**\n\nPass this function a number (of seconds) or a string and appropriate headers will be set for client-side caching. Lactate comes with expiration defaults, such as 'two days' or '5 years and sixteen days' See [Expire](https://github.com/Weltschmerz/Expire) for details.\n\n```js\nlactate.set('max_age', 87500)\n//87500 seconds\nlactate.set('max_age', 'two days')\n//172800 seconds\nlactate.set'max_age', 'five weeks and one minute and ten seconds')\n//3024070 seconds\nlactate.set('max_age', 'one year and 2 months and seven weeks and 16 seconds')\n//41050028 seconds\n```\n\n+ `not found` **string** or **function**\n\nFor custom 404 handling. Functions are supplied the response for 100% custom response handling. Otherwise, if set to a string, this option will be treated as an ordinary file path and abide rules for gzipping / in-memory cache.\n\n+ `gzip patterns` **array**\n\nSet custom gzip RegExp patterns. The patterns are matched with mime types. E.g. `/(\\+|\\/)xml$/` may be used for matching XML documents for gzipping. You may either use:\n\n```js\nlactate.set('gzip patterns', []);\n```\n\nOr perhaps more conveniently:\n\n```js\n//Accepts RegExp or String\nlactate.gzip(/pattern/, ...);\n```\n\n+ `charset` **boolean** or **string**\n\nSet custom response charset, or automatically detect charset using `node-mime`.\n\n```js\nlactate.enable('charset');\n// Content-Type: text/html; charset=UTF-8\n```\n\n```js\nlactate.set('charset', 'utf-8');\n// Content-Type: text/html; charset=UTF-8\n```\n\n+ `debug` **boolean**\n\nColored status / msg / path logging, for debugging purposes.\n\n###Caching options\n\nPass an object to the `cache` option setting. The following fields are accepted and optional:\n\n* `expire` Seconds expiration for cache keys. Keys expire after they are untouched for x-seconds. Default is `15min`.\n* `max keys` Maximum number of keys to keep in memory. Default is `Infinity`.\n* `max size` Maximum size in MB to keep in cache. Default is `100mb`.\n* `segment` Determines the threshold after which to segment a file for streaming instead of traditional writing. Default is `200kb`.\n\n```js\n  var options = {};\n  \n  options.cache = {\n    expire:5,\n    max_keys:200,\n    max_size:2,\n    segment:100\n  };\n\n  var files = lactate.static('files', options);\n\n  // Or use a string representation. Same as setting for max-age.\n  options.cache.expire = 'fifteen minutes';\n  files.set('cache', options.cache);\n```\n\n\n## License\n\nMIT\n\n","readmeFilename":"README.md","_id":"lactate@0.13.11","dist":{"shasum":"3a84642cb7b6c1243082b887978cee9163b72b79","tarball":"https://registry.npmjs.org/lactate/-/lactate-0.13.11.tgz","integrity":"sha512-uK/J7vQqnyHZ6BpuPUOXs2CkFO3Y0EE9TFWnO+uxTql4U36Ju5vpYskGtq3C36188A0UGWrGI7GEVUKF4JMs6g==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCWCyPd/2PmE0eFG3nJIEI4XIpiJ7HOVZ0McbE0N4F0dwIgCsrTZQVK1mzfFf4dtkyD/GW3kcWkBIa3QgVZrRhouU4="}]},"_npmVersion":"1.1.69","_npmUser":{"name":"Weltschmerz","email":"wltsmrz@gmail.com"},"maintainers":[{"name":"Weltschmerz","email":"chlavois@gmail.com"}]},"0.13.12":{"name":"lactate","version":"0.13.12","description":"Simple and featureful assets server","keywords":["static","file","server","assets","cache"],"repository":{"type":"git","url":"git://github.com/wltsmrz/Lactate.git"},"author":{"name":"wltsmrz","email":"wltsmrz@gmail.com"},"dependencies":{"mime":"1.2.9","suckle":"latest","expire":"latest","abridge":"latest","fraction":"latest","optimist":"0.3.5"},"devDependencies":{"mocha":"1.10.0","should":"1.2.2"},"main":"index.js","bin":{"lactate":"bin/lactate"},"scripts":{"test":"make test"},"engines":{"node":">= 0.6.0"},"readme":"# Lactate\n\n`npm install -g lactate`\n\nAn exceedingly fast static file handler, with a few electives.\n\n### Features\n\n* In-memory caching\n* Redis caching\n* Robust cache-control setting\n* Automatic gzipping\n* Automatic minification\n* Custom 404 pages\n* Custom response headers\n* Custom / automatic charset headers\n* Custom gzip patterns\n* Asset bundling and minification\n* Middleware export\n* Default error pages\n* on(status) listeners\n* Colored log output\n* Global executable\n* Directory indexing\n* Express.static API compatibility\n* node-static API compatibility\n\n## Using Lactate\n\n### Global executable\n\nIf installed globally with `npm install -g lactate`, you will have the `lactate` command at your disposal. This will run lactate static file server in the current working directory, utilizing the `cluster` module for multiple CPU cores. All [options](https://github.com/Weltschmerz/Lactate#options) are available.\n\n```code\n$ lactate --help\nUsage: lactate [options]\n\nOptions:\n--root, -r          Local path                          [default: \"\"]\n--from, -f          Public path                         [default: \"\"]\n--subdirs, -s       Serve subdirectories                [default: true]\n--hidden, -h        Serve hidden files                  [default: false]\n--error-pages       Serve error pages                   [default: true]\n--autoindex, -a     Automatically index directories     [default: true]\n--cache, -c         Store assets in-memory              [default: true]\n--watch-files       Watch files for cache update        [default: true]\n--client-cache      Client-side caching max-age         [default: 172800]\n--gzip, -g          Gzip text assets                    [default: true]\n--minify, -m        Minify text assets                  [default: false]\n--bundle, -b        Bundle text assets                  [default: false]\n--rebundle, --rb    Rebundle assets if modified         [default: true]\n--headers, -H       Custom response headers             [default: \"\"]\n--debug, -d         Log HTTP info                       [default: true]\n--quiet, -q         Prevent all log output              [default: false]\n\n```\n\n### Programmatic lactating\n\nLactate can be used with either plain node, or with Express. With Express, Lactate is a drop-in replacement for `static` middleware, but with far more ability. The examples below use Express 2.x API for simplicity. See the [examples](https://github.com/Weltschmerz/Lactate/tree/master/example) for various examples.\n\n```js\nvar lactate = require('lactate');\nvar express = require('express');\n\nvar app = express();\napp.use(lactate.static(__dirname + '/files'));\n```\n\n## Testing Lactate\n\nIf installed locally (without -g flag to npm install):\n\n1. `cd` into `~/node_modules/lactate`\n2. `npm install ./` to install devDependencies\n3. `make test` to run mocha test\n\n##The varieties of Lactate experience\n\n###Creating a Lactate server\n\n```js\nvar lactate = require('lactate'); \nvar options = {root:'files'}; \nvar server = lactate.createServer(options); \n\nserver.listen(8080);\n```\n\n###Creating a directory handler\n\n```js\nvar lactate = require('lactate');\nvar options = {from:'public/path/to/files'};\nvar files = lactate.dir('files', options);\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', function(req, res) {\n  files.serve(req, res);\n});\n\nserver.listen(8080);\n```\n\n###Using directory middleware\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files', options);\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', files.toMiddleware());\nserver.listen(8080);\n```\n\n###Integrating with Express\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files', options);\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8080);\n```\n\n###Using Express.static API\n\n```js\nvar lactate = require('lactate');\nvar express = require('express');\nvar app = express();\n\napp.use(lactate.static(__dirname + '/files'));\napp.listen(8000);\n```\n\n###Using node-static API\n\n```js\nvar lactate = require('lactate');\nvar files = new(lactate.Server)('./files');\n\nvar http = require('http');\nvar server = new http.Server;\n\n// You could also pass a .toMiddleware()'d function\n\nserver.addListener('request', function(req, res) {\n  files.serve(req, res);\n});\n\nserver.listen(8000);\n```\n\n###Serving individual files\n\n```js\nvar lactate = require('lactate');\n\nvar fileOptions = {from:'public/directory'};\nvar files = lactate.dir('files', fileOptions);\n\nvar pageOptions = {};\nvar pages = lactate.dir('pages');\n\nvar http = require('http');\nvar server = new http.Server;\n\nserver.addListener('request', function(req, res) {\n  if (req.url === '/') {\n    pages.serve('index.html', req, res);\n  } else {\n    files.serve(req, res);\n  };\n});\nserver.listen(8000);\n```\n\n###Setting options\n\n```js\nvar lactate = require('lactate');\n\nvar fileOptions = {\n  from:'public'\n};\n\nvar files = lactate.dir('files', fileOptions);\n\nfiles.set('cache', false);\nfiles.disable('gzip');\nfiles.maxAge('ten days');\n\nvar express = require('express');\nvar app = express():\n  \napp.get('/public/*', files.toMiddleware());\napp.listen(8080);\n```\n\n###Bundling assets\n\n```js\nvar lactate = require('lactate');\nvar options = {\n  from:'files'\n};\n\nvar files = lactate.dir('files', options);\n\n// Combine and minify all scripts to 'common.js'\nfiles.bundle('js', 'common.js', function(err, data) {\n// Handle errors\n});\n\n// Combine and minify all CSS to 'common.css'\nfiles.bundleCSS('common.css');\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8000);\n```\n\n###Using custom 404 pages\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files');\n\nfiles.notFound('path/to/404/page.html');\n\nfiles.notFound(function(req, res) {\n  res.writeHead(404);\n  res.end('Woops, 404');\n});\n\nvar express = require('express');\nvar app = express();\n\napp.use(files.toMiddleware());\napp.listen(8000);\n```\n\n###Using custom response headers\n\n```js\nvar lactate = require('lactate');\nvar files = lactate.dir('files');\n\nfiles.setHeader('x-powered-by', 'Lactate');\nfiles.header('x-timestamp', function(req, res) {\n  return new Date().toUTCString();\n});\n\nvar headers = {};\nfiles.headers(headers);\n```\n\n###Status listeners\n\nLactate extends EventEmitter for emitting status code events.\n\n```js\nvar files = lactate.dir('files');\nfiles.on('404', function(req) {\n  console.log('404', req.url);\n});\n```\n\n##Options\n\n### Setting options\n\nBoolean options may be set using `enable` and `disable` methods. Other options may be set using `set` method with either key/value or an options object.\n\n**Passing to initialization function**\n\n```js\nvar lactate = require('lactate').Lactate({\n  max_age:'two days'\n})\n```\n\n**Using `set` method**\n\n```js\nlactate.set('hidden', true)\n```\n\n**Using enable/disable:**\n\n```js\nlactate.disable('gzip');\nlactate.enable('minify');\n```\n\n**Special options methods**\n\nLactate has some special methods to reduce visual clutter. For setting client-side expiration use `maxAge`\n\n```js\nlactate.maxAge('two days');\n```\n\nis equivalent to:\n\n```js\nlactate.set('max age', 'two days');\n```\n\nFor setting `custom headers` you may use `setHeader`\n\n```js\nlactate.setHeader('x-powered-by', 'Rodent exercise');\n```\n\nYou can also use a function with `setHeader` for added variance:\n\n```js\nlactate.setHeader('x-id', function(req, res) {\n  return Math.random().toString(36).substring(2);\n}):\n```\n\nFor defining `charsets`, you may use `Lactate.define`\n\n```js\nlactate.define('js', 'application/javascript');\n```\n\nor with an object\n\n```js\nlactate.define({\n  'html': 'text/html; charset=utf-8',\n  'js': 'application/javascript'\n});\n```\n\n**Underscores or spaces**\n\nUse spaces instead of underscores if you prefer:\n\n```js\nlactate.disable('max age');\nlactate.enable('watch files');\n```\n\n### Options available\n\n+ `root` **string**\n\nLocal directory from which to serve files. By default, the current working directory.\n\n+ `from` **string**\n\nPublic directory exposed to clients. If set, only requests from /*directory* will complete. Contrast this with the `root` option which is the location of files on the serving machine, not necessarily the requested path.\n\n+ `subdirs` **boolean**\n\nBy default subdirectories are served. To disable this, set `subdirs` to false.\n\n+ `hidden` **boolean**\n\nWhether or not to serve hidden files. Default is false.\n\n+ `error pages` **boolean**\n\nEnabled by default. When disabled, Lactate will not serve error pages for 404 resposes, etc..\n\n+ `autoindex` **boolean**\n\nAutomatically display directory indexes. Disabled by default.\n\n+ `cache` **boolean** or **object**\n\nKeep files in-memory. Enabled by default. For caching options and more information about caching strategy, see [Caching Options](https://github.com/Weltschmerz/Lactate#caching-options).\n\n+ `gzip` **boolean**\n\nIf false, disables automatic gzipping for text files (HTML, JS, CSS). Enabled by default.\n\n+ `minify` **boolean**\n\nIf true, will automatically minify JavaScript and CSS using [Abridge](https://github.com/Weltschmerz/Abridge). Disabled by default.\n\n+ `watch files` **boolean**\n\nDetermines whether Lactate will watch files to update its cache. If this is disabled, then your file cache will not update automatically as files are modified on the server.\n\n+ `headers` **object** or **function**\n\nSets custom response headers. If the option value is a function, it is a callback which is give (req, res) arguments. This function should return the header value; it is a mapping function.\n\n+ `max age` **number** or **string**\n\nPass this function a number (of seconds) or a string and appropriate headers will be set for client-side caching. Lactate comes with expiration defaults, such as 'two days' or '5 years and sixteen days' See [Expire](https://github.com/Weltschmerz/Expire) for details.\n\n```js\nlactate.set('max_age', 87500)\n//87500 seconds\nlactate.set('max_age', 'two days')\n//172800 seconds\nlactate.set'max_age', 'five weeks and one minute and ten seconds')\n//3024070 seconds\nlactate.set('max_age', 'one year and 2 months and seven weeks and 16 seconds')\n//41050028 seconds\n```\n\n+ `not found` **string** or **function**\n\nFor custom 404 handling. Functions are supplied the response for 100% custom response handling. Otherwise, if set to a string, this option will be treated as an ordinary file path and abide rules for gzipping / in-memory cache.\n\n+ `gzip patterns` **array**\n\nSet custom gzip RegExp patterns. The patterns are matched with mime types. E.g. `/(\\+|\\/)xml$/` may be used for matching XML documents for gzipping. You may either use:\n\n```js\nlactate.set('gzip patterns', []);\n```\n\nOr perhaps more conveniently:\n\n```js\n//Accepts RegExp or String\nlactate.gzip(/pattern/, ...);\n```\n\n+ `charset` **boolean** or **string**\n\nSet custom response charset, or automatically detect charset using `node-mime`.\n\n```js\nlactate.enable('charset');\n// Content-Type: text/html; charset=UTF-8\n```\n\n```js\nlactate.set('charset', 'utf-8');\n// Content-Type: text/html; charset=UTF-8\n```\n\n+ `debug` **boolean**\n\nColored status / msg / path logging, for debugging purposes.\n\n###Caching options\n\nPass an object to the `cache` option setting. The following fields are accepted and optional:\n\n* `expire` Seconds expiration for cache keys. Keys expire after they are untouched for x-seconds. Default is `15min`.\n* `max keys` Maximum number of keys to keep in memory. Default is `Infinity`.\n* `max size` Maximum size in MB to keep in cache. Default is `100mb`.\n* `segment` Determines the threshold after which to segment a file for streaming instead of traditional writing. Default is `200kb`.\n\n```js\n  var options = {};\n  \n  options.cache = {\n    expire:5,\n    max_keys:200,\n    max_size:2,\n    segment:100\n  };\n\n  var files = lactate.static('files', options);\n\n  // Or use a string representation. Same as setting for max-age.\n  options.cache.expire = 'fifteen minutes';\n  files.set('cache', options.cache);\n```\n\n\n## License\n\nMIT\n\n","readmeFilename":"README.md","_id":"lactate@0.13.12","dist":{"shasum":"9a76e35b749e17d1ae59a0ff0df5eeba23e9ff19","tarball":"https://registry.npmjs.org/lactate/-/lactate-0.13.12.tgz","integrity":"sha512-wctIsVCIHEfzpF3SFIKF7i6PYsh/ujly3Ck7uSlva1AOwoA1quPmDq9AOvdxO0jQl8y5GLVZy8vIRFBto1ekAQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFzUp5VFEzexaxroos9KUPaisQtHZJwmhACr6AoPP4KMAiEArPCjlsugF5NM0ZSBz8lfK4Du9fReARae3U8nOBuFHtE="}]},"_from":".","_npmVersion":"1.2.15","_npmUser":{"name":"Weltschmerz","email":"wltsmrz@gmail.com"},"maintainers":[{"name":"Weltschmerz","email":"chlavois@gmail.com"}]}},"readme":"# Lactate\n\nVery simple static file handler, with a few electives.\n\n`npm install lactate`\n\n## Example\n\nJust pass three arguments to the serve function (`path`, `request`, `response`). Lactate will stream your file to the client in the most efficient way, by piping: readFile > gZip > response.\n\n```js\n\nvar express = require('express')\nvar app = express.createServer()\nvar lactate = require('lactate')()\n\napp.get('/', function(req, res) {\n  reurn lactate.serve('pages/land.html', req, res)\n})\n\napp.get('/files/*', function(req, res) {\n  return lactate.serve(req.url.substring(1), req, res)\n})\n\napp.get('/images/:img', function(req, res) {\n  var img = req.params.img\n  return lactate.serve('thumbs/'+img, req, res)\n})\n\napp.listen(8080)\n\n```\n\n##Options\n\nOptions can be passed to the initialization function or using the `set` method.\n\n```js\n\n//Passing to initialization function\nvar lactate = require('lactate')({expires:172800})\n\n//Set method\nlactate.set('expires', null)\n\n//Either function accepts (key, value) or an object.\n\n```\n\nAvailable options are currently `cache` (boolean), `expires` (seconds), and `debug`.\n\nThe `cache` option will have Lactate save your files in memory. By default this is enabled, and there's no great reason to disable it.\n\nSetting `expires` will have Lactase set appropriate `Expires` and `Cache-Control` headers for client-side caching. This option represents seconds-from-now to expire.\n\n### Debugging\n\nDebugging is level-based. The `debug` function accepts a number and a callback function, or a boolean. By default, the debugging function is console.log. The following syntaxes are valid.\n\n```js\n\nvar lactate = require('lactate')({\n  debug:true\n})\n\nlactate.set('debug', 0, function(level, msg, path, statusCode) {\n  /* \n    Do stuff\n\n    Note however that statusCode arguments are only\n    given for level 0 listeners\n  */\n})\n\nlactate.set('debug', 1, console.log)\nlactate.set({debug:false})\n\n```\n\nMore robust debugging will come in the future as I isolate the functionality into a module of its own.\n\n##TODO\n\n+ Express middleware\n+ Expiration defaults, e.g. 'two days,' 'one month'\n+ Redis integration\n+ Standalone server\n","maintainers":[{"name":"Weltschmerz","email":"chlavois@gmail.com"}],"time":{"modified":"2022-06-19T10:20:33.147Z","created":"2012-05-24T10:28:34.743Z","0.1.1":"2012-05-24T10:28:34.919Z","0.1.2":"2012-05-24T10:41:07.234Z","0.1.3":"2012-05-24T10:46:18.893Z","0.2.0":"2012-05-25T01:35:55.693Z","0.3.0":"2012-06-06T01:29:31.370Z","0.5.0":"2012-06-06T21:53:21.011Z","0.5.1":"2012-06-06T22:17:18.141Z","0.5.2":"2012-06-07T01:10:04.410Z","0.5.3":"2012-06-07T01:11:10.078Z","0.5.4":"2012-06-08T07:52:36.552Z","0.5.5":"2012-06-08T09:48:12.159Z","0.5.6":"2012-06-08T11:03:02.518Z","0.5.7":"2012-06-09T07:15:32.937Z","0.5.8":"2012-06-09T07:26:54.701Z","0.6.0":"2012-06-10T11:59:47.822Z","0.6.2":"2012-06-17T06:58:41.933Z","0.6.4":"2012-06-17T09:27:48.975Z","0.6.5":"2012-06-19T11:27:10.233Z","0.6.6":"2012-06-30T22:38:07.253Z","0.6.7":"2012-06-30T22:38:35.613Z","0.6.8":"2012-06-30T23:34:14.870Z","0.7.0":"2012-07-21T06:14:17.449Z","0.7.2":"2012-07-21T06:16:28.122Z","0.7.5":"2012-07-21T06:19:07.216Z","0.7.6":"2012-07-21T06:22:37.295Z","0.8.0":"2012-07-21T16:05:40.935Z","0.8.1":"2012-07-22T16:15:43.528Z","0.8.2":"2012-07-23T19:22:33.453Z","0.8.3":"2012-07-23T19:27:10.203Z","0.8.4":"2012-08-04T06:40:17.438Z","0.8.5":"2012-08-04T17:35:58.279Z","0.8.6":"2012-08-05T07:58:18.237Z","0.8.8":"2012-08-05T19:03:29.788Z","0.8.9":"2012-08-06T07:23:24.686Z","0.8.11":"2012-08-06T07:37:22.439Z","0.9.0":"2012-08-23T04:15:42.157Z","0.9.1":"2012-08-23T04:25:46.477Z","0.9.2":"2012-08-24T05:52:17.768Z","0.9.4":"2012-08-27T14:06:42.368Z","0.9.5":"2012-08-30T08:41:05.568Z","0.9.6":"2012-08-30T14:24:04.913Z","0.9.7":"2012-08-30T15:39:07.592Z","0.9.8":"2012-08-30T18:19:49.700Z","0.9.10":"2012-09-07T20:57:26.939Z","0.9.11":"2012-09-17T16:24:37.990Z","0.9.12":"2012-09-18T03:14:16.486Z","0.9.14":"2012-09-20T04:50:41.565Z","0.9.15":"2012-09-20T09:46:06.029Z","0.9.16":"2012-09-25T22:47:51.586Z","0.9.17":"2012-09-26T15:04:19.129Z","0.9.18":"2012-09-26T16:46:15.545Z","0.9.19":"2012-10-04T20:09:02.234Z","0.10.20":"2012-10-05T04:39:35.199Z","0.10.0":"2012-10-05T04:39:56.634Z","0.10.2":"2012-10-09T10:06:57.755Z","0.10.3":"2012-10-10T04:05:29.315Z","0.10.5":"2012-10-11T07:53:46.348Z","0.10.6":"2012-10-17T22:02:13.197Z","0.10.7":"2012-10-17T22:09:47.371Z","0.10.8":"2012-10-18T14:41:17.933Z","0.10.9":"2012-10-18T15:36:22.835Z","0.10.10":"2012-10-20T22:40:12.405Z","0.10.11":"2012-10-22T14:38:42.777Z","0.10.12":"2012-10-25T02:55:43.378Z","0.10.13":"2012-10-25T23:15:21.368Z","0.10.14":"2012-10-26T19:19:14.316Z","0.10.15":"2012-10-27T22:04:34.784Z","0.10.17":"2012-10-30T01:10:11.996Z","0.10.18":"2012-10-30T01:14:11.778Z","0.11.0":"2012-10-30T22:16:13.359Z","0.11.1":"2012-10-31T01:46:59.801Z","0.11.3":"2012-11-01T02:31:15.324Z","0.11.4":"2012-11-01T05:19:39.797Z","0.11.5":"2012-11-01T21:23:44.993Z","0.11.6":"2012-11-02T06:42:13.125Z","0.11.7":"2012-11-02T15:53:59.289Z","0.11.8":"2012-11-03T23:01:52.608Z","0.11.9":"2012-11-05T02:57:21.696Z","0.11.10":"2012-11-06T00:24:00.942Z","0.11.11":"2012-11-06T05:09:52.729Z","0.11.12":"2012-11-06T09:43:28.668Z","0.11.13":"2012-11-07T21:28:41.314Z","0.12.0":"2012-11-08T07:40:27.539Z","0.12.1":"2012-11-09T00:56:16.451Z","0.12.2":"2012-11-09T22:00:48.938Z","0.12.3":"2012-11-15T12:09:33.960Z","0.12.4":"2012-11-15T12:12:36.583Z","0.12.5":"2012-11-15T14:43:01.512Z","0.12.6":"2012-11-15T16:34:04.214Z","0.12.7":"2012-11-16T13:35:50.953Z","0.12.8":"2012-11-16T15:08:15.014Z","0.12.9":"2012-11-16T15:41:23.449Z","0.12.10":"2012-11-26T15:36:14.026Z","0.12.11":"2012-12-21T05:49:37.466Z","0.12.12":"2012-12-21T06:13:38.243Z","0.13.0":"2012-12-21T20:35:22.845Z","0.13.1":"2012-12-22T05:21:02.740Z","0.13.2":"2012-12-27T14:31:10.037Z","0.13.3":"2013-01-01T19:39:53.120Z","0.13.4":"2013-01-01T22:47:50.617Z","0.13.5":"2013-01-03T02:55:13.776Z","0.13.6":"2013-01-03T09:19:04.008Z","0.13.7":"2013-01-05T02:59:55.300Z","0.13.8":"2013-02-25T13:32:14.241Z","0.13.9":"2013-02-26T07:50:31.635Z","0.13.10":"2013-03-06T05:51:14.130Z","0.13.11":"2013-03-17T15:18:39.419Z","0.13.12":"2013-06-12T02:49:55.537Z"},"author":{"name":"wltsmrz","email":"wltsmrz@gmail.com"},"repository":{"type":"git","url":"git://github.com/wltsmrz/Lactate.git"},"users":{"fgribreau":true}}