Socket
Socket
Sign inDemoInstall

serve-static

Package Overview
Dependencies
Maintainers
6
Versions
66
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

serve-static - npm Package Compare versions

Comparing version 1.2.1 to 1.2.2

8

History.md

@@ -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 @@ ==================

2

index.js
/*!
* 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 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc