serve-static
Advanced tools
Comparing version 1.2.1 to 1.2.2
@@ -0,1 +1,9 @@ | ||
1.2.2 / 2014-06-09 | ||
================== | ||
* deps: send@0.4.2 | ||
- fix "event emitter leak" warnings | ||
- deps: debug@1.0.1 | ||
- deps: finished@1.2.1 | ||
1.2.1 / 2014-06-02 | ||
@@ -2,0 +10,0 @@ ================== |
/*! | ||
* Connect - static | ||
* serve-static | ||
* Copyright(c) 2010 Sencha Inc. | ||
@@ -4,0 +4,0 @@ * Copyright(c) 2011 TJ Holowaychuk |
{ | ||
"name": "serve-static", | ||
"description": "Serve static files", | ||
"version": "1.2.1", | ||
"version": "1.2.2", | ||
"author": "Douglas Christopher Wilson <doug@somethingdoug.com>", | ||
"license": "MIT", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/expressjs/serve-static.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/expressjs/serve-static/issues" | ||
}, | ||
"repository": "expressjs/serve-static", | ||
"dependencies": { | ||
"escape-html": "1.0.1", | ||
"parseurl": "1.0.1", | ||
"send": "0.4.1" | ||
"send": "0.4.2" | ||
}, | ||
@@ -19,0 +13,0 @@ "devDependencies": { |
@@ -1,2 +0,2 @@ | ||
# Serve Static | ||
# serve-static | ||
@@ -9,14 +9,61 @@ [![NPM version](https://badge.fury.io/js/serve-static.svg)](http://badge.fury.io/js/serve-static) | ||
Usage: | ||
## Install | ||
```sh | ||
$ npm install serve-static | ||
``` | ||
## API | ||
```js | ||
var connect = require('connect'); | ||
var serveStatic = require('serve-static'); | ||
var serveStatic = require('serve-static') | ||
``` | ||
var app = connect(); | ||
### serveStatic(root, options) | ||
app.use(serveStatic('public/ftp', {'index': ['default.html', 'default.htm']})); | ||
app.listen(); | ||
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. | ||
Options: | ||
- `hidden` Allow transfer of hidden files. defaults to `false` | ||
- `index` Default file name, defaults to `'index.html'` | ||
- `maxAge` Browser cache maxAge in milliseconds. defaults to `0` | ||
- `redirect` Redirect to trailing "/" when the pathname is a dir. defaults to `true` | ||
## 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) | ||
``` | ||
## License | ||
@@ -23,0 +70,0 @@ |
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
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
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
8817
91
1
1
+ Addeddebug@1.0.1(transitive)
+ Addedfinished@1.2.1(transitive)
+ Addedms@0.6.2(transitive)
+ Addedsend@0.4.2(transitive)
- Removeddebug@0.8.1(transitive)
- Removedfinished@1.1.4(transitive)
- Removedsend@0.4.1(transitive)
Updatedsend@0.4.2