jayli-server
Advanced tools
Comparing version 0.0.2 to 0.0.3
@@ -115,3 +115,3 @@ var | ||
exports.deliver = function (webroot, req, res) { | ||
exports.deliver = function (webroot, req, res,filepath) { | ||
var | ||
@@ -121,3 +121,3 @@ stream, | ||
fpErr = fpRes[0], | ||
filepath = fpRes[1], | ||
// filepath = fpRes[1], | ||
beforeCallback, | ||
@@ -124,0 +124,0 @@ afterCallback, |
@@ -7,3 +7,3 @@ { | ||
}, | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "A node.js module for delivering static files,width ssi.", | ||
@@ -19,3 +19,3 @@ "keywords": [ | ||
"dependencies": { | ||
"iconv-lite":"" | ||
"iconv-lite": "" | ||
}, | ||
@@ -27,10 +27,10 @@ "devDependencies": {}, | ||
"optionalDependencies": {}, | ||
"readme": "", | ||
"readme": "# jayli\n\n## Purpose\n\nA node.js module for delivering static files.\n\n## Current Status\n\nThis module is used by [tempalias.com](http://tempalias.com/) in production\nand is mainted by [Felix Geisendörfer](https://github.com/felixge). However,\nthis one one of my first node modules and it lacks a test suite, you've been\nwarned : ).\n\n## Features\n \n * Configurable callbacks on most events\n * ETag / 304 Support\n * Custom HTTP headers\n\n## Example\n\nExample from example/basic.js:\n\n var\n path = require('path'),\n http = require('http'),\n jayli = require('../lib/jayli'),\n \n PORT = 8003,\n WEBROOT = path.join(path.dirname(__filename), 'webroot');\n \n http.createServer(function(req, res) {\n var ip = req.connection.remoteAddress;\n jayli\n .deliver(WEBROOT, req, res)\n .addHeader('Expires', 300)\n .addHeader('X-PaperRoute', 'Node')\n .before(function() {\n console.log('Received Request');\n })\n .after(function(statCode) {\n log(statCode, req.url, ip);\n })\n .error(function(statCode, msg) {\n res.writeHead(statCode, {'Content-Type': 'text/plain'});\n res.end(\"Error \" + statCode);\n log(statCode, req.url, ip, msg);\n })\n .otherwise(function(err) {\n res.writeHead(404, {'Content-Type': 'text/plain'});\n res.end(\"Error 404: File not found\");\n log(404, req.url, ip, err);\n });\n }).listen(PORT);\n \n function log(statCode, url, ip, err) {\n var logStr = statCode + ' - ' + url + ' - ' + ip;\n if (err)\n logStr += ' - ' + err;\n console.log(logStr);\n }\n\n## API Docs\n\n### SSI included\n\n\t<!--#include path=\"asdf.html\" -->\n\n### jayli.deliver(webroot, req, res)\n\nChecks the `webroot` folder if it has a file that matches the `req.url` and streams it to the client. If `req.url` ends with a '/' (slash), 'index.html' is appended automatically.\n\nParameters:\n\n* `webroot`: Absolute path where too look for static files to serve\n* `req`: A `http.ServerRequest` object\n* `res`: A `http.ServerResponse` object\n\nThis returns an object with several functions that you can call, to modify how the static content is delivered. Each of these functions returns the object, so you can chain them, as shown in the example above. They each take a callback function, whose arguments and expected behavior are detailed below.\n\n#### before(callback())\n\nFires if a matching file was found in the `webroot` and is about to be delivered. The delivery can be canceled by returning `false` from within the callback.\n\n#### after(callback(statCode))\n\nFires after a file has been successfully delivered from the `webroot`. `statCode` contains the numeric HTTP status code that was sent to the client. You must close the connection yourself if the error callback fires!\n\n#### error(callback(statCode, msg))\n\nFires if there was an error delivering a file from the `webroot`. `statCode` contains the numeric HTTP status code that was sent to the client. `msg` contains the error message. You must close the connection yourself if the error callback fires! The default callback shows a minimal HTTP error page.\n\n#### otherwise(callback(err))\n\nFires if no matching file was found in the `webroot`. Also fires if `false` was returned in the `delegate.before()` callback. If there was a problem stating the file, `err` is set to the contents of that error message. The default callback shows a simple \"HTTP 404 File Not Found\" page.\n\n#### addHeader(callback(name, value))\n\nSets an arbitrary HTTP header. The header name `Expires` is special and expects the number of milliseconds till expiry, from which it will calculate the proper HTTP date.\n\n## License\n\njayli is licensed under the MIT license.\n\n## Credits\n\n* [Jan Lehnardt](http://twitter.com/janl) for coming up with the name \"jayli\"\n", | ||
"readmeFilename": "README.md", | ||
"_id": "jayli-server@0.0.1", | ||
"_id": "jayli-server@0.0.2", | ||
"dist": { | ||
"shasum": "" | ||
}, | ||
"_from": "jayli-server@~0.0.1", | ||
"_from": "jayli-server@", | ||
"_resolved": "https://registry.npmjs.org/bachi/-/jayli-server-0.0.1.tgz" | ||
} |
145416