parallaxis/node_modules/node-static/package.json

58 lines
7.4 KiB
JSON
Raw Permalink Normal View History

{
"name": "node-static",
"description": "simple, compliant file streaming module for node",
"url": "http://github.com/cloudhead/node-static",
"keywords": [
"http",
"static",
"file",
"server"
],
"author": {
"name": "Alexis Sellier",
"email": "self@cloudhead.net"
},
"contributors": [
{
"name": "Pablo Cantero",
"email": "pablo@pablocantero.com"
}
],
"repository": {
"type": "git",
"url": "http://github.com/cloudhead/node-static"
},
"main": "./lib/node-static",
"scripts": {
"test": "vows --spec --isolate"
},
"bin": {
"static": "bin/cli.js"
},
"license": "MIT",
"dependencies": {
"optimist": ">=0.3.4",
"colors": ">=0.6.0",
"mime": ">=1.2.9"
},
"devDependencies": {
"request": "latest",
"vows": "latest"
},
"version": "0.7.3",
"engines": {
"node": ">= 0.4.1"
},
"readme": "node-static\n===========\n\n> a simple, *rfc 2616 compliant* file streaming module for [node](http://nodejs.org)\n\nnode-static has an in-memory file cache, making it highly efficient.\nnode-static understands and supports *conditional GET* and *HEAD* requests.\nnode-static was inspired by some of the other static-file serving modules out there,\nsuch as node-paperboy and antinode.\n\nSynopsis\n--------\n\n var static = require('node-static');\n\n //\n // Create a node-static server instance to serve the './public' folder\n //\n var file = new static.Server('./public');\n\n require('http').createServer(function (request, response) {\n request.addListener('end', function () {\n //\n // Serve files!\n //\n file.serve(request, response);\n }).resume();\n }).listen(8080);\n\nAPI\n---\n\n### Creating a node-static Server #\n\nCreating a file server instance is as simple as:\n\n new static.Server();\n\nThis will serve files in the current directory. If you want to serve files in a specific\ndirectory, pass it as the first argument:\n\n new static.Server('./public');\n\nYou can also specify how long the client is supposed to cache the files node-static serves:\n\n new static.Server('./public', { cache: 3600 });\n\nThis will set the `Cache-Control` header, telling clients to cache the file for an hour.\nThis is the default setting.\n\n### Serving files under a directory #\n\nTo serve files under a directory, simply call the `serve` method on a `Server` instance, passing it\nthe HTTP request and response object:\n \n var static = require('node-static');\n\n var fileServer = new static.Server('./public');\n\n require('http').createServer(function (request, response) {\n request.addListener('end', function () {\n fileServer.serve(request, response);\n }).resume();\n }).listen(8080);\n\n### Serving specific files #\n\nIf you want to serve a specific file, like an error page for example, use the `serveFile` method:\n\n fileServer.serveFile('/error.html', 500, {}, request, response);\n\nThis will serve the `error.html` file, from under the file root directory, with a `500` status code.\nFor example, you could serve an error page, when the initial request wasn't found:\n\n require('http').createServer(function (request, response) {\n request.addListener('end', function () {\n fileServer.serve(request, response, function (e, res) {\n if (e && (e.status === 404)) { // If the file wasn't found\n fileServer.serveFile('/not-found.html', 404, {}, request, response);\n }\n });\n }).resume();\n }).listen(8080);\n\nMore on intercepting errors bellow.\n\n### Intercepting errors & Listening #\n\nAn optional callback can be passed as last argument, it will be called every time a file\nhas been served successfully, or if there was an error serving the file:\n\n var static = require('node-static');\n \n var fileServer = new static.Server('./public');\n\n require('http').createServer(function (request, response) {\n request.addListener('end', function () {\n fileServer.serve(request, response, function (err, result) {\n if (err) { // There was an error serving the file\n sys.error(\"Error serving \" + request.url + \" - \" + err.message);\n\n // Respond to the client\n response.writeHead(err.status, err.headers);\n response.end();\n }\n });\n }).resume();\n }).listen(8080);\n\nNote that if you pass a callback, and there is an error serving the file, node-static\n*will not* respond to the client. This gives you the opportunity to re-route the request,\nor handle it differently.\n\nFor example, you may want to interpret a request as a static request, but if the file isn't found,\nsend it to an application.\n\nIf you only want to *listen* for errors, you can use *event l
"readmeFilename": "README.md",
"bugs": {
"url": "https://github.com/cloudhead/node-static/issues"
},
"_id": "node-static@0.7.3",
"dist": {
"shasum": "87eff7b09dbc5f150aba7161d839ded50f52a05d"
},
"_from": "node-static@",
"_resolved": "https://registry.npmjs.org/node-static/-/node-static-0.7.3.tgz"
}