koa-sendfile
Advanced tools
Comparing version 1.0.3 to 1.1.0
21
index.js
var extname = require('path').extname | ||
var calculate = require('etag') | ||
var fs = require('mz/fs') | ||
@@ -12,11 +13,4 @@ | ||
module.exports = function* sendfile(path) { | ||
var stats | ||
try { | ||
stats = yield fs.stat(path) | ||
} catch (err) { | ||
if (notfound[err.code]) return | ||
err.status = 500 | ||
throw err | ||
} | ||
var stats = yield fs.stat(path).catch(onstaterror) | ||
if (!stats) return null | ||
if (!stats.isFile()) return stats | ||
@@ -27,2 +21,5 @@ | ||
this.response.type = extname(path) | ||
if (!this.response.etag) this.response.etag = calculate(stats, { | ||
weak: true | ||
}) | ||
@@ -46,1 +43,7 @@ // fresh based solely on last-modified | ||
} | ||
function onstaterror(err) { | ||
if (notfound[err.code]) return | ||
err.status = 500 | ||
throw err | ||
} |
{ | ||
"name": "koa-sendfile", | ||
"description": "basic file-sending utility for koa", | ||
"version": "1.0.3", | ||
"version": "1.1.0", | ||
"author": { | ||
@@ -14,2 +14,3 @@ "name": "Jonathan Ong", | ||
"debug": "*", | ||
"etag": "^1.5.1", | ||
"mz": "1" | ||
@@ -16,0 +17,0 @@ }, |
# koa sendfile | ||
[![NPM version][npm-image]][npm-url] | ||
[![Build status][travis-image]][travis-url] | ||
[![Test coverage][coveralls-image]][coveralls-url] | ||
[![Dependency Status][david-image]][david-url] | ||
[![License][license-image]][license-url] | ||
[![Downloads][downloads-image]][downloads-url] | ||
[![Gittip][gittip-image]][gittip-url] | ||
Basic file-sending utility for koa. It does the following: | ||
@@ -35,24 +43,17 @@ | ||
## License | ||
The MIT License (MIT) | ||
Copyright (c) 2014 Jonathan Ong me@jongleberry.com | ||
Permission 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: | ||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
THE 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. | ||
[npm-image]: https://img.shields.io/npm/v/koa-sendfile.svg?style=flat-square | ||
[npm-url]: https://npmjs.org/package/koa-sendfile | ||
[github-tag]: http://img.shields.io/github/tag/koajs/sendfile.svg?style=flat-square | ||
[github-url]: https://github.com/koajs/sendfile/tags | ||
[travis-image]: https://img.shields.io/travis/koajs/sendfile.svg?style=flat-square | ||
[travis-url]: https://travis-ci.org/koajs/sendfile | ||
[coveralls-image]: https://img.shields.io/coveralls/koajs/sendfile.svg?style=flat-square | ||
[coveralls-url]: https://coveralls.io/r/koajs/sendfile?branch=master | ||
[david-image]: http://img.shields.io/david/koajs/sendfile.svg?style=flat-square | ||
[david-url]: https://david-dm.org/koajs/sendfile | ||
[license-image]: http://img.shields.io/npm/l/koa-sendfile.svg?style=flat-square | ||
[license-url]: LICENSE | ||
[downloads-image]: http://img.shields.io/npm/dm/koa-sendfile.svg?style=flat-square | ||
[downloads-url]: https://npmjs.org/package/koa-sendfile | ||
[gittip-image]: https://img.shields.io/gittip/jonathanong.svg?style=flat-square | ||
[gittip-url]: https://www.gittip.com/jonathanong/ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5351
4
39
59
3
+ Addedetag@^1.5.1
+ Addedetag@1.8.1(transitive)