Commit e7537cdf authored by Leo Iannacone's avatar Leo Iannacone

update internals libraries

parent 2c9d9eab
1.2.0 / 2014-09-02
==================
* Display error using `util.inspect` if no other representation
* deps: accepts@~1.1.0
1.1.1 / 2014-06-20 1.1.1 / 2014-06-20
================== ==================
......
# node-fresh
HTTP response freshness testing
## fresh(req, res)
Check freshness of `req` and `res` headers.
When the cache is "fresh" __true__ is returned,
otherwise __false__ is returned to indicate that
the cache is now stale.
## Example:
```js
var req = { 'if-none-match': 'tobi' };
var res = { 'etag': 'luna' };
fresh(req, res);
// => false
var req = { 'if-none-match': 'tobi' };
var res = { 'etag': 'tobi' };
fresh(req, res);
// => true
```
## Installation
```
$ npm install fresh
```
## License
(The MIT License) (The MIT License)
Copyright (c) 2012 TJ Holowaychuk &lt;tj@vision-media.ca&gt; Copyright (c) 2014 Jonathan Ong <me@jongleberry.com>
Permission is hereby granted, free of charge, to any person obtaining Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the a copy of this software and associated documentation files (the
......
# errorhandler # errorhandler
[![NPM version](https://badge.fury.io/js/errorhandler.svg)](http://badge.fury.io/js/errorhandler) [![NPM Version][npm-image]][npm-url]
[![Build Status](https://travis-ci.org/expressjs/errorhandler.svg?branch=master)](https://travis-ci.org/expressjs/errorhandler) [![NPM Downloads][downloads-image]][downloads-url]
[![Coverage Status](https://img.shields.io/coveralls/expressjs/errorhandler.svg?branch=master)](https://coveralls.io/r/expressjs/errorhandler) [![Build Status][travis-image]][travis-url]
[![Test Coverage][coveralls-image]][coveralls-url]
[![Gratipay][gratipay-image]][gratipay-url]
Previously `connect.errorHandler()`. Development-only error handler middleware
## Install ## Install
...@@ -14,11 +16,15 @@ $ npm install errorhandler ...@@ -14,11 +16,15 @@ $ npm install errorhandler
## API ## API
```js
var errorhandler = require('errorhandler')
```
### errorhandler() ### errorhandler()
Create new middleware to handle errors and respond with content negotiation. Create new middleware to handle errors and respond with content negotiation.
This middleware is only intended to be used in a development environment, as This middleware is only intended to be used in a development environment, as
the full error stack traces will be send back to the client when an error the full error stack traces will be sent back to the client when an error
occurs. occurs.
## Example ## Example
...@@ -30,30 +36,22 @@ var errorhandler = require('errorhandler') ...@@ -30,30 +36,22 @@ var errorhandler = require('errorhandler')
var app = connect() var app = connect()
if (process.env.NODE_ENV === 'development') { if (process.env.NODE_ENV === 'development') {
// only use in development
app.use(errorhandler()) app.use(errorhandler())
} }
``` ```
## License ## License
The MIT License (MIT) [MIT](LICENSE)
Copyright (c) 2014 Jonathan Ong me@jongleberry.com [npm-image]: https://img.shields.io/npm/v/errorhandler.svg?style=flat
[npm-url]: https://npmjs.org/package/errorhandler
Permission is hereby granted, free of charge, to any person obtaining a copy [travis-image]: https://img.shields.io/travis/expressjs/errorhandler.svg?style=flat
of this software and associated documentation files (the "Software"), to deal [travis-url]: https://travis-ci.org/expressjs/errorhandler
in the Software without restriction, including without limitation the rights [coveralls-image]: https://img.shields.io/coveralls/expressjs/errorhandler.svg?style=flat
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell [coveralls-url]: https://coveralls.io/r/expressjs/errorhandler?branch=master
copies of the Software, and to permit persons to whom the Software is [downloads-image]: http://img.shields.io/npm/dm/errorhandler.svg?style=flat
furnished to do so, subject to the following conditions: [downloads-url]: https://npmjs.org/package/errorhandler
[gratipay-image]: https://img.shields.io/gratipay/dougwilson.svg?style=flat
The above copyright notice and this permission notice shall be included in [gratipay-url]: https://www.gratipay.com/dougwilson/
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.
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
* errorhandler * errorhandler
* Copyright(c) 2010 Sencha Inc. * Copyright(c) 2010 Sencha Inc.
* Copyright(c) 2011 TJ Holowaychuk * Copyright(c) 2011 TJ Holowaychuk
* Copyright(c) 2014 Jonathan Ong
* MIT Licensed * MIT Licensed
*/ */
...@@ -12,6 +13,14 @@ ...@@ -12,6 +13,14 @@
var accepts = require('accepts') var accepts = require('accepts')
var escapeHtml = require('escape-html'); var escapeHtml = require('escape-html');
var fs = require('fs'); var fs = require('fs');
var util = require('util')
/**
* Module variables.
*/
var inspect = util.inspect
var toString = Object.prototype.toString
/** /**
* Error handler: * Error handler:
...@@ -55,7 +64,7 @@ exports = module.exports = function errorHandler(){ ...@@ -55,7 +64,7 @@ exports = module.exports = function errorHandler(){
// write error to console // write error to console
if (env !== 'test') { if (env !== 'test') {
console.error(err.stack || String(err)) console.error(stringify(err))
} }
// cannot actually respond // cannot actually respond
...@@ -76,7 +85,7 @@ exports = module.exports = function errorHandler(){ ...@@ -76,7 +85,7 @@ exports = module.exports = function errorHandler(){
if (e) return next(e); if (e) return next(e);
fs.readFile(__dirname + '/public/error.html', 'utf8', function(e, html){ fs.readFile(__dirname + '/public/error.html', 'utf8', function(e, html){
if (e) return next(e); if (e) return next(e);
var stack = (err.stack || '') var stack = String(err.stack || '')
.split('\n').slice(1) .split('\n').slice(1)
.map(function(v){ return '<li>' + escapeHtml(v).replace(/ /g, ' &nbsp;') + '</li>'; }).join(''); .map(function(v){ return '<li>' + escapeHtml(v).replace(/ /g, ' &nbsp;') + '</li>'; }).join('');
html = html html = html
...@@ -84,7 +93,7 @@ exports = module.exports = function errorHandler(){ ...@@ -84,7 +93,7 @@ exports = module.exports = function errorHandler(){
.replace('{stack}', stack) .replace('{stack}', stack)
.replace('{title}', escapeHtml(exports.title)) .replace('{title}', escapeHtml(exports.title))
.replace('{statusCode}', res.statusCode) .replace('{statusCode}', res.statusCode)
.replace(/\{error\}/g, escapeHtml(String(err)).replace(/ /g, ' &nbsp;').replace(/\n/g, '<br>')); .replace(/\{error\}/g, escapeHtml(stringify(err)).replace(/ /g, ' &nbsp;').replace(/\n/g, '<br>'));
res.setHeader('Content-Type', 'text/html; charset=utf-8'); res.setHeader('Content-Type', 'text/html; charset=utf-8');
res.end(html); res.end(html);
}); });
...@@ -99,7 +108,7 @@ exports = module.exports = function errorHandler(){ ...@@ -99,7 +108,7 @@ exports = module.exports = function errorHandler(){
// plain text // plain text
} else { } else {
res.setHeader('Content-Type', 'text/plain'); res.setHeader('Content-Type', 'text/plain');
res.end(err.stack || String(err)); res.end(stringify(err));
} }
}; };
}; };
...@@ -109,3 +118,22 @@ exports = module.exports = function errorHandler(){ ...@@ -109,3 +118,22 @@ exports = module.exports = function errorHandler(){
*/ */
exports.title = 'Connect'; exports.title = 'Connect';
/**
* Stringify a value.
* @api private
*/
function stringify(val) {
var stack = val.stack
if (stack) {
return String(stack)
}
var str = String(val)
return str === toString.call(val)
? inspect(val)
: str
}
1.0.7 / 2014-07-04
==================
* Fix wrong type returned from `type` when match after unknown extension
1.0.6 / 2014-06-24
==================
* deps: negotiator@0.4.7
1.0.5 / 2014-06-20
==================
* fix crash when unknown extension given
1.0.4 / 2014-06-19
==================
* use `mime-types`
1.0.3 / 2014-06-11
==================
* deps: negotiator@0.4.6
- Order by specificity when quality is the same
1.0.2 / 2014-05-29
==================
* Fix interpretation when header not in request
* deps: pin negotiator@0.4.5
1.0.1 / 2014-01-18
==================
* Identity encoding isn't always acceptable
* deps: negotiator@~0.4.0
1.0.0 / 2013-12-27
==================
* Genesis
# Accepts # Accepts
[![NPM version](https://badge.fury.io/js/accepts.svg)](http://badge.fury.io/js/accepts) [![NPM version][npm-image]][npm-url]
[![Build Status](https://travis-ci.org/expressjs/accepts.svg?branch=master)](https://travis-ci.org/expressjs/accepts) [![Build status][travis-image]][travis-url]
[![Coverage Status](https://img.shields.io/coveralls/expressjs/accepts.svg?branch=master)](https://coveralls.io/r/expressjs/accepts) [![Test coverage][coveralls-image]][coveralls-url]
[![Dependency Status][david-image]][david-url]
[![License][license-image]][license-url]
[![Downloads][downloads-image]][downloads-url]
Higher level content negotation based on [negotiator](https://github.com/federomero/negotiator). Extracted from [koa](https://github.com/koajs/koa) for general use. Higher level content negotation based on [negotiator](https://github.com/federomero/negotiator). Extracted from [koa](https://github.com/koajs/koa) for general use.
...@@ -76,26 +79,17 @@ accept.types() // -> [], no explicit types ...@@ -76,26 +79,17 @@ accept.types() // -> [], no explicit types
accept.types('text/html', 'text/json') // -> 'text/html', since it was first accept.types('text/html', 'text/json') // -> 'text/html', since it was first
``` ```
## License [npm-image]: https://img.shields.io/npm/v/accepts.svg?style=flat-square
[npm-url]: https://npmjs.org/package/accepts
The MIT License (MIT) [github-tag]: http://img.shields.io/github/tag/jshttp/accepts.svg?style=flat-square
[github-url]: https://github.com/jshttp/accepts/tags
Copyright (c) 2013 Jonathan Ong me@jongleberry.com [travis-image]: https://img.shields.io/travis/jshttp/accepts.svg?style=flat-square
[travis-url]: https://travis-ci.org/jshttp/accepts
Permission is hereby granted, free of charge, to any person obtaining a copy [coveralls-image]: https://img.shields.io/coveralls/jshttp/accepts.svg?style=flat-square
of this software and associated documentation files (the "Software"), to deal [coveralls-url]: https://coveralls.io/r/jshttp/accepts?branch=master
in the Software without restriction, including without limitation the rights [david-image]: http://img.shields.io/david/jshttp/accepts.svg?style=flat-square
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell [david-url]: https://david-dm.org/jshttp/accepts
copies of the Software, and to permit persons to whom the Software is [license-image]: http://img.shields.io/npm/l/accepts.svg?style=flat-square
furnished to do so, subject to the following conditions: [license-url]: LICENSE
[downloads-image]: http://img.shields.io/npm/dm/accepts.svg?style=flat-square
The above copyright notice and this permission notice shall be included in [downloads-url]: https://npmjs.org/package/accepts
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.
\ No newline at end of file
test
build.js
# OS generated files #
######################
.DS_Store*
# Icon?
ehthumbs.db
Thumbs.db
# Node.js #
###########
node_modules
npm-debug.log
language: node_js
node_js:
- "0.8"
- "0.10"
- "0.11"
matrix:
allow_failures:
- node_js: "0.11"
fast_finish: true
before_install:
# remove build script deps before install
- node -pe 'f="./package.json";p=require(f);d=p.devDependencies;for(k in d){if("co"===k.substr(0,2))delete d[k]}require("fs").writeFileSync(f,JSON.stringify(p,null,2))'
2.0.1 / 2014-09-07
==================
* Support Node.js 0.6
2.0.0 / 2014-09-02
==================
* Use `mime-db`
* Remove `.define()`
1.0.2 / 2014-08-04
==================
* Set charset=utf-8 for `text/javascript`
1.0.1 / 2014-06-24
==================
* Add `text/jsx` type
1.0.0 / 2014-05-12
==================
* Return `false` for unknown types
* Set charset=utf-8 for `application/json`
0.1.0 / 2014-05-02
==================
* Initial release
build:
node --harmony-generators build.js
test:
node test/mime.js
mocha --require should --reporter spec test/test.js
.PHONY: build test
# mime-types # mime-types
[![NPM version](https://badge.fury.io/js/mime-types.svg)](https://badge.fury.io/js/mime-types) [![Build Status](https://travis-ci.org/expressjs/mime-types.svg?branch=master)](https://travis-ci.org/expressjs/mime-types)
The ultimate javascript content-type utility. [![NPM Version][npm-image]][npm-url]
[![NPM Downloads][downloads-image]][downloads-url]
### Install [![Node.js Version][node-version-image]][node-version-url]
[![Build Status][travis-image]][travis-url]
[![Test Coverage][coveralls-image]][coveralls-url]
```sh The ultimate javascript content-type utility.
$ npm install mime-types
```
#### Similar to [node-mime](https://github.com/broofa/node-mime), except: Similar to [node-mime](https://github.com/broofa/node-mime), except:
- __No fallbacks.__ Instead of naively returning the first available type, `mime-types` simply returns `false`, so do `var type = mime.lookup('unrecognized') || 'application/octet-stream'`. - __No fallbacks.__ Instead of naively returning the first available type, `mime-types` simply returns `false`,
so do `var type = mime.lookup('unrecognized') || 'application/octet-stream'`.
- No `new Mime()` business, so you could do `var lookup = require('mime-types').lookup`. - No `new Mime()` business, so you could do `var lookup = require('mime-types').lookup`.
- Additional mime types are added such as jade and stylus. Feel free to add more! - Additional mime types are added such as jade and stylus via [mime-db](https://github.com/jshttp/mime-db)
- Browser support via Browserify and Component by converting lists to JSON files. - No `.define()` functionality
Otherwise, the API is compatible. Otherwise, the API is compatible.
### Adding Types ## Install
If you'd like to add additional types, ```sh
simply create a PR adding the type to `custom.json` and $ npm install mime-types
a reference link to the [sources](SOURCES.md). ```
Do __NOT__ edit `mime.json` or `node.json`. ## Adding Types
Those are pulled using `build.js`.
You should only touch `custom.json`. All mime types are based on [mime-db](https://github.com/jshttp/mime-db),
so open a PR there if you'd like to add mime types.
## API ## API
...@@ -74,28 +75,25 @@ Lookup the implied default charset of a content-type. ...@@ -74,28 +75,25 @@ Lookup the implied default charset of a content-type.
mime.charset('text/x-markdown') // 'UTF-8' mime.charset('text/x-markdown') // 'UTF-8'
``` ```
### mime.types[extension] = type ### var type = mime.types[extension]
A map of content-types by extension. A map of content-types by extension.
### mime.extensions[type] = [extensions] ### [extensions...] = mime.extensions[type]
A map of extensions by content-type. A map of extensions by content-type.
### mime.define(types)
Globally add definitions.
`types` must be an object of the form:
```js
{
"<content-type>": [extensions...],
"<content-type>": [extensions...]
}
```
See the `.json` files in `lib/` for examples.
## License ## License
[MIT](LICENSE) [MIT](LICENSE)
[npm-image]: https://img.shields.io/npm/v/mime-types.svg?style=flat
[npm-url]: https://npmjs.org/package/mime-types
[node-version-image]: https://img.shields.io/badge/node.js-%3E%3D_0.6-brightgreen.svg?style=flat
[node-version-url]: http://nodejs.org/download/
[travis-image]: https://img.shields.io/travis/jshttp/mime-types.svg?style=flat
[travis-url]: https://travis-ci.org/jshttp/mime-types
[coveralls-image]: https://img.shields.io/coveralls/jshttp/mime-types.svg?style=flat
[coveralls-url]: https://coveralls.io/r/jshttp/mime-types
[downloads-image]: https://img.shields.io/npm/dm/mime-types.svg?style=flat
[downloads-url]: https://npmjs.org/package/mime-types
### Sources for custom types
This is a list of sources for any custom mime types.
When adding custom mime types, please link to where you found the mime type,
even if it's from an unofficial source.
- `text/coffeescript` - http://coffeescript.org/#scripts
- `text/x-handlebars-template` - https://handlebarsjs.com/#getting-started
- `text/x-sass` & `text/x-scss` - https://github.com/janlelis/rubybuntu-mime/blob/master/sass.xml
- `text.jsx` - http://facebook.github.io/react/docs/getting-started.html [[2]](https://github.com/facebook/react/blob/f230e0a03154e6f8a616e0da1fb3d97ffa1a6472/vendor/browser-transforms.js#L210)
[Sources for node.json types](https://github.com/broofa/node-mime/blob/master/types/node.types)
### Notes on weird types
- `font/opentype` - This type is technically invalid according to the spec. No valid types begin with `font/`. No-one uses the official type of `application/vnd.ms-opentype` as the community standardized `application/x-font-otf`. However, chrome logs nonsense warnings unless opentype fonts are served with `font/opentype`. [[1]](http://stackoverflow.com/questions/2871655/proper-mime-type-for-fonts)
{
"name": "mime-types",
"description": "The ultimate javascript content-type utility.",
"version": "0.1.0",
"author": {
"name": "Jonathan Ong",
"email": "me@jongleberry.com",
"url": "http://jongleberry.com",
"twitter": "https://twitter.com/jongleberry"
},
"repository": "expressjs/mime-types",
"license": "MIT",
"main": "lib/index.js",
"scripts": ["lib/index.js"],
"json": ["mime.json", "node.json", "custom.json"]
}
var db = require('mime-db')
// types[extension] = type // types[extension] = type
exports.types = Object.create(null) exports.types = Object.create(null)
// extensions[type] = [extensions] // extensions[type] = [extensions]
exports.extensions = Object.create(null) exports.extensions = Object.create(null)
// define more mime types
exports.define = define
// store the json files Object.keys(db).forEach(function (name) {
exports.json = { var mime = db[name]
mime: require('./mime.json'), var exts = mime.extensions
node: require('./node.json'), if (!exts || !exts.length) return
custom: require('./custom.json'), exports.extensions[name] = exts
} exts.forEach(function (ext) {
exports.types[ext] = name
})
})
exports.lookup = function (string) { exports.lookup = function (string) {
if (!string || typeof string !== "string") return false if (!string || typeof string !== "string") return false
// remove any leading paths, though we should just use path.basename
string = string.replace(/.*[\.\/\\]/, '').toLowerCase() string = string.replace(/.*[\.\/\\]/, '').toLowerCase()
if (!string) return false if (!string) return false
return exports.types[string] || false return exports.types[string] || false
...@@ -22,6 +26,7 @@ exports.lookup = function (string) { ...@@ -22,6 +26,7 @@ exports.lookup = function (string) {
exports.extension = function (type) { exports.extension = function (type) {
if (!type || typeof type !== "string") return false if (!type || typeof type !== "string") return false
// to do: use media-typer
type = type.match(/^\s*([^;\s]*)(?:;|\s|$)/) type = type.match(/^\s*([^;\s]*)(?:;|\s|$)/)
if (!type) return false if (!type) return false
var exts = exports.extensions[type[1].toLowerCase()] var exts = exports.extensions[type[1].toLowerCase()]
...@@ -31,11 +36,8 @@ exports.extension = function (type) { ...@@ -31,11 +36,8 @@ exports.extension = function (type) {
// type has to be an exact mime type // type has to be an exact mime type
exports.charset = function (type) { exports.charset = function (type) {
// special cases var mime = db[type]
switch (type) { if (mime && mime.charset) return mime.charset
case 'application/json': return 'UTF-8'
case 'application/javascript': return 'UTF-8'
}
// default text/* to utf-8 // default text/* to utf-8
if (/^text\//.test(type)) return 'UTF-8' if (/^text\//.test(type)) return 'UTF-8'
...@@ -48,6 +50,7 @@ exports.charsets = { ...@@ -48,6 +50,7 @@ exports.charsets = {
lookup: exports.charset lookup: exports.charset
} }
// to do: maybe use set-type module or something
exports.contentType = function (type) { exports.contentType = function (type) {
if (!type || typeof type !== "string") return false if (!type || typeof type !== "string") return false
if (!~type.indexOf('/')) type = exports.lookup(type) if (!~type.indexOf('/')) type = exports.lookup(type)
...@@ -58,18 +61,3 @@ exports.contentType = function (type) { ...@@ -58,18 +61,3 @@ exports.contentType = function (type) {
} }
return type return type
} }
define(exports.json.mime)
define(exports.json.node)
define(exports.json.custom)
function define(json) {
Object.keys(json).forEach(function (type) {
var exts = json[type] || []
exports.extensions[type] = exports.extensions[type] || []
exts.forEach(function (ext) {
if (!~exports.extensions[type].indexOf(ext)) exports.extensions[type].push(ext)
exports.types[ext] = type
})
})
}
{
"text/jade": [
"jade"
],
"text/stylus": [
"stylus",
"styl"
],
"text/less": [
"less"
],
"text/x-sass": [
"sass"
],
"text/x-scss": [
"scss"
],
"text/coffeescript": [
"coffee"
],
"text/x-handlebars-template": [
"hbs"
],
"text/jsx": [
"jsx"
]
}
{
"text/vtt": [
"vtt"
],
"application/x-chrome-extension": [
"crx"
],
"text/x-component": [
"htc"
],
"text/cache-manifest": [
"manifest"
],
"application/octet-stream": [
"buffer"
],
"application/mp4": [
"m4p"
],
"audio/mp4": [
"m4a"
],
"video/MP2T": [
"ts"
],
"application/x-web-app-manifest+json": [
"webapp"
],
"text/x-lua": [
"lua"
],
"application/x-lua-bytecode": [
"luac"
],
"text/x-markdown": [
"markdown",
"md",
"mkd"
],
"text/plain": [
"ini"
],
"application/dash+xml": [
"mdp"
],
"font/opentype": [
"otf"
],
"application/json": [
"map"
],
"application/xml": [
"xsd"
]
}
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.
# mime-db
[![NPM Version][npm-version-image]][npm-url]
[![NPM Downloads][npm-downloads-image]][npm-url]
[![Node.js Version][node-image]][node-url]
[![Build Status][travis-image]][travis-url]
[![Coverage Status][coveralls-image]][coveralls-url]
This is a database of all mime types.
It consistents of a single, public JSON file and does not include any logic,
allowing it to remain as unopinionated as possible with an API.
It aggregates data from the following sources:
- http://www.iana.org/assignments/media-types/media-types.xhtml
- http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types
## Usage
```bash
npm i mime-db
```
```js
var db = require('mime-db');
// grab data on .js files
var data = db['application/javascript'];
```
If you're crazy enough to use this in the browser,
you can just grab the JSON file:
```
https://cdn.rawgit.com/jshttp/mime-db/master/db.json
```
## Data Structure
The JSON file is a map lookup for lowercased mime types.
Each mime type has the following properties:
- `.source` - where the mime type is defined.
If not set, it's probably a custom media type.
- `apache` - [Apache common media types](http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types)
- `iana` - [IANA-defined media types](http://www.iana.org/assignments/media-types/media-types.xhtml)
- `.extensions[]` - known extensions associated with this mime type.
- `.compressible` - whether a file of this type is can be gzipped.
- `.charset` - the default charset associated with this type, if any.
If unknown, every property could be `undefined`.
## Repository Structure
- `scripts` - these are scripts to run to build the database
- `src/` - this is a folder of files created from remote sources like Apache and IANA
- `lib/` - this is a folder of our own custom sources and db, which will be merged into `db.json`
- `db.json` - the final built JSON file for end-user usage
## Contributing
To edit the database, only make PRs against files in the `lib/` folder.
To update the build, run `npm run update`.
[npm-version-image]: https://img.shields.io/npm/v/mime-db.svg?style=flat
[npm-downloads-image]: https://img.shields.io/npm/dm/mime-db.svg?style=flat
[npm-url]: https://npmjs.org/package/mime-db
[travis-image]: https://img.shields.io/travis/jshttp/mime-db.svg?style=flat
[travis-url]: https://travis-ci.org/jshttp/mime-db
[coveralls-image]: https://img.shields.io/coveralls/jshttp/mime-db.svg?style=flat
[coveralls-url]: https://coveralls.io/r/jshttp/mime-db?branch=master
[node-image]: http://img.shields.io/badge/node.js->=_0.6-brightgreen.svg?style=flat
[node-url]: http://nodejs.org/download/
/*!
* mime-db
* Copyright(c) 2014 Jonathan Ong
* MIT Licensed
*/
/**
* Module exports.
*/
module.exports = require('./db.json')
{
"name": "mime-db",
"description": "Media Type Database",
"version": "1.0.1",
"author": {
"name": "Jonathan Ong",
"email": "me@jongleberry.com",
"url": "http://jongleberry.com"
},
"license": "MIT",
"repository": {
"type": "git",
"url": "git://github.com/jshttp/mime-db"
},
"devDependencies": {
"co": "3",
"cogent": "1",
"csv-parse": "0",
"gnode": "0.0.8",
"istanbul": "0.3.0",
"mocha": "1",
"stream-to-array": "2"
},
"engine": {
"node": ">= 0.6.0"
},
"files": [
"LICENSE",
"db.json",
"index.js"
],
"scripts": {
"update": "gnode scripts/extensions && gnode scripts/types && node scripts/build",
"clean": "rm src/*",
"test": "mocha --reporter spec --bail --check-leaks test/",
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/",
"test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/"
},
"keywords": [
"mime",
"db",
"type",
"types",
"database",
"charset",
"charsets"
],
"readme": "# mime-db\n\n[![NPM Version][npm-version-image]][npm-url]\n[![NPM Downloads][npm-downloads-image]][npm-url]\n[![Node.js Version][node-image]][node-url]\n[![Build Status][travis-image]][travis-url]\n[![Coverage Status][coveralls-image]][coveralls-url]\n\nThis is a database of all mime types.\nIt consistents of a single, public JSON file and does not include any logic,\nallowing it to remain as unopinionated as possible with an API.\nIt aggregates data from the following sources:\n\n- http://www.iana.org/assignments/media-types/media-types.xhtml\n- http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types\n\n## Usage\n\n```bash\nnpm i mime-db\n```\n\n```js\nvar db = require('mime-db');\n\n// grab data on .js files\nvar data = db['application/javascript'];\n```\n\nIf you're crazy enough to use this in the browser,\nyou can just grab the JSON file:\n\n```\nhttps://cdn.rawgit.com/jshttp/mime-db/master/db.json\n```\n\n## Data Structure\n\nThe JSON file is a map lookup for lowercased mime types.\nEach mime type has the following properties:\n\n- `.source` - where the mime type is defined.\n If not set, it's probably a custom media type.\n - `apache` - [Apache common media types](http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types)\n - `iana` - [IANA-defined media types](http://www.iana.org/assignments/media-types/media-types.xhtml)\n- `.extensions[]` - known extensions associated with this mime type.\n- `.compressible` - whether a file of this type is can be gzipped.\n- `.charset` - the default charset associated with this type, if any.\n\nIf unknown, every property could be `undefined`.\n\n## Repository Structure\n\n- `scripts` - these are scripts to run to build the database\n- `src/` - this is a folder of files created from remote sources like Apache and IANA\n- `lib/` - this is a folder of our own custom sources and db, which will be merged into `db.json`\n- `db.json` - the final built JSON file for end-user usage\n\n## Contributing\n\nTo edit the database, only make PRs against files in the `lib/` folder.\nTo update the build, run `npm run update`.\n\n[npm-version-image]: https://img.shields.io/npm/v/mime-db.svg?style=flat\n[npm-downloads-image]: https://img.shields.io/npm/dm/mime-db.svg?style=flat\n[npm-url]: https://npmjs.org/package/mime-db\n[travis-image]: https://img.shields.io/travis/jshttp/mime-db.svg?style=flat\n[travis-url]: https://travis-ci.org/jshttp/mime-db\n[coveralls-image]: https://img.shields.io/coveralls/jshttp/mime-db.svg?style=flat\n[coveralls-url]: https://coveralls.io/r/jshttp/mime-db?branch=master\n[node-image]: http://img.shields.io/badge/node.js->=_0.6-brightgreen.svg?style=flat\n[node-url]: http://nodejs.org/download/\n",
"readmeFilename": "README.md",
"bugs": {
"url": "https://github.com/jshttp/mime-db/issues"
},
"_id": "mime-db@1.0.1",
"_from": "mime-db@~1.0.1"
}
{ {
"name": "mime-types", "name": "mime-types",
"description": "The ultimate javascript content-type utility.", "description": "The ultimate javascript content-type utility.",
"version": "1.0.2", "version": "2.0.1",
"author": {
"name": "Jonathan Ong",
"email": "me@jongleberry.com",
"url": "http://jongleberry.com"
},
"contributors": [ "contributors": [
{ {
"name": "Jeremiah Senkpiel", "name": "Jeremiah Senkpiel",
"email": "fishrock123@rocketmail.com", "email": "fishrock123@rocketmail.com",
"url": "https://searchbeam.jit.su" "url": "https://searchbeam.jit.su"
},
{
"name": "Jonathan Ong",
"email": "me@jongleberry.com",
"url": "http://jongleberry.com"
} }
], ],
"license": "MIT",
"keywords": [
"mime",
"types"
],
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git://github.com/expressjs/mime-types" "url": "git://github.com/jshttp/mime-types"
},
"dependencies": {
"mime-db": "~1.0.1"
}, },
"license": "MIT",
"main": "lib",
"devDependencies": { "devDependencies": {
"co": "3", "istanbul": "0",
"cogent": "0", "mocha": "1"
"mocha": "1",
"should": "3"
}, },
"files": [
"HISTORY.md",
"LICENSE",
"index.js"
],
"engines": { "engines": {
"node": ">= 0.8.0" "node": ">= 0.6"
}, },
"scripts": { "scripts": {
"test": "make test" "test": "mocha --reporter spec test/test.js",
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot test/test.js",
"test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter dot test/test.js"
}, },
"readme": "# mime-types\n[![NPM version](https://badge.fury.io/js/mime-types.svg)](https://badge.fury.io/js/mime-types) [![Build Status](https://travis-ci.org/expressjs/mime-types.svg?branch=master)](https://travis-ci.org/expressjs/mime-types)\n\nThe ultimate javascript content-type utility.\n\n### Install\n\n```sh\n$ npm install mime-types\n```\n\n#### Similar to [node-mime](https://github.com/broofa/node-mime), except:\n\n- __No fallbacks.__ Instead of naively returning the first available type, `mime-types` simply returns `false`, so do `var type = mime.lookup('unrecognized') || 'application/octet-stream'`.\n- No `new Mime()` business, so you could do `var lookup = require('mime-types').lookup`.\n- Additional mime types are added such as jade and stylus. Feel free to add more!\n- Browser support via Browserify and Component by converting lists to JSON files.\n\nOtherwise, the API is compatible.\n\n### Adding Types\n\nIf you'd like to add additional types,\nsimply create a PR adding the type to `custom.json` and\na reference link to the [sources](SOURCES.md).\n\nDo __NOT__ edit `mime.json` or `node.json`.\nThose are pulled using `build.js`.\nYou should only touch `custom.json`.\n\n## API\n\n```js\nvar mime = require('mime-types')\n```\n\nAll functions return `false` if input is invalid or not found.\n\n### mime.lookup(path)\n\nLookup the content-type associated with a file.\n\n```js\nmime.lookup('json') // 'application/json'\nmime.lookup('.md') // 'text/x-markdown'\nmime.lookup('file.html') // 'text/html'\nmime.lookup('folder/file.js') // 'application/javascript'\n\nmime.lookup('cats') // false\n```\n\n### mime.contentType(type)\n\nCreate a full content-type header given a content-type or extension.\n\n```js\nmime.contentType('markdown') // 'text/x-markdown; charset=utf-8'\nmime.contentType('file.json') // 'application/json; charset=utf-8'\n```\n\n### mime.extension(type)\n\nGet the default extension for a content-type.\n\n```js\nmime.extension('application/octet-stream') // 'bin'\n```\n\n### mime.charset(type)\n\nLookup the implied default charset of a content-type.\n\n```js\nmime.charset('text/x-markdown') // 'UTF-8'\n```\n\n### mime.types[extension] = type\n\nA map of content-types by extension.\n\n### mime.extensions[type] = [extensions]\n\nA map of extensions by content-type.\n\n### mime.define(types)\n\nGlobally add definitions.\n`types` must be an object of the form:\n\n```js\n{\n \"<content-type>\": [extensions...],\n \"<content-type>\": [extensions...]\n}\n```\n\nSee the `.json` files in `lib/` for examples.\n\n## License\n\n[MIT](LICENSE)\n", "readme": "# mime-types\n\n[![NPM Version][npm-image]][npm-url]\n[![NPM Downloads][downloads-image]][downloads-url]\n[![Node.js Version][node-version-image]][node-version-url]\n[![Build Status][travis-image]][travis-url]\n[![Test Coverage][coveralls-image]][coveralls-url]\n\nThe ultimate javascript content-type utility.\n\nSimilar to [node-mime](https://github.com/broofa/node-mime), except:\n\n- __No fallbacks.__ Instead of naively returning the first available type, `mime-types` simply returns `false`,\n so do `var type = mime.lookup('unrecognized') || 'application/octet-stream'`.\n- No `new Mime()` business, so you could do `var lookup = require('mime-types').lookup`.\n- Additional mime types are added such as jade and stylus via [mime-db](https://github.com/jshttp/mime-db)\n- No `.define()` functionality\n\nOtherwise, the API is compatible.\n\n## Install\n\n```sh\n$ npm install mime-types\n```\n\n## Adding Types\n\nAll mime types are based on [mime-db](https://github.com/jshttp/mime-db),\nso open a PR there if you'd like to add mime types.\n\n## API\n\n```js\nvar mime = require('mime-types')\n```\n\nAll functions return `false` if input is invalid or not found.\n\n### mime.lookup(path)\n\nLookup the content-type associated with a file.\n\n```js\nmime.lookup('json') // 'application/json'\nmime.lookup('.md') // 'text/x-markdown'\nmime.lookup('file.html') // 'text/html'\nmime.lookup('folder/file.js') // 'application/javascript'\n\nmime.lookup('cats') // false\n```\n\n### mime.contentType(type)\n\nCreate a full content-type header given a content-type or extension.\n\n```js\nmime.contentType('markdown') // 'text/x-markdown; charset=utf-8'\nmime.contentType('file.json') // 'application/json; charset=utf-8'\n```\n\n### mime.extension(type)\n\nGet the default extension for a content-type.\n\n```js\nmime.extension('application/octet-stream') // 'bin'\n```\n\n### mime.charset(type)\n\nLookup the implied default charset of a content-type.\n\n```js\nmime.charset('text/x-markdown') // 'UTF-8'\n```\n\n### var type = mime.types[extension]\n\nA map of content-types by extension.\n\n### [extensions...] = mime.extensions[type]\n\nA map of extensions by content-type.\n\n## License\n\n[MIT](LICENSE)\n\n[npm-image]: https://img.shields.io/npm/v/mime-types.svg?style=flat\n[npm-url]: https://npmjs.org/package/mime-types\n[node-version-image]: https://img.shields.io/badge/node.js-%3E%3D_0.6-brightgreen.svg?style=flat\n[node-version-url]: http://nodejs.org/download/\n[travis-image]: https://img.shields.io/travis/jshttp/mime-types.svg?style=flat\n[travis-url]: https://travis-ci.org/jshttp/mime-types\n[coveralls-image]: https://img.shields.io/coveralls/jshttp/mime-types.svg?style=flat\n[coveralls-url]: https://coveralls.io/r/jshttp/mime-types\n[downloads-image]: https://img.shields.io/npm/dm/mime-types.svg?style=flat\n[downloads-url]: https://npmjs.org/package/mime-types\n",
"readmeFilename": "README.md", "readmeFilename": "README.md",
"bugs": { "bugs": {
"url": "https://github.com/expressjs/mime-types/issues" "url": "https://github.com/jshttp/mime-types/issues"
},
"_id": "mime-types@2.0.1",
"dist": {
"shasum": "d99a351337ae397ccf7407a584c972b4ee80ca2a"
}, },
"_id": "mime-types@1.0.2", "_from": "mime-types@~2.0.0",
"_from": "mime-types@~1.0.0" "_resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.0.1.tgz"
} }
{ {
"name": "accepts", "name": "accepts",
"description": "Higher-level content negotiation", "description": "Higher-level content negotiation",
"version": "1.0.7", "version": "1.1.0",
"author": { "author": {
"name": "Jonathan Ong", "name": "Jonathan Ong",
"email": "me@jongleberry.com", "email": "me@jongleberry.com",
...@@ -10,16 +10,16 @@ ...@@ -10,16 +10,16 @@
"license": "MIT", "license": "MIT",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git://github.com/expressjs/accepts" "url": "git://github.com/jshttp/accepts"
}, },
"dependencies": { "dependencies": {
"mime-types": "~1.0.0", "mime-types": "~2.0.0",
"negotiator": "0.4.7" "negotiator": "0.4.7"
}, },
"devDependencies": { "devDependencies": {
"istanbul": "0.2.11", "istanbul": "~0.3.0",
"mocha": "*", "mocha": "1",
"should": "*" "should": "4"
}, },
"engines": { "engines": {
"node": ">= 0.8.0" "node": ">= 0.8.0"
...@@ -29,11 +29,20 @@ ...@@ -29,11 +29,20 @@
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --require should --reporter dot test/", "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --require should --reporter dot test/",
"test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --require should --reporter spec test/" "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --require should --reporter spec test/"
}, },
"readme": "# Accepts\n\n[![NPM version](https://badge.fury.io/js/accepts.svg)](http://badge.fury.io/js/accepts)\n[![Build Status](https://travis-ci.org/expressjs/accepts.svg?branch=master)](https://travis-ci.org/expressjs/accepts)\n[![Coverage Status](https://img.shields.io/coveralls/expressjs/accepts.svg?branch=master)](https://coveralls.io/r/expressjs/accepts)\n\nHigher level content negotation based on [negotiator](https://github.com/federomero/negotiator). Extracted from [koa](https://github.com/koajs/koa) for general use.\n\nIn addition to negotatior, it allows:\n\n- Allows types as an array or arguments list, ie `(['text/html', 'application/json'])` as well as `('text/html', 'application/json')`.\n- Allows type shorthands such as `json`.\n- Returns `false` when no types match\n- Treats non-existent headers as `*`\n\n## API\n\n### var accept = new Accepts(req)\n\n```js\nvar accepts = require('accepts')\n\nhttp.createServer(function (req, res) {\n var accept = accepts(req)\n})\n```\n\n### accept\\[property\\]\\(\\)\n\nReturns all the explicitly accepted content property as an array in descending priority.\n\n- `accept.types()`\n- `accept.encodings()`\n- `accept.charsets()`\n- `accept.languages()`\n\nThey are also aliased in singular form such as `accept.type()`. `accept.languages()` is also aliased as `accept.langs()`, etc.\n\nNote: you should almost never do this in a real app as it defeats the purpose of content negotiation.\n\nExample:\n\n```js\n// in Google Chrome\nvar encodings = accept.encodings() // -> ['sdch', 'gzip', 'deflate']\n```\n\nSince you probably don't support `sdch`, you should just supply the encodings you support:\n\n```js\nvar encoding = accept.encodings('gzip', 'deflate') // -> 'gzip', probably\n```\n\n### accept\\[property\\]\\(values, ...\\)\n\nYou can either have `values` be an array or have an argument list of values.\n\nIf the client does not accept any `values`, `false` will be returned.\nIf the client accepts any `values`, the preferred `value` will be return.\n\nFor `accept.types()`, shorthand mime types are allowed.\n\nExample:\n\n```js\n// req.headers.accept = 'application/json'\n\naccept.types('json') // -> 'json'\naccept.types('html', 'json') // -> 'json'\naccept.types('html') // -> false\n\n// req.headers.accept = ''\n// which is equivalent to `*`\n\naccept.types() // -> [], no explicit types\naccept.types('text/html', 'text/json') // -> 'text/html', since it was first\n```\n\n## License\n\nThe MIT License (MIT)\n\nCopyright (c) 2013 Jonathan Ong me@jongleberry.com\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.", "keywords": [
"content",
"negotiation",
"accept",
"accepts"
],
"files": [
"index.js"
],
"readme": "# Accepts\n\n[![NPM version][npm-image]][npm-url]\n[![Build status][travis-image]][travis-url]\n[![Test coverage][coveralls-image]][coveralls-url]\n[![Dependency Status][david-image]][david-url]\n[![License][license-image]][license-url]\n[![Downloads][downloads-image]][downloads-url]\n\nHigher level content negotation based on [negotiator](https://github.com/federomero/negotiator). Extracted from [koa](https://github.com/koajs/koa) for general use.\n\nIn addition to negotatior, it allows:\n\n- Allows types as an array or arguments list, ie `(['text/html', 'application/json'])` as well as `('text/html', 'application/json')`.\n- Allows type shorthands such as `json`.\n- Returns `false` when no types match\n- Treats non-existent headers as `*`\n\n## API\n\n### var accept = new Accepts(req)\n\n```js\nvar accepts = require('accepts')\n\nhttp.createServer(function (req, res) {\n var accept = accepts(req)\n})\n```\n\n### accept\\[property\\]\\(\\)\n\nReturns all the explicitly accepted content property as an array in descending priority.\n\n- `accept.types()`\n- `accept.encodings()`\n- `accept.charsets()`\n- `accept.languages()`\n\nThey are also aliased in singular form such as `accept.type()`. `accept.languages()` is also aliased as `accept.langs()`, etc.\n\nNote: you should almost never do this in a real app as it defeats the purpose of content negotiation.\n\nExample:\n\n```js\n// in Google Chrome\nvar encodings = accept.encodings() // -> ['sdch', 'gzip', 'deflate']\n```\n\nSince you probably don't support `sdch`, you should just supply the encodings you support:\n\n```js\nvar encoding = accept.encodings('gzip', 'deflate') // -> 'gzip', probably\n```\n\n### accept\\[property\\]\\(values, ...\\)\n\nYou can either have `values` be an array or have an argument list of values.\n\nIf the client does not accept any `values`, `false` will be returned.\nIf the client accepts any `values`, the preferred `value` will be return.\n\nFor `accept.types()`, shorthand mime types are allowed.\n\nExample:\n\n```js\n// req.headers.accept = 'application/json'\n\naccept.types('json') // -> 'json'\naccept.types('html', 'json') // -> 'json'\naccept.types('html') // -> false\n\n// req.headers.accept = ''\n// which is equivalent to `*`\n\naccept.types() // -> [], no explicit types\naccept.types('text/html', 'text/json') // -> 'text/html', since it was first\n```\n\n[npm-image]: https://img.shields.io/npm/v/accepts.svg?style=flat-square\n[npm-url]: https://npmjs.org/package/accepts\n[github-tag]: http://img.shields.io/github/tag/jshttp/accepts.svg?style=flat-square\n[github-url]: https://github.com/jshttp/accepts/tags\n[travis-image]: https://img.shields.io/travis/jshttp/accepts.svg?style=flat-square\n[travis-url]: https://travis-ci.org/jshttp/accepts\n[coveralls-image]: https://img.shields.io/coveralls/jshttp/accepts.svg?style=flat-square\n[coveralls-url]: https://coveralls.io/r/jshttp/accepts?branch=master\n[david-image]: http://img.shields.io/david/jshttp/accepts.svg?style=flat-square\n[david-url]: https://david-dm.org/jshttp/accepts\n[license-image]: http://img.shields.io/npm/l/accepts.svg?style=flat-square\n[license-url]: LICENSE\n[downloads-image]: http://img.shields.io/npm/dm/accepts.svg?style=flat-square\n[downloads-url]: https://npmjs.org/package/accepts\n",
"readmeFilename": "README.md", "readmeFilename": "README.md",
"bugs": { "bugs": {
"url": "https://github.com/expressjs/accepts/issues" "url": "https://github.com/jshttp/accepts/issues"
}, },
"_id": "accepts@1.0.7", "_id": "accepts@1.1.0",
"_from": "accepts@~1.0.4" "_from": "accepts@~1.1.0"
} }
{ {
"name": "errorhandler", "name": "errorhandler",
"description": "connect's default error handler page", "description": "Development-only error handler middleware",
"version": "1.1.1", "version": "1.2.0",
"author": { "contributors": [
{
"name": "Douglas Christopher Wilson",
"email": "doug@somethingdoug.com"
},
{
"name": "Jonathan Ong", "name": "Jonathan Ong",
"email": "me@jongleberry.com", "email": "me@jongleberry.com",
"url": "http://jongleberry.com" "url": "http://jongleberry.com"
}, }
],
"license": "MIT", "license": "MIT",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git://github.com/expressjs/errorhandler" "url": "git://github.com/expressjs/errorhandler"
}, },
"dependencies": { "dependencies": {
"accepts": "~1.0.4", "accepts": "~1.1.0",
"escape-html": "1.0.1" "escape-html": "1.0.1"
}, },
"devDependencies": { "devDependencies": {
"connect": "3", "connect": "3",
"istanbul": "0.2.10", "istanbul": "0.3.0",
"mocha": "~1.20.1", "mocha": "~1.21.4",
"should": "~4.0.1", "should": "~4.0.1",
"supertest": "~0.13.0" "supertest": "~0.13.0"
}, },
"files": [
"public/",
"LICENSE",
"HISTORY.md",
"index.js"
],
"engines": { "engines": {
"node": ">= 0.8" "node": ">= 0.8"
}, },
"scripts": { "scripts": {
"test": "mocha --reporter dot test/", "test": "mocha --reporter spec --bail --check-leaks test/",
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot test/", "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/",
"test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec test/" "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/"
}, },
"readme": "# errorhandler\n\n[![NPM version](https://badge.fury.io/js/errorhandler.svg)](http://badge.fury.io/js/errorhandler)\n[![Build Status](https://travis-ci.org/expressjs/errorhandler.svg?branch=master)](https://travis-ci.org/expressjs/errorhandler)\n[![Coverage Status](https://img.shields.io/coveralls/expressjs/errorhandler.svg?branch=master)](https://coveralls.io/r/expressjs/errorhandler)\n\nPreviously `connect.errorHandler()`.\n\n## Install\n\n```sh\n$ npm install errorhandler\n```\n\n## API\n\n### errorhandler()\n\nCreate new middleware to handle errors and respond with content negotiation.\nThis middleware is only intended to be used in a development environment, as\nthe full error stack traces will be send back to the client when an error\noccurs.\n\n## Example\n\n```js\nvar connect = require('connect')\nvar errorhandler = require('errorhandler')\n\nvar app = connect()\n\nif (process.env.NODE_ENV === 'development') {\n app.use(errorhandler())\n}\n```\n\n## License\n\nThe MIT License (MIT)\n\nCopyright (c) 2014 Jonathan Ong me@jongleberry.com\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n", "readme": "# errorhandler\n\n[![NPM Version][npm-image]][npm-url]\n[![NPM Downloads][downloads-image]][downloads-url]\n[![Build Status][travis-image]][travis-url]\n[![Test Coverage][coveralls-image]][coveralls-url]\n[![Gratipay][gratipay-image]][gratipay-url]\n\nDevelopment-only error handler middleware\n\n## Install\n\n```sh\n$ npm install errorhandler\n```\n\n## API\n\n```js\nvar errorhandler = require('errorhandler')\n```\n\n### errorhandler()\n\nCreate new middleware to handle errors and respond with content negotiation.\nThis middleware is only intended to be used in a development environment, as\nthe full error stack traces will be sent back to the client when an error\noccurs.\n\n## Example\n\n```js\nvar connect = require('connect')\nvar errorhandler = require('errorhandler')\n\nvar app = connect()\n\nif (process.env.NODE_ENV === 'development') {\n // only use in development\n app.use(errorhandler())\n}\n```\n\n## License\n\n[MIT](LICENSE)\n\n[npm-image]: https://img.shields.io/npm/v/errorhandler.svg?style=flat\n[npm-url]: https://npmjs.org/package/errorhandler\n[travis-image]: https://img.shields.io/travis/expressjs/errorhandler.svg?style=flat\n[travis-url]: https://travis-ci.org/expressjs/errorhandler\n[coveralls-image]: https://img.shields.io/coveralls/expressjs/errorhandler.svg?style=flat\n[coveralls-url]: https://coveralls.io/r/expressjs/errorhandler?branch=master\n[downloads-image]: http://img.shields.io/npm/dm/errorhandler.svg?style=flat\n[downloads-url]: https://npmjs.org/package/errorhandler\n[gratipay-image]: https://img.shields.io/gratipay/dougwilson.svg?style=flat\n[gratipay-url]: https://www.gratipay.com/dougwilson/\n",
"readmeFilename": "README.md", "readmeFilename": "README.md",
"bugs": { "bugs": {
"url": "https://github.com/expressjs/errorhandler/issues" "url": "https://github.com/expressjs/errorhandler/issues"
}, },
"_id": "errorhandler@1.1.1", "_id": "errorhandler@1.2.0",
"dist": { "dist": {
"shasum": "1bb0d6fa98b4aff72bf60371a0198925b49216fa" "shasum": "71fe9b2f8aee8e836f74c77dffcf55156fcf49cf"
}, },
"_from": "errorhandler @*", "_from": "errorhandler @*",
"_resolved": "https://registry.npmjs.org/errorhandler/-/errorhandler-1.1.1.tgz" "_resolved": "https://registry.npmjs.org/errorhandler/-/errorhandler-1.2.0.tgz"
} }
4.8.8 / 2014-09-04
==================
* deps: send@0.8.5
- Fix a path traversal issue when using `root`
- Fix malicious path detection for empty string path
* deps: serve-static@~1.5.4
- deps: send@0.8.5
4.8.7 / 2014-08-29 4.8.7 / 2014-08-29
================== ==================
...@@ -420,6 +429,15 @@ ...@@ -420,6 +429,15 @@
- `app.route()` - Proxy to the app's `Router#route()` method to create a new route - `app.route()` - Proxy to the app's `Router#route()` method to create a new route
- Router & Route - public API - Router & Route - public API
3.16.10 / 2014-09-04
====================
* deps: connect@2.25.10
- deps: serve-static@~1.5.4
* deps: send@0.8.5
- Fix a path traversal issue when using `root`
- Fix malicious path detection for empty string path
3.16.9 / 2014-08-29 3.16.9 / 2014-08-29
=================== ===================
......
...@@ -35,5 +35,5 @@ ...@@ -35,5 +35,5 @@
"url": "https://github.com/expressjs/accepts/issues" "url": "https://github.com/expressjs/accepts/issues"
}, },
"_id": "accepts@1.0.7", "_id": "accepts@1.0.7",
"_from": "accepts@~1.0.4" "_from": "accepts@~1.0.7"
} }
...@@ -27,5 +27,9 @@ ...@@ -27,5 +27,9 @@
"url": "https://github.com/visionmedia/node-cookie-signature/issues" "url": "https://github.com/visionmedia/node-cookie-signature/issues"
}, },
"_id": "cookie-signature@1.0.4", "_id": "cookie-signature@1.0.4",
"_from": "cookie-signature@1.0.4" "dist": {
"shasum": "aa3b73d0f90834fd3fea70fbab15819cd3ca1441"
},
"_from": "cookie-signature@1.0.4",
"_resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.4.tgz"
} }
...@@ -47,6 +47,5 @@ ...@@ -47,6 +47,5 @@
"shasum": "c24a85a64e0d945f6d61290d10692f4f422ee7d8" "shasum": "c24a85a64e0d945f6d61290d10692f4f422ee7d8"
}, },
"_from": "debug@1.0.4", "_from": "debug@1.0.4",
"_resolved": "https://registry.npmjs.org/debug/-/debug-1.0.4.tgz", "_resolved": "https://registry.npmjs.org/debug/-/debug-1.0.4.tgz"
"scripts": {}
} }
...@@ -36,5 +36,9 @@ ...@@ -36,5 +36,9 @@
"url": "https://github.com/expressjs/finalhandler/issues" "url": "https://github.com/expressjs/finalhandler/issues"
}, },
"_id": "finalhandler@0.1.0", "_id": "finalhandler@0.1.0",
"_from": "finalhandler@0.1.0" "dist": {
"shasum": "488f102e1049cef44b0517ef78cdc99f8b07308d"
},
"_from": "finalhandler@0.1.0",
"_resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-0.1.0.tgz"
} }
...@@ -29,5 +29,9 @@ ...@@ -29,5 +29,9 @@
"url": "https://github.com/visionmedia/node-fresh/issues" "url": "https://github.com/visionmedia/node-fresh/issues"
}, },
"_id": "fresh@0.2.2", "_id": "fresh@0.2.2",
"_from": "fresh@0.2.2" "dist": {
"shasum": "986200e4f225b4dc7efa69aca2aa2b5de69e0b46"
},
"_from": "fresh@0.2.2",
"_resolved": "https://registry.npmjs.org/fresh/-/fresh-0.2.2.tgz"
} }
...@@ -30,5 +30,9 @@ ...@@ -30,5 +30,9 @@
"url": "https://github.com/expressjs/media-typer/issues" "url": "https://github.com/expressjs/media-typer/issues"
}, },
"_id": "media-typer@0.2.0", "_id": "media-typer@0.2.0",
"_from": "media-typer@0.2.0" "dist": {
"shasum": "2af3fe9842d954b5a16d102d197d8a47ead20d3a"
},
"_from": "media-typer@0.2.0",
"_resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.2.0.tgz"
} }
...@@ -29,5 +29,9 @@ ...@@ -29,5 +29,9 @@
"url": "https://github.com/visionmedia/node-range-parser/issues" "url": "https://github.com/visionmedia/node-range-parser/issues"
}, },
"_id": "range-parser@1.0.0", "_id": "range-parser@1.0.0",
"_from": "range-parser@1.0.0" "dist": {
"shasum": "a9932fac2dceed3de5e20a3982195a256df0cf0c"
},
"_from": "range-parser@1.0.0",
"_resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.0.0.tgz"
} }
0.8.5 / 2014-09-04
==================
* Fix malicious path detection for empty string path
0.8.4 / 2014-09-04
==================
* Fix a path traversal issue when using `root`
0.8.3 / 2014-08-16 0.8.3 / 2014-08-16
================== ==================
......
...@@ -412,16 +412,16 @@ SendStream.prototype.pipe = function(res){ ...@@ -412,16 +412,16 @@ SendStream.prototype.pipe = function(res){
if (root !== null) { if (root !== null) {
// join / normalize from optional root dir // join / normalize from optional root dir
path = normalize(join(root, path)) path = normalize(join(root, path))
root = normalize(root) root = normalize(root + sep)
// malicious path // malicious path
if (path.substr(0, root.length) !== root) { if ((path + sep).substr(0, root.length) !== root) {
debug('malicious path "%s"', path) debug('malicious path "%s"', path)
return this.error(403) return this.error(403)
} }
// explode path parts // explode path parts
parts = path.substr(root.length + 1).split(sep) parts = path.substr(root.length).split(sep)
} else { } else {
// ".." is malicious without "root" // ".." is malicious without "root"
if (upPathRegexp.test(path)) { if (upPathRegexp.test(path)) {
......
{ {
"name": "send", "name": "send",
"description": "Better streaming static file server with Range and conditional-GET support", "description": "Better streaming static file server with Range and conditional-GET support",
"version": "0.8.3", "version": "0.8.5",
"author": { "author": {
"name": "TJ Holowaychuk", "name": "TJ Holowaychuk",
"email": "tj@vision-media.ca" "email": "tj@vision-media.ca"
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
"range-parser": "~1.0.0" "range-parser": "~1.0.0"
}, },
"devDependencies": { "devDependencies": {
"istanbul": "0.3.0", "istanbul": "0.3.2",
"mocha": "~1.21.0", "mocha": "~1.21.0",
"should": "~4.0.0", "should": "~4.0.0",
"supertest": "~0.13.0" "supertest": "~0.13.0"
...@@ -52,6 +52,10 @@ ...@@ -52,6 +52,10 @@
"bugs": { "bugs": {
"url": "https://github.com/visionmedia/send/issues" "url": "https://github.com/visionmedia/send/issues"
}, },
"_id": "send@0.8.3", "_id": "send@0.8.5",
"_from": "send@0.8.3" "dist": {
"shasum": "aea8ff6045638cdce888a782529276d1e1413f0f"
},
"_from": "send@0.8.5",
"_resolved": "https://registry.npmjs.org/send/-/send-0.8.5.tgz"
} }
1.5.4 / 2014-09-04
==================
* deps: send@0.8.5
- Fix a path traversal issue when using `root`
- Fix malicious path detection for empty string path
1.5.3 / 2014-08-17 1.5.3 / 2014-08-17
================== ==================
......
(The MIT License)
Copyright (c) 2010 Sencha Inc.
Copyright (c) 2011 LearnBoost
Copyright (c) 2011 TJ Holowaychuk
Copyright (c) 2014 Douglas Christopher Wilson
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.
# serve-static
[![NPM Version][npm-image]][npm-url]
[![NPM Downloads][downloads-image]][downloads-url]
[![Build Status][travis-image]][travis-url]
[![Test Coverage][coveralls-image]][coveralls-url]
[![Gratipay][gratipay-image]][gratipay-url]
## Install
```sh
$ npm install serve-static
```
## API
```js
var serveStatic = require('serve-static')
```
### serveStatic(root, options)
Create a new middleware function to serve files from within a given root
directory. The file to serve will be determined by combining `req.url`
with the provided root directory. When a file is not found, instead of
sending a 404 response, this module will instead call `next()` to move on
to the next middleware, allowing for stacking and fall-backs.
#### Options
##### dotfiles
Set how "dotfiles" are treated when encountered. A dotfile is a file
or directory that begins with a dot ("."). Note this check is done on
the path itself without checking if the path actually exists on the
disk. If `root` is specified, only the dotfiles above the root are
checked (i.e. the root itself can be within a dotfile when when set
to "deny").
The default value is `'ignore'`.
- `'allow'` No special treatment for dotfiles.
- `'deny'` Send a 403 for any request for a dotfile.
- `'ignore'` Pretend like the dotfile does not exist and call `next()`.
##### etag
Enable or disable etag generation, defaults to true.
##### extensions
Set file extension fallbacks. When set, if a file is not found, the given
extensions will be added to the file name and search for. The first that
exists will be served. Example: `['html', 'htm']`.
The default value is `false`.
##### index
By default this module will send "index.html" files in response to a request
on a directory. To disable this set `false` or to supply a new index pass a
string or an array in preferred order.
##### maxAge
Provide a max-age in milliseconds for http caching, defaults to 0. This
can also be a string accepted by the [ms](https://www.npmjs.org/package/ms#readme)
module.
##### redirect
Redirect to trailing "/" when the pathname is a dir. Defaults to `true`.
##### setHeaders
Function to set custom headers on response.
## Examples
### Serve files with vanilla node.js http server
```js
var finalhandler = require('finalhandler')
var http = require('http')
var serveStatic = require('serve-static')
// Serve up public/ftp folder
var serve = serveStatic('public/ftp', {'index': ['index.html', 'index.htm']})
// Create server
var server = http.createServer(function(req, res){
var done = finalhandler(req, res)
serve(req, res, done)
})
// Listen
server.listen(3000)
```
### Serve all files from ftp folder
```js
var connect = require('connect')
var serveStatic = require('serve-static')
var app = connect()
app.use(serveStatic('public/ftp', {'index': ['default.html', 'default.htm']}))
app.listen(3000)
```
### Serve all files as downloads
```js
var express = require('express')
var serveStatic = require('serve-static')
var app = express()
app.use(serveStatic('public/ftp', {
'index': false,
'setHeaders': setHeaders
}))
app.listen(3000)
function setHeaders(res, path) {
res.attachment(path)
}
```
## License
[MIT](LICENSE)
[npm-image]: https://img.shields.io/npm/v/serve-static.svg?style=flat
[npm-url]: https://npmjs.org/package/serve-static
[travis-image]: https://img.shields.io/travis/expressjs/serve-static.svg?style=flat
[travis-url]: https://travis-ci.org/expressjs/serve-static
[coveralls-image]: https://img.shields.io/coveralls/expressjs/serve-static.svg?style=flat
[coveralls-url]: https://coveralls.io/r/expressjs/serve-static
[downloads-image]: https://img.shields.io/npm/dm/serve-static.svg?style=flat
[downloads-url]: https://npmjs.org/package/serve-static
[gratipay-image]: https://img.shields.io/gratipay/dougwilson.svg?style=flat
[gratipay-url]: https://gratipay.com/dougwilson/
/*!
* serve-static
* Copyright(c) 2010 Sencha Inc.
* Copyright(c) 2011 TJ Holowaychuk
* Copyright(c) 2014 Douglas Christopher Wilson
* MIT Licensed
*/
/**
* Module dependencies.
*/
var escapeHtml = require('escape-html');
var merge = require('utils-merge');
var parseurl = require('parseurl');
var resolve = require('path').resolve;
var send = require('send');
var url = require('url');
/**
* @param {String} root
* @param {Object} options
* @return {Function}
* @api public
*/
exports = module.exports = function serveStatic(root, options) {
if (!root) {
throw new TypeError('root path required')
}
// copy options object
options = merge({}, options)
// resolve root to absolute
root = resolve(root)
// default redirect
var redirect = options.redirect !== false
// headers listener
var setHeaders = options.setHeaders
delete options.setHeaders
if (setHeaders && typeof setHeaders !== 'function') {
throw new TypeError('option setHeaders must be function')
}
// setup options for send
options.maxage = options.maxage || options.maxAge || 0
options.root = root
return function serveStatic(req, res, next) {
if (req.method !== 'GET' && req.method !== 'HEAD') {
return next()
}
var opts = merge({}, options)
var originalUrl = parseurl.original(req)
var path = parseurl(req).pathname
if (path === '/' && originalUrl.pathname[originalUrl.pathname.length - 1] !== '/') {
// make sure redirect occurs at mount
path = ''
}
// create send stream
var stream = send(req, path, opts)
if (redirect) {
// redirect relative to originalUrl
stream.on('directory', function redirect() {
originalUrl.pathname += '/'
var target = url.format(originalUrl)
res.statusCode = 303
res.setHeader('Content-Type', 'text/html; charset=utf-8')
res.setHeader('Location', target)
res.end('Redirecting to <a href="' + escapeHtml(target) + '">' + escapeHtml(target) + '</a>\n')
})
} else {
// forward to next middleware on directory
stream.on('directory', next)
}
// add headers listener
if (setHeaders) {
stream.on('headers', setHeaders)
}
// forward non-404 errors
stream.on('error', function error(err) {
next(err.status === 404 ? null : err)
})
// pipe
stream.pipe(res)
}
}
/**
* Expose mime module.
*
* If you wish to extend the mime table use this
* reference to the "mime" module in the npm registry.
*/
exports.mime = send.mime
{
"name": "serve-static",
"description": "Serve static files",
"version": "1.5.4",
"author": {
"name": "Douglas Christopher Wilson",
"email": "doug@somethingdoug.com"
},
"license": "MIT",
"repository": {
"type": "git",
"url": "git://github.com/expressjs/serve-static"
},
"dependencies": {
"escape-html": "1.0.1",
"parseurl": "~1.3.0",
"send": "0.8.5",
"utils-merge": "1.0.0"
},
"devDependencies": {
"istanbul": "0.3.2",
"mocha": "~1.21.0",
"should": "~4.0.0",
"supertest": "~0.13.0"
},
"files": [
"LICENSE",
"HISTORY.md",
"index.js"
],
"engines": {
"node": ">= 0.8.0"
},
"scripts": {
"test": "mocha --reporter spec --bail --check-leaks --require should test/",
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks --require should test/",
"test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks --require should test/"
},
"readme": "# serve-static\n\n[![NPM Version][npm-image]][npm-url]\n[![NPM Downloads][downloads-image]][downloads-url]\n[![Build Status][travis-image]][travis-url]\n[![Test Coverage][coveralls-image]][coveralls-url]\n[![Gratipay][gratipay-image]][gratipay-url]\n\n## Install\n\n```sh\n$ npm install serve-static\n```\n\n## API\n\n```js\nvar serveStatic = require('serve-static')\n```\n\n### serveStatic(root, options)\n\nCreate a new middleware function to serve files from within a given root\ndirectory. The file to serve will be determined by combining `req.url`\nwith the provided root directory. When a file is not found, instead of\nsending a 404 response, this module will instead call `next()` to move on\nto the next middleware, allowing for stacking and fall-backs.\n\n#### Options\n\n##### dotfiles\n\n Set how \"dotfiles\" are treated when encountered. A dotfile is a file\nor directory that begins with a dot (\".\"). Note this check is done on\nthe path itself without checking if the path actually exists on the\ndisk. If `root` is specified, only the dotfiles above the root are\nchecked (i.e. the root itself can be within a dotfile when when set\nto \"deny\").\n\nThe default value is `'ignore'`.\n\n - `'allow'` No special treatment for dotfiles.\n - `'deny'` Send a 403 for any request for a dotfile.\n - `'ignore'` Pretend like the dotfile does not exist and call `next()`.\n\n##### etag\n\nEnable or disable etag generation, defaults to true.\n\n##### extensions\n\nSet file extension fallbacks. When set, if a file is not found, the given\nextensions will be added to the file name and search for. The first that\nexists will be served. Example: `['html', 'htm']`.\n\nThe default value is `false`.\n\n##### index\n\nBy default this module will send \"index.html\" files in response to a request\non a directory. To disable this set `false` or to supply a new index pass a\nstring or an array in preferred order.\n\n##### maxAge\n\nProvide a max-age in milliseconds for http caching, defaults to 0. This\ncan also be a string accepted by the [ms](https://www.npmjs.org/package/ms#readme)\nmodule.\n\n##### redirect\n\nRedirect to trailing \"/\" when the pathname is a dir. Defaults to `true`.\n\n##### setHeaders\n\nFunction to set custom headers on response.\n\n## Examples\n\n### Serve files with vanilla node.js http server\n\n```js\nvar finalhandler = require('finalhandler')\nvar http = require('http')\nvar serveStatic = require('serve-static')\n\n// Serve up public/ftp folder\nvar serve = serveStatic('public/ftp', {'index': ['index.html', 'index.htm']})\n\n// Create server\nvar server = http.createServer(function(req, res){\n var done = finalhandler(req, res)\n serve(req, res, done)\n})\n\n// Listen\nserver.listen(3000)\n```\n\n### Serve all files from ftp folder\n\n```js\nvar connect = require('connect')\nvar serveStatic = require('serve-static')\n\nvar app = connect()\n\napp.use(serveStatic('public/ftp', {'index': ['default.html', 'default.htm']}))\napp.listen(3000)\n```\n\n### Serve all files as downloads\n\n```js\nvar express = require('express')\nvar serveStatic = require('serve-static')\n\nvar app = express()\n\napp.use(serveStatic('public/ftp', {\n 'index': false,\n 'setHeaders': setHeaders\n}))\napp.listen(3000)\n\nfunction setHeaders(res, path) {\n res.attachment(path)\n}\n```\n\n## License\n\n[MIT](LICENSE)\n\n[npm-image]: https://img.shields.io/npm/v/serve-static.svg?style=flat\n[npm-url]: https://npmjs.org/package/serve-static\n[travis-image]: https://img.shields.io/travis/expressjs/serve-static.svg?style=flat\n[travis-url]: https://travis-ci.org/expressjs/serve-static\n[coveralls-image]: https://img.shields.io/coveralls/expressjs/serve-static.svg?style=flat\n[coveralls-url]: https://coveralls.io/r/expressjs/serve-static\n[downloads-image]: https://img.shields.io/npm/dm/serve-static.svg?style=flat\n[downloads-url]: https://npmjs.org/package/serve-static\n[gratipay-image]: https://img.shields.io/gratipay/dougwilson.svg?style=flat\n[gratipay-url]: https://gratipay.com/dougwilson/\n",
"readmeFilename": "README.md",
"bugs": {
"url": "https://github.com/expressjs/serve-static/issues"
},
"_id": "serve-static@1.5.4",
"dist": {
"shasum": "fc11ca7e89f1f0290266bf5345985dace1e9310b"
},
"_from": "serve-static@~1.5.4",
"_resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.5.4.tgz"
}
{ {
"name": "express", "name": "express",
"description": "Fast, unopinionated, minimalist web framework", "description": "Fast, unopinionated, minimalist web framework",
"version": "4.8.7", "version": "4.8.8",
"author": { "author": {
"name": "TJ Holowaychuk", "name": "TJ Holowaychuk",
"email": "tj@vision-media.ca" "email": "tj@vision-media.ca"
...@@ -67,8 +67,8 @@ ...@@ -67,8 +67,8 @@
"proxy-addr": "1.0.1", "proxy-addr": "1.0.1",
"qs": "2.2.2", "qs": "2.2.2",
"range-parser": "1.0.0", "range-parser": "1.0.0",
"send": "0.8.3", "send": "0.8.5",
"serve-static": "~1.5.3", "serve-static": "~1.5.4",
"type-is": "~1.3.2", "type-is": "~1.3.2",
"vary": "0.1.0", "vary": "0.1.0",
"cookie": "0.1.2", "cookie": "0.1.2",
...@@ -79,7 +79,7 @@ ...@@ -79,7 +79,7 @@
}, },
"devDependencies": { "devDependencies": {
"after": "0.8.1", "after": "0.8.1",
"istanbul": "0.3.0", "istanbul": "0.3.2",
"mocha": "~1.21.4", "mocha": "~1.21.4",
"should": "~4.0.4", "should": "~4.0.4",
"supertest": "~0.13.0", "supertest": "~0.13.0",
...@@ -87,14 +87,14 @@ ...@@ -87,14 +87,14 @@
"ejs": "~1.0.0", "ejs": "~1.0.0",
"marked": "0.3.2", "marked": "0.3.2",
"hjs": "~0.0.6", "hjs": "~0.0.6",
"body-parser": "~1.6.7", "body-parser": "~1.7.0",
"cookie-parser": "~1.3.2", "cookie-parser": "~1.3.2",
"express-session": "~1.7.6", "express-session": "~1.7.6",
"jade": "~1.5.0", "jade": "~1.5.0",
"method-override": "~2.1.3", "method-override": "~2.1.3",
"morgan": "~1.2.3", "morgan": "~1.2.3",
"multiparty": "~3.3.2", "multiparty": "~3.3.2",
"vhost": "2.0.0" "vhost": "~3.0.0"
}, },
"engines": { "engines": {
"node": ">= 0.10.0" "node": ">= 0.10.0"
...@@ -110,10 +110,10 @@ ...@@ -110,10 +110,10 @@
"bugs": { "bugs": {
"url": "https://github.com/strongloop/express/issues" "url": "https://github.com/strongloop/express/issues"
}, },
"_id": "express@4.8.7", "_id": "express@4.8.8",
"dist": { "dist": {
"shasum": "1033c54dcc5d0a539b9918acb62c4be9f4aaa5d7" "shasum": "1ec1bd953aa44c5ac1c8144c5b073f91c202394c"
}, },
"_from": "express@4.x", "_from": "express@4.x",
"_resolved": "https://registry.npmjs.org/express/-/express-4.8.7.tgz" "_resolved": "https://registry.npmjs.org/express/-/express-4.8.8.tgz"
} }
language: node_js
node_js:
- 0.10
- 0.11
The ISC License
Copyright (c) Isaac Z. Schlueter and Contributors
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
This diff is collapsed.
var Glob = require("../").Glob
var pattern = "test/a/**/[cg]/../[cg]"
console.log(pattern)
var mg = new Glob(pattern, {mark: true, sync:true}, function (er, matches) {
console.log("matches", matches)
})
console.log("after")
var Glob = require("../").Glob
var pattern = "{./*/*,/*,/usr/local/*}"
console.log(pattern)
var mg = new Glob(pattern, {mark: true}, function (er, matches) {
console.log("matches", matches)
})
console.log("after")
This diff is collapsed.
Copyright (c) Isaac Z. Schlueter ("Author")
All rights reserved.
The BSD License
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# graceful-fs
graceful-fs functions as a drop-in replacement for the fs module,
making various improvements.
The improvements are meant to normalize behavior across different
platforms and environments, and to make filesystem access more
resilient to errors.
## Improvements over [fs module](http://api.nodejs.org/fs.html)
graceful-fs:
* Queues up `open` and `readdir` calls, and retries them once
something closes if there is an EMFILE error from too many file
descriptors.
* fixes `lchmod` for Node versions prior to 0.6.2.
* implements `fs.lutimes` if possible. Otherwise it becomes a noop.
* ignores `EINVAL` and `EPERM` errors in `chown`, `fchown` or
`lchown` if the user isn't root.
* makes `lchmod` and `lchown` become noops, if not available.
* retries reading a file if `read` results in EAGAIN error.
On Windows, it retries renaming a file for up to one second if `EACCESS`
or `EPERM` error occurs, likely because antivirus software has locked
the directory.
## USAGE
```javascript
// use just like fs
var fs = require('graceful-fs')
// now go and do stuff with it...
fs.readFileSync('some-file-or-whatever')
```
// eeeeeevvvvviiiiiiillllll
// more evil than monkey-patching the native builtin?
// Not sure.
var mod = require("module")
var pre = '(function (exports, require, module, __filename, __dirname) { '
var post = '});'
var src = pre + process.binding('natives').fs + post
var vm = require('vm')
var fn = vm.runInThisContext(src)
return fn(exports, require, module, __filename, __dirname)
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment