Revert "Changements dans les modules (nouvelle version Express, mysql, ..)"
This reverts commit bdab795506.
This commit is contained in:
85
node_modules/serve-static/README.md
generated
vendored
85
node_modules/serve-static/README.md
generated
vendored
@@ -1,14 +1,17 @@
|
||||
# serve-static
|
||||
|
||||
[![NPM Version][npm-image]][npm-url]
|
||||
[![NPM Downloads][downloads-image]][downloads-url]
|
||||
[![Linux Build][travis-image]][travis-url]
|
||||
[![NPM Version][npm-version-image]][npm-url]
|
||||
[![NPM Downloads][npm-downloads-image]][npm-url]
|
||||
[![Linux Build][github-actions-ci-image]][github-actions-ci-url]
|
||||
[![Windows Build][appveyor-image]][appveyor-url]
|
||||
[![Test Coverage][coveralls-image]][coveralls-url]
|
||||
[![Gratipay][gratipay-image]][gratipay-url]
|
||||
|
||||
## Install
|
||||
|
||||
This is a [Node.js](https://nodejs.org/en/) module available through the
|
||||
[npm registry](https://www.npmjs.com/). Installation is done using the
|
||||
[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):
|
||||
|
||||
```sh
|
||||
$ npm install serve-static
|
||||
```
|
||||
@@ -29,6 +32,17 @@ to the next middleware, allowing for stacking and fall-backs.
|
||||
|
||||
#### Options
|
||||
|
||||
##### acceptRanges
|
||||
|
||||
Enable or disable accepting ranged requests, defaults to true.
|
||||
Disabling this will not send `Accept-Ranges` and ignore the contents
|
||||
of the `Range` request header.
|
||||
|
||||
##### cacheControl
|
||||
|
||||
Enable or disable setting `Cache-Control` response header, defaults to
|
||||
true. Disabling this will ignore the `immutable` and `maxAge` options.
|
||||
|
||||
##### dotfiles
|
||||
|
||||
Set how "dotfiles" are treated when encountered. A dotfile is a file
|
||||
@@ -76,6 +90,14 @@ all methods.
|
||||
|
||||
The default value is `true`.
|
||||
|
||||
##### immutable
|
||||
|
||||
Enable or disable the `immutable` directive in the `Cache-Control` response
|
||||
header, defaults to `false`. If set to `true`, the `maxAge` option should
|
||||
also be specified to enable caching. The `immutable` directive will prevent
|
||||
supported clients from making conditional requests during the life of the
|
||||
`maxAge` option to check if the file has changed.
|
||||
|
||||
##### index
|
||||
|
||||
By default this module will send "index.html" files in response to a request
|
||||
@@ -117,12 +139,11 @@ var http = require('http')
|
||||
var serveStatic = require('serve-static')
|
||||
|
||||
// Serve up public/ftp folder
|
||||
var serve = serveStatic('public/ftp', {'index': ['index.html', 'index.htm']})
|
||||
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)
|
||||
var server = http.createServer(function onRequest (req, res) {
|
||||
serve(req, res, finalhandler(req, res))
|
||||
})
|
||||
|
||||
// Listen
|
||||
@@ -139,19 +160,18 @@ var serveStatic = require('serve-static')
|
||||
|
||||
// Serve up public/ftp folder
|
||||
var serve = serveStatic('public/ftp', {
|
||||
'index': false,
|
||||
'setHeaders': setHeaders
|
||||
index: false,
|
||||
setHeaders: setHeaders
|
||||
})
|
||||
|
||||
// Set header to force download
|
||||
function setHeaders(res, path) {
|
||||
function setHeaders (res, path) {
|
||||
res.setHeader('Content-Disposition', contentDisposition(path))
|
||||
}
|
||||
|
||||
// Create server
|
||||
var server = http.createServer(function(req, res){
|
||||
var done = finalhandler(req, res)
|
||||
serve(req, res, done)
|
||||
var server = http.createServer(function onRequest (req, res) {
|
||||
serve(req, res, finalhandler(req, res))
|
||||
})
|
||||
|
||||
// Listen
|
||||
@@ -170,24 +190,25 @@ var serveStatic = require('serve-static')
|
||||
|
||||
var app = express()
|
||||
|
||||
app.use(serveStatic('public/ftp', {'index': ['default.html', 'default.htm']}))
|
||||
app.use(serveStatic('public/ftp', { index: ['default.html', 'default.htm'] }))
|
||||
app.listen(3000)
|
||||
```
|
||||
|
||||
#### Multiple roots
|
||||
|
||||
This example shows a simple way to search through multiple directories.
|
||||
Files are look for in `public-optimized/` first, then `public/` second as
|
||||
a fallback.
|
||||
Files are searched for in `public-optimized/` first, then `public/` second
|
||||
as a fallback.
|
||||
|
||||
```js
|
||||
var express = require('express')
|
||||
var path = require('path')
|
||||
var serveStatic = require('serve-static')
|
||||
|
||||
var app = express()
|
||||
|
||||
app.use(serveStatic(__dirname + '/public-optimized'))
|
||||
app.use(serveStatic(__dirname + '/public'))
|
||||
app.use(serveStatic(path.join(__dirname, 'public-optimized')))
|
||||
app.use(serveStatic(path.join(__dirname, 'public')))
|
||||
app.listen(3000)
|
||||
```
|
||||
|
||||
@@ -199,18 +220,19 @@ is for 1 day.
|
||||
|
||||
```js
|
||||
var express = require('express')
|
||||
var path = require('path')
|
||||
var serveStatic = require('serve-static')
|
||||
|
||||
var app = express()
|
||||
|
||||
app.use(serveStatic(__dirname + '/public', {
|
||||
app.use(serveStatic(path.join(__dirname, 'public'), {
|
||||
maxAge: '1d',
|
||||
setHeaders: setCustomCacheControl
|
||||
}))
|
||||
|
||||
app.listen(3000)
|
||||
|
||||
function setCustomCacheControl(res, path) {
|
||||
function setCustomCacheControl (res, path) {
|
||||
if (serveStatic.mime.lookup(path) === 'text/html') {
|
||||
// Custom Cache-Control for HTML files
|
||||
res.setHeader('Cache-Control', 'public, max-age=0')
|
||||
@@ -222,15 +244,14 @@ function setCustomCacheControl(res, path) {
|
||||
|
||||
[MIT](LICENSE)
|
||||
|
||||
[npm-image]: https://img.shields.io/npm/v/serve-static.svg
|
||||
[npm-url]: https://npmjs.org/package/serve-static
|
||||
[travis-image]: https://img.shields.io/travis/expressjs/serve-static/master.svg?label=linux
|
||||
[travis-url]: https://travis-ci.org/expressjs/serve-static
|
||||
[appveyor-image]: https://img.shields.io/appveyor/ci/dougwilson/serve-static/master.svg?label=windows
|
||||
[appveyor-image]: https://badgen.net/appveyor/ci/dougwilson/serve-static/master?label=windows
|
||||
[appveyor-url]: https://ci.appveyor.com/project/dougwilson/serve-static
|
||||
[coveralls-image]: https://img.shields.io/coveralls/expressjs/serve-static/master.svg
|
||||
[coveralls-url]: https://coveralls.io/r/expressjs/serve-static
|
||||
[downloads-image]: https://img.shields.io/npm/dm/serve-static.svg
|
||||
[downloads-url]: https://npmjs.org/package/serve-static
|
||||
[gratipay-image]: https://img.shields.io/gratipay/dougwilson.svg
|
||||
[gratipay-url]: https://gratipay.com/dougwilson/
|
||||
[coveralls-image]: https://badgen.net/coveralls/c/github/expressjs/serve-static/master
|
||||
[coveralls-url]: https://coveralls.io/r/expressjs/serve-static?branch=master
|
||||
[github-actions-ci-image]: https://badgen.net/github/checks/expressjs/serve-static/master?label=linux
|
||||
[github-actions-ci-url]: https://github.com/expressjs/serve-static/actions/workflows/ci.yml
|
||||
[node-image]: https://badgen.net/npm/node/serve-static
|
||||
[node-url]: https://nodejs.org/en/download/
|
||||
[npm-downloads-image]: https://badgen.net/npm/dm/serve-static
|
||||
[npm-url]: https://npmjs.org/package/serve-static
|
||||
[npm-version-image]: https://badgen.net/npm/v/serve-static
|
||||
|
||||
Reference in New Issue
Block a user