Merge "LOG SQL dump files getting installed"
[sdnc/oam.git] / dgbuilder / dgeflows / node_modules / serve-index / README.md
1 # serve-index
2
3 [![NPM Version][npm-image]][npm-url]
4 [![NPM Downloads][downloads-image]][downloads-url]
5 [![Linux Build][travis-image]][travis-url]
6 [![Windows Build][appveyor-image]][appveyor-url]
7 [![Test Coverage][coveralls-image]][coveralls-url]
8 [![Gratipay][gratipay-image]][gratipay-url]
9
10   Serves pages that contain directory listings for a given path.
11
12 ## Install
13
14 ```sh
15 $ npm install serve-index
16 ```
17
18 ## API
19
20 ```js
21 var serveIndex = require('serve-index')
22 ```
23
24 ### serveIndex(path, options)
25
26 Returns middlware that serves an index of the directory in the given `path`.
27
28 The `path` is based off the `req.url` value, so a `req.url` of `'/some/dir`
29 with a `path` of `'public'` will look at `'public/some/dir'`. If you are using
30 something like `express`, you can change the URL "base" with `app.use` (see
31 the express example).
32
33 #### Options
34
35 Serve index accepts these properties in the options object.
36
37 ##### filter
38
39 Apply this filter function to files. Defaults to `false`. The `filter` function
40 is called for each file, with the signature `filter(filename, index, files, dir)`
41 where `filename` is the name of the file, `index` is the array index, `files` is
42 the array of files and `dir` is the absolute path the file is located (and thus,
43 the directory the listing is for).
44
45 ##### hidden
46
47 Display hidden (dot) files. Defaults to `false`.
48
49 ##### icons
50
51 Display icons. Defaults to `false`.
52
53 ##### stylesheet
54
55 Optional path to a CSS stylesheet. Defaults to a built-in stylesheet.
56
57 ##### template
58
59 Optional path to an HTML template. Defaults to a built-in template.
60
61 The following tokens are replaced in templates:
62
63   * `{directory}` with the name of the directory.
64   * `{files}` with the HTML of an unordered list of file links.
65   * `{linked-path}` with the HTML of a link to the directory.
66   * `{style}` with the specified stylesheet and embedded images.
67
68 ##### view
69
70 Display mode. `tiles` and `details` are available. Defaults to `tiles`.
71
72 ## Examples
73
74 ### Serve directory indexes with vanilla node.js http server
75
76 ```js
77 var finalhandler = require('finalhandler')
78 var http = require('http')
79 var serveIndex = require('serve-index')
80 var serveStatic = require('serve-static')
81
82 // Serve directory indexes for public/ftp folder (with icons)
83 var index = serveIndex('public/ftp', {'icons': true})
84
85 // Serve up public/ftp folder files
86 var serve = serveStatic('public/ftp')
87
88 // Create server
89 var server = http.createServer(function onRequest(req, res){
90   var done = finalhandler(req, res)
91   serve(req, res, function onNext(err) {
92     if (err) return done(err)
93     index(req, res, done)
94   })
95 })
96
97 // Listen
98 server.listen(3000)
99 ```
100
101 ### Serve directory indexes with express
102
103 ```js
104 var express    = require('express')
105 var serveIndex = require('serve-index')
106
107 var app = express()
108
109 // Serve URLs like /ftp/thing as public/ftp/thing
110 app.use('/ftp', serveIndex('public/ftp', {'icons': true}))
111 app.listen()
112 ```
113
114 ## License
115
116 [MIT](LICENSE). The [Silk](http://www.famfamfam.com/lab/icons/silk/) icons
117 are created by/copyright of [FAMFAMFAM](http://www.famfamfam.com/).
118
119 [npm-image]: https://img.shields.io/npm/v/serve-index.svg
120 [npm-url]: https://npmjs.org/package/serve-index
121 [travis-image]: https://img.shields.io/travis/expressjs/serve-index/master.svg?label=linux
122 [travis-url]: https://travis-ci.org/expressjs/serve-index
123 [appveyor-image]: https://img.shields.io/appveyor/ci/dougwilson/serve-index/master.svg?label=windows
124 [appveyor-url]: https://ci.appveyor.com/project/dougwilson/serve-index
125 [coveralls-image]: https://img.shields.io/coveralls/expressjs/serve-index/master.svg
126 [coveralls-url]: https://coveralls.io/r/expressjs/serve-index?branch=master
127 [downloads-image]: https://img.shields.io/npm/dm/serve-index.svg
128 [downloads-url]: https://npmjs.org/package/serve-index
129 [gratipay-image]: https://img.shields.io/gratipay/dougwilson.svg
130 [gratipay-url]: https://www.gratipay.com/dougwilson/